vivarium-collective / vivarium-core

Core Interface and Engine for Vivarium
https://vivarium-core.readthedocs.io/
Apache License 2.0
25 stars 2 forks source link

Schema validation fails with Numpy arrays #228

Closed thalassemia closed 1 year ago

thalassemia commented 1 year ago

The equality comparisons here and here throw the following error when any values are Numpy arrays:

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

For example, this occurs when the new and current schemas are {'_divider': {'divider': 'set_value', 'config': {'value': np.zeros(10)}}}. The above Exception is raised due to the np.zeros(10) buried deep within the _divider schema. A custom recursive function is needed to check all schema values for embedded Numpy arrays and compare them separately using np.array_equal.