예제 #1
0
 def test_complex_array(self):
     d = Dictionary()
     d['complex'] = fzeros(10, dtype='D')
     a = FortranArray(d.get_array('complex'))
     a[:] = 1 + 2j
     self.assertEqual(a.dtype.kind, 'c')
     self.assertArrayAlmostEqual(a, d['complex'])
예제 #2
0
 def test_real_array2(self):
     d = Dictionary()
     d.add_array('real', 0.0, (3, 3))
     d_real = FortranArray(d.get_array('real'))
     d_real[1, 1] = 3.
     d_real[2, 2] = 1.
     d_real[:, 3] = (4., 1., 5.)
     self.assertArrayAlmostEqual(d_real, d['real'])
예제 #3
0
 def test_int_array2(self):
     d = Dictionary()
     d.add_array('int', 0, (3, 3))
     d_int = FortranArray(d.get_array('int'))
     d_int[1, 1] = 3
     d_int[2, 2] = 1
     d_int[:, 3] = (4, 1, 5)
     self.assert_(all(d_int == d['int']))
예제 #4
0
 def test_logical_array(self):
     d = Dictionary()
     d['logical'] = fzeros(5, dtype='bool')
     a = FortranArray(d.get_array('logical'))
     a[:] = [True, False, False, True, True]
     self.assertEqual(
         a.dtype,
         dtype('int32'))  # Fortran logical represented as int32 internally
     self.assertArrayAlmostEqual(a, d['logical'])
예제 #5
0
 def test_string_array(self):
     d = Dictionary()
     d['string'] = ['one', 'two', 'three']
     a = FortranArray(d.get_array('string'))
     a[:, 1] = farray(list('hello'), 'S1')
     self.assertEqual(list(a2s(d['string'])), list(a2s(a)))
예제 #6
0
 def test_real_array(self):
     d = Dictionary()
     d['real'] = [float(i) for i in range(10)]
     self.assertArrayAlmostEqual(FortranArray(d.get_array('real')),
                                 d['real'])
예제 #7
0
 def test_int_array(self):
     d = Dictionary()
     d['int'] = [i for i in range(10)]
     self.assertArrayAlmostEqual(FortranArray(d.get_array('int')), d['int'])