-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: Let check_exact_index default to True for integers #58189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -861,12 +861,19 @@ def assert_series_equal( | |
check_names : bool, default True | ||
Whether to check the Series and Index names attribute. | ||
check_exact : bool, default False | ||
Whether to compare number exactly. | ||
Whether to compare number exactly. This also applies when checking | ||
Index equivalence. | ||
|
||
.. versionchanged:: 2.2.0 | ||
|
||
Defaults to True for integer dtypes if none of | ||
``check_exact``, ``rtol`` and ``atol`` are specified. | ||
|
||
.. versionchanged:: 3.0.0 | ||
|
||
When checking Index equivalence, the default value for check_exact | ||
Aloqeely marked this conversation as resolved.
Show resolved
Hide resolved
|
||
is based off the Index dtype, instead of the Series dtype. | ||
|
||
check_datetimelike_compat : bool, default False | ||
Compare datetime-like which is comparable ignoring dtype. | ||
check_categorical : bool, default True | ||
|
@@ -902,7 +909,6 @@ def assert_series_equal( | |
>>> tm.assert_series_equal(a, b) | ||
""" | ||
__tracebackhide__ = True | ||
check_exact_index = False if check_exact is lib.no_default else check_exact | ||
if ( | ||
check_exact is lib.no_default | ||
and rtol is lib.no_default | ||
|
@@ -914,8 +920,23 @@ def assert_series_equal( | |
or is_numeric_dtype(right.dtype) | ||
and not is_float_dtype(right.dtype) | ||
) | ||
left_index_dtypes = ( | ||
[left.index.dtype] if left.index.nlevels == 1 else left.index.dtypes | ||
) | ||
right_index_dtypes = ( | ||
[right.index.dtype] if right.index.nlevels == 1 else right.index.dtypes | ||
) | ||
check_exact_index = ( | ||
all(is_numeric_dtype(dtype) for dtype in left_index_dtypes) | ||
and not any(is_float_dtype(dtype) for dtype in left_index_dtypes) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Brilliant! That doesn't seem to work for multiindexes (as in I can't just use this on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Probably because MultiIndex can be composed of levels that are mixed types so |
||
or all(is_numeric_dtype(dtype) for dtype in right_index_dtypes) | ||
and not any(is_float_dtype(dtype) for dtype in right_index_dtypes) | ||
) | ||
elif check_exact is lib.no_default: | ||
check_exact = False | ||
check_exact_index = False | ||
else: | ||
check_exact_index = check_exact | ||
|
||
rtol = rtol if rtol is not lib.no_default else 1.0e-5 | ||
atol = atol if atol is not lib.no_default else 1.0e-8 | ||
|
Uh oh!
There was an error while loading. Please reload this page.