-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
ENH: add copy parameter for api.reshape function #23789
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 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c19e84e
BUG: add copy parameter for api.reshape function
bwalshe 78923f0
fixup: linting issue
bwalshe 8bc1478
fixup: linting issue
bwalshe 6535f88
enable copy=False
bwalshe 38444c5
fixup: more linter issues
bwalshe 0d831f0
release note
bwalshe 5822464
Shorten release note to single point
bwalshe 8c184b5
delete 23789.new_feature.rst from this PR
mattip 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add copy parameter for api.reshape function. | ||
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from numpy.testing import assert_raises | ||
import numpy as np | ||
|
||
from .. import all | ||
from .._creation_functions import asarray | ||
from .._dtypes import float64, int8 | ||
from .._manipulation_functions import ( | ||
concat, | ||
reshape, | ||
stack | ||
) | ||
|
||
|
||
def test_concat_errors(): | ||
assert_raises(TypeError, lambda: concat((1, 1), axis=None)) | ||
assert_raises(TypeError, lambda: concat([asarray([1], dtype=int8), | ||
asarray([1], dtype=float64)])) | ||
|
||
|
||
def test_stack_errors(): | ||
assert_raises(TypeError, lambda: stack([asarray([1, 1], dtype=int8), | ||
asarray([2, 2], dtype=float64)])) | ||
|
||
|
||
def test_reshape_copy(): | ||
a = asarray(np.ones((2, 3))) | ||
b = reshape(a, (3, 2), copy=True) | ||
assert not np.shares_memory(a._array, b._array) | ||
|
||
a = asarray(np.ones((2, 3))) | ||
b = reshape(a, (3, 2), copy=False) | ||
assert np.shares_memory(a._array, b._array) | ||
|
||
a = asarray(np.ones((2, 3)).T) | ||
b = reshape(a, (3, 2), copy=True) | ||
assert_raises(AttributeError, lambda: reshape(a, (2, 3), copy=False)) | ||
|
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.