Browse Source

!12386 issue #I37W2N & #I37W2L

From: @jachua
Reviewed-by: @liangchenghui,@liangchenghui
Signed-off-by: @liangchenghui
tags/v1.2.0-rc1
mindspore-ci-bot Gitee 4 years ago
parent
commit
4b805b87ee
4 changed files with 6 additions and 31 deletions
  1. +6
    -13
      mindspore/numpy/logic_ops.py
  2. +0
    -8
      tests/st/numpy_native/test_array_creations.py
  3. +0
    -8
      tests/st/numpy_native/test_logic_ops.py
  4. +0
    -2
      tests/st/numpy_native/test_math_ops.py

+ 6
- 13
mindspore/numpy/logic_ops.py View File

@@ -347,15 +347,8 @@ def isfinite(x, out=None, where=True, dtype=None):




def _isnan(x): def _isnan(x):
"""Compures isnan without applying keyword arguments."""
shape = F.shape(x)
zeros_tensor = zeros(shape, mstype.float32)
ones_tensor = ones(shape, mstype.float32)
non_neg = F.tensor_ge(x, zeros_tensor)
non_pos = F.tensor_le(x, zeros_tensor)
res = F.select(non_neg, zeros_tensor, ones_tensor)
res = F.select(non_pos, zeros_tensor, res)
return F.cast(res, mstype.bool_)
"""Computes isnan without applying keyword arguments."""
return F.not_equal(x, x)




def isnan(x, out=None, where=True, dtype=None): def isnan(x, out=None, where=True, dtype=None):
@@ -392,7 +385,7 @@ def isnan(x, out=None, where=True, dtype=None):
TypeError: if the input is not a tensor. TypeError: if the input is not a tensor.


Supported Platforms: Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
``GPU`` ``CPU``


Examples: Examples:
>>> output = np.isnan(np.array(np.nan, np.float32)) >>> output = np.isnan(np.array(np.nan, np.float32))
@@ -453,7 +446,7 @@ def isinf(x, out=None, where=True, dtype=None):
TypeError: if the input is not a tensor. TypeError: if the input is not a tensor.


Supported Platforms: Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
``GPU`` ``CPU``


Examples: Examples:
>>> output = np.isinf(np.array(np.inf, np.float32)) >>> output = np.isinf(np.array(np.inf, np.float32))
@@ -497,7 +490,7 @@ def isposinf(x):
TypeError: if the input is not a tensor. TypeError: if the input is not a tensor.


Supported Platforms: Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
``GPU`` ``CPU``


Examples: Examples:
>>> output = np.isposinf(np.array([-np.inf, 0., np.inf], np.float32)) >>> output = np.isposinf(np.array([-np.inf, 0., np.inf], np.float32))
@@ -527,7 +520,7 @@ def isneginf(x):
TypeError: if the input is not a tensor. TypeError: if the input is not a tensor.


Supported Platforms: Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
``GPU`` ``CPU``


Examples: Examples:
>>> output = np.isneginf(np.array([-np.inf, 0., np.inf], np.float32)) >>> output = np.isneginf(np.array([-np.inf, 0., np.inf], np.float32))


+ 0
- 8
tests/st/numpy_native/test_array_creations.py View File

@@ -748,14 +748,6 @@ def test_diag_indices():
onp_res = onp.diag_indices(0) onp_res = onp.diag_indices(0)
match_all_arrays(mnp_res, onp_res) match_all_arrays(mnp_res, onp_res)


mnp_res = mnp.diag_indices(3, 0)
onp_res = onp.diag_indices(3, 0)
match_all_arrays(mnp_res, onp_res)

mnp_res = mnp.diag_indices(5, 7)
onp_res = onp.diag_indices(5, 7)
match_all_arrays(mnp_res, onp_res)



def mnp_ix_(*args): def mnp_ix_(*args):
return mnp.ix_(*args) return mnp.ix_(*args)


+ 0
- 8
tests/st/numpy_native/test_logic_ops.py View File

@@ -191,8 +191,6 @@ def onp_isnan(x):




@pytest.mark.level1 @pytest.mark.level1
@pytest.mark.platform_arm_ascend_training
@pytest.mark.platform_x86_ascend_training
@pytest.mark.platform_x86_gpu_training @pytest.mark.platform_x86_gpu_training
@pytest.mark.platform_x86_cpu @pytest.mark.platform_x86_cpu
@pytest.mark.env_onecard @pytest.mark.env_onecard
@@ -209,8 +207,6 @@ def onp_isinf(x):




@pytest.mark.level1 @pytest.mark.level1
@pytest.mark.platform_arm_ascend_training
@pytest.mark.platform_x86_ascend_training
@pytest.mark.platform_x86_gpu_training @pytest.mark.platform_x86_gpu_training
@pytest.mark.platform_x86_cpu @pytest.mark.platform_x86_cpu
@pytest.mark.env_onecard @pytest.mark.env_onecard
@@ -227,8 +223,6 @@ def onp_isposinf(x):




@pytest.mark.level1 @pytest.mark.level1
@pytest.mark.platform_arm_ascend_training
@pytest.mark.platform_x86_ascend_training
@pytest.mark.platform_x86_gpu_training @pytest.mark.platform_x86_gpu_training
@pytest.mark.platform_x86_cpu @pytest.mark.platform_x86_cpu
@pytest.mark.env_onecard @pytest.mark.env_onecard
@@ -245,8 +239,6 @@ def onp_isneginf(x):




@pytest.mark.level1 @pytest.mark.level1
@pytest.mark.platform_arm_ascend_training
@pytest.mark.platform_x86_ascend_training
@pytest.mark.platform_x86_gpu_training @pytest.mark.platform_x86_gpu_training
@pytest.mark.platform_x86_cpu @pytest.mark.platform_x86_cpu
@pytest.mark.env_onecard @pytest.mark.env_onecard


+ 0
- 2
tests/st/numpy_native/test_math_ops.py View File

@@ -1002,8 +1002,6 @@ def onp_fmod(x, y):




@pytest.mark.level1 @pytest.mark.level1
@pytest.mark.platform_arm_ascend_training
@pytest.mark.platform_x86_ascend_training
@pytest.mark.platform_x86_gpu_training @pytest.mark.platform_x86_gpu_training
@pytest.mark.platform_x86_cpu @pytest.mark.platform_x86_cpu
@pytest.mark.env_onecard @pytest.mark.env_onecard


Loading…
Cancel
Save