Conversation
|
numpy is not a project dependency. It's currently an optional dependency for "test". Is there a way to make numpy types optional? |
|
@kylebarron thank you, but this kind of complicated typing makes me depressed. Instead, I'm inclined to deprecate >>> import array
>>> class Foo:
... __array_interface__ = {"shape": (2, 2), "typestr": "d", "data": array.array("d", [1,2,3,4]), "version": 3}
...
>>> import numpy
>>> numpy.array(Foo())
array([[1., 2.],
[3., 4.]])The |
|
I pushed another option, which hard-codes
So it's a viable option if you don't expect users to call
To be clear, this is pretty low value for me, so it's totally fine if you want to reject it for complexity. (I think #137 is much higher value, since matrix multiplication is probably much more common, and the typing pain of the currently-inferred union is much worse)
I don't know enough about pros and cons of I don't think it's possible to type that array interface because the type checker isn't able to statically match the |


Similar in spirit to #137 for for the
__array__conversion to numpy.This one is less important than #137 so it's ok if you reject it for complexity:
Before:
After:
np.asarraywhen no explicitdtypeis provided (assuming users callnp.asarrayand notAffine.__array__)float64array specifically.