Exemplo n.º 1
0
 def testMillisecondEpochTime(self):
     datetimes = [
         '1465803236.495412', '1465803236.999362', '1465803237.504311',
         '1465803238.009261', '1465803238.512211', '1465803239.016160',
         '1465803239.520110', '1465803240.026059', '1465803240.529009'
     ]
     for datetime in datetimes:
         with self.subTest(datetime=datetime):
             dtype = number.min_numerical_convertible_type(datetime)
             self.assertEqual(dtype, numpy.float64)
Exemplo n.º 2
0
    def testMantissa80(self):
        self.skipIfFloat80NotSupported()
        dtype = number.min_numerical_convertible_type("1000000000.00001013")

        if pkg_resources.parse_version(numpy.version.version) <= pkg_resources.parse_version("1.10.4"):
            # numpy 1.8.2 -> Debian 8
            # Checking a float128 precision with numpy 1.8.2 using abs(diff) is not working.
            # It looks like the difference is done using float64 (diff == 0.0)
            expected = (numpy.longdouble, numpy.float64)
        else:
            expected = (numpy.longdouble, )
        self.assertIn(dtype, expected)
Exemplo n.º 3
0
 def testMillisecondEpochTime(self):
     datetimes = ['1465803236.495412',
                  '1465803236.999362',
                  '1465803237.504311',
                  '1465803238.009261',
                  '1465803238.512211',
                  '1465803239.016160',
                  '1465803239.520110',
                  '1465803240.026059',
                  '1465803240.529009']
     for datetime in datetimes:
         with self.subTest(datetime=datetime):
             dtype = number.min_numerical_convertible_type(datetime)
             self.assertEqual(dtype, numpy.float64)
Exemplo n.º 4
0
    def testMantissa80(self):
        self.skipIfFloat80NotSupported()
        dtype = number.min_numerical_convertible_type("1000000000.00001013")

        if pkg_resources.parse_version(
                numpy.version.version) <= pkg_resources.parse_version(
                    "1.10.4"):
            # numpy 1.8.2 -> Debian 8
            # Checking a float128 precision with numpy 1.8.2 using abs(diff) is not working.
            # It looks like the difference is done using float64 (diff == 0.0)
            expected = (numpy.longdouble, numpy.float64)
        else:
            expected = (numpy.longdouble, )
        self.assertIn(dtype, expected)
Exemplo n.º 5
0
 def testMantissa64(self):
     dtype = number.min_numerical_convertible_type("10000.000010")
     self.assertEqual(dtype, numpy.float64)
Exemplo n.º 6
0
 def testMantissa32(self):
     dtype = number.min_numerical_convertible_type("1400.50")
     self.assertEqual(dtype, numpy.float32)
Exemplo n.º 7
0
 def testPositiveNumberDecimal(self):
     dtype = number.min_numerical_convertible_type("+14.5")
     self.assertTrue(numpy.issubdtype(dtype, numpy.floating))
Exemplo n.º 8
0
 def testNegativeInteger(self):
     dtype = number.min_numerical_convertible_type("-1456")
     self.assertTrue(numpy.issubdtype(dtype, numpy.signedinteger))
Exemplo n.º 9
0
 def testExponent80(self):
     self.skipIfFloat80NotSupported()
     dtype = number.min_numerical_convertible_type("14.0e3000")
     self.assertEqual(dtype, numpy.longdouble)
Exemplo n.º 10
0
 def testNegativeInteger(self):
     dtype = number.min_numerical_convertible_type("-1456")
     self.assertTrue(numpy.issubdtype(dtype, numpy.signedinteger))
Exemplo n.º 11
0
 def testTrailledInteger(self):
     dtype = number.min_numerical_convertible_type(" \t\n\r1456\t\n\r")
     self.assertTrue(numpy.issubdtype(dtype, numpy.unsignedinteger))
Exemplo n.º 12
0
 def testFloat32ToString(self):
     value = str(numpy.float32(numpy.pi))
     dtype = number.min_numerical_convertible_type(value)
     self.assertIn(dtype, (numpy.float32, numpy.float64))
Exemplo n.º 13
0
 def testExponent80(self):
     self.skipIfFloat80NotSupported()
     dtype = number.min_numerical_convertible_type("14.0e3000")
     self.assertEqual(dtype, numpy.longdouble)
Exemplo n.º 14
0
 def testExponent64(self):
     dtype = number.min_numerical_convertible_type("14.0e300")
     self.assertEqual(dtype, numpy.float64)
Exemplo n.º 15
0
 def testIntegerNegativeExponential(self):
     dtype = number.min_numerical_convertible_type("14e-10")
     self.assertTrue(numpy.issubdtype(dtype, numpy.floating))
Exemplo n.º 16
0
 def testExponent64(self):
     dtype = number.min_numerical_convertible_type("14.0e300")
     self.assertEqual(dtype, numpy.float64)
Exemplo n.º 17
0
 def testPositiveNumberDecimal(self):
     dtype = number.min_numerical_convertible_type("+14.5")
     self.assertTrue(numpy.issubdtype(dtype, numpy.floating))
Exemplo n.º 18
0
 def testFloat32ToString(self):
     value = str(numpy.float32(numpy.pi))
     dtype = number.min_numerical_convertible_type(value)
     self.assertIn(dtype, (numpy.float32, numpy.float64))
Exemplo n.º 19
0
 def testNegativeDecimal(self):
     dtype = number.min_numerical_convertible_type("-.5")
     self.assertTrue(numpy.issubdtype(dtype, numpy.floating))
Exemplo n.º 20
0
 def testTrailledInteger(self):
     dtype = number.min_numerical_convertible_type(" \t\n\r1456\t\n\r")
     self.assertTrue(numpy.issubdtype(dtype, numpy.unsignedinteger))
Exemplo n.º 21
0
 def testMantissa16(self):
     dtype = number.min_numerical_convertible_type("1.50")
     self.assertEqual(dtype, numpy.float16)
Exemplo n.º 22
0
 def testIntegerNegativeExponential(self):
     dtype = number.min_numerical_convertible_type("14e-10")
     self.assertTrue(numpy.issubdtype(dtype, numpy.floating))
Exemplo n.º 23
0
 def testFloat32(self):
     dtype = number.min_numerical_convertible_type("-23.172")
     self.assertEqual(dtype, numpy.float32)
Exemplo n.º 24
0
 def testNegativeDecimal(self):
     dtype = number.min_numerical_convertible_type("-.5")
     self.assertTrue(numpy.issubdtype(dtype, numpy.floating))
Exemplo n.º 25
0
 def testMantissa64(self):
     dtype = number.min_numerical_convertible_type("10000.000010")
     self.assertEqual(dtype, numpy.float64)