From 15b40b47167ab285adb3377a1828c41a9de4cb5d Mon Sep 17 00:00:00 2001 From: Yiyan66 Date: Wed, 11 Dec 2019 03:20:27 +0000 Subject: [PATCH] solve conflict --- python/mxnet/symbol/numpy/_symbol.py | 204 ++++++++++++------------- tests/python/unittest/test_numpy_op.py | 6 +- 2 files changed, 96 insertions(+), 114 deletions(-) diff --git a/python/mxnet/symbol/numpy/_symbol.py b/python/mxnet/symbol/numpy/_symbol.py index 1ba9f9917295..f8a62ac80eb3 100644 --- a/python/mxnet/symbol/numpy/_symbol.py +++ b/python/mxnet/symbol/numpy/_symbol.py @@ -36,11 +36,11 @@ except ImportError: from builtins import slice as py_slice -__all__ = ['zeros', 'zeros_like', 'ones', 'ones_like', 'full_like', +__all__ = ['zeros', 'zeros_like', 'ones', 'ones_like', 'full_like', 'bitwise_not', 'invert', 'add', 'subtract', 'multiply', 'divide', 'mod', 'remainder', 'power', 'arctan2', 'sin', 'cos', 'tan', 'sinh', 'cosh', 'tanh', 'log10', 'sqrt', 'cbrt', 'abs', 'absolute', 'exp', - 'expm1', 'arcsin', 'arccos', 'arctan', 'sign', 'log', 'degrees', 'log2', 'log1p', 'bitwise_not', - 'rint', 'radians', 'reciprocal', 'square', 'negative', 'fix', 'ceil', 'floor', 'invert', + 'expm1', 'arcsin', 'arccos', 'arctan', 'sign', 'log', 'degrees', 'log2', 'log1p', + 'rint', 'radians', 'reciprocal', 'square', 'negative', 'fix', 'ceil', 'floor', 'trunc', 'logical_not', 'arcsinh', 'arccosh', 'arctanh', 'argsort', 'tensordot', 'histogram', 'eye', 'linspace', 'logspace', 'expand_dims', 'tile', 'arange', 'split', 'vsplit', 'concatenate', 'append', 'stack', 'vstack', 'column_stack', 'dstack', 'average', 'mean', 'maximum', 'minimum', 'swapaxes', 'clip', @@ -1040,6 +1040,98 @@ def ones(shape, dtype=_np.float32, order='C', ctx=None): return _npi.ones(shape=shape, ctx=ctx, dtype=dtype) +@set_module('mxnet.symbol.numpy') +@wrap_np_unary_func +def invert(x, out=None, **kwargs): + r""" + Compute bit-wise inversion, or bit-wise NOT, element-wise. + Computes the bit-wise NOT of the underlying binary representation of + the integers in the input arrays. This ufunc implements the C/Python + operator ``~``. + Parameters + ---------- + x : array_like + Only integer and boolean types are handled. + out : ndarray, None, or tuple of ndarray and None, optional + A location into which the result is stored. If provided, it must have + a shape that the inputs broadcast to. If not provided or `None`, + a freshly-allocated array is returned. A tuple (possible only as a + keyword argument) must have length equal to the number of outputs. + Returns + ------- + out : ndarray or scalar + Result. + This is a scalar if `x` is a scalar. + See Also + -------- + bitwise_and, bitwise_or, bitwise_xor + logical_not + binary_repr : + Return the binary representation of the input number as a string. + Examples + -------- + We've seen that 13 is represented by ``00001101``. + The invert or bit-wise NOT of 13 is then: + >>> x = np.invert(np.array(13, dtype=np.uint8)) + >>> x + 242 + >>> np.binary_repr(x, width=8) + '11110010' + Notes + ----- + `bitwise_not` is an alias for `invert`: + >>> np.bitwise_not is np.invert + True + """ + return _unary_func_helper(x, _npi.bitwise_not, _np.bitwise_not, out=out, **kwargs) + + +@set_module('mxnet.symbol.numpy') +@wrap_np_unary_func +def bitwise_not(x, out=None, **kwargs): + r""" + Compute bit-wise inversion, or bit-wise NOT, element-wise. + Computes the bit-wise NOT of the underlying binary representation of + the integers in the input arrays. This ufunc implements the C/Python + operator ``~``. + Parameters + ---------- + x : array_like + Only integer and boolean types are handled. + out : ndarray, None, or tuple of ndarray and None, optional + A location into which the result is stored. If provided, it must have + a shape that the inputs broadcast to. If not provided or `None`, + a freshly-allocated array is returned. A tuple (possible only as a + keyword argument) must have length equal to the number of outputs. + Returns + ------- + out : ndarray or scalar + Result. + This is a scalar if `x` is a scalar. + See Also + -------- + bitwise_and, bitwise_or, bitwise_xor + logical_not + binary_repr : + Return the binary representation of the input number as a string. + Examples + -------- + We've seen that 13 is represented by ``00001101``. + The invert or bit-wise NOT of 13 is then: + >>> x = np.invert(np.array(13, dtype=np.uint8)) + >>> x + 242 + >>> np.binary_repr(x, width=8) + '11110010' + Notes + ----- + `bitwise_not` is an alias for `invert`: + >>> np.bitwise_not is np.invert + True + """ + return _unary_func_helper(x, _npi.bitwise_not, _np.bitwise_not, out=out, **kwargs) + + @set_module('mxnet.symbol.numpy') def full(shape, fill_value, dtype=None, order='C', ctx=None, out=None): # pylint: disable=too-many-arguments """ @@ -2806,112 +2898,6 @@ def floor(x, out=None, **kwargs): return _unary_func_helper(x, _npi.floor, _np.floor, out=out, **kwargs) -@set_module('mxnet.symbol.numpy') -@wrap_np_unary_func -def invert(x, out=None, **kwargs): - r""" - Compute bit-wise inversion, or bit-wise NOT, element-wise. - Computes the bit-wise NOT of the underlying binary representation of - the integers in the input arrays. This ufunc implements the C/Python - operator ``~``. - - Parameters - ---------- - x : array_like - Only integer and boolean types are handled. - out : ndarray, None, or tuple of ndarray and None, optional - A location into which the result is stored. If provided, it must have - a shape that the inputs broadcast to. If not provided or `None`, - a freshly-allocated array is returned. A tuple (possible only as a - keyword argument) must have length equal to the number of outputs. - - Returns - ------- - out : ndarray or scalar - Result. - This is a scalar if `x` is a scalar. - - See Also - -------- - bitwise_and, bitwise_or, bitwise_xor - logical_not - binary_repr : - Return the binary representation of the input number as a string. - - Examples - -------- - We've seen that 13 is represented by ``00001101``. - The invert or bit-wise NOT of 13 is then: - - >>> x = np.invert(np.array(13, dtype=np.uint8)) - >>> x - 242 - >>> np.binary_repr(x, width=8) - '11110010' - - Notes - ----- - `bitwise_not` is an alias for `invert`: - - >>> np.bitwise_not is np.invert - True - """ - return _unary_func_helper(x, _npi.bitwise_not, _np.bitwise_not, out=out, **kwargs) - - -@set_module('mxnet.symbol.numpy') -@wrap_np_unary_func -def bitwise_not(x, out=None, **kwargs): - r""" - Compute bit-wise inversion, or bit-wise NOT, element-wise. - Computes the bit-wise NOT of the underlying binary representation of - the integers in the input arrays. This ufunc implements the C/Python - operator ``~``. - - Parameters - ---------- - x : array_like - Only integer and boolean types are handled. - out : ndarray, None, or tuple of ndarray and None, optional - A location into which the result is stored. If provided, it must have - a shape that the inputs broadcast to. If not provided or `None`, - a freshly-allocated array is returned. A tuple (possible only as a - keyword argument) must have length equal to the number of outputs. - - Returns - ------- - out : ndarray or scalar - Result. - This is a scalar if `x` is a scalar. - - See Also - -------- - bitwise_and, bitwise_or, bitwise_xor - logical_not - binary_repr : - Return the binary representation of the input number as a string. - - Examples - -------- - We've seen that 13 is represented by ``00001101``. - The invert or bit-wise NOT of 13 is then: - - >>> x = np.invert(np.array(13, dtype=np.uint8)) - >>> x - 242 - >>> np.binary_repr(x, width=8) - '11110010' - - Notes - ----- - `bitwise_not` is an alias for `invert`: - - >>> np.bitwise_not is np.invert - True - """ - return _unary_func_helper(x, _npi.bitwise_not, _np.bitwise_not, out=out, **kwargs) - - @set_module('mxnet.symbol.numpy') @wrap_np_unary_func def trunc(x, out=None, **kwargs): diff --git a/tests/python/unittest/test_numpy_op.py b/tests/python/unittest/test_numpy_op.py index 3e9f0fcd2af9..cbd61a2ed4ed 100644 --- a/tests/python/unittest/test_numpy_op.py +++ b/tests/python/unittest/test_numpy_op.py @@ -3737,11 +3737,7 @@ def get_grad_b(A, X): nrhs = (-1, 0, 1, 2, 3) dtypes = ['float32', 'float64'] for hybridize, shape, dtype, nrh in itertools.product([False, True], shapes, dtypes, nrhs): - rtol = 1e-3 - atol = 1e-5 - if dtype == 'float32': - rtol = 1e-2 - atol = 1e-4 + rtol, atol =1e-2, 1e-4 test_solve = TestSolve() if hybridize: test_solve.hybridize()