Skip to content

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

Merged
merged 2 commits into from
Sep 28, 2022
Merged

WARN: Catch warning in tests #48753

merged 2 commits into from
Sep 28, 2022

Conversation

phofl
Copy link
Member

@phofl phofl commented Sep 23, 2022

  • closes #xxxx (Replace xxxx with the Github issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

cc @mroeschke

@@ -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):
Copy link
Member

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?

Copy link
Member

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?

Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

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

@mroeschke mroeschke added Visualization plotting Warnings Warnings that appear or should be added to pandas labels Sep 26, 2022
Copy link
Member

@MarcoGorelli MarcoGorelli left a 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

@MarcoGorelli MarcoGorelli added this to the 1.6 milestone Sep 27, 2022
@@ -15,6 +15,8 @@
_check_plot_works,
)

from pandas.plotting._matplotlib.compat import mpl_ge_3_6_0
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 this needs to be imported in the test

Copy link
Member Author

Choose a reason for hiding this comment

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

thx, moved

@phofl
Copy link
Member Author

phofl commented Sep 28, 2022

I'd prefer keeping it as one test, this makes comparing easier.

Copy link
Member

@MarcoGorelli MarcoGorelli left a 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

@mroeschke mroeschke merged commit c68d053 into pandas-dev:main Sep 28, 2022
@mroeschke
Copy link
Member

Thanks @phofl

@phofl phofl deleted the plot branch September 29, 2022 08:05
@mroeschke mroeschke modified the milestones: 1.6, 2.0 Oct 13, 2022
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
* WARN: Catch warning in tests

* Move import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Visualization plotting Warnings Warnings that appear or should be added to pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants