Skip to content

BUG: tm.assert_frame_equal fails to raise near int64 implementation bounds when check_exact=True #40719

Open
@jbrockmendel

Description

@jbrockmendel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugTestingpandas testing functions or related to the test suite

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions