From d66f612476891d94143dbb9c987dd31d838f8aea Mon Sep 17 00:00:00 2001 From: owinter Date: Mon, 18 Nov 2024 14:40:42 +0000 Subject: [PATCH] refactor for numpy 2.0 compatibility --- iblatlas/genomics/merfish_scrapping/01_ingest_zhuang.py | 4 ++-- iblatlas/regions.py | 2 +- iblatlas/tests/test_atlas.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/iblatlas/genomics/merfish_scrapping/01_ingest_zhuang.py b/iblatlas/genomics/merfish_scrapping/01_ingest_zhuang.py index 3b4e0f7..5afe538 100644 --- a/iblatlas/genomics/merfish_scrapping/01_ingest_zhuang.py +++ b/iblatlas/genomics/merfish_scrapping/01_ingest_zhuang.py @@ -45,7 +45,7 @@ def int_after_colon(text): captured_integer = int(match.group(1)) return float(captured_integer) else: - return np.NaN + return np.nan def fcn_groupby_check_unique(df_cells, group, fields): @@ -79,7 +79,7 @@ def reindex_missing_rows(df): elif isinstance(missing_rec[k], int | np.uint32 | np.int32 | np.uint64 | np.int64): missing_rec[k] = 0 elif isinstance(missing_rec[k], float | np.float32 | np.float64): - missing_rec[k] = np.NaN + missing_rec[k] = np.nan df = df.reindex(pd.Index(np.arange(np.max(df.index) + 1), name=df.index.name), fill_value=0) df.iloc[imiss, :] = missing_rec return df diff --git a/iblatlas/regions.py b/iblatlas/regions.py index 0907779..fb9a45c 100644 --- a/iblatlas/regions.py +++ b/iblatlas/regions.py @@ -658,7 +658,7 @@ def propagate_down(self, acronyms, values): _, user_indices = ismember(user_aids, self.id) self.compute_hierarchy() ia, ib = ismember(self.hierarchy, user_indices) - v = np.zeros_like(ia, dtype=np.float64) * np.NaN + v = np.zeros_like(ia, dtype=np.float64) * np.nan v[ia] = values[ib] all_values = np.nanmedian(v, axis=0) indices = np.where(np.any(ia, axis=0))[0] diff --git a/iblatlas/tests/test_atlas.py b/iblatlas/tests/test_atlas.py index 49d9aba..9d62179 100644 --- a/iblatlas/tests/test_atlas.py +++ b/iblatlas/tests/test_atlas.py @@ -527,7 +527,7 @@ def test_init_from_dict(self): brain_atlas = _create_mock_atlas() brain_atlas.compute_surface() - brain_atlas.top = brain_atlas.top * np.NaN + brain_atlas.top = brain_atlas.top * np.nan ins = Insertion.from_dict(d, brain_atlas=brain_atlas) # eval the entry point, should be super close dxyz = ins.trajectory.eval_x(d['x'] / 1e6) - np.array((d['x'], d['y'], d['z'])) / 1e6 @@ -562,7 +562,7 @@ def test_init_from_track(self): brain_exit = insertion.get_brain_exit(insertion.trajectory, brain_atlas) self.assertTrue(brain_exit[2] == brain_atlas.bc.i2z(104)) # test getting no intersection with the brain surface - brain_atlas.srf_xyz *= np.NaN + brain_atlas.srf_xyz *= np.nan with self.assertRaises(ValueError): insertion.get_brain_entry(insertion.trajectory, brain_atlas) self.assertIsNone(insertion.get_brain_entry(insertion.trajectory, brain_atlas, mode='none'))