Skip to content

Commit

Permalink
Merge pull request #55 from ad12/master
Browse files Browse the repository at this point in the history
fix sigpy.mri._poisson to avoid overriding existing numpy state
  • Loading branch information
frankong committed Jun 15, 2020
2 parents b902e15 + 5e3cea3 commit c3efa3d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions sigpy/mri/samp.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,18 @@ def _poisson(nx, ny, K, R, calib, seed):
f = ny / nx

if seed is not None:
np.random.seed(int(seed))
rand_state = np.random.RandomState(int(seed))
else:
rand_state = np.random

pxs = np.empty(nx * ny, np.int32)
pys = np.empty(nx * ny, np.int32)
pxs[0] = np.random.randint(0, nx)
pys[0] = np.random.randint(0, ny)
pxs[0] = rand_state.randint(0, nx)
pys[0] = rand_state.randint(0, ny)
m = 1
while (m > 0):

i = np.random.randint(0, m)
i = rand_state.randint(0, m)
px = pxs[i]
py = pys[i]
rad = R[py, px]
Expand All @@ -156,8 +158,8 @@ def _poisson(nx, ny, K, R, calib, seed):
while not done and k < K:

# Generate point randomly from R and 2R
rd = rad * (np.random.random() * 3 + 1)**0.5
t = 2 * np.pi * np.random.random()
rd = rad * (rand_state.random() * 3 + 1)**0.5
t = 2 * np.pi * rand_state.random()
qx = px + rd * np.cos(t)
qy = py + rd * f * np.sin(t)

Expand Down

0 comments on commit c3efa3d

Please sign in to comment.