Skip to content

Commit 4ddf3fb

Browse files
FBumannclaude
andauthored
chore: fix typing with new highspy version (#795)
* fix(highs): pass uint8 integrality array to changeColsIntegrality highspy's changeColsIntegrality expects var_types as a uint8 array (matching HiGHS's uint8-backed HighsVarType enum). The persistent update path already builds it as uint8 (_apply_var_types); align the direct-solve path so it matches highspy's tightened type stubs and is robust across versions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(highs): silence assignment error on highspy lazy module highspy is imported under TYPE_CHECKING, so mypy types `highspy` as the module; assigning the `_LazyModule` shim then trips [assignment] once highspy ships recognized types (highspy 1.13.1). Mirror the existing gurobipy line with `# type: ignore[assignment]`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2d47d4a commit 4ddf3fb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

linopy/solvers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def __getattr__(self, attr: str) -> Any:
294294

295295

296296
gurobipy = _LazyModule("gurobipy") # type: ignore[assignment]
297-
highspy = _LazyModule("highspy")
297+
highspy = _LazyModule("highspy") # type: ignore[assignment]
298298
scip = _LazyModule("pyscipopt")
299299
cplex = _LazyModule("cplex")
300300
knitro = _LazyModule("knitro")
@@ -1656,7 +1656,7 @@ def _build_solver_model(
16561656
int_mask = (vtypes == "B") | (vtypes == "I") | (vtypes == "S")
16571657
labels = np.arange(len(vtypes))[int_mask]
16581658
integrality = np.array(
1659-
[integrality_map[v] for v in vtypes[int_mask]], dtype=np.int32
1659+
[integrality_map[v] for v in vtypes[int_mask]], dtype=np.uint8
16601660
)
16611661
h.changeColsIntegrality(len(labels), labels, integrality)
16621662

0 commit comments

Comments
 (0)