From 22629cb62810d28a31804260edddfd19a7de8f1c Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Sun, 10 Dec 2023 09:49:00 -0500 Subject: [PATCH 1/2] Allow None input to convert_time_format_spk --- chandra_aca/planets.py | 2 +- chandra_aca/tests/test_planets.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/chandra_aca/planets.py b/chandra_aca/planets.py index 0b8464eb..e2c4d979 100644 --- a/chandra_aca/planets.py +++ b/chandra_aca/planets.py @@ -134,7 +134,7 @@ def convert_time_format_spk(time, fmt_out): ndarray or numpy scalar Converted time or times """ - if fmt_out not in ("jd", "secs"): + if fmt_out not in ("jd", "secs") or time is None: return getattr(CxoTime(time).tdb, fmt_out) # Check if input is in "secs" by determining if it is a float type scalar or array diff --git a/chandra_aca/tests/test_planets.py b/chandra_aca/tests/test_planets.py index 8bce167d..9b159ea3 100644 --- a/chandra_aca/tests/test_planets.py +++ b/chandra_aca/tests/test_planets.py @@ -9,6 +9,7 @@ from testr.test_helper import has_internet from chandra_aca.planets import ( + convert_time_format_spk, get_planet_angular_sep, get_planet_barycentric, get_planet_chandra, @@ -194,3 +195,11 @@ def test_get_planet_ang_separation_array(obs_pos, exp_sep): ra0, dec0 = 304.89116, -20.08328 sep = get_planet_angular_sep("jupiter", ra0, dec0, times, observer_position=obs_pos) assert np.allclose(sep * 3600, exp_sep, atol=1e-2, rtol=0) + + +def test_convert_time_format_spk_none(): + """Test bug fix where convert_time_format_spk failed when time was None""" + time0 = convert_time_format_spk(None, "secs") + time1 = CxoTime(None).secs + # Times within 10 seconds + assert np.isclose(time0, time1, atol=10, rtol=0) \ No newline at end of file From c0417104afc14126419124e0f5d78a1dfafcd2f5 Mon Sep 17 00:00:00 2001 From: Jean Connelly Date: Sun, 10 Dec 2023 21:31:11 -0500 Subject: [PATCH 2/2] Add missing newline --- chandra_aca/tests/test_planets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chandra_aca/tests/test_planets.py b/chandra_aca/tests/test_planets.py index 9b159ea3..d568c3a3 100644 --- a/chandra_aca/tests/test_planets.py +++ b/chandra_aca/tests/test_planets.py @@ -202,4 +202,4 @@ def test_convert_time_format_spk_none(): time0 = convert_time_format_spk(None, "secs") time1 = CxoTime(None).secs # Times within 10 seconds - assert np.isclose(time0, time1, atol=10, rtol=0) \ No newline at end of file + assert np.isclose(time0, time1, atol=10, rtol=0)