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

Marten van Kerkwijk m.h.vankerkwijk at gmail.com
Sun Mar 18 11:57:32 EDT 2018


Yes, a tuple of types would make more sense, given `isinstance` --
string abbreviations for those could be there for convenience.
-- Marten


On Sat, Mar 17, 2018 at 8:25 PM, Eric Wieser
<wieser.eric+numpy at gmail.com> wrote:
> I would have thought that a simple tuple of types would be more appropriate
> than using integer flags, since that means that isinstance can be used on
> the individual elements. Ideally there’d be a typing.Intersection[TraitA,
> TraitB] for this kind of thing.
>
>
> On Sat, 17 Mar 2018 at 15:10 Thomas Caswell <tcaswell at gmail.com> wrote:
>>
>> Yes, meant IntFlag :sheep:
>>
>> On Sat, Mar 17, 2018 at 6:02 PM Hameer Abbasi <einstein.edison at gmail.com>
>> wrote:
>>>
>>>
>>> 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? 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:
>>>
>>> Check with isinstance for the ABCs, or
>>> 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.
>>>
>>> _______________________________________________
>>> NumPy-Discussion mailing list
>>> NumPy-Discussion at python.org
>>> https://mail.python.org/mailman/listinfo/numpy-discussion
>>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion at python.org
>> https://mail.python.org/mailman/listinfo/numpy-discussion
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list