__repr__ and type hints for quaternion class updated

This commit is contained in:
Nicolas 2026-04-05 13:54:47 +02:00
parent 5d3d6bdf63
commit 139cfad9dd
2 changed files with 3 additions and 1 deletions

View File

@ -31,6 +31,8 @@ def grad(x: Any, y: value[Any] | Sequence[value[Any]] | vector[Any] | tensor[Any
"""
assert isinstance(x, value), f"Argument x for grad function must be a copapy value but is {type(x)}."
y_set: set[value[float] | float]
if isinstance(y, value):
y_set = {y}
if isinstance(y, tensor):

View File

@ -218,7 +218,7 @@ class quaternion(ArrayType[float]):
return self.norm()
def __repr__(self) -> str:
return f"vector({self.values})"
return f"quaternion(w={self.w}, x={self.x}, y={self.y}, z={self.z})"
def __len__(self) -> int:
return len(self.values)