From f41687bde9ca7ebde78488a83035163ecf5ae5df Mon Sep 17 00:00:00 2001 From: yanglf1121 Date: Mon, 22 Mar 2021 13:27:16 +0800 Subject: [PATCH] fix numpy_native ci error on cpu --- mindspore/numpy/array_creations.py | 3 +-- tests/st/numpy_native/__init__.py | 2 +- tests/st/numpy_native/test_array_creations.py | 6 +++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mindspore/numpy/array_creations.py b/mindspore/numpy/array_creations.py index 8fd8a00e02..7ffe8d669d 100644 --- a/mindspore/numpy/array_creations.py +++ b/mindspore/numpy/array_creations.py @@ -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) diff --git a/tests/st/numpy_native/__init__.py b/tests/st/numpy_native/__init__.py index bd8949921a..efdee8dee7 100644 --- a/tests/st/numpy_native/__init__.py +++ b/tests/st/numpy_native/__init__.py @@ -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) diff --git a/tests/st/numpy_native/test_array_creations.py b/tests/st/numpy_native/test_array_creations.py index 0a46ba26f0..69ea19602b 100644 --- a/tests/st/numpy_native/test_array_creations.py +++ b/tests/st/numpy_native/test_array_creations.py @@ -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,