Skip to content

Commit f8dea12

Browse files
TST: ensuring bins in cut during tiling are predictably small (pandas-dev#62868)
1 parent 94c7e88 commit f8dea12

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/tests/reshape/test_cut.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,22 @@ def test_single_bin(data, length):
410410
tm.assert_series_equal(result, expected)
411411

412412

413+
@pytest.mark.parametrize(
414+
"values,threshold",
415+
[
416+
([0.1, 0.1, 0.1], 0.001), # small positive values
417+
([-0.1, -0.1, -0.1], 0.001), # negative values
418+
([0.01, 0.01, 0.01], 0.0001), # very small values
419+
],
420+
)
421+
def test_single_bin_edge_adjustment(values, threshold):
422+
# gh-58517 - edge adjustment mutation when all values are same
423+
result, bins = cut(values, 3, retbins=True)
424+
425+
bin_range = bins[-1] - bins[0]
426+
assert bin_range < threshold
427+
428+
413429
@pytest.mark.parametrize(
414430
"array_1_writeable,array_2_writeable", [(True, True), (True, False), (False, False)]
415431
)

0 commit comments

Comments
 (0)