Esempio n. 1
0
    def test_pow(self):
        from _numpypy import int_

        assert int_(4) ** 2 == 16
Esempio n. 2
0
    def test_operators(self):
        from operator import truediv
        from _numpypy import float64, int_, True_, False_

        assert 5 / int_(2) == int_(2)
        assert truediv(int_(3), int_(2)) == float64(1.5)
        assert truediv(3, int_(2)) == float64(1.5)
        assert int_(8) % int_(3) == int_(2)
        assert 8 % int_(3) == int_(2)
        assert divmod(int_(8), int_(3)) == (int_(2), int_(2))
        assert divmod(8, int_(3)) == (int_(2), int_(2))
        assert 2 ** int_(3) == int_(8)
        assert int_(3) << int_(2) == int_(12)
        assert 3 << int_(2) == int_(12)
        assert int_(8) >> int_(2) == int_(2)
        assert 8 >> int_(2) == int_(2)
        assert int_(3) & int_(1) == int_(1)
        assert 2 & int_(3) == int_(2)
        assert int_(2) | int_(1) == int_(3)
        assert 2 | int_(1) == int_(3)
        assert int_(3) ^ int_(5) == int_(6)
        assert True_ ^ False_ is True_
        assert 5 ^ int_(3) == int_(6)

        assert +int_(3) == int_(3)
        assert ~int_(3) == int_(-4)

        raises(TypeError, lambda: float64(3) & 1)
Esempio n. 3
0
    def test_new(self):
        import _numpypy as np

        assert np.int_(4) == 4
        assert np.float_(3.4) == 3.4
Esempio n. 4
0
 def test_long_as_index(self):
     from _numpypy import int_, float64
     assert (1, 2, 3)[int_(1)] == 2
     raises(TypeError, lambda: (1, 2, 3)[float64(1)])
Esempio n. 5
0
 def test_operators(self):
     from operator import truediv
     from _numpypy import float64, int_, True_, False_
     assert 5 / int_(2) == int_(2)
     assert truediv(int_(3), int_(2)) == float64(1.5)
     assert truediv(3, int_(2)) == float64(1.5)
     assert int_(8) % int_(3) == int_(2)
     assert 8 % int_(3) == int_(2)
     assert divmod(int_(8), int_(3)) == (int_(2), int_(2))
     assert divmod(8, int_(3)) == (int_(2), int_(2))
     assert 2**int_(3) == int_(8)
     assert int_(3) << int_(2) == int_(12)
     assert 3 << int_(2) == int_(12)
     assert int_(8) >> int_(2) == int_(2)
     assert 8 >> int_(2) == int_(2)
     assert int_(3) & int_(1) == int_(1)
     assert 2 & int_(3) == int_(2)
     assert int_(2) | int_(1) == int_(3)
     assert 2 | int_(1) == int_(3)
     assert int_(3) ^ int_(5) == int_(6)
     assert True_ ^ False_ is True_
     assert 5 ^ int_(3) == int_(6)
     assert +int_(3) == int_(3)
     assert ~int_(3) == int_(-4)
     raises(TypeError, lambda: float64(3) & 1)
Esempio n. 6
0
 def test_long_as_index(self):
     from _numpypy import int_, float64
     assert (1, 2, 3)[int_(1)] == 2
     raises(TypeError, lambda: (1, 2, 3)[float64(1)])
Esempio n. 7
0
 def test_pow(self):
     from _numpypy import int_
     assert int_(4)**2 == 16
Esempio n. 8
0
 def test_new(self):
     import _numpypy as np
     assert np.int_(4) == 4
     assert np.float_(3.4) == 3.4