From 26c50c8a572e34342982b8dbab002ea108db7c09 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 14 Jul 2026 02:56:36 +0000 Subject: [PATCH] Fix mypy return-type error in _mreg_distances FACTOR branch np.mean(..., axis=2) is typed as float64 | ndarray by the numpy stubs even though axis=2 always yields an array. Narrow it with the same cast(NDArray[np.float64], ...) idiom already used elsewhere in the file, making mypy fully clean (47 files, no issues). Pure type narrowing; no runtime change. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_019F6ZjcfXSxZWGMuSmQGmLN --- src/nns/_reg_engine.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/nns/_reg_engine.py b/src/nns/_reg_engine.py index 820d566b..d8ece6d7 100644 --- a/src/nns/_reg_engine.py +++ b/src/nns/_reg_engine.py @@ -908,8 +908,9 @@ def _mreg_distances( ) -> NDArray[np.float64]: """(m, n) distance matrix under the repaired metric.""" if dist == "FACTOR": - return np.mean( - rpm_x[None, :, :] != xtest[:, None, :], axis=2, dtype=np.float64 + return cast( + NDArray[np.float64], + np.mean(rpm_x[None, :, :] != xtest[:, None, :], axis=2, dtype=np.float64), ) ranges = maxs - mins active = np.isfinite(ranges) & (ranges > 0)