mirror of
https://github.com/kristoferssolo/grovers-visualizer.git
synced 2025-10-21 20:10:35 +00:00
fix: little-endian
This commit is contained in:
parent
a8b7b054f0
commit
2b705b0f8b
@ -77,7 +77,7 @@ def all_states(n_qubits: int) -> Iterator[QubitState]:
|
|||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
shots = 128
|
shots = 128
|
||||||
target = QubitState("1" * 4)
|
target = QubitState("1010")
|
||||||
n_qubits = len(target)
|
n_qubits = len(target)
|
||||||
|
|
||||||
qc = grover_search(target, iterations=1)
|
qc = grover_search(target, iterations=1)
|
||||||
@ -103,8 +103,7 @@ def main() -> None:
|
|||||||
ax.set_ylim(0, shots)
|
ax.set_ylim(0, shots)
|
||||||
|
|
||||||
for i, measured in enumerate(memory, 1):
|
for i, measured in enumerate(memory, 1):
|
||||||
measured_be = measured[::-1] # Qiskit returns little-endian
|
counts[measured] += 1
|
||||||
counts[measured_be] += 1
|
|
||||||
for bar, state in zip(bars, all_states, strict=False):
|
for bar, state in zip(bars, all_states, strict=False):
|
||||||
bar.set_height(counts[state])
|
bar.set_height(counts[state])
|
||||||
bar.set_color("orange" if state == str(target) else "skyblue")
|
bar.set_color("orange" if state == str(target) else "skyblue")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user