Fix Grid.moments Cartesian orders on 1D grids - #338
PaulWAyers with Copilot wants to merge 3 commits into
Conversation
Co-authored-by: PaulWAyers <15361871+PaulWAyers@users.noreply.github.com>
Co-authored-by: PaulWAyers <15361871+PaulWAyers@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation matches the documented order semantics and includes targeted regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes Cartesian moment-order generation for 1D grids while preserving multidimensional behavior.
Changes:
- Returns correctly shaped Cartesian orders for 1D grids.
- Adds utility and integration-level regression tests across 1D–3D grids.
- Ignores setuptools-scm’s generated version file.
| File | Description |
|---|---|
src/grid/utils.py |
Corrects 1D Cartesian order generation. |
src/grid/tests/test_utils.py |
Tests Cartesian orders across dimensions. |
src/grid/tests/test_grid.py |
Tests Cartesian moments on 1D–3D grids. |
.gitignore |
Excludes generated version metadata. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Your thoughts @marco-2023 and/or @FarnazH ? |
|
I think this is redundant with the other PR from the external contributor and can be closed in lieu of that, but let me know. I"m curious how good (or bad) direct Copilot contributions are. |
|
@PaulWAyers, both branches solve the problem. I think #335 has a better test, and Copilot added an unnecessary commit. I would keep #335 and close this one. |
|
Superseded by #335 |
Grid.moments(..., type_mom="cartesian")raisedAttributeError: module 'numpy' has no attribute 'int'on grids with 1D point arrays (shape(N, 1)), sincenp.intwas removed in NumPy 1.24. Thedim == 1branch also returned the wrong shape (arange(0, order+1)instead of a single row), which would have brokennp.vstackinGrid.momentseven with a valid dtype.generate_orders_horton_order(src/grid/utils.py):dim == 1branch now returnsnp.array([[order]]), matching the row shape produced by thedim == 2anddim == 3branches.generate_orders_horton_orderatdim=1/2/3, and atest_moments_cartesiancase exercised across 1D/2D/3DGridpoint arrays.