Skip to content

Commit ba574a4

Browse files
committed
Fix mypy errors in scaling module
1 parent 8d8b3d4 commit ba574a4

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

linopy/scaling.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ def resolve_options(scale: bool | str | ScaleOptions | None) -> ScaleOptions:
126126
if scale is True:
127127
return ScaleOptions()
128128
if isinstance(scale, str):
129-
return ScaleOptions(method=scale)
129+
if scale not in ("row-max", "row-l2"):
130+
msg = f"Invalid scale method: {scale!r}. Must be 'row-max' or 'row-l2'."
131+
raise ValueError(msg)
132+
return ScaleOptions(method=scale) # type: ignore[arg-type]
130133
if isinstance(scale, ScaleOptions):
131134
return scale
132135

test/test_scaling.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def test_row_scaling_and_dual_unscale() -> None:
2323

2424
assert np.isclose(ctx.row_scale[0], 0.25)
2525
assert np.isclose(ctx.row_scale[1], 2.0)
26+
assert M.A is not None
2627
A = np.asarray(M.A.todense())
2728
# Row 0 scaled
2829
assert np.isclose(A[0, 0], 0.5)

0 commit comments

Comments
 (0)