Example #1
0
    def test_int32(self):
        import sys
        import _numpypy as numpy

        x = numpy.int32(23)
        assert x == 23
        assert numpy.int32(2147483647) == 2147483647
        assert numpy.int32("2147483647") == 2147483647
        if sys.maxint > 2 ** 31 - 1:
            assert numpy.int32(2147483648) == -2147483648
            assert numpy.int32("2147483648") == -2147483648
        else:
            raises(OverflowError, numpy.int32, 2147483648)
            raises(OverflowError, numpy.int32, "2147483648")
Example #2
0
    def test_int32(self):
        import sys
        import _numpypy as numpy

        x = numpy.int32(23)
        assert x == 23
        assert numpy.int32(2147483647) == 2147483647
        assert numpy.int32('2147483647') == 2147483647
        if sys.maxint > 2 ** 31 - 1:
            assert numpy.int32(2147483648) == -2147483648
            assert numpy.int32('2147483648') == -2147483648
        else:
            raises(OverflowError, numpy.int32, 2147483648)
            raises(OverflowError, numpy.int32, '2147483648')
        assert numpy.dtype('int32') is numpy.dtype(numpy.int32)
Example #3
0
    def test_int32(self):
        import sys
        import _numpypy as numpy

        x = numpy.int32(23)
        assert x == 23
        assert numpy.int32(2147483647) == 2147483647
        assert numpy.int32('2147483647') == 2147483647
        if sys.maxint > 2**31 - 1:
            assert numpy.int32(2147483648) == -2147483648
            assert numpy.int32('2147483648') == -2147483648
        else:
            raises(OverflowError, numpy.int32, 2147483648)
            raises(OverflowError, numpy.int32, '2147483648')
        assert numpy.dtype('int32') is numpy.dtype(numpy.int32)
Example #4
0
 def test_tolist_scalar(self):
     from _numpypy import int32, bool_
     x = int32(23)
     assert x.tolist() == 23
     assert type(x.tolist()) is int
     y = bool_(True)
     assert y.tolist() is True
Example #5
0
 def test_tolist_scalar(self):
     from _numpypy import int32, bool_
     x = int32(23)
     assert x.tolist() == 23
     assert type(x.tolist()) is int
     y = bool_(True)
     assert y.tolist() is True
Example #6
0
 def test_scalar_subtract(self):
     from _numpypy import int32
     assert int32(2) - 1 == 1
     assert 1 - int32(2) == -1
Example #7
0
 def test_scalar_subtract(self):
     from _numpypy import int32
     assert int32(2) - 1 == 1
     assert 1 - int32(2) == -1