コード例 #1
0
 def test_bad_np(self):
     a1 = ['1. 2, 3.0, a', '1. 2, -3.0, -4.0']
     a = array_float_np(a1)
     self.assertIsNone(a)
     a1 = ['1. 2, 3.0, -4.0', '1. 2, -3.0, -4.0']
     a2 = ['1. 2, 3.0, a', '1. 2, -3.0, -4.0']
     aa = [a1, a2]
     a = array_float_np(aa)
     self.assertIsNone(a)
コード例 #2
0
 def test_multi_dim_array_np(self):
     a1 = ['1. 2, 3.0, -4.0', '1. 2, -3.0, -4.0']
     a2 = ['1. 2, 3.0, -4.0', '1. 2, -3.0, -4.0']
     aa = [a1, a2]
     a = array_float_np(aa)
     b = np.array([array_float_np(r) for r in aa])
     pass_val = np.any(np.less_equal(np.abs(a - b), self.epsilon))
     self.assertTrue(pass_val)
     a_shape = np.array(a.shape)
     t_shape = np.array((2, 2, 4))
     self.assertTrue(np.any(np.equal(a_shape, t_shape)))
コード例 #3
0
 def test_tuple(self):
     a = (1.0, 2.0, 3.0, 4)
     b = np.array(a)
     b_shape = b.shape
     a_vals = array_float_np(a)
     a_vals_shape = a_vals.shape
     self.assertTrue(np.array_equal(a_vals_shape, b_shape))
     self.assertTrue(np.array_equal(a_vals, b))
コード例 #4
0
 def test_two_dim_array_np(self):
     a1 = ['1. 2, 3.0, -4.0', '1. 2, -3.0, -4.0']
     a = array_float_np(a1)
     b = np.array([str_array_floats(r) for r in a1])
     pass_val = np.any(np.less_equal(np.abs(a - b), self.epsilon))
     self.assertTrue(pass_val)
     a_shape = np.array(a.shape)
     t_shape = np.array((2, 4))
     self.assertTrue(np.any(np.equal(a_shape, t_shape)))