-
Notifications
You must be signed in to change notification settings - Fork 472
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 tests and documentation with improvement of downcast type compatibility (part of #845) #963
Conversation
I agree with closing 845 and, if needed opening more specific issues referencing the upstream repos |
bors r+ |
963: Add tests and documentation with improvement of downcast type compatibility (part of #845) r=hgrecco a=jthielen As a part of #845, this PR adds tests for downcast type compatibility with Sparse's `COO` and NumPy's `MaskedArray`, along with more careful handling of downcast types throughout the library. Also included is new documentation on array type compatibility, including the type casting hierarchy digraph by @shoyer and @crusaderky. While this PR doesn't fully bring Pint's downcast type compatibility to a completed state, I think this gets it "good enough" for the upcoming release, and the remaining issues are fairly well defined: - MaskedArray non-commutativity (#633 / numpy/numpy#15200) - Dask compatibility (#883) - Addition of CuPy tests (no issue on issue tracker yet) Because of that, I think this can close #845, but if @hgrecco you want that kept open until the above items are resolved, let me know. - [x] Closes #37; Closes #845 - [x] Executed ``black -t py36 . && isort -rc . && flake8`` 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: Jon Thielen <github@jont.cc>
Build succeeded |
After testing this downstream with MetPy, the issue in #37 (comment) reappeared, making it so that multiplying by a Unit on the right gives an object MaskedArray of Quantities instead of a Quantity with MaskedArray magnitude. This unfortunately ends up being a pretty bad breaking change that makes the situation worse than before. However, when I reverted the change to Unit replacing So, unless I'm missing a fix that works for both Sparse and MaskedArray, there is a dilemma:
Or, put another way, given that we can't have both, for which type of array would we rather have
In either case, a follow-up PR to document the issue is likely needed (since the ideal behavior cannot be realized until numpy/numpy#15200 is resolved). @hgrecco What are your thoughts on this? |
This PR is good step into the right direction. |
966: Update documentation to address MaskedArray breaking change r=hgrecco a=jthielen As discussed in #963 (comment), #963 introduced a breaking change with MaskedArrays with the implementation of `__array_ufunc__` on Unit. This PR documents this breaking change as prompted by #963 (comment) (with the hope that numpy/numpy#15200 can be resolved soon!) - ~~Closes # (insert issue number)~~ - [x] Executed ``black -t py36 . && isort -rc . && flake8`` with no errors - ~~The change is fully covered by automated unit tests~~ (documentation update only) - [x] Documented in docs/ as appropriate - [x] Added an entry to the CHANGES file Co-authored-by: Jon Thielen <github@jont.cc>
As a part of #845, this PR adds tests for downcast type compatibility with Sparse's
COO
and NumPy'sMaskedArray
, along with more careful handling of downcast types throughout the library. Also included is new documentation on array type compatibility, including the type casting hierarchy digraph by @shoyer and @crusaderky.While this PR doesn't fully bring Pint's downcast type compatibility to a completed state, I think this gets it "good enough" for the upcoming release, and the remaining issues are fairly well defined:
Because of that, I think this can close #845, but if @hgrecco you want that kept open until the above items are resolved, let me know.
black -t py36 . && isort -rc . && flake8
with no errors