mirror of
https://github.com/kristoferssolo/grovers-visualizer.git
synced 2025-10-21 20:10:35 +00:00
fix(circle): value sign
This commit is contained in:
parent
50e843a884
commit
64650dd7b0
@ -9,7 +9,7 @@ from matplotlib.patches import Circle
|
|||||||
from qiskit.quantum_info import Statevector
|
from qiskit.quantum_info import Statevector
|
||||||
|
|
||||||
from .state import QubitState
|
from .state import QubitState
|
||||||
from .utils import get_bar_color, is_optimal_iteration, sign
|
from .utils import get_bar_color, is_optimal_iteration
|
||||||
|
|
||||||
|
|
||||||
def plot_amplitudes(
|
def plot_amplitudes(
|
||||||
@ -87,7 +87,7 @@ def plot_circle(
|
|||||||
ax.text(
|
ax.text(
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
f"{prob * sign(y):.2f}",
|
f"{prob:.2f}",
|
||||||
color=color,
|
color=color,
|
||||||
fontsize=10,
|
fontsize=10,
|
||||||
ha="left" if x >= 0 else "right",
|
ha="left" if x >= 0 else "right",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
from collections.abc import Iterator
|
from collections.abc import Iterator
|
||||||
from itertools import product
|
from itertools import product
|
||||||
from math import copysign, floor, pi, sqrt
|
from math import floor, pi, sqrt
|
||||||
|
|
||||||
from .state import QubitState
|
from .state import QubitState
|
||||||
|
|
||||||
@ -27,7 +27,3 @@ def get_bar_color(state: str, target_state: QubitState | None, iteration: int, o
|
|||||||
if optimal_iteration and is_optimal_iteration(iteration, optimal_iteration):
|
if optimal_iteration and is_optimal_iteration(iteration, optimal_iteration):
|
||||||
return "green"
|
return "green"
|
||||||
return "orange"
|
return "orange"
|
||||||
|
|
||||||
|
|
||||||
def sign(x: float) -> int:
|
|
||||||
return int(copysign(1, x))
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user