Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
leofang committed Jun 26, 2020
1 parent f8c0ada commit c67c656
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cupy/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from cupy.testing.helper import NumpyAliasBasicTestBase # NOQA
from cupy.testing.helper import NumpyAliasValuesTestBase # NOQA
from cupy.testing.helper import NumpyError # NOQA
from cupy.testing.helper import CUBMockTest # NOQA
from cupy.testing.helper import AssertFunctionIsCalled # NOQA
from cupy.testing.helper import shaped_arange # NOQA
from cupy.testing.helper import shaped_random # NOQA
from cupy.testing.helper import shaped_reverse_arange # NOQA
Expand Down
2 changes: 1 addition & 1 deletion cupy/testing/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ def test_values(self):
assert self.cupy_func(*self.args) == self.numpy_func(*self.args)


class CUBMockTest:
class AssertFunctionIsCalled:

def __init__(self, mock_mod, **kwargs):
self.patch = mock.patch(mock_mod, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions tests/cupy_tests/core_tests/test_ndarray_reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def test_cub_min(self, xp, dtype, axis):
func = 'cupy.core._routines_statistics.cub.device_reduce'
else:
func = 'cupy.core._routines_statistics.cub.device_segmented_reduce'
with testing.CUBMockTest(func, return_value=ret):
with testing.AssertFunctionIsCalled(func, return_value=ret):
a.min(axis=axis)
# ...then perform the actual computation
return a.min(axis=axis)
Expand All @@ -265,7 +265,7 @@ def test_cub_max(self, xp, dtype, axis):
func = 'cupy.core._routines_statistics.cub.device_reduce'
else:
func = 'cupy.core._routines_statistics.cub.device_segmented_reduce'
with testing.CUBMockTest(func, return_value=ret):
with testing.AssertFunctionIsCalled(func, return_value=ret):
a.max(axis=axis)
# ...then perform the actual computation
return a.max(axis=axis)
8 changes: 4 additions & 4 deletions tests/cupy_tests/math_tests/test_sumprod.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def test_cub_sum(self, xp, dtype, axis):
func = 'cupy.core._routines_math.cub.device_reduce'
else:
func = 'cupy.core._routines_math.cub.device_segmented_reduce'
with testing.CUBMockTest(func, return_value=ret):
with testing.AssertFunctionIsCalled(func, return_value=ret):
a.sum(axis=axis)
# ...then perform the actual computation
return a.sum(axis=axis)
Expand All @@ -247,7 +247,7 @@ def test_cub_prod(self, xp, dtype, axis):
func = 'cupy.core._routines_math.cub.device_reduce'
else:
func = 'cupy.core._routines_math.cub.device_segmented_reduce'
with testing.CUBMockTest(func, return_value=ret):
with testing.AssertFunctionIsCalled(func, return_value=ret):
a.prod(axis=axis)
# ...then perform the actual computation
return a.prod(axis=axis)
Expand All @@ -270,7 +270,7 @@ def test_cub_cumsum(self, xp, dtype):
# xp is cupy, first ensure we really use CUB
ret = cupy.empty(()) # Cython checks return type, need to fool it
func = 'cupy.core._routines_math.cub.device_scan'
with testing.CUBMockTest(func, return_value=ret):
with testing.AssertFunctionIsCalled(func, return_value=ret):
a.cumsum()
# ...then perform the actual computation
return a.cumsum()
Expand All @@ -294,7 +294,7 @@ def test_cub_cumprod(self, xp, dtype):
# xp is cupy, first ensure we really use CUB
ret = cupy.empty(()) # Cython checks return type, need to fool it
func = 'cupy.core._routines_math.cub.device_scan'
with testing.CUBMockTest(func, return_value=ret):
with testing.AssertFunctionIsCalled(func, return_value=ret):
a.cumprod()
# ...then perform the actual computation
result = a.cumprod()
Expand Down
4 changes: 2 additions & 2 deletions tests/cupy_tests/sorting_tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def test_cub_argmin(self, xp, dtype):
# xp is cupy, first ensure we really use CUB
ret = cupy.empty(()) # Cython checks return type, need to fool it
func = 'cupy.core._routines_statistics.cub.device_reduce'
with testing.CUBMockTest(func, return_value=ret):
with testing.AssertFunctionIsCalled(func, return_value=ret):
a.argmin()
# ...then perform the actual computation
return a.argmin()
Expand All @@ -205,7 +205,7 @@ def test_cub_argmax(self, xp, dtype):
# xp is cupy, first ensure we really use CUB
ret = cupy.empty(()) # Cython checks return type, need to fool it
func = 'cupy.core._routines_statistics.cub.device_reduce'
with testing.CUBMockTest(func, return_value=ret):
with testing.AssertFunctionIsCalled(func, return_value=ret):
a.argmax()
# ...then perform the actual computation
return a.argmax()
Expand Down
2 changes: 1 addition & 1 deletion tests/cupyx_tests/scipy_tests/sparse_tests/test_csr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ def test_mul_dense_vector(self, xp, sp):

# xp is cupy, first ensure we really use CUB
func = 'cupyx.scipy.sparse.csr.device_csrmv'
with testing.CUBMockTest(func):
with testing.AssertFunctionIsCalled(func):
m * x
# ...then perform the actual computation
return m * x

0 comments on commit c67c656

Please sign in to comment.