fifth commit: test_rot 2D/3D added

This commit is contained in:
Tia Lechner committed 2026-10-20 19:26:40 +02:00
1 parent 043440e38c
commit b649addb49
4 files changed
+33 -4

No files matched your search

+1
View File
@@ -2,6 +2,7 @@
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/.venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.13 (matrixmania)" jdkType="Python SDK" />
+1 -1
View File
@@ -1 +1 @@
from compute import matmul, transpose, rot_2D
from .compute import matmul, transpose, rot_2D, rot_3D
-1
View File
@@ -1 +0,0 @@
from compute import matmul, transpose, rot_2D
+31 -2
View File
@@ -1,9 +1,38 @@
import pytest
from matrixmania import rot_2D, rot_3D
import math
def test_matrixmania():
def test_rot_2D():
#Arrange
theta = math.pi / 2
expected_value = [
[0.0, -1.0],
[1.0, 0.0]
]
#Act
result = rot_2D(theta)
#Assert
assert len(result) == len(expected_value)
for row_result, row_expected in zip(result, expected_value):
assert row_result == pytest.approx(row_expected, abs=1e-5)
#Assert
def test_rot_3D():
#Arrange
angle = 90
axis = "z"
expected_value = [
[0.0, -1.0, 0.0],
[1.0, 0.0, 0.0],
[0.0, 0.0, 1.0]
]
#Act
result = rot_3D(angle,axis)
#Assert
assert len(result) == len(expected_value)
for row_result, row_expected in zip(result, expected_value):
assert row_result == pytest.approx(row_expected, abs=1e-5)