Repository navigation
support order kwarg in asarray, asanyarray, ndarray.get, tonumpy - #1845
Conversation
|
There is another case I still need to fix: asarray doesn't preserve order for numpy array inputs import numpy
import cupy
# cupy.asarray on cupy.ndarray input preserves contiguity
cupy.asarray(cupy.empty((16, 16), order='F')).flags
Out[119]:
C_CONTIGUOUS : False
F_CONTIGUOUS : True
OWNDATA : True
# cupy.asarray on numpy.ndarray input DOES NOT
cupy.asarray(np.empty((16, 16), order='F')).flags
Out[120]:
C_CONTIGUOUS : True
F_CONTIGUOUS : False
OWNDATA : True
# numpy.asarray preserves contiguity
numpy.asarray(numpy.empty((16, 16), order='F')).flags
Out[120]:
C_CONTIGUOUS : True
F_CONTIGUOUS : False
OWNDATA : TrueThe Fortran-ordered NumPy array should result in a Fortran ordered CuPy array. This can be done by having Another question is whether the |
This change results in cupy.asarray(numpy_fortran_ordered_ndarray) giving a Fortran-ordered array
|
I think the line corresponding to the change in bf8683d above in NumPy are: initial setting of default to 'K' Then in this section when order_obj is None it looks like order will never be reassigned, so it should keep the default value of 'K': |
simplify ordering test code by using the order option in testing.shaped_arange
|
I just went ahead and added the orders 'C', 'F', 'A' to I can split that to its own separate PR if preferred, but thought it may be easier and save CI resources just review multiple ordering-related things together. |
|
jenkins, test this please. |
|
Thank you for your PR.
I want equivalent behavior. Cloud you send another PR because I will put |
|
Jenkins CI test (for commit 85155a4, target branch master) succeeded! |
|
LGTM! |
I am not sure what you are requesting. It looks like you already merged all of the proposed changes? |
|
OK, I understand that this PR contains all.
I misunderstood that this change is not included. This line cares it. |
This is a small PR that continues the quest to improve
orderkwarg support in CuPy (see also #1819 and #1843).One outstanding question is what to do for non-cupy objects that define
__cuda_array_interface__. For now, I chose to ignore theorderargument in that case.