-
Notifications
You must be signed in to change notification settings - Fork 66
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
Inconsistent broadcasting behavior of Py arrays #392
Comments
I don't think this is a bug. Your If you want to broadcast it like an array, then you need to explicitly convert it to an array like you have done (or |
However the fact that you get 2x2 matrix of length-2 vectors back from This isn't a bug, it's just that broadcasting behaviour is as-yet undefined by PythonCall. We could define that behaviour - namely always treat |
Note also
so indeed Julia's broadcasting mechanism is expecting |
Indeed, it's simple to make
|
Is it viable to have a semantic where Python scalars broadcast as scalars and Numpy arrays broadcast as multidimensional arrays? |
You could, by trying to If you want to treat your numpy array as a Julia array, it's much clearer and explicit to do the |
Agreed, attempted |
That also seems magical - |
Yeah, okay. :( So the best we can do without magic is make them all scalars, right? |
I think so. |
Scalar broadcasting implemented on 'main'. |
Affects: Both (easier to reproduce with PythonCall, but I actually hit it using JuliaCall)
Describe the bug
x .* y
wherex
is aPy
wrapping a numpy array andy
is aMatrix
gives strange (buggy) results. Converting to aPyArray
is a workaround:The text was updated successfully, but these errors were encountered: