Skip to content

Commit

Permalink
avoid error for incompat unit conversion request
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed May 24, 2024
1 parent 281f32b commit f977a48
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lcviz/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
@unit_converter('custom-lcviz')
class UnitConverter:
def equivalent_units(self, data, cid, units):
return set(list(map(str, u.Unit(units).find_equivalent_units(
include_prefix_units=True, equivalencies=u.spectral()))))
return set(list(map(str, u.Unit(units).find_equivalent_units(include_prefix_units=True))))

def to_unit(self, data, cid, values, original_units, target_units):
# for some reason, glue is trying to request a change for cid='flux' from d to electron / s
if target_units not in self.equivalent_units(data, cid, original_units):
return values
return (values * u.Unit(original_units)).to_value(u.Unit(target_units))


Expand Down

0 comments on commit f977a48

Please sign in to comment.