From 3d58f5fba20519bfe7aeccd765caf0b166f63aab Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Wed, 26 Jun 2024 14:04:55 -0400 Subject: [PATCH 1/3] fix units with empty strings affects CDIPS HLSP light curves --- lcviz/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lcviz/utils.py b/lcviz/utils.py index 549b6b3..afdcab7 100644 --- a/lcviz/utils.py +++ b/lcviz/utils.py @@ -281,7 +281,7 @@ def to_object(self, data_or_subset): if len(values) and isinstance(values[0], Time): values = Time(values.base) - elif hasattr(component, 'units') and component.units != "None": + elif hasattr(component, 'units') and component.units not in ("None", ""): values = u.Quantity(values, component.units) if component_id.label not in names: From 96dd39c02979754c5fa0c44c8633cc8b1927a6c3 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Wed, 26 Jun 2024 14:06:36 -0400 Subject: [PATCH 2/3] changelog entry --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index db14cb2..7a52bd3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,8 @@ 0.4.1 (unreleased) ------------------ +* Fixes CDIPS support by handling units stored as empty strings. [#122] + 0.4.0 (06-11-2024) ------------------ From b547ad60b61652ee0ce0bb61920670f504b67f77 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Thu, 27 Jun 2024 09:09:04 -0400 Subject: [PATCH 3/3] more robust handling that still accepts unitless empty string --- CHANGES.rst | 2 +- lcviz/utils.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 7a52bd3..546fd83 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,7 +6,7 @@ 0.4.1 (unreleased) ------------------ -* Fixes CDIPS support by handling units stored as empty strings. [#122] +* Fixes CDIPS support by handling columns filled with strings with empty units. [#122] 0.4.0 (06-11-2024) ------------------ diff --git a/lcviz/utils.py b/lcviz/utils.py index afdcab7..27245da 100644 --- a/lcviz/utils.py +++ b/lcviz/utils.py @@ -281,8 +281,14 @@ def to_object(self, data_or_subset): if len(values) and isinstance(values[0], Time): values = Time(values.base) - elif hasattr(component, 'units') and component.units not in ("None", ""): - values = u.Quantity(values, component.units) + elif hasattr(component, 'units') and component.units != "None": + try: + values = u.Quantity(values, component.units) + except TypeError: + if component.units != "": + raise + # values could have been an array of strings with units "" + values = values if component_id.label not in names: columns.append(values)