xgcm / xhistogram

Fast, flexible, label-aware histograms for numpy and xarray
https://xhistogram.readthedocs.io
MIT License
89 stars 19 forks source link

Use numpy histogram_bin_edges to define bins #45

Closed dougiesquire closed 3 years ago

dougiesquire commented 3 years ago

Description

Currently bins must be a list of arrays despite what the documentation says. This PR makes it so that users can provide bins in broadly the same way as they do for np.histogram (i.e. as an int, str, or array).

Closes #13

Type of change

Testing

Things to note

codecov[bot] commented 3 years ago

Codecov Report

Merging #45 (d5a23c2) into master (c62cf9f) will increase coverage by 1.19%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #45      +/-   ##
==========================================
+ Coverage   94.54%   95.74%   +1.19%     
==========================================
  Files           3        3              
  Lines         220      235      +15     
  Branches       58       67       +9     
==========================================
+ Hits          208      225      +17     
+ Misses          8        7       -1     
+ Partials        4        3       -1     
Impacted Files Coverage Δ
xhistogram/core.py 100.00% <100.00%> (+1.48%) :arrow_up:
xhistogram/xarray.py 91.07% <100.00%> (-0.87%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update c62cf9f...d5a23c2. Read the comment docs.

rabernat commented 3 years ago

Thanks a lot for your PR @dougiesquire! I hope to review it within a few days. Thanks for your patience.

rabernat commented 3 years ago

So now that #50 is ready, should we merge this?

dougiesquire commented 3 years ago

So now that #50 is ready, should we merge this?

This comment makes me realise I misunderstand the process here. I had thought we were going to hold off on merging this and merge/release #50 so that users will get the warning about this upcoming change before it is merged. Can you please set me straight?

rabernat commented 3 years ago

No I think I'm the one who misunderstood! 🙃 It totally makes sense that we merge #50 first. But then we should do a release right away (v0.2), with #50, and then make this part of the next release (v0.3). This involves a lot of releases for a project that doesn't release very often. But I think it's the right way to go.

Just to be sure we are on the same page, let me describe my understanding of the deprecation cycle.

Releases

All the matters to users is releases. Our latest release, available on pip and conda, is v0.1.3. We don't have to assume that users are installing from the latest github master branch. Most of the dev work we are doing now is ostensibly going to be part of the next release, probably v0.2, given the significant feature changes. (We use semantic versioning, like most python packages.) It's okay if the master branch is temporarily in a slightly inconsistent or even broken state, as long as everything is cleaned up by the next release. So in this view, the order of operations (this vs #50) doesn't matter; they will both be merged by the next release.

Deprecation

Deprecation cycles give our users, especially anyone using xhistogram in a "production" context, to get warnings of upcoming API changes before they become defaults / breaking changes. If we merge #50 and the do our next release (v0.2), we will start raising these FutureWarnings about the core.histogram return stuff. We would then merge this after that and include it as part of the next release (v0.3).

dougiesquire commented 3 years ago

Yup - that aligns with my thinking. I'll go ahead and merge #50 and then have a go at a release? (this will be my first release so apologies in advance if I have questions)

rabernat commented 3 years ago

Beat you merging #50. Full speed ahead with the release. The CI should be set up so you can just make a release on GitHub. No other manual steps required.

rabernat commented 3 years ago

Ok great, now that 0.2 is out, we can merge this (once you have resolved the conflicts).

dougiesquire commented 3 years ago

I've also removed the FutureWarning here. I think this is the right thing to do since we don't want to keep warning the user that a change is coming after the change has been made. Let me know if I've made the wrong call here and I'll add it back in.