Skip to content

Commit

Permalink
Merge 5d37283 into 0836d05
Browse files Browse the repository at this point in the history
  • Loading branch information
chainer-ci committed Nov 7, 2021
2 parents 0836d05 + 5d37283 commit 4f884c4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cupy/_core/core.pyx
Expand Up @@ -677,7 +677,8 @@ cdef class ndarray:
:meth:`numpy.ndarray.ravel`
"""
return _manipulation._ndarray_ravel(self, order)
return _internal_ascontiguousarray(
_manipulation._ndarray_ravel(self, order))

cpdef ndarray squeeze(self, axis=None):
"""Returns a view with size-one axes removed.
Expand Down
19 changes: 19 additions & 0 deletions tests/cupy_tests/manipulation_tests/test_shape.py
Expand Up @@ -170,6 +170,25 @@ def test_ravel3(self, xp, order):
a = xp.asfortranarray(a)
return a.ravel(order)

@testing.for_orders('CFA')
@testing.numpy_cupy_array_equal()
def test_ravel_non_contiguous(self, xp, order):
a = xp.arange(10)[::2]
assert not a.flags.c_contiguous and not a.flags.f_contiguous
b = a.ravel(order)
assert b.flags.c_contiguous
return b

@testing.for_orders('CFA')
@testing.numpy_cupy_array_equal()
def test_ravel_broadcasted(self, xp, order):
a = xp.array([1])
b = xp.broadcast_to(a, (10,))
assert not b.flags.c_contiguous and not b.flags.f_contiguous
b = b.ravel(order)
assert b.flags.c_contiguous
return b

@testing.numpy_cupy_array_equal()
def test_external_ravel(self, xp):
a = testing.shaped_arange((2, 3, 4), xp)
Expand Down

0 comments on commit 4f884c4

Please sign in to comment.