Skip to content

Commit

Permalink
fix: unpin numpy<2 for python>3.10 (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
ollie-bell authored Feb 9, 2025
1 parent 9347bcb commit 060f9ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion linopy/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,11 @@ def infer_schema_polars(ds: Dataset) -> dict[Hashable, pl.DataType]:
dict: A dictionary mapping column names to their corresponding Polars data types.
"""
schema = {}
np_major_version = int(np.__version__.split(".")[0])
use_int32 = os.name == "nt" and np_major_version < 2
for name, array in ds.items():
if np.issubdtype(array.dtype, np.integer):
schema[name] = pl.Int32 if os.name == "nt" else pl.Int64
schema[name] = pl.Int32 if use_int32 else pl.Int64
elif np.issubdtype(array.dtype, np.floating):
schema[name] = pl.Float64 # type: ignore
elif np.issubdtype(array.dtype, np.bool_):
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ classifiers = [

requires-python = ">=3.9"
dependencies = [
"numpy<2.0",
"numpy; python_version > '3.10'",
"numpy<2; python_version <= '3.10'",
"scipy",
"bottleneck",
"toolz",
Expand Down

0 comments on commit 060f9ad

Please sign in to comment.