Skip to content

Commit 453125d

Browse files
committed
BUG: Fix plot_objective() error on 32-bit OS
Fixes #3
1 parent a3cc528 commit 453125d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

sambo/_sceua.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ def _evolve_complex(func, args, population, func_values, complex_indices, bounds
5151
complex_population[worst_idx] = contraction
5252
complex_values[worst_idx] = contraction_value
5353
else:
54-
# Replace worst with random point
55-
x = _sample_population(bounds, 1, constraints, rng)
56-
complex_population[worst_idx:] = x
57-
complex_values[worst_idx:] = np.apply_along_axis(func, 1, x, *args)
54+
n_worst = len(complex_indices) - 2 # This includes our +1 at index 0
55+
x = _sample_population(bounds, n_worst, constraints, rng)
56+
complex_population[-n_worst:] = x
57+
complex_values[-n_worst:] = np.apply_along_axis(func, 1, x, *args)
5858

5959
sorted_indices = np.argsort(complex_values)
6060
complex_population = complex_population[sorted_indices]

sambo/plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def _check_plot_dims(plot_dims, bounds) -> list[int]:
414414
plot_dims = np.where(bounds[:, 0] != bounds[:, 1])[0]
415415
if not plot_dims.size:
416416
raise ValueError(f'All dimensions are constant: {bounds[:, 0].tolist()}')
417-
plot_dims = np.unique(plot_dims).astype(int, casting='safe')
417+
plot_dims = np.unique(plot_dims).astype(np.int_, casting='safe')
418418
return plot_dims.tolist()
419419

420420

0 commit comments

Comments
 (0)