Skip to content

fix(numpy): broadcast result coordinate shapes - #762

Open
peterolkhov wants to merge 1 commit into
scikit-hep:mainfrom
peterolkhov:codex/broadcast-numpy-vector-coordinate-shapes
Open

peterolkhov wants to merge 1 commit into
scikit-hep:mainfrom
peterolkhov:codex/broadcast-numpy-vector-coordinate-shapes

Conversation

@peterolkhov

Copy link
Copy Markdown

🤖 AI-generated PR description, prepared with Codex (GPT-6.1 Sol, high reasoning).

Description

NumPy vector conversions can raise IndexError after np.sum, or reject broadcastable coordinate arrays such as (2, 1) and (1, 3). Compute the joint result shape with numpy.broadcast so scalar aggregates and multidimensional coordinates convert successfully, while preserving the existing Python-scalar wrapping behavior.

Adds native regressions across generic and momentum 2D/3D/4D conversions, zero-dimensional coordinates, multidimensional and empty-array broadcasts, and scalar arithmetic controls. The shape helper's doctests document the behavior.

Validation: 42 regression failures before the fix; Python 3.14 / NumPy 2.4: 4,979 tests and 119 doctests pass (16 optional skips); Python 3.11 / NumPy 1.23.5: 2,976 available tests pass (1,562 optional skips). All applicable pre-commit hooks pass. The native Sphinx HTML build succeeds with 14 Markdown-extension unknown-node warnings. GPU, ROOT, notebook execution and Dask-Awkward/JAX extras were not run.

Checklist

  • Followed the contribution guidelines.
  • Checked current open pull requests for a competing change.
  • All applicable pre-commit hooks pass.
  • Available native tests pass; optional matrix limits are listed above.
  • Documentation builds locally; the 14 warnings are reported above.
  • Doctests pass.

Before Merging

  • Summarize commit messages into a brief review of the pull request.

Assisted-by: Codex:gpt-6.1-sol

This branch has not been deployed

No deployments
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