8000 ENH: Add shape to *_like() array creation by pentschev · Pull Request #13046 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Add shape to *_like() array creation #13046

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 24 commits into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f885c08
ENH: Added shape argument to *_like() array creation functions
pentschev Feb 26, 2019
5ad61b6
ENH: C backend adjustments for shape argument on *_like()
pentschev Feb 26, 2019
fd3e270
TST: Added test for shape argument in *_like() functions
pentschev Feb 26, 2019
b7202a7
ENH: Added PyArray_NewLikeArrayWithShape()
pentschev Feb 26, 2019
013cbce
BUG: Fix for PyArray_NewLikeArrayWithShape strides and ndim == 0
pentschev Feb 27, 2019
807f512
REL: Updates for C-API, version 1.17.x
pentschev Feb 27, 2019
95bbfd0
Revert "REL: Updates for C-API, version 1.17.x"
pentschev Mar 13, 2019
43b9828
Revert exposing PyArray_NewLikeArrayWithShape on C-API
pentschev Mar 13, 2019
fa7fd75
DOC: fix versionadded for *_like() shape argument
pentschev Mar 13, 2019
d57e6d3
STY: add missing spaces in array initializers
pentschev Mar 13, 2019
f1b3e91
ENH: empty_like raises ValueError
pentschev Mar 16, 2019
d24ac10
TST: test for exception of *_like() functions
pentschev Mar 16, 2019 10000
ec26417
DOC: release note for shape argument in *_like() functions
pentschev Mar 16, 2019
40e7e9e
DOC: fix *_like() documentation on raises
pentschev Mar 17, 2019
928952d
BUG: *_like() raises for non-C/F-layout arrays
pentschev Mar 17, 2019
e394356
TST: change *_like() shapes to prevent NPY_RELAXED_STRIDE_DEBUG=1 fai…
pentschev Mar 17, 2019
d938fb9
Move empty_like() exception to C implementation
pentschev Mar 19, 2019
99a55e0
Merge branch 'master' into add-shape-to-like-array-creation
pentschev Mar 28, 2019
c087801
Update *_like() ValueError documentation
pentschev Apr 4, 2019
db7614b
Merge remote-tracking branch 'upstream/master' into add-shape-to-like…
pentschev Apr 5, 2019
669ea71
Rearrange stride computation for *_like() if new shape and order='K'
pentschev Apr 10, 2019
f53afbe
Change handling of order= for *_like()
pentschev Apr 19, 2019
c3ac08e
Merge branch 'master' into add-shape-to-like-array-creation
pentschev Apr 19, 2019
695b836
Fix *_like() tests
pentschev Apr 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ENH: empty_like raises ValueError
This occurs when shape is defined and number of dimensions match but
order is 'K'.
  • Loading branch information
pentschev committed Mar 16, 2019
commit f1b3e91c7578abad100dbbd9b32d2e367d8bb60d
8 changes: 8 additions & 0 deletions numpy/core/multiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ def empty_like(prototype, dtype=None, order=None, subok=None, shape=None):
Array of uninitialized (arbitrary) data with the same
shape and type as `prototype`.

Raises
------
ValueError
If len(ndim) different from a.ndim and order is 'K'

See Also
--------
ones_like : Return an array of ones with shape and type of input.
Expand All @@ -133,6 +138,9 @@ def empty_like(prototype, dtype=None, order=None, subok=None, shape=None):
[ 4.38791518e-305, -2.00000715e+000, 4.17269252e-309]])

"""
if (shape is not None and prototype.ndim != len(shape) and
order not in 'CFA'):
raise ValueError("mismatching ndim can not keep order")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shoyer: Is this the place for this type of check?

return (prototype,)


Expand Down
15 changes: 15 additions & 0 deletions numpy/core/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ def zeros_like(a, dtype=None, order='K', subok=True, shape=None):
out : ndarray
Array of zeros with the same shape and type as `a`.

Raises
------
ValueError
If len(ndim) different from a.ndim and order is 'K'

See Also
--------
empty_like : Return an empty array with shape and type of input.
Expand Down Expand Up @@ -269,6 +274,11 @@ def ones_like(a, dtype=None, order='K', subok=True, shape=None):
out : ndarray
Array of ones with the same shape and type as `a`.

Raises
------
ValueError
If len(ndim) different from a.ndim and order is 'K'

See Also
--------
empty_like : Return an empty array with shape and type of input.
Expand Down Expand Up @@ -383,6 +393,11 @@ def full_like(a, fill_value, dtype=None, order='K', subok=True, shape=None):
out : ndarray
Array of `fill_value` with the same shape and type as `a`.

Raises
------
ValueError
If len(ndim) different from a.ndim and order is 'K'

See Also
--------
empty_like : Return an empty array with shape and type of input.
Expand Down
0