Skip to content

Commit

Permalink
more robust handling that still accepts unitless empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Jun 27, 2024
1 parent 96dd39c commit 9a405ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
------------------
Expand Down
12 changes: 9 additions & 3 deletions lcviz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,18 @@ def to_object(self, data_or_subset):
continue
component = data.get_component(component_id)

values = component.data[glue_mask]
values = np.asarray(component.data[glue_mask])

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)
Expand Down

0 comments on commit 9a405ce

Please sign in to comment.