Spaces:
Sleeping
Sleeping
| import numpy as np | |
| from app.services.boundary_detector import find_boundaries | |
| def test_no_boundary_for_identical_embeddings(): | |
| emb = np.ones((10, 768)) | |
| assert find_boundaries(emb, hop_duration=5.0, min_segment_duration=10.0) == [] | |
| def test_boundary_at_sharp_transition(): | |
| a = np.random.randn(768) | |
| b = -a | |
| emb = np.stack([a] * 5 + [b] * 5) | |
| boundaries = find_boundaries(emb, hop_duration=5.0, min_segment_duration=10.0) | |
| assert len(boundaries) >= 1 | |
| assert 3 <= boundaries[0] <= 6 | |
| def test_returns_list_of_ints(): | |
| emb = np.random.randn(8, 768) | |
| for b in find_boundaries(emb, hop_duration=5.0, min_segment_duration=10.0): | |
| assert isinstance(b, int) | |
| def test_single_chunk_returns_empty(): | |
| assert find_boundaries(np.random.randn(1, 768), hop_duration=5.0, min_segment_duration=10.0) == [] | |