From be1b67c79f90fd5236f55215f0f58065e91db4c2 Mon Sep 17 00:00:00 2001 From: Joni Herttuainen Date: Mon, 8 Jul 2024 14:06:18 +0200 Subject: [PATCH] Fix tests for numpy>=2 --- bluepysnap/circuit_validation.py | 3 +++ tests/test_edges.py | 6 +++--- tests/test_nodes.py | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bluepysnap/circuit_validation.py b/bluepysnap/circuit_validation.py index c40443f7..f310af3b 100644 --- a/bluepysnap/circuit_validation.py +++ b/bluepysnap/circuit_validation.py @@ -20,6 +20,9 @@ L = logging.getLogger("brainbuilder") MAX_MISSING_FILES_DISPLAY = 10 +# print numpy scalars as "1" instead of "np.uint64(1)" +np.set_printoptions(legacy="1.25") + def _check_partial_circuit_config(config): return config.get("metadata", {}).get("status") == "partial" diff --git a/tests/test_edges.py b/tests/test_edges.py index 7cab4001..114e5899 100644 --- a/tests/test_edges.py +++ b/tests/test_edges.py @@ -233,9 +233,9 @@ def test_get(self): tested = self.test_obj.get(ids, properties=["other2", "other1", "@source_node"]) expected = pd.DataFrame( { - "other2": np.array([np.NaN, np.NaN, np.NaN, np.NaN, 10, 11, 12, 13], dtype=float), + "other2": np.array([np.nan, np.nan, np.nan, np.nan, 10, 11, 12, 13], dtype=float), "other1": np.array( - [np.NaN, np.NaN, np.NaN, np.NaN, "A", "B", "C", "D"], dtype=object + [np.nan, np.nan, np.nan, np.nan, "A", "B", "C", "D"], dtype=object ), "@source_node": np.array([2, 0, 0, 2, 2, 0, 0, 2], dtype=int), }, @@ -329,7 +329,7 @@ def test_get(self): tested = self.test_obj.get(ids, properties="other2") expected = pd.DataFrame( { - "other2": np.array([np.NaN, np.NaN, np.NaN, np.NaN, 10, 11, 12, 13], dtype=float), + "other2": np.array([np.nan, np.nan, np.nan, np.nan, 10, 11, 12, 13], dtype=float), }, index=pd.MultiIndex.from_tuples( [ diff --git a/tests/test_nodes.py b/tests/test_nodes.py index c135bfe9..d3f4da7e 100644 --- a/tests/test_nodes.py +++ b/tests/test_nodes.py @@ -286,8 +286,8 @@ def test_get(self): tested = pd.concat(df for _, df in tested) expected = pd.DataFrame( { - "other2": np.array([np.NaN, np.NaN, np.NaN, 10, 11, 12, 13], dtype=float), - "other1": np.array([np.NaN, np.NaN, np.NaN, "A", "B", "C", "D"], dtype=object), + "other2": np.array([np.nan, np.nan, np.nan, 10, 11, 12, 13], dtype=float), + "other1": np.array([np.nan, np.nan, np.nan, "A", "B", "C", "D"], dtype=object), "layer": np.array([2, 6, 6, 7, 8, 8, 2], dtype=int), }, index=pd.MultiIndex.from_tuples( @@ -373,7 +373,7 @@ def test_get(self): tested = self.test_obj.get(properties="other2") expected = pd.DataFrame( { - "other2": np.array([np.NaN, np.NaN, np.NaN, 10, 11, 12, 13], dtype=float), + "other2": np.array([np.nan, np.nan, np.nan, 10, 11, 12, 13], dtype=float), }, index=pd.MultiIndex.from_tuples( [