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 b547ad6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 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
10 changes: 8 additions & 2 deletions lcviz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 289 in lcviz/utils.py

View check run for this annotation

Codecov / codecov/patch

lcviz/utils.py#L287-L289

Added lines #L287 - L289 were not covered by tests
# values could have been an array of strings with units ""
values = values

Check warning on line 291 in lcviz/utils.py

View check run for this annotation

Codecov / codecov/patch

lcviz/utils.py#L291

Added line #L291 was not covered by tests

if component_id.label not in names:
columns.append(values)
Expand Down

0 comments on commit b547ad6

Please sign in to comment.