We may be getting a bit distracted by the naming -- though I'll throw out `asarraymimic` as another non-programmer-lingo option that doesn't reuse `arraylike` and might describe what the duck array is attempting to do more closely.
But more to the point: I think in essence, we're trying to create a function that does the equivalent of: ``` def ...(arraylike, ...) if isinstance(arraylike, NDAbstractArray): return arraylike else: return np.array(arraylike, ...) ``` Given that one possibly might want to check for partial compatibility, maybe the new or old function should just expose what compatibility is desired, via something like: ``` input = np.as...(input, ..., mimicok='shape|operator|...') ``` Where one could have `mimicok=True` to indicate the highest level (maybe not including being viewable?), `False` to not allow any mimics. This might even work for np.array itself: - dtype - any mimic must provide `astype` (which can error if not possible; this could be the ABC default) - copy - can't one just use `copy.copy`? I think this defaults to `__copy__`. - order - can be passed to `astype` as well; up to code to error if not possible. - subok - meaningless - ndmin - requirement of mimicok='shape' would be to provide a shape attribute and reshape method. -- Marten _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion