Skip to content

Commit

Permalink
Apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsokol committed Apr 24, 2024
1 parent fed445b commit c59773b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion numpy/_core/fromnumeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,10 @@ def reshape(a, /, shape=None, *, newshape=None, order='C', copy=None):
stacklevel=2,
)
shape = newshape
return _wrapfunc(a, 'reshape', shape, order=order, copy=copy)
kwargs = {"order": order}
if copy is not None:
kwargs["copy"] = copy
return _wrapfunc(a, 'reshape', shape, **kwargs)


def _choose_dispatcher(a, choices, out=None, mode=None):
Expand Down
4 changes: 4 additions & 0 deletions numpy/_core/src/multiarray/shape.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ _reshape_with_copy_arg(PyArrayObject *array, PyArray_Dims *newdims,
if (_fix_unknown_dimension(newdims, array) < 0) {
return NULL;
}
/*
* Memory order doesn't depend on a copy/no-copy context.
* 'order' argument is always honored.
*/
if (copy == NPY_COPY_ALWAYS) {
PyObject *newcopy = PyArray_NewCopy(array, order);
if (newcopy == NULL) {
Expand Down

0 comments on commit c59773b

Please sign in to comment.