optimize code docs and global a int replace

This commit is contained in:
tacyi139 2021-12-15 17:23:55 +08:00
parent b93494c6bb
commit 868f0de469
10 changed files with 17 additions and 16 deletions

View File

@ -866,7 +866,7 @@ def check_input_format(input_param):
def _expand_tuple(n_dimensions):
"""To expand a int number to tuple."""
"""To expand an int number to tuple."""
def convert(m):
if not isinstance(m, tuple):

View File

@ -81,13 +81,13 @@ def imshow_det_bbox(image, bboxes, labels, segm=None, class_names=None, score_th
"text_color must be a three tuple, formatted (B, G, R)."
assert isinstance(mask_color, tuple) and len(mask_color) == 3, \
"mask_color must be a three tuple, formatted (B, G, R)."
assert isinstance(thickness, int), "thickness must be a int."
assert isinstance(thickness, int), "thickness must be an int."
assert thickness >= 0, "thickness must be larger than or equal to zero."
assert isinstance(font_size, (int, float)), "font_size must be a int or float."
assert isinstance(font_size, (int, float)), "font_size must be an int or float."
assert font_size >= 0, "font_size must be larger than or equal to zero."
assert isinstance(show, bool), "show must be a bool."
assert isinstance(win_name, str), "win_name must be a str."
assert isinstance(wait_time, int), "wait_time must be a int."
assert isinstance(wait_time, int), "wait_time must be an int."
assert wait_time >= 0, "wait_time must be larger than or equal to zero."
if out_file is not None:
assert isinstance(out_file, str), "out_file must be a str."

View File

@ -338,7 +338,7 @@ class MSSSIM(Cell):
ValueError: If length of shape of `img1` or `img2` is not equal to 4.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
``Ascend`` ``GPU``
Examples:
>>> import numpy as np

View File

@ -875,7 +875,7 @@ def cummin(x, axis):
Raises:
TypeError: If `input_x` is not a Tensor.
TypeError: If 'axis' is not a int.
TypeError: If 'axis' is not an int.
ValueError:If 'axis' is out the range of [-len(`input_x`.shape) to len(`input_x`.shape) - 1]
Supported Platforms:

View File

@ -750,7 +750,7 @@ def tensor_setitem_by_ellipsis(self, index, value):
def _tensor_setitem_by_int_tensor_with_tensor(data, index, value):
"""Set a tensor item by a int tensor with a tensor."""
"""Set a tensor item by an int tensor with a tensor."""
updates = _generate_updates_from_tensor(data, index, value, const_utils.SET_ITEM_BY_ONE_TENSOR)
index = F.select(index < 0, index + F.shape(data)[0], index)
index = F.expand_dims(index, -1)

View File

@ -167,13 +167,13 @@ class RegOp:
def _is_int(self, value):
"""
Check if the value is a int.
Check if the value is an int.
Args:
value: Parameter to be checked.
Raises:
TypeError: If the type of value is not a int.
TypeError: If the type of value is not an int.
"""
if not isinstance(value, int):
raise TypeError("%s value must be int" % str(value))

View File

@ -1456,7 +1456,7 @@ class Cummin(Primitive):
Raises:
TypeError: If `input_x` is not a Tensor.
TypeError: If 'axis' is not a int.
TypeError: If 'axis' is not an int.
ValueError:If 'axis' is out the range from -len(`input_x`.shape) to len(`input_x`.shape) - 1
Supported Platforms:

View File

@ -5665,7 +5665,7 @@ class InplaceUpdate(PrimitiveWithInfer):
Args:
indices (Union[int, tuple]): Indices into the left-most dimension of `x`, and determines which rows of x
to update with v. It is a int or tuple, whose value is in [0, the first dimension size of x).
to update with v. It is an int or tuple, whose value is in [0, the first dimension size of x).
Inputs:
- **x** (Tensor) - A tensor which to be inplace updated. It can be one of the following data types:
@ -6773,7 +6773,7 @@ class ExtractVolumePatches(Primitive):
Raises:
TypeError: If dtype of input_x is neither float16 nor float32.
TypeError: If kernel_size or strides is not a list, a tuple or a int.
TypeError: If kernel_size or strides is not a list, a tuple or an int.
TypeError: If input_x is not a tensor.
TypeError: If padding is not str.
ValueError: If the length of kernel_size is neither 3 nor 5 and kernel_size is not an integer.

View File

@ -150,7 +150,7 @@ class Ger(Primitive):
Outputs:
Tensor, output matrix with the same dtype as inputs.With `x1` shape :math:`(m,)` and
`x2` shape of :math:`(n,)`,`output` has shape :math:`(m * n)`.
`x2` shape of :math:`(n,)`,the `output` has shape :math:`(m * n)`.
Raises:
TypeError: If `x1` or `x2` is not a Tensor.
@ -1149,6 +1149,7 @@ class LpNorm(Primitive):
axis(int,list,tuple): Specifies which dimension or dimensions of input to calculate the norm across.
p(int): The order of norm.
keep_dims(bool): Whether the output tensors have dim retained or not.
epsilon(float): A value added to the denominator for numerical stability. Default: 1e-12.
Inputs:
- **input** (Tensor) - Input tensor.
@ -1667,7 +1668,7 @@ class InplaceSub(PrimitiveWithInfer):
Args:
indices (Union[int, tuple]): Indices into the left-most dimension of x, and determines which rows of x
to subtract with v. It is a int or tuple, whose value is in [0, the first dimension size of x).
to subtract with v. It is an int or tuple, whose value is in [0, the first dimension size of x).
Inputs:
- **x** (Tensor) - The first input is a tensor whose data type is float16, float32 or int32.

View File

@ -227,12 +227,12 @@ class _DepthwiseConv2dNative(nn.Cell):
self.group = group
if not (isinstance(in_channels, int) and in_channels > 0):
raise ValueError('Attr \'in_channels\' of \'DepthwiseConv2D\' Op passed '
+ str(in_channels) + ', should be a int and greater than 0.')
+ str(in_channels) + ', should be an int and greater than 0.')
if (not isinstance(kernel_size, tuple)) or len(kernel_size) != 2 or \
(not isinstance(kernel_size[0], int)) or (not isinstance(kernel_size[1], int)) or \
kernel_size[0] < 1 or kernel_size[1] < 1:
raise ValueError('Attr \'kernel_size\' of \'DepthwiseConv2D\' Op passed '
+ str(self.kernel_size) + ', should be a int or tuple and equal to or greater than 1.')
+ str(self.kernel_size) + ', should be an int or tuple and equal to or greater than 1.')
self.weight = Parameter(initializer(weight_init, [1, in_channels // group, *kernel_size]),
name='weight')