-
-
Notifications
You must be signed in to change notification settings - Fork 11k
ENH: Add support for copy modes to NumPy #19173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
496bd1a
Added np.CopyMode
czgdp1807 3a3d31b
initial work for supporting never_copy
czgdp1807 be5823f
Addressed reviews and PyArray_CopyConverter defined
czgdp1807 e16f3ff
np.CopyMode.NEVER gives error if copy cannot be avoided in np.array.a…
czgdp1807 645fadb
Updated API ready for formal testing
czgdp1807 8538720
tests for astype added
czgdp1807 8c00223
Added tests for np.array
czgdp1807 4e59da1
Testing for copy argument for existing APIs complete
czgdp1807 6f0f6ac
resolved conflicts
czgdp1807 6bff3dd
Added some notes for future commits
czgdp1807 a90880a
RuntimeError -> ValueError
czgdp1807 5481a8a
enum.IntEnum -> enum.Enum
czgdp1807 f2e7a81
aligned astype with main branch
czgdp1807 e828f15
Add tests for scalars
czgdp1807 1a92ae9
Merge branch 'main' into never_copy
czgdp1807 91d6693
resolved linting issues
czgdp1807 7b53a02
Fixed blank line linting issue
czgdp1807 eedb300
Apply suggestions from code review
czgdp1807 bc8903d
renaming complete
czgdp1807 3268a48
fixed failures due to Python 3.8.2
czgdp1807 ab01330
Merge branch 'main' into never_copy
czgdp1807 782d823
fixed PYPY errors
czgdp1807 342e0c5
removed complicated checks for copy_mode
czgdp1807 a09929b
Merge branch 'main' into never_copy
czgdp1807 30e3472
interface shifted
czgdp1807 a6caf9c
Apply suggestions from code review
czgdp1807 3dcf3a9
resolved conflicts
czgdp1807 321e028
Shifted to CopyMode to np.array_api
czgdp1807 844883c
corrected linting issues
czgdp1807 d995ecc
resolved conflicts
czgdp1807 0f8d4c5
fixed linting issues
czgdp1807 698fb6d
Made _CopyMode private
czgdp1807 b341e4c
Fixed linting issues
czgdp1807 781d0a7
resolved conflicts
czgdp1807 45dbdc9
CopyMode added to np.array_api
czgdp1807 a39312c
fixed linting issues
czgdp1807 c2acd5b
fixed linting issues
czgdp1807 56647dd
Addressed reviews
czgdp1807 c04509e
resolved conflicts
czgdp1807 790f927
Addressed reviews
czgdp1807 2677788
Fixed type check
czgdp1807 d9a9785
Addressed reviews and increased code coverage
czgdp1807 5cb2d64
Addressed reviews and increased code coverage
czgdp1807 8b939c9
Intentional RuntimeError
czgdp1807 7658ad9
Removed dead code
czgdp1807 2cf561b
Prohibited calling ``__array__`` method in never copy mode
czgdp1807 37cd05e
Fixed warning and updated docs
czgdp1807 9f9a348
Apply suggestions from code review
czgdp1807 946ab24
Updated docs
czgdp1807 2c51b0a
Merge branch 'never_copy' of https://github.com/czgdp1807/numpy into …
czgdp1807 5ede7eb
Added release notes entry
czgdp1807 d1cb662
L[0]->L[False], L[1]->L[True]
czgdp1807 6c01915
Deleted release notes entry
czgdp1807 5f1965f
do_copy -> allow_copy
czgdp1807 05ff102
Apply suggestions from code review
czgdp1807 68dfa4b
Merge branch 'never_copy' of https://github.com/czgdp1807/numpy into …
czgdp1807 2db65c9
Addressed reviews
czgdp1807 d0d75f3
Reverted dead code removal
czgdp1807 eccb8df
Merge branch 'main' into never_copy
rgommers 4b2cd27
STY: Small style fixups for never-copy changes
seberg 84951a6
MAINT: Remove private CopyMode enum to private header
seberg f31c4a6
MAINT,BUG: Refactor __array__ and never-copy to move check later
seberg dea4055
MAINT: Rename `allow_copy` to `never_copy` in never-copy machinery
seberg 9fee0f8
DOC: Slightly extend to docs to note that we assume no-copy buffer pr…
seberg f058aea
BUG: Fix refcounting issue and missed scalar special case for never-c…
seberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -868,7 +868,7 @@ typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *); | |
|
||
/* | ||
* Always copy the array. Returned arrays are always CONTIGUOUS, | ||
* ALIGNED, and WRITEABLE. | ||
* ALIGNED, and WRITEABLE. See also: NPY_ARRAY_ENSURENOCOPY = 0x4000. | ||
* | ||
* This flag may be requested in constructor functions. | ||
*/ | ||
|
@@ -937,6 +937,13 @@ typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *); | |
#define NPY_ARRAY_UPDATEIFCOPY 0x1000 /* Deprecated in 1.14 */ | ||
#define NPY_ARRAY_WRITEBACKIFCOPY 0x2000 | ||
|
||
/* | ||
* No copy may be made while converting from an object/array (result is a view) | ||
* | ||
* This flag may be requested in constructor functions. | ||
*/ | ||
#define NPY_ARRAY_ENSURENOCOPY 0x4000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know it is bound to get outdated, but maybe we should add a comment which functions honor this? I guess most do, but it seems things are a bit confusing with many of these flags just honored by the |
||
|
||
/* | ||
* NOTE: there are also internal flags defined in multiarray/arrayobject.h, | ||
* which start at bit 31 and work down. | ||
|
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.