8000 Fix compatibility with numpy>=1.21 by adrien-berchet · Pull Request #80 · BlueBrain/morph-tool · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Fix compatibility with numpy>=1.21 #80

Merged
merged 1 commit into from
Jun 25, 2021

Conversation

adrien-berchet
Copy link
Member

Context

Numpy 1.21 changed the signature of np.random.Generator.uniform.

Resolution

Use kwargs for rng.random.uniform.

@@ -95,8 +96,8 @@ def test_graft_axon_on_synthesized_cell():
graft.graft_axon(synthesized_cell, donor_neuron)
axon = graft.find_axon(synthesized_cell)
assert_array_almost_equal(axon.points,
[[5.110419, 5.486378, 4.9647303],
[5.110419, 1.486378, 4.9647303]])
[[5.1272364, 5.4825425, 4.9689593],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why those changes? Is it due to new version of numpy? In that case should its version be fixed in setup.py?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this change is expected and made me discover that we were not using np.random.uniform correctly.
np.random.uniform(low=0, high=1) automatically sorts the low and high arguments, so when calling np.random.uniform(2 * np.pi), we were actually calling np.random.uniform(low=1, high=2 * np.pi)... This behavior is very strange but they did not want to fix it for np.random.uniform because it is frozen and should no more be used, they only fixed it for np.random.Generator.uniform: numpy/numpy#17921

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you for explanation. Up to you to merge.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, nice catch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)

@adrien-berchet adrien-berchet merged commit 5fa91d1 into BlueBrain:master Jun 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0