Commit eb78e381 authored by René Fritze's avatar René Fritze Committed by René Fritze

[tools] adds util function to find 0 vecs in arrays

parent ba84cd00
......@@ -64,3 +64,24 @@ def bounded(lower, upper, x, rtol=None, atol=None):
absolute tolerance for float_cmp
return (lower < x < upper) or float_cmp(x, lower, rtol, atol) or float_cmp(x, upper, rtol, atol)
def contains_zero_vector(vector_array, rtol=None, atol=None):
"""returns `True` iff any vector in the array float_compares to 0s of the same dim
a |VectorArray| implementation
relative tolerance for float_cmp
absolute tolerance for float_cmp
zero = np.zeros(vector_array.dim)
for i in range(len(vector_array)):
vec = vector_array[i].to_numpy()
if float_cmp_all(vec, zero, rtol, atol):
return True
return False
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment