8000 TST: GH30999 Add match=msg to all pytest.raises in tests/reductions and add an error message to nanmedian by moink · Pull Request #38720 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

TST: GH30999 Add match=msg to all pytest.raises in tests/reductions and add an error message to nanmedian #38720

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
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
TST: GH30999 change error message returned by Series.any and Series.a…
…ll when bool_only is passed
  • Loading branch information
moink committed Dec 30, 2020
commit bee21902eb7086fbd72b48f166040508f97b9f1f
25 changes: 16 additions & 9 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10351,15 +10351,22 @@ def _logical_func(
name, func, axis=0, bool_only=bool_only, skipna=skipna, **kwargs
)
return res._logical_func(name, func, skipna=skipna, **kwargs)

return self._reduce(
func,
name=name,
axis=axis,
skipna=skipna,
numeric_only=bool_only,
filter_type="bool",
)
try:
return self._reduce(
func,
name=name,
axis=axis,
skipna=skipna,
numeric_only=bool_only,
filter_type="bool",
)
except NotImplementedError as exc:
err_msg = str(exc)
if err_msg.endswith("does not implement numeric_only."):
raise NotImplementedError(
err_msg.replace("numeric_only", "bool_only")
) from exc
raise

def any(self, axis=0, bool_only=None, skipna=True, level=None, **kwargs):
return self._logical_func(
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/reductions/test_reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,10 +895,10 @@ def test_all_any_params(self):
s.all(bool_only=True, level=0)

# bool_only is not implemented alone.
msg = "Series.any does not implement numeric_only"
msg = "Series.any does not implement bool_only"
with pytest.raises(NotImplementedError, match=msg):
s.any(bool_only=True)
msg = "Series.all does not implement numeric_only."
msg = "Series.all does not implement bool_only."
with pytest.raises(NotImplementedError, match=msg):
s.all(bool_only=True)

Expand Down
0