diff --git a/.idea/matrixmania.iml b/.idea/matrixmania.iml index c5f5bf2..d343a26 100644 --- a/.idea/matrixmania.iml +++ b/.idea/matrixmania.iml @@ -2,6 +2,7 @@ + diff --git a/src/matrixmania/__init__.py b/src/matrixmania/__init__.py index 2eeb846..c812c86 100644 --- a/src/matrixmania/__init__.py +++ b/src/matrixmania/__init__.py @@ -1 +1 @@ -from compute import matmul, transpose, rot_2D \ No newline at end of file +from .compute import matmul, transpose, rot_2D, rot_3D \ No newline at end of file diff --git a/test/test_matrixmania/__init__.py b/test/test_matrixmania/__init__.py index 2eeb846..e69de29 100644 --- a/test/test_matrixmania/__init__.py +++ b/test/test_matrixmania/__init__.py @@ -1 +0,0 @@ -from compute import matmul, transpose, rot_2D \ No newline at end of file diff --git a/test/test_matrixmania/test_rot.py b/test/test_matrixmania/test_rot.py index 26f6a69..fec3be3 100644 --- a/test/test_matrixmania/test_rot.py +++ b/test/test_matrixmania/test_rot.py @@ -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 \ No newline at end of file +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) \ No newline at end of file