Skip to content

Commit

Permalink
fix np.random.default_rng() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasberent committed Apr 19, 2024
1 parent 84587dc commit 75b2f9d
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def generate_err(
residual_err_z = residual_err[1]

for i in range(nr_qubits):
rand = np.random.default_rng() # this returns a random float in [0,1)
rand = np.random.default_rng().random() # this returns a random float in [0,1)
# e.g. if err channel is p = 0.3, then an error will be applied if rand < p
if rand < channel_probs_z[i]: # if probability for z error high enough, rand < p, apply
# if there is a z error on the i-th bit, flip the bit but take residual error into account
Expand Down Expand Up @@ -165,7 +165,7 @@ def generate_syndr_err(channel_probs: NDArray[np.float64]) -> NDArray[np.int32]:
error: NDArray[np.int32] = np.zeros_like(channel_probs, dtype=np.int32)

for i, p in np.ndenumerate(channel_probs):
rand = np.random.default_rng()
rand = np.random.default_rng().random()

if rand < p:
error[i] = 1
Expand Down

0 comments on commit 75b2f9d

Please sign in to comment.