Skip to content

Commit 45ee535

Browse files
committed
Fix the type check the previous commit did not run
CI runs bare `mypy`, over all 57 files. I ran `mypy src/oosim/`, which skips tests and examples, and pushed on the strength of it. Two things it would have caught. `row` had already been inferred as list[str] earlier in the same function, so reusing the name for a list of EVM floats made the subtraction a string operation. And six `type: ignore` comments were unnecessary, which mypy reports as errors under its own strictness settings. No behaviour change: the example prints the same table.
1 parent b7dbf13 commit 45ee535

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

examples/wdm_nonlinear.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def main() -> None:
274274
print(" " + "-" * 60)
275275
for launch_dbm in (-3.0, 0.0, 3.0):
276276
for dispersion in (0.0, 17.0):
277-
row = []
277+
evms = []
278278
for coupled in (False, True):
279279
graph, ports = build(
280280
channels=CHANNELS,
@@ -283,10 +283,10 @@ def main() -> None:
283283
coupled=coupled,
284284
mixing=coupled,
285285
)
286-
row.append(graph.run()[ports["vsa"]].evm * 100.0)
286+
evms.append(graph.run()[ports["vsa"]].evm * 100.0)
287287
print(
288288
f" {launch_dbm:5.0f}dBm {dispersion:6.0f}ps/nm/km "
289-
f"{row[0]:10.2f} % {row[1]:7.2f} % {row[1] - row[0]:+8.2f} %"
289+
f"{evms[0]:10.2f} % {evms[1]:7.2f} % {evms[1] - evms[0]:+8.2f} %"
290290
)
291291
print(" the independent column is what this simulator reported before today.")
292292
print(" at zero dispersion the neighbours never slide past, so the penalty is")

tests/test_wdm_nonlinearity.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def test_step_bounds_must_be_positive(bad: dict[str, float]) -> None:
279279
gamma=GAMMA,
280280
alpha=ALPHA,
281281
distance=SPAN,
282-
**bad, # type: ignore[arg-type]
282+
**bad,
283283
)
284284

285285

@@ -355,8 +355,8 @@ def test_non_degenerate_products_are_six_db_stronger() -> None:
355355
"distance": SPAN,
356356
"phase_mismatch": 0.0,
357357
}
358-
degenerate = fwm_product_power(POWER, POWER, POWER, degenerate=True, **common) # type: ignore[arg-type]
359-
mixed = fwm_product_power(POWER, POWER, POWER, degenerate=False, **common) # type: ignore[arg-type]
358+
degenerate = fwm_product_power(POWER, POWER, POWER, degenerate=True, **common)
359+
mixed = fwm_product_power(POWER, POWER, POWER, degenerate=False, **common)
360360
assert 10.0 * math.log10(mixed / degenerate) == pytest.approx(6.0206, rel=1e-6)
361361

362362

@@ -554,6 +554,6 @@ def test_a_linear_span_is_untouched_by_either_effect() -> None:
554554
ctx, signal = comb(4)
555555
fiber = Fiber(length=80.0, attenuation=0.2, dispersion=17.0, nonlinearity=0.0)
556556
result = fiber.run(ctx, {"in": signal})
557-
assert result["diagnostics"].mixing_products == 0 # type: ignore[attr-defined]
558-
assert result["diagnostics"].steps == 0 # type: ignore[attr-defined]
559-
assert len(result["out"].bands) == 4 # type: ignore[attr-defined]
557+
assert result["diagnostics"].mixing_products == 0
558+
assert result["diagnostics"].steps == 0
559+
assert len(result["out"].bands) == 4

0 commit comments

Comments
 (0)