Hi Nathaniel,

Overall, hugely in favour!  For detailed comments, it would be good to
have a link to a PR; could you put that up?

A larger comment: you state that you think `np.asanyarray` is a
mistake since `np.matrix` and `np.ma.MaskedArray` would pass through
and that those do not strictly mimic `NDArray`. Here, I agree with
`matrix` (but since we're deprecating it, let's remove that from the
discussion), but I do not see how your proposed interface would not
let `MaskedArray` pass through, nor really that one would necessarily
want that.

I think it may be good to distinguish two separate cases:
1. Everything has exactly the same meaning as for `ndarray` but the
data is stored differently (i.e., only `view` does not work). One can
thus expect that for `output = function(inputs)`, at the end all
`duck_output == ndarray_output`.
2. Everything is implemented but operations may give different output
(depending on masks for masked arrays, units for quantities, etc.), so
generally `duck_output != ndarray_output`.

Which one of these are you aiming at? By including
`NDArrayOperatorsMixin`, it would seem option (2), but perhaps not? Is
there a case for both separately?

Smaller general comment: at least in the NEP I would not worry about
deprecating `NDArrayOperatorsMixin` - this may well be handy in itself
(for things that implement `__array_ufunc__` but do not have shape,
etc. (I have been doing some work on creating ufunc chains that would
use this -- but they definitely are not array-like). Similarly, I
think there is room for an `NDArrayShapeMixin` which might help with
`concatenate` and friends.

Finally, on the name: `asarray` and `asanyarray` are just shims over
`array`, so one option would be to add an argument in `array` (or
broaden the scope of `subok`).

As an explicit suggestion, one could introduce a `duck` or `abstract`
argument to `array` which is used in `asarray` and `asanyarray` as
well (corresponding to options 1 and 2), and eventually default to
something sensible (I would think `False` for `asarray` and `True` for
`asanyarray`).

All the best,

Marten
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to