Skip to content

Commit 7666ab9

Browse files
committed
ensure a width of at least 1 for integers, update test
1 parent c287c0b commit 7666ab9

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/arviz_stats/base/core.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,9 @@ def _get_bininfo(self, values, bins="arviz"):
210210
width_sqrt = (x_max - x_min) / np.sqrt(values.size)
211211
corr_fd = max(width_fd, width_sqrt / 2)
212212

213+
width = min(width_sturges, corr_fd)
213214
if dtype == "i":
214-
width = np.round(np.min([1, width_sturges, corr_fd])).astype(int)
215-
else:
216-
width = min(width_sturges, corr_fd)
215+
width = np.round(max(1, width)).astype(int)
217216

218217
return x_min, x_max, width
219218

tests/base/test_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def test_get_bins_basic(self, array_stats, rng):
376376
ary = rng.normal(size=(100,))
377377
bins = array_stats.get_bins(ary)
378378
assert bins.ndim == 1
379-
assert len(bins) == 9
379+
assert len(bins) == 10
380380
assert bins[0] == ary.min()
381381
assert ary.max() <= bins[-1]
382382

0 commit comments

Comments
 (0)