Skip to content

Fix mypy return-type error in _mreg_distances FACTOR branch - #115

Merged
OVVO-Financial merged 1 commit into
mainfrom
claude/nns-python-v1.3-release-in5n5t
Jul 14, 2026
Merged

Fix mypy return-type error in _mreg_distances FACTOR branch#115
OVVO-Financial merged 1 commit into
mainfrom
claude/nns-python-v1.3-release-in5n5t

Conversation

@OVVO-Financial

Copy link
Copy Markdown
Owner

Summary

Closes the one remaining mypy error so the type-check is fully green.

_mreg_distances returned np.mean(rpm_x[None, :, :] != xtest[:, None, :], axis=2, dtype=np.float64) in the FACTOR branch. numpy's stubs type np.mean(...) as float64 | ndarray even though passing axis=2 always yields an array, so mypy flagged an incompatible return value against the declared NDArray[np.float64].

Narrowed the result with cast(NDArray[np.float64], ...) — the same idiom already used elsewhere in this module (e.g. _reg_engine.py:400). This is a pure type narrowing with no runtime change.

Verification

  • mypy src/nnsSuccess: no issues found in 47 source files (was 1 error)
  • ruff check → clean
  • Regression parity suites pass (tests/parity/test_multivariate_regression.py, tests/parity/test_regression.py: 323 passed)

🤖 Generated with Claude Code


Generated by Claude Code

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019F6ZjcfXSxZWGMuSmQGmLN
@OVVO-Financial
OVVO-Financial merged commit de90862 into main Jul 14, 2026
8 checks passed
@OVVO-Financial
OVVO-Financial deleted the claude/nns-python-v1.3-release-in5n5t branch July 14, 2026 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants