-
Notifications
You must be signed in to change notification settings - Fork 767
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
Code marked as unreachable after numpy.cross() #3277
Comments
This appears to be a bug in the type stubs that ship with @overload
def cross(
a: _ArrayLikeBool_co,
b: _ArrayLikeBool_co,
axisa: int = ...,
axisb: int = ...,
axisc: int = ...,
axis: None | int = ...,
) -> NoReturn: ... If the provided arguments have an unknown type, this first overload will be selected, and a You can work around the issue by providing appropriate type annotations for The real fix will need to be made by the maintainers of numpy. They should delete the first overload, the one that returns a |
Ok I'll close the issue in that case |
Has a corresponding issue been opened with the numpy maintainers? |
Code snippet to work around the problem import numpy as np
#option 1
cross1 = lambda x,y:np.cross(x,y)
#option 2
def cross2(a:np.ndarray,b:np.ndarray)->np.ndarray:
return np.cross(a,b)
def cross_test():
y_ax1 = cross1(np.array([1, 0, 0]), np.array([0, 1, 0]))
y_ax2 = cross2(np.array([1, 0, 0]), np.array([0, 1, 0]))
print(y_ax1)
return y_ax1,y_ax2
if __name__ == "__main__":
cross_test() |
@Korijn Yes, see numpy/numpy#22146. |
Environment data
Code Snippet
Logs
Unclear how to do this, I changed the settings.json as instructed and no additional output was generated.
The text was updated successfully, but these errors were encountered: