7
7
from collections .abc import Iterable , Mapping
8
8
from enum import Enum , IntEnum , IntFlag
9
9
10
- import pint
11
-
12
10
from openff .evaluator import unit
13
11
from openff .evaluator .attributes .typing import is_instance_of_type , is_supported_type
14
12
from openff .evaluator .utils .serialization import TypedBaseModel
@@ -94,7 +92,7 @@ def validate(self, attribute_type=None):
94
92
)
95
93
96
94
elif isinstance (attribute_value , Iterable ) and not isinstance (
97
- attribute_value , pint .Quantity
95
+ attribute_value , ( unit .Quantity , unit . Measurement )
98
96
):
99
97
100
98
iterable_values = (
@@ -188,8 +186,6 @@ def __getstate__(self):
188
186
189
187
def __setstate__ (self , state ):
190
188
191
- import pint
192
-
193
189
attribute_names = self .get_attributes ()
194
190
195
191
for name in attribute_names :
@@ -205,22 +201,6 @@ def __setstate__(self, state):
205
201
elif attribute .optional and name not in state :
206
202
state [name ] = UNDEFINED
207
203
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
-
224
204
self ._set_value (name , state [name ])
225
205
226
206
@@ -276,14 +256,7 @@ def __init__(
276
256
)
277
257
278
258
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 } "
287
260
elif hasattr (type_hint , "__name__" ):
288
261
docstring = f"{ type_hint .__name__ } : { docstring } "
289
262
else :
@@ -293,7 +266,7 @@ def __init__(
293
266
self ._default_value = default_value
294
267
295
268
if isinstance (
296
- default_value , (int , float , str , pint .Quantity , pint .Measurement , Enum )
269
+ default_value , (int , float , str , unit .Quantity , unit .Measurement , Enum )
297
270
) or (
298
271
isinstance (default_value , (list , tuple , set , frozenset ))
299
272
and len (default_value ) <= 4
0 commit comments