-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Remove return values for asserts #25462
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 9 commits
8b2f085
15510de
aaca9a7
220052a
394fd96
09ebf42
60ec5ee
091a00e
e600bbe
ce3a0a1
a3370fc
fbd9962
e2c085c
24f3b74
3a10a48
f678030
1f29f3b
b72e99f
3ccbe98
f4497fd
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 |
---|---|---|
|
@@ -286,25 +286,25 @@ def assert_almost_equal(left, right, check_dtype="equiv", | |
""" | ||
|
||
if isinstance(left, pd.Index): | ||
return assert_index_equal(left, right, | ||
check_exact=False, | ||
exact=check_dtype, | ||
check_less_precise=check_less_precise, | ||
**kwargs) | ||
assert_index_equal(left, right, | ||
check_exact=False, | ||
exact=check_dtype, | ||
check_less_precise=check_less_precise, | ||
**kwargs) | ||
|
||
elif isinstance(left, pd.Series): | ||
return assert_series_equal(left, right, | ||
check_exact=False, | ||
check_dtype=check_dtype, | ||
check_less_precise=check_less_precise, | ||
**kwargs) | ||
assert_series_equal(left, right, | ||
check_exact=False, | ||
check_dtype=check_dtype, | ||
check_less_precise=check_less_precise, | ||
**kwargs) | ||
|
||
elif isinstance(left, pd.DataFrame): | ||
return assert_frame_equal(left, right, | ||
check_exact=False, | ||
check_dtype=check_dtype, | ||
check_less_precise=check_less_precise, | ||
**kwargs) | ||
assert_frame_equal(left, right, | ||
check_exact=False, | ||
check_dtype=check_dtype, | ||
check_less_precise=check_less_precise, | ||
**kwargs) | ||
|
||
else: | ||
# Other sequences. | ||
|
@@ -322,7 +322,7 @@ def assert_almost_equal(left, right, check_dtype="equiv", | |
else: | ||
obj = "Input" | ||
assert_class_equal(left, right, obj=obj) | ||
return _testing.assert_almost_equal( | ||
_testing.assert_almost_equal( | ||
left, right, | ||
check_dtype=check_dtype, | ||
check_less_precise=check_less_precise, | ||
|
@@ -360,7 +360,7 @@ def _check_isinstance(left, right, cls): | |
def assert_dict_equal(left, right, compare_keys=True): | ||
|
||
_check_isinstance(left, right, dict) | ||
return _testing.assert_dict_equal(left, right, compare_keys=compare_keys) | ||
_testing.assert_dict_equal(left, right, compare_keys=compare_keys) | ||
|
||
|
||
def randbool(size=(), p=0.5): | ||
|
@@ -967,10 +967,11 @@ def isiterable(obj): | |
|
||
|
||
def is_sorted(seq): | ||
"""Assert that the sequence is sorted.""" | ||
if isinstance(seq, (Index, Series)): | ||
seq = seq.values | ||
# sorting does not change precisions | ||
return assert_numpy_array_equal(seq, np.sort(np.array(seq))) | ||
assert_numpy_array_equal(seq, np.sort(np.array(seq))) | ||
|
||
|
||
def assert_categorical_equal(left, right, check_dtype=True, | ||
|
@@ -1168,8 +1169,6 @@ def _raise(left, right, err_msg): | |
if isinstance(left, np.ndarray) and isinstance(right, np.ndarray): | ||
assert_attr_equal('dtype', left, right, obj=obj) | ||
|
||
return True | ||
|
||
|
||
def assert_extension_array_equal(left, right, check_dtype=True, | ||
check_less_precise=False, | ||
|
@@ -1324,11 +1323,13 @@ def assert_series_equal(left, right, check_dtype=True, | |
# .values is an ndarray, but ._values is the ExtensionArray. | ||
# TODO: Use .array | ||
assert is_extension_array_dtype(right.dtype) | ||
return assert_extension_array_equal(left._values, right._values) | ||
assert_extension_array_equal(left._values, right._values) | ||
return | ||
jreback marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
elif (is_extension_array_dtype(left) and not is_categorical_dtype(left) and | ||
is_extension_array_dtype(right) and not is_categorical_dtype(right)): | ||
return assert_extension_array_equal(left.array, right.array) | ||
assert_extension_array_equal(left.array, right.array) | ||
return | ||
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. same don't need a return 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. I tried this earlier but some of the tests failed so I added the returns back. 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. See 091a00e (this was in response to an earlier PR comment) 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. this just returns None which is the same as if you leave the return out, pls remove |
||
|
||
else: | ||
_testing.assert_almost_equal(left.get_values(), right.get_values(), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you rename this routine to tm.assert_is_sorted