-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can we replace Array = Any
with Array = ndarray
now?
#10186
Comments
I don't think it's as simple as that – for example, inputs to JAX functions will accept any array-like object, including Python scalar types, numpy scalar types, numpy arrays, jax arrays/tracers, plus for many functions, arbitrary objects that define a |
I personally prefer |
Oh, I forget |
@jakevdp WDYT about annotate the return type as |
Sure, we could try it, and just be ready to roll it back quickly if it breaks things. |
I have to say though, I have a knee-jerk dislike for using |
@jakevdp |
What's Jax's long term plan with this? Perhaps the Array API will provide annotations that can be used in Jax? |
I wrote a design doc a while ago regarding how the project should approach type annotations (surprise, it's not that simple because "type annotations" are a multiply-overloaded concept in Python!)... it got lost in the shuffle. I'll dust it off and try to generate some discussion. |
❤️Does the design doc also discuss things mentioned in #10322 ? |
BTW, now I know |
It's still unclear whether |
The design doc is coming together here: #11859 In particular, it does answer the main question of this Issue
The answer is No, because we need inputs to functions to be far more flexible than For return values, we can annotate with |
Would it be possible to create a type alias for |
actually in jax, the problem is simpler than numpy, since jax.numpy is not designed to be compatible with sequence, e.g. list. It is not too bad to use an union of scalar, ndarray and supportsjaxarray. |
Yes, the draft doc I linked to mentions doing that in the roadmap. |
I'm going to close this issue, because I think the work going forward is better outlined and tracked elsewhere. If you have thoughts about the type annotation roadmap, please feel free to comment on #11859 |
Hi @YouJiacheng - if you're still interested in this, we've started the process of doing these sorts of annotations in #12049. See the attached PRs for a few examples. Sorry it took such a long time to get there, but we'd love your help now if you'd like to contribute! |
It seems that problems in #943 have been resolved?
The text was updated successfully, but these errors were encountered: