rot_3d and transpose test added
This commit is contained in:
parent
deba331de9
commit
cdbdb8b10a
18
tests/test_rot3D.py
Normal file
18
tests/test_rot3D.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import math, pytest
|
||||||
|
from matrixmania import rot_3D
|
||||||
|
|
||||||
|
def test_rot_3D_x_axis():
|
||||||
|
angle = math.pi / 2
|
||||||
|
R = rot_3D(angle, 'x')
|
||||||
|
expected = [
|
||||||
|
[1, 0, 0],
|
||||||
|
[0, 0, -1],
|
||||||
|
[0, 1, 0]
|
||||||
|
]
|
||||||
|
for r, e in zip(R, expected):
|
||||||
|
for rv, ev in zip(r, e):
|
||||||
|
assert math.isclose(rv, ev, abs_tol=1e-9)
|
||||||
|
|
||||||
|
def test_rot_3D_invalid_axis():
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
rot_3D(math.pi/4, 'a')
|
||||||
12
tests/test_transpose.py
Normal file
12
tests/test_transpose.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import math, pytest
|
||||||
|
from matrixmania import transpose
|
||||||
|
|
||||||
|
def test_transpose_basic():
|
||||||
|
matrix = [[1, 2, 3], [4, 5, 6]]
|
||||||
|
expected = [[1, 4], [2, 5], [3, 6]]
|
||||||
|
assert transpose(matrix) == expected
|
||||||
|
|
||||||
|
def test_transpose_invalid():
|
||||||
|
matrix = [[1, 2], [3]]
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
transpose(matrix)
|
||||||
Loading…
x
Reference in New Issue
Block a user