passing check_exact=True makes it raise as expected, but I was surprised to find it necessary. This likely hides some bugs.
Motivating example adapted from tests.groupby.test_function.test_cummin.
dtype = np.dtype(np.int64)
min_val = np.iinfo(dtype).min
base_df = DataFrame({"A": [1, 1, 1, 1, 2, 2, 2, 2], "B": [3, 4, 3, 2, 2, 3, 2, 1]})
expected_mins = [3, 3, 3, 2, 2, 2, 2, 1]
expected = DataFrame({"B": expected_mins}).astype(dtype)
df = base_df.astype(dtype)
# Test w/ min value for dtype
df.loc[[2, 6], "B"] = min_val
df.loc[[1, 5], "B"] = min_val + 1
result = df.groupby("A").cummin()
expected.loc[[1, 5], "B"] = min_val + 1
expected.loc[[2, 3, 6, 7], "B"] = min_val
tm.assert_frame_equal(result, expected) # <-- passes
tm.assert_frame_equal(result, expected, check_exact=True) # <-- raises
>>> result
B
0 3
1 -9223372036854775808
2 -9223372036854775808
3 -9223372036854775808
4 2
5 -9223372036854775808
6 -9223372036854775808
7 -9223372036854775808
>>> expected
B
0 3
1 -9223372036854775807
2 -9223372036854775808
3 -9223372036854775808
4 2
5 -9223372036854775807
6 -9223372036854775808
7 -9223372036854775808
Comment From: mzeitlin11
This ends up falling down to using math.isclose
with tolerances large enough that these compare as equal. I'm guessing the default of comparison with tolerance is just to avoid floating point comparison problems. Seems like ints should just always be given an exact comparison by default?
Comment From: jbrockmendel
Seems like ints should just always be given an exact comparison by default?
thats my thought too
Comment From: mzeitlin11
@jbrockmendel how public are these functions (eg can we just change the default for integer data to check_exact=True
or do we have to worry about backwards compat?) Also xref #30347
Comment From: jbrockmendel
in the past when ive changed tm.assert_foo functions @jorisvandenbossche eventually reports that a downstream package has been affectd
Comment From: topper-123
IMO the check_exact
param should only apply to floats, i.e. the example in OP should fail. I also think this is a bug, i.e. we can fix just this without deprecation.