Esempio n. 1
0
 def test_init(self):
     # Setting sctype_list
     R = Recaster()
     assert set(R.sctype_list) == set(sctype_attributes().keys()), \
                            'Default recaster should include all system types'
     T = np.float32
     R = Recaster([T])
     assert R.sctype_list == [T], 'Scalar type list not correctly set'
     # Setting tolerances
     R = Recaster()
     tols = R.default_sctype_tols()
     assert tols == R.sctype_tols, 'Unexpected tols dictionary'
     F = np.finfo(T)
     R = Recaster(sctype_tols={
         T: {
             'rtol': F.eps * 2,
             'atol': F.tiny * 2,
             'silly': 'silly text'
         }
     })
     assert R.sctype_tols[T]['rtol'] == F.eps*2, \
            'Rtol not correctly set'
     assert R.sctype_tols[T]['atol'] == F.tiny*2, \
            'Atol not correctly set'
     T = np.complex128
     F = np.finfo(T)
     assert R.sctype_tols[T]['rtol'] == F.eps, \
            'Rtol defaults not correctly set'
     assert R.sctype_tols[T]['atol'] == F.tiny, \
            'Atol defaults not correctly set'
 def test_init(self):
     # Setting sctype_list
     R = Recaster()
     assert set(R.sctype_list) == set(sctype_attributes().keys()), \
                            'Default recaster should include all system types'
     T = np.float32
     R = Recaster([T])
     assert R.sctype_list == [T], 'Scalar type list not correctly set'
     # Setting tolerances
     R = Recaster()
     tols = R.default_sctype_tols()
     assert tols == R.sctype_tols, 'Unexpected tols dictionary'
     F = np.finfo(T)
     R = Recaster(sctype_tols={T: {
         'rtol': F.eps*2,
         'atol': F.tiny*2,
         'silly': 'silly text'}})
     assert R.sctype_tols[T]['rtol'] == F.eps*2, \
            'Rtol not correctly set'
     assert R.sctype_tols[T]['atol'] == F.tiny*2, \
            'Atol not correctly set'
     T = np.complex128
     F = np.finfo(T)
     assert R.sctype_tols[T]['rtol'] == F.eps, \
            'Rtol defaults not correctly set'
     assert R.sctype_tols[T]['atol'] == F.tiny, \
            'Atol defaults not correctly set'