Skip to content

Fix JAX sparse array flat indexing#2091

Merged
FlorianPfaff merged 3 commits into
mainfrom
fix/jax-array-from-sparse-flat-indexing
May 19, 2026
Merged

Fix JAX sparse array flat indexing#2091
FlorianPfaff merged 3 commits into
mainfrom
fix/jax-array-from-sparse-flat-indexing

Conversation

@FlorianPfaff
Copy link
Copy Markdown
Owner

Summary

  • Fix array_from_sparse in the JAX backend by applying raveled indices to a flattened dense array before reshaping back to the requested target shape.
  • Add regression tests for 2-D and 3-D multidimensional sparse-to-dense conversion.

Why

The previous implementation computed flat/raveled indices with jnp.ravel_multi_index, but then used those positions to index the original n-D output array. For multidimensional target shapes this indexes the first axis rather than the flattened storage order, which can write values to the wrong positions or raise out-of-bounds errors.

Tests

  • Not run locally; change was made through the GitHub connector.
  • Added tests/backend/test_jax_array_from_sparse.py for CI coverage.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 19, 2026

MegaLinter analysis: Error

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 16.97s
✅ JSON prettier 2 0 0 0 0.43s
✅ JSON v8r 2 0 0 2.77s
✅ MARKDOWN markdownlint 28 0 0 0 1.31s
✅ MARKDOWN markdown-table-formatter 28 0 0 0 0.33s
✅ PYTHON bandit 575 0 0 9.15s
✅ PYTHON black 575 1 0 0 14.27s
✅ PYTHON flake8 575 0 0 5.33s
✅ PYTHON isort 575 2 0 0 1.02s
✅ PYTHON mypy 575 0 0 6.95s
✅ PYTHON pylint 575 0 0 97.57s
✅ PYTHON ruff 575 2 0 0 0.11s
✅ REPOSITORY checkov yes no no 25.33s
✅ REPOSITORY gitleaks yes no no 14.16s
✅ REPOSITORY git_diff yes no no 0.09s
❌ REPOSITORY osv-scanner yes 3 no 1.05s
✅ REPOSITORY secretlint yes no no 9.55s
✅ REPOSITORY syft yes no no 3.17s
✅ REPOSITORY trivy-sbom yes no no 3.57s
✅ REPOSITORY trufflehog yes no no 20.8s
✅ YAML prettier 5 0 0 0 0.5s
✅ YAML v8r 5 0 0 4.9s
✅ YAML yamllint 5 0 0 0.44s

Detailed Issues

❌ REPOSITORY / osv-scanner - 3 errors
Scanning dir .
Starting filesystem walk for root: /
Scanned requirements.txt file and found 63 packages
Scanned requirements-dev.txt file and found 75 packages
Scanned poetry.lock file and found 89 packages
End status: 45 dirs visited, 719 inodes visited, 3 Extract calls, 75.627155ms elapsed, 75.627315ms wall time

Total 3 packages affected by 3 known vulnerabilities (0 Critical, 0 High, 3 Medium, 0 Low, 0 Unknown) from 1 ecosystem.
3 vulnerabilities can be fixed.

+-------------------------------------+------+-----------+---------+---------+---------------+----------------------+
| OSV URL                             | CVSS | ECOSYSTEM | PACKAGE | VERSION | FIXED VERSION | SOURCE               |
+-------------------------------------+------+-----------+---------+---------+---------------+----------------------+
| https://osv.dev/GHSA-65pc-fj4g-8rjx | 6.9  | PyPI      | idna    | 3.13    | 3.15          | poetry.lock          |
| https://osv.dev/GHSA-65pc-fj4g-8rjx | 6.9  | PyPI      | idna    | 3.13    | 3.15          | requirements-dev.txt |
| https://osv.dev/GHSA-65pc-fj4g-8rjx | 6.9  | PyPI      | idna    | 3.13    | 3.15          | requirements.txt     |
+-------------------------------------+------+-----------+---------+---------+---------------+----------------------+

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.5.0 --custom-flavor-setup --custom-flavor-linters PYTHON_PYLINT,PYTHON_BLACK,PYTHON_FLAKE8,PYTHON_ISORT,PYTHON_BANDIT,PYTHON_MYPY,PYTHON_RUFF,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GITLEAKS,REPOSITORY_OSV_SCANNER,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

@github-actions
Copy link
Copy Markdown
Contributor

Test Results

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ❌ ±0 

Results for commit ea7dc2b. ± Comparison against base commit a91f29c.

@FlorianPfaff FlorianPfaff merged commit 09ce143 into main May 19, 2026
7 of 20 checks passed
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