From c049a5de78e2914b85abb9cdc9afa438200cabd9 Mon Sep 17 00:00:00 2001 From: Javier Gonzalez Date: Fri, 8 Jul 2022 15:08:22 -0400 Subject: [PATCH 1/2] bugfix: in the vectorized get_dark_cal_id, if result is a scalar, convert to underlying type --- mica/archive/aca_dark/dark_cal.py | 6 +++++- mica/archive/tests/test_aca_dark_cal.py | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mica/archive/aca_dark/dark_cal.py b/mica/archive/aca_dark/dark_cal.py index 90c9f613..3f9f49e0 100644 --- a/mica/archive/aca_dark/dark_cal.py +++ b/mica/archive/aca_dark/dark_cal.py @@ -104,7 +104,11 @@ def get_dark_cal_id(date, select='before'): :returns: dark cal id string (YYYYDOY) """ - return _get_dark_cal_id_vector(date, select=select) + dark_id = _get_dark_cal_id_vector(date, select=select) + if not dark_id.shape: + # returning an instance of the type, not a numpy array + return dark_id.dtype.type(dark_id) + return dark_id def _get_dark_cal_id_scalar(date, select='before'): diff --git a/mica/archive/tests/test_aca_dark_cal.py b/mica/archive/tests/test_aca_dark_cal.py index 479d3e31..c2e70048 100644 --- a/mica/archive/tests/test_aca_dark_cal.py +++ b/mica/archive/tests/test_aca_dark_cal.py @@ -109,6 +109,12 @@ def test_get_dark_cal_props_table_mixed(): 'n_ccd_img', 'datestart', 'datestop', 'filename'] +@pytest.mark.skipif('not HAS_DARK_ARCHIVE', reason='Test requires dark archive') +def test_scalar(): + dark_cal_id = dark_cal.get_dark_cal_id('2022:100') + assert dark_cal_id[:4] == '2022' and dark_cal_id[4:] == '069' + + @pytest.mark.skipif('not HAS_DARK_ARCHIVE', reason='Test requires dark archive') def test_vectorized(): dark_id_ref = ['2022100', '2022105', '2022127'] From 5898e420f3e1893ef47854db3422e21dcbbc9d80 Mon Sep 17 00:00:00 2001 From: Javier Gonzalez Date: Fri, 8 Jul 2022 16:02:22 -0400 Subject: [PATCH 2/2] fixup --- mica/archive/aca_dark/dark_cal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mica/archive/aca_dark/dark_cal.py b/mica/archive/aca_dark/dark_cal.py index 3f9f49e0..bcc3ed7d 100644 --- a/mica/archive/aca_dark/dark_cal.py +++ b/mica/archive/aca_dark/dark_cal.py @@ -107,7 +107,7 @@ def get_dark_cal_id(date, select='before'): dark_id = _get_dark_cal_id_vector(date, select=select) if not dark_id.shape: # returning an instance of the type, not a numpy array - return dark_id.dtype.type(dark_id) + return dark_id.tolist() return dark_id