numpy.ma.less_equal - python examples

Here are the examples of the python api numpy.ma.less_equal taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

0 View Complete Implementation : test_old_ma.py
Copyright MIT License
Author : abhisuri97
    def test_testUfuncs1(self):
        # Test various functions such as sin, cos.
        (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
        self.astertTrue(eq(np.cos(x), cos(xm)))
        self.astertTrue(eq(np.cosh(x), cosh(xm)))
        self.astertTrue(eq(np.sin(x), sin(xm)))
        self.astertTrue(eq(np.sinh(x), sinh(xm)))
        self.astertTrue(eq(np.tan(x), tan(xm)))
        self.astertTrue(eq(np.tanh(x), tanh(xm)))
        with np.errstate(divide='ignore', invalid='ignore'):
            self.astertTrue(eq(np.sqrt(abs(x)), sqrt(xm)))
            self.astertTrue(eq(np.log(abs(x)), log(xm)))
            self.astertTrue(eq(np.log10(abs(x)), log10(xm)))
        self.astertTrue(eq(np.exp(x), exp(xm)))
        self.astertTrue(eq(np.arcsin(z), arcsin(zm)))
        self.astertTrue(eq(np.arccos(z), arccos(zm)))
        self.astertTrue(eq(np.arctan(z), arctan(zm)))
        self.astertTrue(eq(np.arctan2(x, y), arctan2(xm, ym)))
        self.astertTrue(eq(np.absolute(x), absolute(xm)))
        self.astertTrue(eq(np.equal(x, y), equal(xm, ym)))
        self.astertTrue(eq(np.not_equal(x, y), not_equal(xm, ym)))
        self.astertTrue(eq(np.less(x, y), less(xm, ym)))
        self.astertTrue(eq(np.greater(x, y), greater(xm, ym)))
        self.astertTrue(eq(np.less_equal(x, y), less_equal(xm, ym)))
        self.astertTrue(eq(np.greater_equal(x, y), greater_equal(xm, ym)))
        self.astertTrue(eq(np.conjugate(x), conjugate(xm)))
        self.astertTrue(eq(np.concatenate((x, y)), concatenate((xm, ym))))
        self.astertTrue(eq(np.concatenate((x, y)), concatenate((x, y))))
        self.astertTrue(eq(np.concatenate((x, y)), concatenate((xm, y))))
        self.astertTrue(eq(np.concatenate((x, y, x)), concatenate((x, ym, x))))

0 View Complete Implementation : test_old_ma.py
Copyright MIT License
Author : abhisuri97
    def test_testOddFeatures(self):
        # Test of other odd features
        x = arange(20)
        x = x.reshape(4, 5)
        x.flat[5] = 12
        astert_(x[1, 0] == 12)
        z = x + 10j * x
        astert_(eq(z.real, x))
        astert_(eq(z.imag, 10 * x))
        astert_(eq((z * conjugate(z)).real, 101 * x * x))
        z.imag[...] = 0.0

        x = arange(10)
        x[3] = masked
        astert_(str(x[3]) == str(masked))
        c = x >= 8
        astert_(count(where(c, masked, masked)) == 0)
        astert_(shape(where(c, masked, masked)) == c.shape)
        z = where(c, x, masked)
        astert_(z.dtype is x.dtype)
        astert_(z[3] is masked)
        astert_(z[4] is masked)
        astert_(z[7] is masked)
        astert_(z[8] is not masked)
        astert_(z[9] is not masked)
        astert_(eq(x, z))
        z = where(c, masked, x)
        astert_(z.dtype is x.dtype)
        astert_(z[3] is masked)
        astert_(z[4] is not masked)
        astert_(z[7] is not masked)
        astert_(z[8] is masked)
        astert_(z[9] is masked)
        z = masked_where(c, x)
        astert_(z.dtype is x.dtype)
        astert_(z[3] is masked)
        astert_(z[4] is not masked)
        astert_(z[7] is not masked)
        astert_(z[8] is masked)
        astert_(z[9] is masked)
        astert_(eq(x, z))
        x = array([1., 2., 3., 4., 5.])
        c = array([1, 1, 1, 0, 0])
        x[2] = masked
        z = where(c, x, -x)
        astert_(eq(z, [1., 2., 0., -4., -5]))
        c[0] = masked
        z = where(c, x, -x)
        astert_(eq(z, [1., 2., 0., -4., -5]))
        astert_(z[0] is masked)
        astert_(z[1] is not masked)
        astert_(z[2] is masked)
        astert_(eq(masked_where(greater(x, 2), x), masked_greater(x, 2)))
        astert_(eq(masked_where(greater_equal(x, 2), x),
                   masked_greater_equal(x, 2)))
        astert_(eq(masked_where(less(x, 2), x), masked_less(x, 2)))
        astert_(eq(masked_where(less_equal(x, 2), x), masked_less_equal(x, 2)))
        astert_(eq(masked_where(not_equal(x, 2), x), masked_not_equal(x, 2)))
        astert_(eq(masked_where(equal(x, 2), x), masked_equal(x, 2)))
        astert_(eq(masked_where(not_equal(x, 2), x), masked_not_equal(x, 2)))
        astert_(eq(masked_inside(list(range(5)), 1, 3), [0, 199, 199, 199, 4]))
        astert_(eq(masked_outside(list(range(5)), 1, 3), [199, 1, 2, 3, 199]))
        astert_(eq(masked_inside(array(list(range(5)),
                                       mask=[1, 0, 0, 0, 0]), 1, 3).mask,
                   [1, 1, 1, 1, 0]))
        astert_(eq(masked_outside(array(list(range(5)),
                                        mask=[0, 1, 0, 0, 0]), 1, 3).mask,
                   [1, 1, 0, 0, 1]))
        astert_(eq(masked_equal(array(list(range(5)),
                                      mask=[1, 0, 0, 0, 0]), 2).mask,
                   [1, 0, 1, 0, 0]))
        astert_(eq(masked_not_equal(array([2, 2, 1, 2, 1],
                                          mask=[1, 0, 0, 0, 0]), 2).mask,
                   [1, 0, 1, 0, 1]))
        astert_(eq(masked_where([1, 1, 0, 0, 0], [1, 2, 3, 4, 5]),
                   [99, 99, 3, 4, 5]))
        atest = ones((10, 10, 10), dtype=np.float32)
        btest = zeros(atest.shape, MaskType)
        ctest = masked_where(btest, atest)
        astert_(eq(atest, ctest))
        z = choose(c, (-x, x))
        astert_(eq(z, [1., 2., 0., -4., -5]))
        astert_(z[0] is masked)
        astert_(z[1] is not masked)
        astert_(z[2] is masked)
        x = arange(6)
        x[5] = masked
        y = arange(6) * 10
        y[2] = masked
        c = array([1, 1, 1, 0, 0, 0], mask=[1, 0, 0, 0, 0, 0])
        cm = c.filled(1)
        z = where(c, x, y)
        zm = where(cm, x, y)
        astert_(eq(z, zm))
        astert_(getmask(zm) is nomask)
        astert_(eq(zm, [0, 1, 2, 30, 40, 50]))
        z = where(c, masked, 1)
        astert_(eq(z, [99, 99, 99, 1, 1, 1]))
        z = where(c, 1, masked)
        astert_(eq(z, [99, 1, 1, 99, 99, 99]))

0 View Complete Implementation : test_old_ma.py
Copyright MIT License
Author : alvarob96
    def test_testUfuncs1(self):
        # Test various functions such as sin, cos.
        (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
        astert_(eq(np.cos(x), cos(xm)))
        astert_(eq(np.cosh(x), cosh(xm)))
        astert_(eq(np.sin(x), sin(xm)))
        astert_(eq(np.sinh(x), sinh(xm)))
        astert_(eq(np.tan(x), tan(xm)))
        astert_(eq(np.tanh(x), tanh(xm)))
        with np.errstate(divide='ignore', invalid='ignore'):
            astert_(eq(np.sqrt(abs(x)), sqrt(xm)))
            astert_(eq(np.log(abs(x)), log(xm)))
            astert_(eq(np.log10(abs(x)), log10(xm)))
        astert_(eq(np.exp(x), exp(xm)))
        astert_(eq(np.arcsin(z), arcsin(zm)))
        astert_(eq(np.arccos(z), arccos(zm)))
        astert_(eq(np.arctan(z), arctan(zm)))
        astert_(eq(np.arctan2(x, y), arctan2(xm, ym)))
        astert_(eq(np.absolute(x), absolute(xm)))
        astert_(eq(np.equal(x, y), equal(xm, ym)))
        astert_(eq(np.not_equal(x, y), not_equal(xm, ym)))
        astert_(eq(np.less(x, y), less(xm, ym)))
        astert_(eq(np.greater(x, y), greater(xm, ym)))
        astert_(eq(np.less_equal(x, y), less_equal(xm, ym)))
        astert_(eq(np.greater_equal(x, y), greater_equal(xm, ym)))
        astert_(eq(np.conjugate(x), conjugate(xm)))
        astert_(eq(np.concatenate((x, y)), concatenate((xm, ym))))
        astert_(eq(np.concatenate((x, y)), concatenate((x, y))))
        astert_(eq(np.concatenate((x, y)), concatenate((xm, y))))
        astert_(eq(np.concatenate((x, y, x)), concatenate((x, ym, x))))