Skip to content

Commit

Permalink
Add documentation for array interface protocol deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
jthielen committed Dec 26, 2019
1 parent 674e839 commit d555c07
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Pint Changelog
0.10 (unreleased)
-----------------

- Deprecate array protocol fallback except where explicitly defined (`__array__`,
`__array_priority__`, `__array_function__`, `__array_ufunc__`). The fallback will
remain until the next minor version, or if the environment variable
`PINT_ARRAY_PROTOCOL_FALLBACK` is set to 0.
(Issue #953, Thanks Jon Thielen)
- Removed eval usage when creating UnitDefinition and PrefixDefinition from string.
(Issue #942)
- Added `fmt_locale` argument to registry.
Expand Down
9 changes: 9 additions & 0 deletions docs/numpy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ memory and CPU cycles. Therefore, for numerically intensive code, you
might want to convert the objects first and then use directly the magnitude,
such as by using Pint's `wraps` utility (see :ref:`wrapping`).

Array interface protocol attributes (such as `__array_struct__` and
`__array_interface__`) are available on Pint Quantities by deferring to the
corresponding `__array_*` attribute on the magnitude as casted to an ndarray. This
has been found to be potentially incorrect and to cause unexpected behavior, and has
therefore been deprecated. As of the next minor version of Pint (or when the
`PINT_ARRAY_PROTOCOL_FALLBACK` environment variable is set to 0 prior to importing
Pint), attempting to access these attributes will instead raise an AttributeError.





Expand Down

0 comments on commit d555c07

Please sign in to comment.