File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1527,15 +1527,21 @@ def have_units(self):
15271527 def convert_units (self , x ):
15281528 # If x is already a number
15291529 if munits .ConversionInterface .is_numlike (x ):
1530+ if np .iterable (x ):
1531+ is_decimal = False
1532+ # use iterator to avoid key error
1533+ for thisx in x :
1534+ is_decimal = isinstance (thisx , Decimal )
1535+ if is_decimal :
1536+ converter = np .asarray
1537+ if isinstance (x , ma .MaskedArray ):
1538+ converter = ma .asarray
1539+ return converter (x , dtype = np .float )
1540+ else :
1541+ return x
15301542 # need to convert when x is a Decimal
1531- if isinstance (x , Decimal ):
1543+ elif isinstance (x , Decimal ):
15321544 return np .float (x )
1533- # need to convert when x is a list of Decimal
1534- elif np .iterable (x ) and len (x ) > 0 and isinstance (x [0 ], Decimal ):
1535- converter = np .asarray
1536- if isinstance (x , ma .MaskedArray ):
1537- converter = ma .asarray
1538- return converter (x , dtype = np .float )
15391545 # Otherwise, doesn't need converting
15401546 else :
15411547 return x
You can’t perform that action at this time.
0 commit comments