Skip to content

Commit

Permalink
Merge #963
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bors[bot] and jthielen authored Dec 30, 2019
2 parents f36cc74 + bd1897e commit 0d09f54
Show file tree
Hide file tree
Showing 9 changed files with 1,027 additions and 244 deletions.
9 changes: 8 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ Pint Changelog
0.10 (unreleased)
-----------------

- Documentation on Pint's array type compatibility has been added to the NumPy support
page, including a graph of the duck array type casting hierarchy as understood by Pint
for N-dimensional arrays.
(Issue #963, Thanks Jon Thielen, Stephan Hoyer, and Guido Imperiale)
- Improved compatibility for downcast duck array types like Sparse and Masked Arrays. A
collection of basic tests has been added.
(Issue #963, Thanks Jon Thielen)
- Improvements to wraps and check:
- fail upon decoration (not execution) by checking wrapped function signature against
wraps/check arguments.
Expand All @@ -12,7 +19,7 @@ Pint Changelog
(might BREAK code not conforming to documentation)
- when strict=True, strings that can be parsed to quantities are accepted as arguments.
- Add revolutions per second (rps)
- Improved compatbility for upcast types like xarray's DataArray or Dataset, to which
- Improved compatibility for upcast types like xarray's DataArray or Dataset, to which
Pint Quantities now fully defer for arithmetic and NumPy operations. A collection of
basic tests for proper deferral has been added (for full integration tests, see
xarray's test suite). The list of upcast types is available at
Expand Down
Loading

0 comments on commit 0d09f54

Please sign in to comment.