-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* implement dpnp.ndim * rename direcotry * implement dpnp.size * remove parameters section
- Loading branch information
Showing
5 changed files
with
243 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import unittest | ||
|
||
import numpy | ||
|
||
import dpnp as cupy | ||
from tests.third_party.cupy import testing | ||
|
||
|
||
class TestNdim(unittest.TestCase): | ||
@testing.numpy_cupy_equal() | ||
def test_ndim_ndarray1d(self, xp): | ||
return xp.ndim(xp.arange(5)) | ||
|
||
@testing.numpy_cupy_equal() | ||
def test_ndim_ndarray2d(self, xp): | ||
return xp.ndim(xp.ones((2, 4))) | ||
|
||
@testing.numpy_cupy_equal() | ||
def test_ndim_ndarray0d(self, xp): | ||
return xp.ndim(xp.asarray(5)) | ||
|
||
@testing.numpy_cupy_equal() | ||
def test_ndim_scalar(self, xp): | ||
return xp.ndim(5) | ||
|
||
@testing.numpy_cupy_equal() | ||
def test_ndim_none(self, xp): | ||
return xp.ndim(None) | ||
|
||
@testing.numpy_cupy_equal() | ||
def test_ndim_string(self, xp): | ||
return xp.ndim("abc") | ||
|
||
@testing.numpy_cupy_equal() | ||
def test_ndim_list1(self, xp): | ||
return xp.ndim([1, 2, 3]) | ||
|
||
@testing.numpy_cupy_equal() | ||
def test_ndim_list2(self, xp): | ||
return xp.ndim([[1, 2, 3], [4, 5, 6]]) | ||
|
||
@testing.numpy_cupy_equal() | ||
def test_ndim_tuple(self, xp): | ||
return xp.ndim(((1, 2, 3), (4, 5, 6))) | ||
|
||
@testing.numpy_cupy_equal() | ||
def test_ndim_set(self, xp): | ||
return xp.ndim({1, 2, 3}) | ||
|
||
@testing.numpy_cupy_equal() | ||
def test_ndim_object(self, xp): | ||
return xp.ndim(dict(a=5, b="b")) | ||
|
||
# numpy.dim works on dpnp arrays and dpnp.ndim works on NumPy arrays | ||
def test_ndim_array_function(self): | ||
a = cupy.ones((4, 4)) | ||
assert numpy.ndim(a) == 2 | ||
|
||
a = cupy.asarray(5) | ||
assert numpy.ndim(a) == 0 | ||
|
||
a = numpy.ones((4, 4)) | ||
assert cupy.ndim(a) == 2 | ||
|
||
a = numpy.asarray(5) | ||
assert cupy.ndim(a) == 0 |