Exemplo n.º 1
0
    def test_cabs_inf_nan(self):
        # cabs(+-nan + nani) returns nan
        self.assertTrue(blaze.isnan(blaze.abs(complex(blaze.nan, blaze.nan))))
        self.assertTrue(blaze.isnan(blaze.abs(complex(-blaze.nan, blaze.nan))))
        self.assertTrue(blaze.isnan(blaze.abs(complex(blaze.nan, -blaze.nan))))
        self.assertTrue(blaze.isnan(blaze.abs(complex(-blaze.nan, -blaze.nan))))

        # According to C99 standard, if exactly one of the real/part is inf and
        # the other nan, then cabs should return inf
        assert_equal(blaze.abs(complex(blaze.inf, blaze.nan)), blaze.inf)
        assert_equal(blaze.abs(complex(blaze.nan, blaze.inf)), blaze.inf)
        assert_equal(blaze.abs(complex(-blaze.inf, blaze.nan)), blaze.inf)
        assert_equal(blaze.abs(complex(blaze.nan, -blaze.inf)), blaze.inf)

        values = [complex(blaze.nan, blaze.nan),
                  complex(-blaze.nan, blaze.nan),
                  complex(blaze.inf, blaze.nan),
                  complex(-blaze.inf, blaze.nan)]

        for z in values:
            abs_conj_z = blaze.abs(blaze.conj(z))
            conj_abs_z = blaze.conj(blaze.abs(z))
            abs_z = blaze.abs(z)
            assert_equal(abs_conj_z, conj_abs_z)
            assert_equal(abs_conj_z, abs_z)
            assert_equal(conj_abs_z, abs_z)
Exemplo n.º 2
0
 def test_nan(self):
     self.assertTrue(blaze.isnan(blaze.logaddexp2(blaze.nan, blaze.inf)))
     self.assertTrue(blaze.isnan(blaze.logaddexp2(blaze.inf, blaze.nan)))
     self.assertTrue(blaze.isnan(blaze.logaddexp2(blaze.nan, 0)))
     self.assertTrue(blaze.isnan(blaze.logaddexp2(0, blaze.nan)))
     self.assertTrue(blaze.isnan(blaze.logaddexp2(blaze.nan, blaze.nan)))