Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilio Castillo committed Nov 2, 2021
1 parent afec5a8 commit 53682ee
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cupy/_core/core.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,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
25 changes: 25 additions & 0 deletions tests/cupy_tests/manipulation_tests/test_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,31 @@ 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)
if order == 'C':
assert b.flags.c_contiguous
else:
assert b.flags.f_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)
if order == 'C':
assert b.flags.c_contiguous
else:
assert b.flags.f_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 53682ee

Please sign in to comment.