fifth commit: test_rot 2D/3D added
This commit is contained in:
1 parent
043440e38c
commit
b649addb49
4 files changed
+33
-4
No files matched your search
@@ -1 +0,0 @@
|
||||
from compute import matmul, transpose, rot_2D
|
||||
@@ -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)
|
||||
Reference in new issue
Block a user