File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 99import numpy as np
1010from mendeleev import element
1111import PIL .Image
12- from pint import UnitRegistry
12+ from pint import Unit , UnitRegistry
1313from .encode import JsonEncoder
1414
1515
@@ -40,10 +40,13 @@ def __init__(self, **kwargs):
4040 if hasattr (self , 'units' ):
4141 units = kwargs .get ('units' )
4242 if units :
43- try :
44- self ['units' ] = ureg .parse_units (units )
45- except :
46- raise ValueError ('Unrecognized units: %s' % (units ))
43+ if isinstance (units ,Unit ):
44+ self ['units' ] = units
45+ else :
46+ try :
47+ self ['units' ] = ureg .parse_units (units )
48+ except :
49+ raise ValueError ('Unrecognized units: %s' % (units ))
4750 if hasattr (self , 'min' ):
4851 self ['min' ] = self ._getNumericValueFromQuantity (kwargs .get ('min' ),checkMinMax = False )
4952 if hasattr (self , 'max' ):
You can’t perform that action at this time.
0 commit comments