Skip to content

Commit

Permalink
Merge e6056b1 into 48e2296
Browse files Browse the repository at this point in the history
  • Loading branch information
okuta committed Jul 14, 2017
2 parents 48e2296 + e6056b1 commit 06c33aa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
7 changes: 1 addition & 6 deletions cupy/core/core.pyx
Expand Up @@ -556,12 +556,7 @@ cdef class ndarray:
"""
# TODO(beam2d): Support ordering option
if self._c_contiguous:
newarray = self.copy()
else:
newarray = ndarray(self.shape, self.dtype)
elementwise_copy(self, newarray)

newarray = self.copy(order='C')
newarray._shape.assign(<Py_ssize_t>1, self.size)
newarray._strides.assign(<Py_ssize_t>1,
<Py_ssize_t>self.itemsize)
Expand Down
2 changes: 1 addition & 1 deletion cupy/creation/from_data.py
Expand Up @@ -80,7 +80,7 @@ def ascontiguousarray(a, dtype=None):
# TODO(okuta): Implement asmatrix


def copy(a, order='C'):
def copy(a, order='K'):
"""Creates a copy of a given array on the current device.
This function allocates the new array on the current device. If the given
Expand Down
11 changes: 9 additions & 2 deletions tests/cupy_tests/creation_tests/test_from_data.py
Expand Up @@ -120,7 +120,7 @@ def test_ascontiguousarray_on_contiguous_array(self):
@testing.numpy_cupy_array_equal()
def test_copy(self, xp, dtype, order):
a = xp.zeros((2, 3, 4), dtype=dtype)
b = a.copy(order=order)
b = xp.copy(a, order=order)
a[1] = 1
return b

Expand All @@ -131,9 +131,16 @@ def test_copy_multigpu(self, dtype, order):
with cuda.Device(0):
src = cupy.random.uniform(-1, 1, (2, 3)).astype(dtype)
with cuda.Device(1):
dst = src.copy(order)
dst = cupy.copy(src, order)
testing.assert_allclose(src, dst, rtol=0, atol=0)

@testing.for_CF_orders()
@testing.numpy_cupy_equal()
def test_copy_order(self, xp, order):
a = xp.zeros((2, 3, 4), order=order)
b = xp.copy(a)
return (b.flags.c_contiguous, b.flags.f_contiguous)


@testing.parameterize(
*testing.product({
Expand Down

0 comments on commit 06c33aa

Please sign in to comment.