Beispiel #1
0
 def test_conj(self):
     self.assertEqual(vf.conj(VecField(1 + 1j, 2j, 3)),
                      VecField(1 - 1j, -2j, 3))
Beispiel #2
0
 def test_real(self):
     self.assertEqual(vf.real(VecField(1 + 1j, 2j, 3)), VecField(1, 0, 3))
Beispiel #3
0
 def test_dot(self):
     self.assertEqual(
         vf.dot(VecField(*((1 + 1j) * np.ones(5) for _ in range(3)), ),
                VecField(*((1 + 1j) * np.ones(5) for _ in range(3)), )),
         30j)
Beispiel #4
0
 def test_norm(self):
     self.assertEqual(
         vf.norm(VecField(*(3j * np.ones(3) for _ in range(3)))), 9)
Beispiel #5
0
 def test_scalar_mul(self):
     self.assertEqual(2 * VecField(1, 2, 3), VecField(2, 4, 6))
Beispiel #6
0
 def test_mul(self):
     self.assertEqual(
         VecField(1, 2, 3) * VecField(4, 5, 6), VecField(4, 10, 18))
Beispiel #7
0
 def test_sub(self):
     self.assertEqual(
         VecField(1, 2, 3) - VecField(4, 5, 6), VecField(-3, -3, -3))
Beispiel #8
0
 def test_add(self):
     self.assertEqual(
         VecField(1, 2, 3) + VecField(4, 5, 6), VecField(5, 7, 9))
Beispiel #9
0
 def test_as_array(self):
     self.assertIsInstance(
         VecField(*(onp.zeros(5) for _ in range(3))).as_array().x,
         np.ndarray)