Skip to content

Commit 060f9ad

Browse files
authored
fix: unpin numpy<2 for python>3.10 (#415)
1 parent 9347bcb commit 060f9ad

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

linopy/common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,11 @@ def infer_schema_polars(ds: Dataset) -> dict[Hashable, pl.DataType]:
318318
dict: A dictionary mapping column names to their corresponding Polars data types.
319319
"""
320320
schema = {}
321+
np_major_version = int(np.__version__.split(".")[0])
322+
use_int32 = os.name == "nt" and np_major_version < 2
321323
for name, array in ds.items():
322324
if np.issubdtype(array.dtype, np.integer):
323-
schema[name] = pl.Int32 if os.name == "nt" else pl.Int64
325+
schema[name] = pl.Int32 if use_int32 else pl.Int64
324326
elif np.issubdtype(array.dtype, np.floating):
325327
schema[name] = pl.Float64 # type: ignore
326328
elif np.issubdtype(array.dtype, np.bool_):

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ classifiers = [
2525

2626
requires-python = ">=3.9"
2727
dependencies = [
28-
"numpy<2.0",
28+
"numpy; python_version > '3.10'",
29+
"numpy<2; python_version <= '3.10'",
2930
"scipy",
3031
"bottleneck",
3132
"toolz",

0 commit comments

Comments
 (0)