Skip to content

Commit 9f7f88b

Browse files
feat: use "diagonal_relaxed" to avoid dtype incompat in polars concat function when writing lp (#507)
1 parent 343bce0 commit 9f7f88b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

doc/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Upcoming Version
88
* Reduced memory usage and faster file I/O operations when exporting models to LP format
99
* Improved constraint equality check in `linopy.testing.assert_conequal` to less strict optionally
1010
* Minor bugfix for multiplying variables with numpy type constants
11+
* Harmonize dtypes before concatenation in lp file writing to avoid dtype mismatch errors. This error occurred when creating and storing models in netcdf format using windows machines and loading and solving them on linux machines.
1112

1213
Version 0.5.6
1314
--------------

linopy/constraints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ def to_polars(self) -> pl.DataFrame:
631631
short = filter_nulls_polars(short)
632632
check_has_nulls_polars(short, name=f"{self.type} {self.name}")
633633

634-
df = pl.concat([short, long], how="diagonal").sort(["labels", "rhs"])
634+
df = pl.concat([short, long], how="diagonal_relaxed").sort(["labels", "rhs"])
635635
# delete subsequent non-null rhs (happens is all vars per label are -1)
636636
is_non_null = df["rhs"].is_not_null()
637637
prev_non_is_null = is_non_null.shift(1).fill_null(False)

0 commit comments

Comments
 (0)