Add shape handling and better compatabilty with numpy#31
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands the array constructors and conversion helpers in the three numpy-backed extension modules (qarray, qiarray, qcarray) to accept tuple shapes (multidimensional) and adds numpy-compatible copy/order/ndmin keyword arguments to array/asarray, plus an order keyword to ravel. Tests are added for the new shapes/keywords and for numpy reductions/concatenate/stack interoperability. A small fix in qcmplx.c adds float/int acceptance in PyObject_to_QuadCObject and corrects two bool-returning paths that wrongly returned NULL.
Changes:
- Add multidimensional shape parsing and shared
..._from_object/..._parse_orderhelpers inqfloatarray.c,qiarray.c,qcarray.c; rewirearray/asarray/ravelto useMETH_VARARGS | METH_KEYWORDSwith new kwargs; update.pyistubs accordingly. - In
qcmplx.c, acceptPyFloat/PyLonginputs inPyObject_to_QuadCObjectand replace tworeturn NULL;withreturn false;in abool-returning function. - Tooling: tighten
build_and_test.shwithset -euo pipefail, and tweak.github/copilot-instructions.mdwording (require limited API; ufunc preference; broaden test guidance). Tests added intests/qarray_test.py,tests/qiarray_test.py,tests/qcarray_test.py.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pyquadp/qfloatarray.c | Adds shape/order helpers, refactors array/asarray/ravel/constructors for ND shapes and kwargs. |
| pyquadp/qiarray.c | Same refactor pattern as qfloatarray for the integer array module. |
| pyquadp/qcarray.c | Same refactor pattern as qfloatarray for the complex array module. |
| pyquadp/qcmplx.c | Adds float/int support in PyObject_to_QuadCObject and fixes wrong NULL returns in bool paths. |
| pyquadp/qarray.pyi | Stubs updated for ShapeLike and new keyword arguments. |
| pyquadp/qiarray.pyi | Stubs updated for ShapeLike and new keyword arguments. |
| pyquadp/qcarray.pyi | Stubs updated for ShapeLike and new keyword arguments. |
| tests/qarray_test.py | New tests for tuple shapes, ravel order, array/asarray kwargs, and numpy reductions/concat/stack. |
| tests/qiarray_test.py | Same set of new tests for the integer array module. |
| tests/qcarray_test.py | Same set of new tests for the complex array module. |
| build_and_test.sh | Adds set -euo pipefail to fail fast on errors. |
| .github/copilot-instructions.md | Tightens limited-API requirement, adds ufunc preference, broadens test validation guidance. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.