Skip to content

TST: adding a test for bar plot with intervalrange xaxis #47344

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 6 commits into from
Jun 15, 2022

Conversation

noatamir
Copy link
Member

@noatamir noatamir commented Jun 14, 2022

@noatamir
Copy link
Member Author

noatamir commented Jun 14, 2022

The smoke test LGTM
The assert is giving me a weird error locally, maybe you can give me some advice here:
The two lists appear to be identical yet I get this error:

E       AssertionError: assert [Text(0, 0, '([0, 1],)'), Text(1, 0, '([1, 2],)')] == [Text(0, 0, '([0, 1],)'), Text(1, 0, '([1, 2],)')]
E         At index 0 diff: Text(0, 0, '([0, 1],)') != Text(0, 0, '([0, 1],)')
E         Full diff:
E           [Text(0, 0, '([0, 1],)'), Text(1, 0, '([1, 2],)')]

@noatamir
Copy link
Member Author

I have a fix coming up! ✨

@noatamir
Copy link
Member Author

OK, I think this is ready now.

I also opened an issue with Matplotlib to add eq to the Text object in the hope that writing these tests would be easier in the future 😇

Copy link
Member

@phofl phofl 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, couple of small comments

def test_bar_plt_xaxis_intervalrange(self):
# GH 38969
# Ensure IntervalIndex x-axis produces a bar plot as expected
from matplotlib.text import Text
Copy link
Member

Choose a reason for hiding this comment

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

We normally don't add these comments, when an issue is linked.

I don't know matplotlib very well, but can we import this at the top?

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like we can. I will go ahead and clean it from the other 2 tests that import it.

Huh, do you mean the 2nd line comment? I noticed that most tests in this Misc file do this. But I really don't mind deleting it...

Copy link
Member

Choose a reason for hiding this comment

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

Thx.

Oh interesting. I am not really familiar with our plotting code-base. We try to avoid most comments in tests in other places. I think you can keep it in, if it is consistent with the rest though.

@phofl
Copy link
Member

phofl commented Jun 14, 2022

I also opened an issue with Matplotlib to add eq to the Text object in the hope that writing these tests would be easier in the future 😇

this would be really nice!

@noatamir
Copy link
Member Author

See matplotlib/matplotlib#23273 for follow up ✨

@noatamir noatamir marked this pull request as ready for review June 14, 2022 18:25
@noatamir
Copy link
Member Author

@phofl I'm getting this error on the CI now:

/opt/python/cp38-cp38/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
pandas/tests/plotting/test_misc.py:3: in <module>
    from matplotlib.text import Text
E   ModuleNotFoundError: No module named 'matplotlib'

Might be because I moved the import up? Any suggestions on how to proceed? revert or what's the underlying cause to address?

@phofl
Copy link
Member

phofl commented Jun 14, 2022

Ah this makes sense. Looks like we are not installing matplotlib everywhere. Reverting is the best way forward here, this explains why the imports were done within the tests.

Thanks for trying this out

@mroeschke mroeschke added the Testing pandas testing functions or related to the test suite label Jun 15, 2022
@mroeschke mroeschke added this to the 1.5 milestone Jun 15, 2022
@mroeschke mroeschke added Visualization plotting Interval Interval data type labels Jun 15, 2022
Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

LGTM. Merge when ready @phofl

@phofl phofl merged commit a803b7c into pandas-dev:main Jun 15, 2022
@phofl
Copy link
Member

phofl commented Jun 15, 2022

thx @noatamir

yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
…47344)

* adding a test for bar plot with intervalrange xaxis

* fixed assert in test

* moved import to top

* Revert "moved import to top"

This reverts commit db9401b.
@noatamir noatamir deleted the regression_test_for_bar_plot branch October 20, 2022 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Interval Interval data type Testing pandas testing functions or related to the test suite Visualization plotting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

REGR: Bar plot from Series with IntervalIndex fails in pandas 1.2.0
3 participants