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

DeprecationWarning with numpy 1.25: Conversion of an array with ndim > 0 to a scalar is deprecated #279

Open
GianlucaFicarelli opened this issue Jun 27, 2023 · 2 comments
Assignees

Comments

@GianlucaFicarelli
Copy link
Contributor

With numpy 1.25 and libsonata 0.1.21, this code causes a DeprecationWarning:

import numpy as np
import libsonata
cc = libsonata.CircuitConfig.from_file("tests/data/config/circuit_config.json")
pop = cc.edge_population("edges-AB")
ids = np.asarray([1])
pop.afferent_edges(ids)

Result:

<ipython-input-1-d0433371129e>:6: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
  pop.afferent_edges(ids)
Selection([(0, 1), (2, 4)])

While these calls don't cause any warning:

In [2]: ids = [1]
   ...: pop.afferent_edges(ids)
   ...: 
Selection([(0, 1), (2, 4)])

In [3]: ids = 1
   ...: pop.afferent_edges(ids)
Selection([(0, 1), (2, 4)])
@mgeplf
Copy link
Contributor

mgeplf commented Jun 28, 2023

Thanks for the repro, I can generate the same error.

I will look into it.

@mgeplf mgeplf self-assigned this Jun 28, 2023
@mgeplf
Copy link
Contributor

mgeplf commented Jun 28, 2023

It's an ordering issue when creating the bindings; because the scalar version is registered first, it is used. I guess previously, auto-coercion would happen from the single element array, to a scalar (since this came first), where we would change it back into a vector...

I need to check where else we may be doing this.

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

No branches or pull requests

2 participants