-
-
Notifications
You must be signed in to change notification settings - Fork 31
What to do with array_like variables #37
Comments
I don't think we've turned |
Would it make sense to type |
That seems like a reasonable start, though given the currently state of Numpy's aggressive coercion, arguably |
Looping back around to this, in a non-generic ndarray world, I think Ralf's suggestion of
(I took out
When we get around to "generic ndarray" then the original question of @johanvergeer becomes wide open again; it might be a good situation for protocols (possible post #63) + a MyPy plugin. (The plugin can handle more complex things like "choose between the But, from the discussion in #48 with @seberg, it's looking very much like the right move re generic |
Closes numpy#37. Add tests to check various examples.
Closes numpy#37. Add tests to check various examples.
Concrete proposal here: #66. |
Closes numpy#37. Add tests to check various examples.
Closes numpy#37. Add tests to check various examples. Note that supporting __array__ also requires making _DtypeLike public too, so this does that as well.
Closes numpy#37. Add tests to check various examples. Note that supporting __array__ also requires making _DtypeLike public too, so this does that as well.
Closes numpy#37. Add tests to check various examples. Note that supporting __array__ also requires making _DtypeLike public too, so this does that as well.
Closes numpy#37. Add tests to check various examples. Note that supporting __array__ also requires making _DtypeLike public too, so this does that as well.
Closes numpy#37. Add tests to check various examples. Note that supporting __array__ also requires making _DtypeLike public too, so this does that as well.
Closes numpy#37. Add tests to check various examples. Note that supporting __array__ also requires making _DtypeLike public too, so this does that as well.
Closes #37. Add tests to check various examples. Note that supporting __array__ also requires making _DtypeLike public too, so this does that as well.
I'm currently working on
core.numeric
and I'm running into an interesting issue.A lot of methods have an
array_like
input parameter and anndarray
as the output parameter.For now I created a
TypeVar
like the following:As an example I will use the
zeros_like
functionThis function returns an instance of
ndarray
containing the same type asa
, or it can be overridden bydtype
.This brought me to the following conclusions (please correct me if I'm wrong)
a
can be either_ArrayLike
whena
is a scalar or object_ArrayLike[T]
whena
is a collectionndarray[_ArrayLike]
whena
is a scalar or object anddtype
isNone
ndarray[T]
whena
is_ArrayLike[T]
anddtype
isNone
ndarray[dtype]
whendtype
is notNone
I'm wondering what the type annotations of
a
and the return value should look like.The text was updated successfully, but these errors were encountered: