Spaces:
Running on Zero
Running on Zero
Download tests/test_evaluate.py from stevafernandes/cellquant: direct link, hf CLI and curl.
- Browser
- Download file 925 Bytes
-
https://huggingface.co/spaces/stevafernandes/cellquant/resolve/main/tests/test_evaluate.py
- Command line
-
hf download hf://spaces/stevafernandes/cellquant/tests/test_evaluate.py
-
curl -L -o test_evaluate.py https://huggingface.co/spaces/stevafernandes/cellquant/resolve/main/tests/test_evaluate.py
925 Bytes
| import numpy as np | |
| import evaluate as ev | |
| def test_dihedral_transforms_invert_for_2d_and_3d(): | |
| rng = np.random.default_rng(0) | |
| a2 = rng.random((5, 7)) | |
| a3 = rng.random((3, 5, 7)) | |
| for k, f in ev.DIHEDRAL: | |
| assert np.array_equal(ev.inv_np(ev.fwd_np(a2, k, f), k, f), a2) | |
| assert np.array_equal(ev.inv_np(ev.fwd_np(a3, k, f), k, f), a3) | |
| def test_dihedral_transforms_are_distinct(): | |
| a = np.arange(12).reshape(3, 4).astype(float) | |
| outs = [ev.fwd_np(a, k, f).tobytes() + bytes(ev.fwd_np(a, k, f).shape) for k, f in ev.DIHEDRAL] | |
| assert len(set(outs)) == 8 | |
| def test_photometric_is_deterministic_and_valid(): | |
| img = (np.random.default_rng(1).random((16, 16, 3)) * 255).astype(np.uint8) | |
| a = ev.photometric(img, 5) | |
| b = ev.photometric(img, 5) | |
| assert np.array_equal(a, b) and a.dtype == np.uint8 and a.shape == img.shape | |
| assert not np.array_equal(ev.photometric(img, 6), a) | |