Skip to content

Commit

Permalink
[python] Support NumPy 2 (#2934) (#3248)
Browse files Browse the repository at this point in the history
* [python] NumPy 2 experiment [WIP]

* fixups from latest CI run

Co-authored-by: John Kerl <[email protected]>
  • Loading branch information
github-actions[bot] and johnkerl authored Oct 28, 2024
1 parent 29ed055 commit 503fa55
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apis/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def run(self):
"pyparsing~=3.1.4",
"attrs>=22.2",
"numba>=0.58.0",
"numpy<2.0",
"numpy",
"pandas",
"pyarrow",
"scanpy>=1.9.2",
Expand Down
4 changes: 2 additions & 2 deletions apis/python/tests/test_basic_anndata_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ def test_null_obs(conftest_pbmc_small, tmp_path: Path):
seed = 42
# Create column of all null values
conftest_pbmc_small.obs["empty_categorical_all"] = pd.Categorical(
[np.NaN] * conftest_pbmc_small.n_obs,
[np.nan] * conftest_pbmc_small.n_obs,
dtype=pd.CategoricalDtype(categories=[], ordered=False),
)
conftest_pbmc_small.obs["empty_extension_all"] = pd.Series(
Expand All @@ -755,7 +755,7 @@ def test_null_obs(conftest_pbmc_small, tmp_path: Path):
rng = np.random.RandomState(seed)

conftest_pbmc_small.obs["empty_categorical_partial"] = rng.choice(
(np.NaN, 1.0), conftest_pbmc_small.n_obs, True
(np.nan, 1.0), conftest_pbmc_small.n_obs, True
)
conftest_pbmc_small.obs["empty_extension_partial"] = pd.Series(
[1] * conftest_pbmc_small.n_obs + [np.nan], dtype=pd.Int64Dtype()
Expand Down
2 changes: 1 addition & 1 deletion apis/python/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ def test_extend_enumerations(tmp_path):
np.array([0, 1.1, 2.1, 0, 1.1, 2.1], dtype=np.float64), dtype="category"
),
"float64_w_non_finite": pd.Series(
np.array([0, 1.1, 2.1, 0, np.Inf, np.NINF], dtype=np.float64),
np.array([0, 1.1, 2.1, 0, np.inf, -np.inf], dtype=np.float64),
dtype="category",
),
"str_ordered": pd.Series(
Expand Down
4 changes: 1 addition & 3 deletions apis/python/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ def test_nd_dense_non_contiguous_write(tmp_path):
"""Test regression dected in GitHub Issue #2537"""
# Create data.
data = (
np.arange(np.product(24), dtype=np.uint8)
.reshape((4, 3, 2))
.transpose((2, 0, 1))
np.arange(np.prod(24), dtype=np.uint8).reshape((4, 3, 2)).transpose((2, 0, 1))
)
coords = tuple(slice(0, dim_len) for dim_len in data.shape)
tensor = pa.Tensor.from_numpy(data)
Expand Down

0 comments on commit 503fa55

Please sign in to comment.