Add cross-product and tests #9

Merged
TimDiller merged 3 commits from enh/cross-product into unit_tests 2025-10-24 15:25:26 +00:00
Showing only changes of commit 64f06ce7c1 - Show all commits

View File

@@ -32,3 +32,16 @@ class TestVector(unittest.TestCase):
v3 = v1 + v2
self.assertIsInstance(v3, Vector)
self.assertEqual(v3.x, v1.x + v2.x)
def test_dot_failure(self):
with self.assertRaises(ValueError):
v1 = Vector(1, 2, 3)
v1.dot(3)
def test_dot_product(self):
v1 = Vector(1, 2, 3)
v2 = Vector(-3, -2, -1)
v3 = v1.dot(v2)
self.assertEqual(v3,v1.x * v2.x + v1.y * v2.y + v1.z * v2.z)
vzero = Vector(0, 0, 0)
self.assertEqual(v1.dot(vzero),0)