-
Notifications
You must be signed in to change notification settings - Fork 49
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
BUG: fix raising a unyt array to an array power in sensible cases #524
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m sorry for the delayed response. When
a = unyt_array([1, 2, 3])
p = unyt_array([1, 2, 3, 4])
a**p
should not raise an error. However, I tried it and that’s not the case.
unyt/tests/test_unyt_array.py
Outdated
@pytest.mark.parametrize( | ||
"p", | ||
[ | ||
pytest.param(unyt_array([0, 1, 2, 3]), id="non-uniform power"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be valid only when a
is a dimensionless array.
What's your expectation when the array shapes don't match? In your example, those arrays will raise a broadcast error with plain numpy, so I wouldn't expect the operation to work with unyt.
ValueError: operands could not be broadcast together with shapes (3,) (4,) |
Oh, I'm sorry for the typo! These two arrays are supposed to be the same, or any two dimensionless unyt_arrays with the same shape. |
1fedbac
to
2908100
Compare
Phew, that was a wild ride, but I think I fixed it. I don't like how complex this is turning out but I'm running out of time. Let me know if you see ways to simplify the logic. |
Thank you so much for your work, everything is working fine now. Since I don’t fully understand some of your implements, I’m unable to suggest ways to simplify the logic. Nevertheless, I really appreciate it! |
Alright. @jzuhone this is currently the last bugfix on the 3.0.4 milestone. Can you have a look ? |
Trying to fix the few cases where it does make sense to raise a unyt array to a power array.
Close #522