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

add __array_function__ #152

Closed
wants to merge 145 commits into from

Conversation

andrewgsavage
Copy link
Collaborator

  • Closes # (insert issue number)
  • Executed pre-commit run --all-files with no errors
  • The change is fully covered by automated unit tests
  • Documented in docs/ as appropriate
  • Added an entry to the CHANGES file

bors bot and others added 29 commits June 24, 2023 23:04
186: Add accumulate r=andrewgsavage a=andrewgsavage

- [x] Closes hgrecco#170
- [x] Executed `pre-commit run --all-files` with no errors
- [x] The change is fully covered by automated unit tests
- [x] Documented in docs/ as appropriate
- [x] Added an entry to the CHANGES file


Co-authored-by: Andrew <[email protected]>
Co-authored-by: andrewgsavage <[email protected]>
58: [WIP] Convert object dtype r=andrewgsavage a=andrewgsavage

Addresses hgrecco#55

Co-authored-by: andrewgsavage <[email protected]>
Co-authored-by: Andrew <[email protected]>
Additional code synchronizations (and the addition of a dtype-preserving map method).  These changes were initially developed to support uncertainties, but the uncertainty changes have all been stripped out to simplify merging of underlying code.  Once these changes are fully synced with a release version of Pandas 2.1, we can look at adding back uncertainties.

These changes also tolerate complex128 as a base type for magnitudes, with one except (under discussion as pandas-dev/pandas#54445).

Signed-off-by: Michael Tiemann <[email protected]>
The PintArray map function should return a PintArray if the mapper returns PintQuantities, but otherwise it should just return whatever was the result of the mapper.

We follow the examples from pandas in the definition and use of _get_expected_exception in the test suite.

Signed-off-by: Michael Tiemann <[email protected]>
Fix canonicalization of NaNs to use na_value (with units) rather than pure np.nan.  While np.nan is correctly handled as a value in PintArrays, and work as expected with addition (adding a quantity to a NaN produces a NaN, which remains value), it doesn't work for multiplication (where a quantity times a NaN produces not a NaN but new quantity of NaN magnitude the units of the non-NaN value).  Canonicalizing to na_value provides consistent unit handling with NaNs through all arithmetic operations.

Signed-off-by: Michael Tiemann <[email protected]>
Make black happy.

Signed-off-by: Michael Tiemann <[email protected]>
195: fix pandas v2.1 NumpyEADtype issue r=andrewgsavage a=topper-123

- [x] Closes hgrecco#194
- [x] Executed `pre-commit run --all-files` with no errors
- [x] The change is fully covered by automated unit tests
- [ ] Documented in docs/ as appropriate
- [ ] Added an entry to the CHANGES file

Precursor to working on hgrecco#174.


Co-authored-by: Terji Petersen <[email protected]>
Fix errors that crept into value_counts concerning na_type.

And canonicalize na_value in quantities a bit more generally.  As stated in a previous commit comment, if we leave naked NA/NaNs in our Quantity array, the code gracefully handles unit addition/subtraction, but unit multiplication/division loses.

Signed-off-by: Michael Tiemann <[email protected]>
Simplify type annotations for _get_expected_exception to make Python 3.9 happy.

Signed-off-by: Michael Tiemann <[email protected]>
Delete the last vestiges of some old code from a different PR.

Also use Pandas public APIs for `infer_dtype` (used in `_from_factorized`).

Signed-off-by: Michael Tiemann <[email protected]>
Remove unrelated comment about UFloats.

Signed-off-by: Michael Tiemann <[email protected]>
Restore some Pandas 2.0.x interfaces and use pandas_version_info from pint_array to condition logic.

Also change some more `self.assert_series_equal` to `tm.assert_series_equal` in the restored code to accommodate Pandas 2.1 BaseExtensionTests behavior.

Signed-off-by: Michael Tiemann <[email protected]>
Simplify PintArray.map to let `pandas.core.algorithms.map_array` do the mapping and we just clean up the PintArray details if necessary.

Pandas 2.1.0rc0 added to CI

Updated CHANGES

Signed-off-by: Michael Tiemann <[email protected]>
Implement `map` for PintArrays also only with Pandas 2.0.2 interfaces.

Signed-off-by: Michael Tiemann <[email protected]>
Until Pandas resolves pandas-dev/pandas#54445 we cannot feed complex128 types to the test_setitem_2d_values test case.

Signed-off-by: Michael Tiemann <[email protected]>
196: Pandas21 compat r=andrewgsavage a=MichaelTiemannOSC

- [ ] Closes # (insert issue number)
- [x] Executed `pre-commit run --all-files` with no errors
- [x] The change is fully covered by automated unit tests
- [ ] Documented in docs/ as appropriate
- [x] Added an entry to the CHANGES file

CI/CD doesn't quite work yet because we don't have a Pandas 2.1 rc to point to.  But comments are welcome!

Co-authored-by: Michael Tiemann <[email protected]>
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.

8 participants