Implement Unit Testing for fancymath #8

Merged
TimDiller merged 17 commits from unit_tests into main 2025-10-24 17:10:59 +00:00
6 changed files with 94 additions and 0 deletions
Showing only changes of commit 437be17f51 - Show all commits

View File

@@ -36,6 +36,14 @@ class Vector(object):
z = self.z + other.z z = self.z + other.z
return self.__class__(x, y, z) return self.__class__(x, y, z)
def __mul__(self, other):
if not isinstance(other, Vector):
Review

Do we want to handle scalar multiplication here? If so we should implement __rmul__ and __imul__.

Do we want to handle scalar multiplication here? If so we should implement `__rmul__` and `__imul__`.
return NotImplemented
x = self.y * other.z - self.z * other.y
y = self.z * other.x - self.x * other.z
z = self.x * other.y - self.y * other.x
return self.__class__(x, y, z)
if __name__ == "__main__": if __name__ == "__main__":
v1 = Vector(3, 4, 0) v1 = Vector(3, 4, 0)