Browse Source

fix numpy_native ci error on cpu

tags/v1.2.0-rc1
yanglf1121 5 years ago
parent
commit
f41687bde9
3 changed files with 7 additions and 4 deletions
  1. +1
    -2
      mindspore/numpy/array_creations.py
  2. +1
    -1
      tests/st/numpy_native/__init__.py
  3. +5
    -1
      tests/st/numpy_native/test_array_creations.py

+ 1
- 2
mindspore/numpy/array_creations.py View File

@@ -451,6 +451,7 @@ def _type_checking_for_xspace(start, stop, num, endpoint, dtype, axis):
dtype = _check_dtype(dtype)
else:
dtype = mstype.float32
start, stop = broadcast_arrays(start, stop)
axis = _canonicalize_axis(axis, start.ndim+1)
return start, stop, num, endpoint, dtype, axis

@@ -499,8 +500,6 @@ def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis
start, stop, num, endpoint, dtype, axis = _type_checking_for_xspace(start, stop, num, endpoint, dtype, axis)
if not isinstance(retstep, bool):
_raise_type_error("retstep should be an boolean, but got ", retstep)
start, stop = broadcast_arrays(start, stop)
axis = _canonicalize_axis(axis, start.ndim+1)
bounds_shape = start.shape
bounds_shape = _tuple_slice(bounds_shape, None, axis) + (1,) + _tuple_slice(bounds_shape, axis, None)
iota_shape = _list_comprehensions(start.ndim+1, 1, True)


+ 1
- 1
tests/st/numpy_native/__init__.py View File

@@ -18,4 +18,4 @@ import mindspore.context as context

# pylint: disable=unused-argument
def setup_module(module):
context.set_context(mode=context.GRAPH_MODE)
context.set_context(mode=context.PYNATIVE_MODE)

+ 5
- 1
tests/st/numpy_native/test_array_creations.py View File

@@ -332,7 +332,7 @@ def test_arange():
match_array(actual, expected, error=6)


@pytest.mark.level1
@pytest.mark.level0
@pytest.mark.platform_arm_ascend_training
@pytest.mark.platform_x86_ascend_training
@pytest.mark.platform_x86_gpu_training
@@ -363,6 +363,10 @@ def test_linspace():
2.0, [3, 4, 5], num=5, endpoint=False).asnumpy()
match_array(actual, expected, error=6)

actual = onp.linspace(2.0, [[3, 4, 5]], num=5, endpoint=False, axis=2)
expected = mnp.linspace(2.0, [[3, 4, 5]], num=5, endpoint=False, axis=2).asnumpy()
match_array(actual, expected, error=6)

start = onp.random.random([2, 1, 4]).astype("float32")
stop = onp.random.random([1, 5, 1]).astype("float32")
actual = onp.linspace(start, stop, num=20, retstep=True,


Loading…
Cancel
Save