Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions tests/test_clustering.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python3

import pytest
from astropy import units as u


@pytest.mark.skip(reason="clustering_targets is not part of targetdb")
def test_run_clustering():
ra = [0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5]
dec = [0.0, 0.0, 30.0, 30.0, 60.0, 60.0, 85.0, 85.0]

threshs = [
0.51 * u.degree,
0.49 * u.degree,
0.26 * u.degree,
0.24 * u.degree,
0.04 * u.degree,
]

expected_n_clusters = [4, 5, 6, 7, 8]
# expected_n_noises = [0, 0, 0, 0, 0]

returned_n_clusters = []
# returned_n_noises = []

for th in threshs:
labels = clustering_targets.run_clustering(ra, dec, distance_threshold=th) # noqa: F821
print(f"{labels=}")
n_clusters_ = len(set(labels)) - (1 if -1 in labels else 0)
# n_noise_ = list(labels).count(-1)

returned_n_clusters.append(n_clusters_)
# returned_n_noises.append(n_noise_)

assert returned_n_clusters == expected_n_clusters

Check warning on line 35 in tests/test_clustering.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

tests/test_clustering.py#L35

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
# assert returned_n_noises == expected_n_noises


if __name__ == "__main__":
test_run_clustering()
Loading