Skip to content
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

Pandas 2.2.0 #359

Merged
merged 31 commits into from
Mar 16, 2024
Merged

Pandas 2.2.0 #359

merged 31 commits into from
Mar 16, 2024

Conversation

AdamOrmondroyd
Copy link
Collaborator

@AdamOrmondroyd AdamOrmondroyd commented Jan 23, 2024

Description

Pandas 2.2.0 just released, with a flurry of changes to the plotting to become more stateless (though not even close to achieving it), and a whole flood of deprecations ready for pandas 3.0 (!!!!!!!)

Unfortunately, the changes to the plotting are incompatible with the old

I'm yet to do anything about the warnings

Fixes # (issue)

Checklist:

  • I have performed a self-review of my own code
  • My code is PEP8 compliant (flake8 anesthetic tests)
  • My code contains compliant docstrings (pydocstyle --convention=numpy anesthetic)
  • New and existing unit tests pass locally with my changes (python -m pytest)
  • I have added tests that prove my fix is effective or that my feature works
  • I have appropriately incremented the semantic version number in both README.rst and anesthetic/_version.py

def _calculate_bins(self, data, bins):
nd_values = data.infer_objects(copy=False)._get_numeric_data()
values = np.ravel(nd_values)
values = values[~isna(values)]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not happy with repeating this a third time, and I haven't checked if the weights definitely need checking for nans

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not work with data.to_numpy().ravel() in quantile below? seems simpler to me...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Essentially because I'm attempting to replicate the pandas versions as closely as possible

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well, considering that Hist1dPlot was created for a WeightedSeries, we could simplify things here.
Even simpler than my previous suggestion:

            xmin, xmax = data.quantile(q).to_numpy().ravel()

Not sure what is easier for maintenance in the long run, though, so happy with either approach.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's too tidy to resist!

Copy link

codecov bot commented Jan 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (54170d8) to head (a009988).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #359   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           36        36           
  Lines         3043      3032   -11     
=========================================
- Hits          3043      3032   -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AdamOrmondroyd
Copy link
Collaborator Author

I think that's all the new deprecation warnings, aside from the warnings about constructing from a BlockManager. Discussion on this seems to be ongoing, so I'm tempted to wait until pandas 2.2.1 to see if I still need to deal with these. pandas-dev/pandas#57032

@AdamOrmondroyd
Copy link
Collaborator Author

AdamOrmondroyd commented Feb 26, 2024

PR here which may clean up some of the BlockManager mess, pandas-dev/pandas#57553

Edit: I've just run anesthetic with this branch of pandas, and all the BlockManager warnings seem to have gone away, so I'm not going to worry about them any further

anesthetic/plot.py Outdated Show resolved Hide resolved
def _calculate_bins(self, data, bins):
nd_values = data.infer_objects(copy=False)._get_numeric_data()
values = np.ravel(nd_values)
values = values[~isna(values)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not work with data.to_numpy().ravel() in quantile below? seems simpler to me...

lukashergt
lukashergt previously approved these changes Mar 12, 2024
Copy link
Collaborator

@lukashergt lukashergt left a comment

Choose a reason for hiding this comment

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

Is there anything else that needs to be taken into account for this?

If not, I am happy with this. Thanks for catching this so quickly @AdamOrmondroyd!

Feel free to handle my inline reply as you see fit.

@AdamOrmondroyd AdamOrmondroyd marked this pull request as ready for review March 16, 2024 13:51
Copy link
Collaborator

@lukashergt lukashergt left a comment

Choose a reason for hiding this comment

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

Thanks @AdamOrmondroyd!

@AdamOrmondroyd AdamOrmondroyd merged commit cb60b9a into master Mar 16, 2024
22 checks passed
@AdamOrmondroyd AdamOrmondroyd deleted the pandas2.2 branch March 16, 2024 20:48
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.

2 participants