Skip to content
Snippets Groups Projects
Commit e4ac79c9 authored by Martin Lange's avatar Martin Lange
Browse files

convert units in to_units only if required - units noop 400ms -> 16ms

parent 4feb52c7
No related branches found
No related tags found
1 merge request!222Xarray optimizations
......@@ -407,7 +407,10 @@ def to_units(xdata, units):
Converted data.
"""
check_quantified(xdata, "to_units")
return xdata.pint.to(pint.Unit(units))
units = UNITS.Unit(units)
if units == xdata.pint.units:
return xdata
return xdata.pint.to(units)
def full_like(xdata, value):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment