forked from mergeos-bounties/Loru
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_loader.py
More file actions
40 lines (30 loc) · 1.22 KB
/
Copy pathtest_loader.py
File metadata and controls
40 lines (30 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from __future__ import annotations
from loru.config import SAMPLES_DIR
from loru.data.loader import list_sample_files, load_sequence, sequence_summary
from loru.infer.text import gloss_to_sentence
from loru.models.vocab import DEFAULT_GLOSS
def test_samples_exist() -> None:
files = list_sample_files()
assert len(files) >= 10
assert SAMPLES_DIR.exists()
def test_load_sequence_shapes() -> None:
path = list_sample_files()[0]
gloss, frames = load_sequence(path)
assert isinstance(gloss, str) and gloss
assert frames.ndim == 3 # frames, landmarks, xyz
assert frames.shape[0] >= 1
summary = sequence_summary(path)
assert summary["gloss"] == gloss
assert summary["language"]
assert summary["frames"] == frames.shape[0]
def test_school_sign_pack_has_sample_vocab_and_unique_frames() -> None:
path = SAMPLES_DIR / "school.json"
assert path.exists()
assert "school" in DEFAULT_GLOSS
assert gloss_to_sentence("school") == "I am at school."
gloss, frames = load_sequence(path)
assert gloss == "school"
assert frames.ndim == 3
assert frames.shape[0] >= 6
assert frames.shape[1:] == (21, 3)
assert len({frame.tobytes() for frame in frames}) == frames.shape[0]