Skip to content

Commit

Permalink
make flaky test deterministic; fix error if nsteps is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesBuchner committed Dec 12, 2024
1 parent 83dd88f commit 881d3f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 7 additions & 5 deletions tests/test_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ def test_clusteringcase_eggbox():
points = np.loadtxt(os.path.join(here, "eggboxregion.txt"))
transformLayer = ScalingLayer()
transformLayer.optimize(points, points)
region = MLFriends(points, transformLayer)
maxr = region.compute_maxradiussq(nbootstraps=30)
assert 1e-10 < maxr < 6e-10
print('maxradius:', maxr)
nclusters, clusteridxs, overlapped_points = update_clusters(points, points, maxr)
for seed in range(10):
np.random.seed(seed)
region = MLFriends(points, transformLayer)
maxr = region.compute_maxradiussq(nbootstraps=30)
assert 1e-10 < maxr < 6e-10
print('maxradius:', maxr)
nclusters, clusteridxs, overlapped_points = update_clusters(points, points, maxr)
# plt.title('nclusters: %d' % nclusters)
# for i in np.unique(clusteridxs):
# x, y = points[clusteridxs == i].transpose()
Expand Down
3 changes: 2 additions & 1 deletion ultranest/stepsampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1505,9 +1505,10 @@ def SpeedVariableRegionSliceSampler(step_matrix, *args, **kwargs):
Updates only some dimensions at a time, completely user-definable.
"""
generate_direction = kwargs.pop('generate_direction', generate_region_random_direction)
nsteps = kwargs.pop('nsteps', len(step_matrix))
return SliceSampler(
*args, **kwargs,
nsteps=kwargs.pop('nsteps', len(step_matrix)),
nsteps=nsteps,
generate_direction=SpeedVariableGenerator(
step_matrix=step_matrix,
generate_direction=generate_direction
Expand Down

0 comments on commit 881d3f5

Please sign in to comment.