Skip to content

Commit 7276a60

Browse files
committed
MAINT: remove call to np.random
1 parent d2eca13 commit 7276a60

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

py/dynesty/sampler.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
from .results import Results, print_fn
1515
from .bounding import UnitCube
1616
from .sampling import sample_unif, SamplerArgument
17-
from .utils import (get_seed_sequence, get_print_func, progress_integration,
17+
from .utils import (get_random_generator, get_seed_sequence,
18+
get_print_func, progress_integration,
1819
IteratorResult, RunRecord, get_neff_from_logwt,
1920
compute_integrals, DelayTimer, _LOWL_VAL)
2021

@@ -430,10 +431,11 @@ def _distance_insertion_index(self, start, point):
430431
if distance == 0:
431432
log_ratio = np.inf
432433
else:
433-
other = self.live_u[np.random.choice(len(self.live_u))]
434+
rstate = get_random_generator(self.rstate)
435+
other = self.live_u[rstate.choice(len(self.live_u))]
434436
other_distance = np.linalg.norm((other - start) / norms)
435437
while other_distance == 0:
436-
other = self.live_u[np.random.choice(len(self.live_u))]
438+
other = self.live_u[rstate.choice(len(self.live_u))]
437439
other_distance = np.linalg.norm((other - start) / norms)
438440
alt_distance = np.linalg.norm((point - other) / norms)
439441
log_ratio = self.ndim * (np.log(other_distance / distance) + np.log(other_distance / alt_distance)) / 2

0 commit comments

Comments
 (0)