Skip to content

Commit

Permalink
Catch warnings, and add data to avoid them. (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
delucchi-cmu authored Feb 21, 2024
1 parent 1227138 commit ce29177
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
2 changes: 2 additions & 0 deletions tests/data/small_sky_to_xmatch/partition_info.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Norder,Npix,Dir
0,11,0
4 changes: 4 additions & 0 deletions tests/data/small_sky_to_xmatch/partition_join_info.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Norder,Npix,join_Norder,join_Npix
0,11,1,44
0,11,1,45
0,11,1,46
8 changes: 4 additions & 4 deletions tests/data/small_sky_xmatch/partition_info.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Norder,Dir,Npix,num_rows
1,0,44,41
1,0,45,29
1,0,46,41
Norder,Npix,Dir
1,44,0
1,45,0
1,46,0
6 changes: 6 additions & 0 deletions tests/data/small_sky_xmatch_margin/partition_info.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Norder,Npix,Dir
0,4,0
1,44,0
1,45,0
1,46,0
1,47,0
28 changes: 16 additions & 12 deletions tests/lsdb/catalog/test_crossmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
class TestCrossmatch:
@staticmethod
def test_kdtree_crossmatch(algo, small_sky_catalog, small_sky_xmatch_catalog, xmatch_correct):
xmatched = small_sky_catalog.crossmatch(
small_sky_xmatch_catalog, algorithm=algo, radius_arcsec=0.01 * 3600
).compute()
with pytest.warns(RuntimeWarning, match="Results may be inaccurate"):
xmatched = small_sky_catalog.crossmatch(
small_sky_xmatch_catalog, algorithm=algo, radius_arcsec=0.01 * 3600
).compute()
assert len(xmatched) == len(xmatch_correct)
for _, correct_row in xmatch_correct.iterrows():
assert correct_row["ss_id"] in xmatched["id_small_sky"].values
Expand All @@ -24,9 +25,10 @@ def test_kdtree_crossmatch(algo, small_sky_catalog, small_sky_xmatch_catalog, xm

@staticmethod
def test_kdtree_crossmatch_thresh(algo, small_sky_catalog, small_sky_xmatch_catalog, xmatch_correct_005):
xmatched = small_sky_catalog.crossmatch(
small_sky_xmatch_catalog, radius_arcsec=0.005 * 3600, algorithm=algo
).compute()
with pytest.warns(RuntimeWarning, match="Results may be inaccurate"):
xmatched = small_sky_catalog.crossmatch(
small_sky_xmatch_catalog, radius_arcsec=0.005 * 3600, algorithm=algo
).compute()
assert len(xmatched) == len(xmatch_correct_005)
for _, correct_row in xmatch_correct_005.iterrows():
assert correct_row["ss_id"] in xmatched["id_small_sky"].values
Expand All @@ -38,9 +40,10 @@ def test_kdtree_crossmatch_thresh(algo, small_sky_catalog, small_sky_xmatch_cata
def test_kdtree_crossmatch_multiple_neighbors(
algo, small_sky_catalog, small_sky_xmatch_catalog, xmatch_correct_3n_2t_no_margin
):
xmatched = small_sky_catalog.crossmatch(
small_sky_xmatch_catalog, n_neighbors=3, radius_arcsec=2 * 3600, algorithm=algo
).compute()
with pytest.warns(RuntimeWarning, match="Results may be inaccurate"):
xmatched = small_sky_catalog.crossmatch(
small_sky_xmatch_catalog, n_neighbors=3, radius_arcsec=2 * 3600, algorithm=algo
).compute()
assert len(xmatched) == len(xmatch_correct_3n_2t_no_margin)
for _, correct_row in xmatch_correct_3n_2t_no_margin.iterrows():
assert correct_row["ss_id"] in xmatched["id_small_sky"].values
Expand Down Expand Up @@ -102,9 +105,10 @@ def test_wrong_suffixes(algo, small_sky_catalog, small_sky_xmatch_catalog):


def test_custom_crossmatch_algorithm(small_sky_catalog, small_sky_xmatch_catalog, xmatch_mock):
xmatched = small_sky_catalog.crossmatch(
small_sky_xmatch_catalog, algorithm=MockCrossmatchAlgorithm, mock_results=xmatch_mock
).compute()
with pytest.warns(RuntimeWarning, match="Results may be inaccurate"):
xmatched = small_sky_catalog.crossmatch(
small_sky_xmatch_catalog, algorithm=MockCrossmatchAlgorithm, mock_results=xmatch_mock
).compute()
assert len(xmatched) == len(xmatch_mock)
for _, correct_row in xmatch_mock.iterrows():
assert correct_row["ss_id"] in xmatched["id_small_sky"].values
Expand Down

0 comments on commit ce29177

Please sign in to comment.