77from collections .abc import Iterable , Mapping
88from enum import Enum , IntEnum , IntFlag
99
10- import pint
11-
1210from openff .evaluator import unit
1311from openff .evaluator .attributes .typing import is_instance_of_type , is_supported_type
1412from openff .evaluator .utils .serialization import TypedBaseModel
@@ -94,7 +92,7 @@ def validate(self, attribute_type=None):
9492 )
9593
9694 elif isinstance (attribute_value , Iterable ) and not isinstance (
97- attribute_value , pint .Quantity
95+ attribute_value , ( unit .Quantity , unit . Measurement )
9896 ):
9997
10098 iterable_values = (
@@ -188,8 +186,6 @@ def __getstate__(self):
188186
189187 def __setstate__ (self , state ):
190188
191- import pint
192-
193189 attribute_names = self .get_attributes ()
194190
195191 for name in attribute_names :
@@ -205,22 +201,6 @@ def __setstate__(self, state):
205201 elif attribute .optional and name not in state :
206202 state [name ] = UNDEFINED
207203
208- if isinstance (state [name ], pint .Measurement ) and not isinstance (
209- state [name ], unit .Measurement
210- ):
211-
212- state [name ] = unit .Measurement .__new__ (
213- unit .Measurement , state [name ].value , state [name ].error
214- )
215-
216- elif isinstance (state [name ], pint .Quantity ) and not isinstance (
217- state [name ], unit .Quantity
218- ):
219-
220- state [name ] = unit .Quantity .__new__ (
221- unit .Quantity , state [name ].magnitude , state [name ].units
222- )
223-
224204 self ._set_value (name , state [name ])
225205
226206
@@ -276,14 +256,7 @@ def __init__(
276256 )
277257
278258 if hasattr (type_hint , "__qualname__" ):
279-
280- if type_hint .__qualname__ == "build_quantity_class.<locals>.Quantity" :
281- docstring = f"Quantity: { docstring } "
282- elif type_hint .__qualname__ == "build_quantity_class.<locals>.Unit" :
283- docstring = f"Unit: { docstring } "
284- else :
285- docstring = f"{ type_hint .__qualname__ } : { docstring } "
286-
259+ docstring = f"{ type_hint .__qualname__ } : { docstring } "
287260 elif hasattr (type_hint , "__name__" ):
288261 docstring = f"{ type_hint .__name__ } : { docstring } "
289262 else :
@@ -293,7 +266,7 @@ def __init__(
293266 self ._default_value = default_value
294267
295268 if isinstance (
296- default_value , (int , float , str , pint .Quantity , pint .Measurement , Enum )
269+ default_value , (int , float , str , unit .Quantity , unit .Measurement , Enum )
297270 ) or (
298271 isinstance (default_value , (list , tuple , set , frozenset ))
299272 and len (default_value ) <= 4
0 commit comments