diff --git a/linopy/common.py b/linopy/common.py index 5ff685e7..0dd66d39 100644 --- a/linopy/common.py +++ b/linopy/common.py @@ -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_): diff --git a/pyproject.toml b/pyproject.toml index 7fcc21bc..fbcbebea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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",