[Numpy-discussion] NEP 42 and physical unit DType

Lee Johnston lee.johnston.100 at gmail.com
Fri Oct 9 08:48:17 EDT 2020


NEP 42 mentions physical units as a possible use case for the new DType.
Having worked on `unyt`, which is an ndarray subclass, and other unit
system implementations based on the dispatch mechanism, I am quite familiar
with the challenges. One challenge is integration with Matplotlib that has
a unit conversion interface. This interface is invoked by a registry
mapping from unit array type, such as `unyt_array`, and its conversion
class. A custom DType will still result in an ndarray type - correct? If
so, Matplotlib will attempt to perform its internal calculations eventually
leading to an invalid operation when adding a physical quantity to a pure
number. This happens today with `unyt_array` and some of the plotting
functions that allow the subclass to leak through into the internals. Has
this been discussed? I can imagine other libraries will have the same
challenge.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20201009/8902c364/attachment.html>


More information about the NumPy-Discussion mailing list