-
Notifications
You must be signed in to change notification settings - Fork 50
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
Disallowed typing in linalg.vector_norm
#817
Comments
Yes, this is a known issue. There are some instances where the Python typing rules disallow certain things and we've opted to keep the annotations accurate in those cases. Implementations may need to adjust them until the upstream typing rules can be fixed. |
To illustrate VectorOrder: typing.TypeAlias = int | float
orf: VectorOrder = float('inf') # no problem |
That probably make sense for vector_norm, which actually accepts any float value (other than nan) https://data-apis.org/array-api/latest/extensions/generated/array_api.linalg.vector_norm.html#vector-norm For In any case, it probably is better to just loosen the typing here so that it can work with typing machinery. The actual set of allowed inputs is not representable by Python's typing rules, but it is spelled out in the standard text. |
FYI, |
Spec:
ord: int | float | ~typing.Literal[inf, -inf] = 2
Stubs:
ord: Union[int, float, Literal[inf, -inf]] = 2
Literals
docsA relevant issue: python/typing#1160
I don't know if anything can be done, and this was probably done deliberately, but useful to have an issue nonetheless.
The text was updated successfully, but these errors were encountered: