diff --git a/include/aidge/utils/TensorUtils.hpp b/include/aidge/utils/TensorUtils.hpp index ef8883fe4255c12368839d4d519226f3bde85429..6387619546c66922e48cf95a8a56487d4b0d0641 100644 --- a/include/aidge/utils/TensorUtils.hpp +++ b/include/aidge/utils/TensorUtils.hpp @@ -27,14 +27,17 @@ * @tparam T should correspond to the type of the tensor, define the type of the absolute and relative error * @param t1 first :cpp:class:`Aidge::Tensor` to test * @param t2 second :cpp:class:`Aidge::Tensor` to test - * @param relative relative difference allowed - * @param absolute absolute error allowed + * @param relative relative difference allowed (should be betwen 0 and 1) + * @param absolute absolute error allowed (shoulmd be positive) * @return true if both tensor are approximately equal and have the datatype, shape. Else return false */ template <typename T> bool approxEq(Aidge::Tensor t1, Aidge::Tensor t2, float relative, float absolute){ assert(t1.dataType() == t2.dataType()); assert(t1.dataType() == NativeType<T>::type); + assert(relative >= 0); + assert(absolute >= 0 && absolute<=1); + if (t1.size() != t2.size()){ return false; } diff --git a/python_binding/utils/pybind_TensorUtils.cpp b/python_binding/utils/pybind_TensorUtils.cpp index 07dc7e9321e4588518ef92b17cf6e19059380254..78825a5f3b8d45f22f76c57bd780dc7019fbc123 100644 --- a/python_binding/utils/pybind_TensorUtils.cpp +++ b/python_binding/utils/pybind_TensorUtils.cpp @@ -41,9 +41,9 @@ void addTensorUtilsFunction(py::module &m){ :type t1: :py:class:`aidge_core.Tensor` :param t2: second tensor to test :type t2: :py:class:`aidge_core.Tensor` - :param relative: relative difference allowed + :param relative: relative difference allowed (should be betwen 0 and 1) :type relative: float - :param absolute: absolute error allowed + :param absolute: absolute error allowed (shoulmd be positive) :type absolute: float )mydelimiter"); }