[Numpy-discussion] new NEP: np.AbstractArray and np.asabstractarray

Hameer Abbasi einstein.edison at gmail.com
Sat Mar 17 18:01:57 EDT 2018


It would be nice if there was an IntEnum [1] that was taken is an input to
`np.asarrayish` and `np.isarrayish` to require a combination of the groups
of attributes/methods/semantics.


Don’t you mean IntFlag <https://docs.python.org/3/library/enum.html#intflag>?
I like Marten’s idea of “grouping together” related functionality via ABCs
and implementing different parts via ABCs (for example, in pydata/sparse we
use NDArrayOperatorsMixin for exactly this), but I believe that separate
ABCs should be provided for different parts of the interface.

Then we can either:

   1. Check with isinstance for the ABCs, or
   2. Check with hasattr.

I like the IntFlag idea most (it seems to be designed for use-cases like
these), but a string-based (np.aspyarray(x,
functionality=‘arithmetic|reductions')) or list-based (np.aspyarray(x,
functionality=[‘arithmetic’, ‘reductions’]) is also fine.

It might help to have some sort of a “dry-run” interface that (given a run
of code) figures out which parts you need.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180317/48b15a31/attachment.html>


More information about the NumPy-Discussion mailing list