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

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

@GianlucaFicarelli

Description

@GianlucaFicarelli

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)])

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions