JBAujogue commited on
Commit
ff5d990
·
1 Parent(s): 328da4d

scratch of unit tests

Browse files
tests/unit/test_action.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+ from typing import Iterable
3
+
4
+ import torch
5
+
6
+ from rubik.action import (
7
+ POS_ROTATIONS,
8
+ )
9
+
10
+
11
+ def test_position_rotation_shape():
12
+ expected = (3, 4, 4)
13
+ observed = POS_ROTATIONS.shape
14
+ assert expected == observed, f"Position rotation tensor expected shape '{expected}', but got '{observed}' instead"
15
+
16
+
17
+ @pytest.mark.parametrize(
18
+ "axis, input, expected",
19
+ [
20
+ (0, (1, 1, 0, 0), (1, 1, 0, 0)),
21
+ (0, (1, 0, 1, 0), (1, 0, 0, -1)),
22
+ (0, (1, 0, 0, 1), (1, 0, 1, 0)),
23
+ (1, (1, 1, 0, 0), (1, 0, 0, 1)),
24
+ (1, (1, 0, 1, 0), (1, 0, 1, 0)),
25
+ (1, (1, 0, 0, 1), (1, -1, 0, 0)),
26
+ (2, (1, 1, 0, 0), (1, 0, -1, 0)),
27
+ (2, (1, 0, 1, 0), (1, 1, 0, 0)),
28
+ (2, (1, 0, 0, 1), (1, 0, 0, 1)),
29
+ ],
30
+ )
31
+ def test_position_rotation(axis: int, input: Iterable[int], expected: Iterable[int]):
32
+ out = POS_ROTATIONS[axis] @ torch.tensor(input, dtype=POS_ROTATIONS.dtype)
33
+ exp = torch.tensor(expected, dtype=POS_ROTATIONS.dtype)
34
+ assert torch.equal(out, exp), f"Position rotation tensor is incorrect along axis {axis}: {out} != {exp}"
tests/unit/test_cube.py ADDED
File without changes
tests/unit/test_display.py ADDED
File without changes
tests/unit/test_tensor_utils.py ADDED
File without changes