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
Allow simplified syntax: arr: NDArray["2, 2", int]
?
#92
Comments
Hi @petered , Concerning your two proposals:
|
Hi Ramon, thanks for your response. I don't understand MyPy enough to know the difficulty involved, and honestly probably won't have the time to invest to see if it's doable. For me - the primary value of Perhaps, assuming other people are using
What would you think of this idea? |
Hi there Peter, If documentation is the only thing you're after, then maybe aliasing literals may be sufficient for you? It would save you a dependency and you would be free to use Python primitives as well. You could still choose to use the from typing import Literal as NDArray
arr: NDArray["H, W, 3", int] What this lacks is that there is no checking of that syntax of course, but you could do that "offline" in a repl. You could also alias from nptyping import NDArray, Int, Shape as _
arr: NDArray[_["H, W, 3", Int]] I actually plan to promote this last trick for the upcoming
The difficulty is that MyPy simply regards a piece of string inside any type that is not a |
No more recent activity: closing. |
NPTyping is great, but could be more concise.
The main value of NDArray to me is to have a very concise way of documenting shapes.
I would propose
NDArray["2,2", Int]
orNDArray[(2, 2), Int]
, as opposed to the more verboseNDArray[Shape["2,2"], Int]
int
vsnptyping.Int
, etc.I'd be happy to make a PR to this effect if it is approved in spirit.
The text was updated successfully, but these errors were encountered: