Skip to content
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

Fix unit bug when upgrading numpy to > 1.21 #110

Merged
merged 8 commits into from
Sep 15, 2022

Conversation

Adnan-Ali-Ahmad
Copy link
Collaborator

Hi,

I've upgraded my numpy version to '1.23.3' and this is causing some weird behavior when dividing Arrays/Vectors.
See the example below:

data["hydro"]["velocity"] / data["amr"]["position"]
Out:
'' Min: 1.279e-14 Max: 1.712e-11 [cm / s] (340488,), {x,y,z}

The units are not being properly converted. The reason this happens is because np.divide.__name__ no longer returns 'true_divide', but now returns 'divide'.

Fixing this bug simply requires replacing the string in APPLY_OP_TO_UNIT.

@Adnan-Ali-Ahmad Adnan-Ali-Ahmad changed the title Vaytet osyris Fix unit bug when upgrading numpy to > 1.21 Sep 15, 2022
@Adnan-Ali-Ahmad
Copy link
Collaborator Author

On second thought, it's better to also keep "true_divide" in APPLY_OP_TO_UNIT for compatibility with older versions of numpy.

@nvaytet
Copy link
Collaborator

nvaytet commented Sep 15, 2022

On second thought, it's better to also keep "true_divide" in APPLY_OP_TO_UNIT for compatibility with older versions of numpy.

Yes, that's what I was about to comment.

@nvaytet nvaytet merged commit 36d22bb into osyris-project:main Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants