Skip to content

fix: resolve mypy type errors in decomposition, utils, and viz - #1

Merged
awdemos merged 1 commit into
mainfrom
fix/mypy-type-errors
Sep 6, 2026
Merged

awdemos merged 1 commit into
mainfrom
fix/mypy-type-errors

Conversation

@awdemos

@awdemos awdemos commented Sep 6, 2026

Copy link
Copy Markdown
Owner

This PR resolves the remaining mypy errors in jspace/decomposition.py, jspace/utils.py, and jspace/viz.py.

Changes:

  • Cast numpy arrays returned by torch.detach().cpu().numpy() and safetensors to np.ndarray.
  • Use the Sized protocol for the jl_track iterable length check instead of hasattr.
  • Convert np.arange tick indices to plain Python ints before passing to matplotlib's set_xticks/set_yticks.
  • Cast np.linalg.norm results and operands to float so mypy accepts the arithmetic.

Verification:

  • mypy jspace passes with no issues.
  • ruff check jspace tests scripts passes.
  • pytest tests/test_security.py tests/test_bugfixes.py tests/test_cli.py passes (23 tests).

- Cast numpy arrays from torch.detach().cpu().numpy() and safetensors load to ndarray.

- Use Sized protocol for jl_track iterable length check.

- Convert np.arange tick indices to plain Python ints for matplotlib set_xticks/set_yticks.

- Cast arithmetic operands around np.linalg.norm results to float to satisfy mypy.

All mypy, ruff, and fast tests pass.
@awdemos
awdemos merged commit 5dfee22 into main Sep 6, 2026
1 check failed
@awdemos
awdemos deleted the fix/mypy-type-errors branch September 6, 2026 00:45
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.

1 participant