Example #1
0
    def test_binary_cast_array_array_with_out_with_where_broadcast(
            self, xp, op, in1, in2, out, where):
        in1 = xp.array(in1)
        in2 = xp.array(in2)
        out = xp.array(out)
        where = xp.array(where)

        with testing.NumpyError(divide='ignore'):
            with testing.NlcpyError(divide='ignore',
                                    over='ignore',
                                    invalid='ignore'):
                with numpy.warnings.catch_warnings():
                    numpy.warnings.simplefilter('ignore', numpy.ComplexWarning)
                    func = getattr(xp, op)
                    y = func(in1, in2, out=out, where=where)
                    if xp is numpy and op in float16_op_set:
                        if in1.dtype.kind == 'b' and in2.dtype.kind == 'b':
                            y = func(in1,
                                     in2,
                                     out=out,
                                     where=where,
                                     dtype='f4')
                            return y
                    if xp is nlcpy:
                        nlcpy.request.flush()
        return y
Example #2
0
    def test_binary_cast_scalar_scalar_with_out_with_where(
            self, xp, op, in1, in2, out, where):
        out = xp.array(out)
        where = xp.array(where)

        with testing.NumpyError(divide='ignore'):
            with testing.NlcpyError(divide='ignore',
                                    over='ignore',
                                    invalid='ignore'):
                with numpy.warnings.catch_warnings():
                    numpy.warnings.simplefilter('ignore', numpy.ComplexWarning)
                    func = getattr(xp, op)
                    y = func(in1, in2, out=out, where=where)
                    if xp is numpy and op in float16_op_set:
                        if isinstance(in1, bool) and \
                                isinstance(in2, bool):
                            y = func(in1,
                                     in2,
                                     out=out,
                                     where=where,
                                     dtype='f4')
                            return y
                    if xp is nlcpy:
                        nlcpy.request.flush()
        return y
Example #3
0
 def test_unary_cast_scalar_with_dtype(self, xp, op, in1, dtype):
     with testing.NumpyError(divide='ignore'):
         with testing.NlcpyError(divide='ignore', over='ignore', invalid='ignore'):
             func = getattr(xp, op)
             y = func(in1, dtype=dtype)
             if xp is nlcpy:
                 nlcpy.request.flush()
     return y
Example #4
0
    def test_unary_cast_array(self, xp, op, in1):
        in1 = xp.array(in1)

        with testing.NumpyError(divide='ignore'):
            with testing.NlcpyError(divide='ignore', over='ignore', invalid='ignore'):
                func = getattr(xp, op)
                y = func(in1)
                if xp is nlcpy:
                    nlcpy.request.flush()
        return y
Example #5
0
    def test_unary_cast_array_with_out_with_dtype(self, xp, op, in1, out, dtype):
        in1 = xp.array(in1)
        out = xp.array(out)

        with testing.NumpyError(divide='ignore'):
            with testing.NlcpyError(divide='ignore', over='ignore', invalid='ignore'):
                func = getattr(xp, op)
                y = func(in1, out=out, dtype=dtype)
                if xp is nlcpy:
                    nlcpy.request.flush()
        return y
Example #6
0
    def test_unary_cast_scalar_with_out_with_where_with_dtype_broadcast(
            self, xp, op, in1, out, where, dtype):
        out = xp.array(out)
        where = xp.array(where)

        with testing.NumpyError(divide='ignore'):
            with testing.NlcpyError(divide='ignore', over='ignore', invalid='ignore'):
                with numpy.warnings.catch_warnings():
                    numpy.warnings.simplefilter('ignore', numpy.ComplexWarning)
                    func = getattr(xp, op)
                    y = func(in1, out=out, where=where, dtype=dtype)
                    if xp is nlcpy:
                        nlcpy.request.flush()
        return y
Example #7
0
    def test_unary_cast_scalar_with_out(self, xp, op, in1, out):
        out = xp.array(out)

        with testing.NumpyError(divide='ignore'):
            with testing.NlcpyError(divide='ignore', over='ignore', invalid='ignore'):
                func = getattr(xp, op)
                y = func(in1, out=out)
                if xp is numpy and op in float16_op_set:
                    if isinstance(in1, bool):
                        y = func(in1, out=out, dtype='f4')
                        return y
                if xp is nlcpy:
                    nlcpy.request.flush()
        return y
Example #8
0
    def test_binary_cast_scalar_scalar_with_out_with_dtype(
            self, xp, op, in1, in2, out):
        out = xp.array(out)
        dtype = out.dtype

        with testing.NumpyError(divide='ignore'):
            with testing.NlcpyError(divide='ignore',
                                    over='ignore',
                                    invalid='ignore'):
                func = getattr(xp, op)
                y = func(in1, in2, out=out, dtype=dtype)
                if xp is nlcpy:
                    nlcpy.request.flush()
        return y
Example #9
0
    def test_unary_cast_array_with_out_broadcast(self, xp, op, in1, out):
        in1 = xp.array(in1)
        out = xp.array(out)

        with testing.NumpyError(divide='ignore'):
            with testing.NlcpyError(divide='ignore', over='ignore', invalid='ignore'):
                func = getattr(xp, op)
                y = func(in1, out=out)
                if xp is numpy and op in float16_op_set:
                    if in1.dtype == numpy.dtype('bool'):
                        y = func(in1, out=out, dtype='f4')
                        return y
                if xp is nlcpy:
                    nlcpy.request.flush()
        return y
Example #10
0
    def test_binary_broadcast_array_array_with_where(self, xp, op, in1, in2,
                                                     out, where):
        in1 = xp.array(in1)
        in2 = xp.array(in2)
        out = xp.array(out)
        where = xp.array(where)

        with testing.NumpyError(divide='ignore'):
            with testing.NlcpyError(divide='ignore',
                                    over='ignore',
                                    invalid='ignore'):
                func = getattr(xp, op)
                y = func(in1, in2, out=out, where=where)
                if xp is nlcpy:
                    nlcpy.request.flush()
        return y
Example #11
0
    def test_binary_cast_array_array_with_out(self, xp, op, in1, in2, out):
        in1 = xp.array(in1)
        in2 = xp.array(in2)
        out = xp.array(out)

        with testing.NumpyError(divide='ignore'):
            with testing.NlcpyError(divide='ignore',
                                    over='ignore',
                                    invalid='ignore'):
                func = getattr(xp, op)
                y = func(in1, in2, out=out)
                if xp is numpy and op in float16_op_set:
                    if in1.dtype.kind == 'b' and in2.dtype.kind == 'b':
                        y = func(in1, in2, out=out, dtype='f4')
                        return y
                if xp is nlcpy:
                    nlcpy.request.flush()
        return y
Example #12
0
    def test_binary_cast_array_array_with_out_with_where_with_dtype(
            self, xp, op, in1, in2, out, where):
        in1 = xp.array(in1)
        in2 = xp.array(in2)
        out = xp.array(out)
        where = xp.array(where)
        dtype = out.dtype

        with testing.NumpyError(divide='ignore'):
            with testing.NlcpyError(divide='ignore',
                                    over='ignore',
                                    invalid='ignore'):
                with numpy.warnings.catch_warnings():
                    numpy.warnings.simplefilter('ignore', numpy.ComplexWarning)
                    func = getattr(xp, op)
                    y = func(in1, in2, out=out, where=where, dtype=dtype)
                    if xp is nlcpy:
                        nlcpy.request.flush()
        return y