-
-
Notifications
You must be signed in to change notification settings - Fork 409
Closed
Description
When appending a state to a SolutionArray, an item of length greater than 1 can be passed for any extra items. This raises a DeprecationWarning from NumPy, and gives a... less than useful result:
>>> gas = ct.Solution("air.yaml")
>>> states = ct.SolutionArray(gas, 3, extra={"prop": [5, 6, 7]}
>>> states.append(TPX=(1100, 3e5, "AR:1.0"), prop=[1, 2, 3])
>>> states.prop
/Users/bryan/GitHub/cantera/build/python/cantera/composite.py:576: VisibleDeprecationWarning:
Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays
with different lengths or shapes) is deprecated. If you meant to do this, you must specify
'dtype=object' when creating the ndarray
return np.array(self._extra[name])
array([5, 6, 7, list([1, 2, 3])], dtype=object)Yes, that's a list as an item in a NumPy array.
Fixing this is not super straightforward, because we may need to also account for the possibility of strings as values, so a simple if len(item) > 1 check is not sufficient, see #896.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels