-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
WARN: Catch warning in tests #48753
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
WARN: Catch warning in tests #48753
Conversation
@@ -204,7 +206,11 @@ def test_scatter_with_c_column_name_with_colors(self, cmap, kw): | |||
columns=["length", "width"], | |||
) | |||
df["species"] = ["r", "r", "g", "g", "b"] | |||
ax = df.plot.scatter(x=0, y=1, cmap=cmap, **{kw: "species"}) | |||
if mpl_ge_3_6_0() and cmap is not None: | |||
with tm.assert_produces_warning(UserWarning, check_stacklevel=False): |
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.
does this indicate that we are doing something wrong/outdated?
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.
@MarcoGorelli looks like you raised and addressed this issue in #34344
Do you remember if passing cmap
in plot.scatter was necessary
to test this behavior?
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.
FWIW: I think this is a new warning in mpl 3.6 so plot.scatter
may have been doing something "wrong" before?
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.
It was silently ignored before. They added stricter checks in a few places. If we want to check that the colormap is not applied, then we have to check for the user warning
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.
i have some recollection of this issue/PR, I'll take a look tomorrow
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.
Looks good to me
Not overly keen on if-then
inside tests, slight preference to split the test into two:
test_scatter_with_c_column_name_with_colors_no_cmap
test_scatter_with_c_column_name_with_colors_with_cmap
and also to add a comment that the warning comes from matplotlib, so it's fine to not check the stacklevel
Not blockers though
@@ -15,6 +15,8 @@ | |||
_check_plot_works, | |||
) | |||
|
|||
from pandas.plotting._matplotlib.compat import mpl_ge_3_6_0 |
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.
I think this needs to be imported in the test
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.
thx, moved
I'd prefer keeping it as one test, this makes comparing easier. |
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.
Thanks @phofl |
* WARN: Catch warning in tests * Move import
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.cc @mroeschke