Skip to content

Reject masked JAX norm axes - #4983

Closed
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/reject-masked-jax-norm-axes
Closed

Reject masked JAX norm axes#4983
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/reject-masked-jax-norm-axes

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

What changed

  • reject genuinely masked NumPy axis values before JAX/static-axis coercion
  • cover direct masked axes and masked scalar entries nested in lists or tuples
  • preserve valid ordinary static-axis inputs and fully unmasked nested scalar axes
  • add a focused backend-portable regression

Root cause

The JAX linalg.norm compatibility layer normalizes list and tuple axes entry by entry. For a masked NumPy scalar such as np.ma.array(1, mask=True), operator.index() exposes the hidden payload. Consequently, axis=[np.ma.array(1, mask=True)] was silently normalized to (1,) and the norm was evaluated along axis 1 instead of rejecting a missing axis value.

Direct masked arrays could also leak backend-specific ValueErrors during JAX conversion rather than producing the documented axis validation error.

Impact

Missing or masked configuration can no longer become a real norm axis through its hidden payload. Callers now receive a deterministic TypeError for all genuinely masked axis forms.

Validation

  • reproduced the pre-fix nested-axis behavior: a masked scalar payload of 1 produced [5.0, 13.0]
  • exercised the patched normalizer against scalar, vector, nested-list, and nested-tuple masked axes
  • verified all masked cases raise the documented TypeError
  • verified existing NumPy/JAX scalar, array, list, and tuple axis forms still produce [5.0, 13.0]
  • final comparison is 2 commits ahead and 0 behind main, limited to 4 source lines and one focused regression file

GitHub Actions will run the repository's full supported backend and Python-version matrix.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 19.06s
✅ JSON prettier 7 0 0 0 1.03s
✅ JSON v8r 7 0 0 3.3s
✅ MARKDOWN markdownlint 68 0 0 0 1.59s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.69s
✅ PYTHON black 1810 56 0 0 70.7s
✅ PYTHON isort 1810 89 0 0 2.19s
✅ REPOSITORY betterleaks yes no no 1.65s
✅ REPOSITORY checkov yes no no 43.83s
✅ REPOSITORY gitleaks yes no no 13.12s
✅ REPOSITORY git_diff yes no no 0.31s
✅ REPOSITORY secretlint yes no no 65.53s
✅ REPOSITORY syft yes no no 4.24s
✅ REPOSITORY trivy-sbom yes no no 3.43s
✅ REPOSITORY trufflehog yes no no 26.32s
✅ YAML prettier 11 0 0 0 0.57s
✅ YAML v8r 11 0 0 9.42s
✅ YAML yamllint 11 0 0 0.4s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.6.0 --custom-flavor-setup --custom-flavor-linters PYTHON_BLACK,PYTHON_ISORT,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GITLEAKS,REPOSITORY_BETTERLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

Copy link
Copy Markdown
Owner Author

Closing as low value. This adds masked-array semantics to a JAX batched-solve path, but masked arrays are not part of the normal JAX/PyRecEst array contract. Supporting them here in isolation would create an inconsistent API without broader end-to-end masked-array support.

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