-
Notifications
You must be signed in to change notification settings - Fork 29
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
dtype NDArray based on enum values #79
Comments
What exactly are you trying to express? Do I understand it correctly that you mean to express an >>> NDArray[Shape["N zeroes or ones or twos"], Int32]
NDArray[Shape['N zeroes or ones or twos'], Int] The |
It's not so much about the shape of the array, as the values in the array. We would like to limit the values inside the NDArray to these of a limited set. Not all values need to be the same. def my_function() -> NDArray[Shape['Any'], MyEnum]: by def my_function() -> NDArray[Shape['Any'], Int]: which works, but ideally we would like to limit the possible values in the result to a set defined by us. |
I see what you mean. This is at this moment not possible; you can express types and shapes, but not values. This would require a new construct. I could imagine something like this: NDArray[Any, Value["0 | 1 | 2"]] Would that express what you want? Off-topic: |
I'm trying to limit the values of an entry in an NDArray to those of an enum class.
Here is a minimal example that illustrates one of my tries until now:
The line in question is:
With versions of nptyping < 2 the code above would pass lint checks. Now the following error is thrown:
The documentation provides a list of possible dtypes. In addition, the Structure keyword can be used to build more complex data structures. Is there also some way to restrict values based on an Enum, since the representation of every option is an integer?
I'd also be happy to use something
Integer[Values[0, 1, 2]]
orSet[0, 1, 2]
in the case above.The text was updated successfully, but these errors were encountered: