Skip to content

TYP: testing.pyi #40594

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

Merged
merged 1 commit into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pandas/_libs/testing.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


def assert_dict_equal(a, b, compare_keys: bool = ...): ...

def assert_almost_equal(a, b,
rtol: float = ..., atol: float = ...,
check_dtype: bool = ...,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think check_dtype should just be Union[bool, str] right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the .pyx file its typed as bint, which i think is better anyway; better to make the casting explicit

obj=..., lobj=..., robj=..., index_values=...): ...
8 changes: 7 additions & 1 deletion pandas/_testing/asserters.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ def assert_almost_equal(
else:
obj = "Input"
assert_class_equal(left, right, obj=obj)

# if we have "equiv", this becomes True
check_dtype = bool(check_dtype)
_testing.assert_almost_equal(
left, right, check_dtype=check_dtype, rtol=rtol, atol=atol, **kwargs
)
Expand Down Expand Up @@ -388,12 +391,15 @@ def _get_ilevel_values(index, level):
msg = f"{obj} values are different ({np.round(diff, 5)} %)"
raise_assert_detail(obj, msg, left, right)
else:

# if we have "equiv", this becomes True
exact_bool = bool(exact)
_testing.assert_almost_equal(
left.values,
right.values,
rtol=rtol,
atol=atol,
check_dtype=exact,
check_dtype=exact_bool,
obj=obj,
lobj=left,
robj=right,
Expand Down