Skip to content

Commit

Permalink
Clean up comments and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonbb committed Nov 12, 2024
1 parent ec65f66 commit 77aeeb3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 52 deletions.
2 changes: 2 additions & 0 deletions src/kbmod/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import logging as _logging
from logging import config as _config

from scipy.special import erfinv

# Import the rest of the package
from kbmod.search import Logging

Expand Down
3 changes: 1 addition & 2 deletions src/kbmod/filters/known_object_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from astropy.table import Table
from astropy.coordinates import search_around_sky, SkyCoord
# import astropy units
import astropy.units as u

from kbmod.trajectory_utils import trajectory_predict_skypos
Expand Down Expand Up @@ -216,4 +215,4 @@ def apply_known_obj_filters(result_data, known_objs, obstimes, wcs, filter_param
if remove_match_obs:
result_data.update_obs_valid(new_obs_valid)

return all_matches
return all_matches
58 changes: 8 additions & 50 deletions tests/test_known_object_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,8 @@ def setUp(self):
assert set(self.res.table.columns) == set(['x','y','vx','vy','likelihood','flux','obs_count', 'obs_valid'])

# Use the results' trajectories to generate a set of known objects that we can use to test the filter
# 1) a known object that is slightly different in time and space then in the trajcectory
# 2) a known object that is slightly different in time but not space
# 3) a known object that is slightly different in space but not time
# 4) a known object with a very different trajectory but interects both the start and endpoints
# Now we want to create a data set of known objects some
# of which will intersect or previous results,
# Now we want to create a data set of known objects that interset our generated results in various
# ways.
known_obj_table = Table({"Name": np.empty(0, dtype=str), "RA": [], "DEC": [], "mjd_mid": []})

# Case 1: Near in space (<1") and near in time (>1 s) and near in time to result 1
Expand Down Expand Up @@ -94,7 +90,7 @@ def setUp(self):
spatial_offset=5,
time_offset=0.00025)

# Case 5: A similar trajectory to result 7, but far off spatially and temporally
# Case 4: A similar trajectory to result 7, but far off spatially and temporally
self.generate_known_obj_from_result(
known_obj_table,
7, # Base off result 7
Expand All @@ -104,42 +100,18 @@ def setUp(self):
time_offset=0.3)


# Check for a trajectory matching result 8 but with only a few observations.
# Case 5: a trajectory matching result 8 but with only a few observations.
self.generate_known_obj_from_result(
known_obj_table,
8, # Base off result 8
self.obstimes[::10], # Samples down to every 5th observation
"sparse_8",
spatial_offset=0.0001,
time_offset=0.00025)
"""
curr_trj_skycoords = trajectory_predict_skypos(
self.res.make_trajectory_list()[8],
self.wcs,
self.obstimes, # Note that we use all obstimes and not just the valid ones for this result.
)
for i in range(len(self.obstimes)):
known_obj_table.add_row({
"Name": "sparse_8",
"RA": curr_trj_skycoords[i].ra.degree,
"DEC": curr_trj_skycoords[i].dec.degree,
"mjd_mid": self.obstimes[i],
})
"""

# Check that intersect 1 and intersect 2 both match to result 7, but only to one observation
# each


# Check for an object that is an exact spatial match but omitted is outside the larger time
# window we apply during the filtering steps.
# Check for the max time step separation




self.known_objs = KnownObjs(known_obj_table)
def test_known_obj_init(self):
# Test a table with no columns specified raises a ValueError

def test_known_obj_init(self): # Test a table with no columns specified raises a ValueError
with self.assertRaises(ValueError):
KnownObjs(Table())

Expand Down Expand Up @@ -180,11 +152,7 @@ def generate_known_obj_from_result(
spatial_offset=0.0001,
time_offset=0.00025,
):
""" Helper function to generate a known object based on existing result trajectory
Parameters
----------
"""
""" Helper function to generate a known object based on existing result trajectory """
trj_skycoords = trajectory_predict_skypos(
self.res.make_trajectory_list()[res_idx],
self.wcs,
Expand All @@ -198,12 +166,6 @@ def generate_known_obj_from_result(
"mjd_mid": obstimes[i] + time_offset,
})

def test_known_obj_filter_rows_by_time(self):
assert True

def test_known_obj_filter_wrapper(self):
assert True

def test_apply_known_obj_empty(self):
# Here we test that the filter across various empty parameters

Expand Down Expand Up @@ -368,7 +330,3 @@ def test_apply_known_obj_time_no_filtering(self):
np.count_nonzero(matches[i][obj_name])
)

def test_apply_known_obj_matching(self):
# Here we apply the filter successively without removing matching observations,
# then successively pare down observations more aggressively.
assert True

0 comments on commit 77aeeb3

Please sign in to comment.