Spaces:
Sleeping
Sleeping
Download code/tests/test_auto_clusters.py from acra-thesis/acra-backend: direct link, hf CLI and curl.
- Browser
- Download file 505 Bytes
-
https://huggingface.co/spaces/acra-thesis/acra-backend/resolve/main/code/tests/test_auto_clusters.py
- Command line
-
hf download hf://spaces/acra-thesis/acra-backend/code/tests/test_auto_clusters.py
-
curl -L -o test_auto_clusters.py https://huggingface.co/spaces/acra-thesis/acra-backend/resolve/main/code/tests/test_auto_clusters.py
505 Bytes
| import numpy as np | |
| from pipeline.auto_clusters import estimate_n_clusters | |
| def test_tiny_image_returns_k_min_of_two(): | |
| tiny = np.zeros((5, 5, 3), dtype=np.float64) | |
| assert estimate_n_clusters(tiny) == 2 | |
| def test_red_green_image_enforces_cluster_floor(): | |
| lab = np.zeros((200, 200, 3), dtype=np.float64) | |
| lab[:, :, 0] = 50 | |
| lab[:, :100, 1] = 40 | |
| lab[:, 100:, 1] = -40 | |
| lab[:, :, 2] = 10 | |
| k = estimate_n_clusters(lab) | |
| assert k >= 12, f"red/green floor should be 12, got {k}" | |