Skip to content

Commit

Permalink
[util] Account for scalar results
Browse files Browse the repository at this point in the history
  • Loading branch information
Viviane Potocnik committed Jun 19, 2024
1 parent da74393 commit 0bbe21d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions util/sim/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ def flatten(array):
return array.numpy().flatten()
elif isinstance(array, list):
return np.array(array).flatten()
# if scalar return it as a list
elif isinstance(array, np.generic):
return np.array([array]).flatten()
else:
raise TypeError(f"Unsupported type: {type(array)}")


def _variable_attributes(alignment=None, section=None):
Expand Down

0 comments on commit 0bbe21d

Please sign in to comment.