!18498 Fix numpy interfaces including array_str, sum, copysign

Merge pull request !18498 from wangrao124/fix_numpy
This commit is contained in:
i-robot 2021-06-21 10:47:44 +08:00 committed by Gitee
commit e7152ea01f
4 changed files with 8 additions and 3 deletions

View File

@ -834,6 +834,8 @@ class Validator:
raise ValueError(f'axis {ax} is out of bounds for array of dimension {ndim}')
ax = ax if ax >= 0 else ax + ndim
new_axes += (ax,)
if any(new_axes.count(el) > 1 for el in new_axes):
raise ValueError('duplicate value in "axis"')
return new_axes
@staticmethod

View File

@ -2239,6 +2239,7 @@ def array_str(a):
Note:
Numpy argument `max_line_width`, `precision` and `suppress_small` are not supported.
Graph mode dose not support the function.
Args:
a (Tensor): Input data.

View File

@ -4490,7 +4490,9 @@ def copysign(x1, x2, dtype=None):
if not isinstance(x2, (int, float, list, tuple, Tensor)):
_raise_type_error('integer, float, list, tuple or Tensor are expected, but got', x2)
x1, x2 = _to_tensor(x1, x2)
x2 = _broadcast_to_shape(x2, x1.shape)
shape_out = _infer_out_shape(F.shape(x1), F.shape(x2))
x1 = _broadcast_to_shape(x1, shape_out)
x2 = _broadcast_to_shape(x2, shape_out)
if _check_same_type(F.dtype(x1), mstype.bool_) or _check_same_type(F.dtype(x2), mstype.bool_):
_raise_type_error("sign does not accept dtype bool.")

View File

@ -2637,7 +2637,7 @@ class Acosh(PrimitiveWithInfer):
TypeError: If `input_x` is not a Tensor.
Supported Platforms:
``Ascend`` ``GPU``
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> import numpy as np
@ -2718,7 +2718,7 @@ class Asinh(PrimitiveWithInfer):
TypeError: If `input_x` is not a Tensor.
Supported Platforms:
``Ascend`` ``GPU``
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> asinh = ops.Asinh()