Utils API Reference
This page documents the utility functions available in the skq.utils
module.
Helper Functions
skq.utils._check_quantum_state_array(X)
Ensure that input are normalized state vectors of the right size.
Source code in src/skq/utils.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
skq.utils.to_bitstring(arr)
Convert a 2D binary array to a list of bitstrings. :param arr: A 2D binary array For example: [[0, 1], [1, 0]] :return: List of bitstrings For example: ['01', '10']
Source code in src/skq/utils.py
27 28 29 30 31 32 33 34 35 36 37 38 |
|
Visualization Functions
skq.utils.matrix_heatmap(matrix, title='Matrix Heatmap')
Visualize a matrix as a heatmap. :param matrix: A 2D array :param title: Title of the plot :return: A plotly figure
Source code in src/skq/utils.py
41 42 43 44 45 46 47 48 49 50 |
|
skq.utils.bloch(state)
Plot single qubit state on a Bloch sphere (3D plot). :param state: A statevector array for a single qubit :return: A plotly figure
Source code in src/skq/utils.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
Quantum Operations
skq.utils.measure_state(state)
Measure a quantum state and return a classical bit. :param state: A statevector array :return: A classical bit
Source code in src/skq/utils.py
100 101 102 103 104 105 106 107 108 109 |
|