Skip to content

GH1147 Drop version restriction on matplotlib and prevent test to write to root folder #1148

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 3 commits into from
Mar 10, 2025

Conversation

loicdiridollou
Copy link
Contributor

@loicdiridollou loicdiridollou marked this pull request as draft March 7, 2025 03:37
check(
assert_type(
grouped.boxplot(
subplots=False, rot=45, fontsize=12, figsize=(8, 10), vert=False
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switching this to orientation='horizontal' creates an error, needs to dig into it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

error in pytest or in typing? If pytest, then if you can reproduce by just using pandas, then report a pandas issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a runtime error, if you try and run the code it will throw an error.
Right now with vert=False then it runs fine but changing to orientation=‘horizontal’ then it will throw an error. I need to step into the code to understand why the conversion they are recommending is actually broken in this particular case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems a pandas bug, I am going to do a little bit of investigation, it happens because the orientation parameter is not passed properly.
For now if you run the plot and there are no other Axes available this will work so I will split the test and ship it as is not to block this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dug into it and I was not able to reproduce it on the main branch of pandas.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So you could keep the test in there and surround it with if not PD_LTE_22, and just have the test as you modified it here, and add the new test with the if statement that would then be executed in the nightly tests (which we have to separately fix)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually that would not work since the issue was how pandas passed the information to matplotlib (and we upgraded matplotlib version) and we don't have a test of the matplotlib version if I am correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test was originally failing because of the matplotlib version that was upgraded and then it was how pandas supplied the kwargs to matplotlib.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, so in the current form, with the upgraded matplotlib, the test using orientation='horizontal', the test fails with pandas 2.2.3, but works with the version in main (larger than 2.2.x).

So you could surround your desired test that includes orientation='horizontal' with a if not PD_LTE_22 code, and leave in the test as you wrote it in this PR without the if not PD_LTE_22, with a comment to remove that test once pandas releases a version beyond 2.2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I completely missed your point. This is addressed. I kept the split test and added for both a check on PD_LTE_22 with the new orientation="horizontal", I tested with poetry run poe pytest --nightly and it passed for the test_plotting.py tests (we have other tests failing but this is addressed in another PR #1152).

pyproject.toml Outdated
@@ -43,7 +43,7 @@ pyright = ">=1.1.396"
poethepoet = ">=0.16.5"
loguru = ">=0.6.0"
typing-extensions = ">=4.4.0"
matplotlib = ">=3.5.1,<3.9.0" # TODO https://github.com/pandas-dev/pandas/issues/58851
matplotlib = ">=3.5.10" # TODO https://github.com/pandas-dev/pandas/issues/58851
Copy link
Collaborator

Choose a reason for hiding this comment

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

pandas now requires 3.6.3, so can update this constraint to that version, and remove the comment since that issue is now closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will adjust this is a good point.

pyproject.toml Outdated
@@ -231,7 +231,7 @@ filterwarnings = [
# treat warnings as errors
"error",
# until there is a new dateutil release: github.com/dateutil/dateutil/pull/1285
"ignore:datetime.datetime.utc:DeprecationWarning",
# "ignore:datetime.datetime.utc:DeprecationWarning",
Copy link
Collaborator

Choose a reason for hiding this comment

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

If commenting this out works, you can just remove this line and the line above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried for testing since that is still a draft PR but indeed will delete.

check(
assert_type(
grouped.boxplot(
subplots=False, rot=45, fontsize=12, figsize=(8, 10), vert=False
Copy link
Collaborator

Choose a reason for hiding this comment

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

error in pytest or in typing? If pytest, then if you can reproduce by just using pandas, then report a pandas issue.

@loicdiridollou loicdiridollou marked this pull request as ready for review March 8, 2025 00:40
@loicdiridollou loicdiridollou requested a review from Dr-Irv March 8, 2025 00:40
@loicdiridollou
Copy link
Contributor Author

/pandas_nightly

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

I think you can fix up the test to work with both pandas 2.2.3 and > 2.2

check(
assert_type(
grouped.boxplot(
subplots=False, rot=45, fontsize=12, figsize=(8, 10), vert=False
Copy link
Collaborator

Choose a reason for hiding this comment

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

So you could keep the test in there and surround it with if not PD_LTE_22, and just have the test as you modified it here, and add the new test with the if statement that would then be executed in the nightly tests (which we have to separately fix)

@loicdiridollou
Copy link
Contributor Author

/pandas_nightly

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

@Dr-Irv Dr-Irv merged commit a6ebdaf into pandas-dev:main Mar 10, 2025
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drop matplotlib version restriction
2 participants