Skip to content

Commit 9a405ce

Browse files
committed
more robust handling that still accepts unitless empty string
1 parent 96dd39c commit 9a405ce

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGES.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
0.4.1 (unreleased)
77
------------------
88

9-
* Fixes CDIPS support by handling units stored as empty strings. [#122]
9+
* Fixes CDIPS support by handling columns filled with strings with empty units. [#122]
1010

1111
0.4.0 (06-11-2024)
1212
------------------

lcviz/utils.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,18 @@ def to_object(self, data_or_subset):
277277
continue
278278
component = data.get_component(component_id)
279279

280-
values = component.data[glue_mask]
280+
values = np.asarray(component.data[glue_mask])
281281

282282
if len(values) and isinstance(values[0], Time):
283283
values = Time(values.base)
284-
elif hasattr(component, 'units') and component.units not in ("None", ""):
285-
values = u.Quantity(values, component.units)
284+
elif hasattr(component, 'units') and component.units != "None":
285+
try:
286+
values = u.Quantity(values, component.units)
287+
except TypeError:
288+
if component.units != "":
289+
raise
290+
# values could have been an array of strings with units ""
291+
values = values
286292

287293
if component_id.label not in names:
288294
columns.append(values)

0 commit comments

Comments
 (0)