From 5a104feb922cb2617891042446462c9c8cbfc52c Mon Sep 17 00:00:00 2001
From: cmoineau <cyril.moineau@cea.fr>
Date: Fri, 22 Sep 2023 15:27:43 +0000
Subject: [PATCH] [approxEq] relactive and absolute T -> float.

---
 include/aidge/utils/TensorUtils.hpp         | 6 +++---
 python_binding/utils/pybind_TensorUtils.cpp | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/aidge/utils/TensorUtils.hpp b/include/aidge/utils/TensorUtils.hpp
index 7a4dfc56b..ef8883fe4 100644
--- a/include/aidge/utils/TensorUtils.hpp
+++ b/include/aidge/utils/TensorUtils.hpp
@@ -11,7 +11,7 @@
 
 #ifndef AIDGE_CORE_UTILS_TENSOR_UTILS_H_
 #define AIDGE_CORE_UTILS_TENSOR_UTILS_H_
-
+#include <cmath>  // std::abs
 #include "aidge/data/Tensor.hpp"
 
 /**
@@ -32,14 +32,14 @@
  * @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, T relative, T absolute){
+bool approxEq(Aidge::Tensor t1, Aidge::Tensor t2, float relative, float absolute){
     assert(t1.dataType() == t2.dataType());
     assert(t1.dataType() == NativeType<T>::type);
     if (t1.size() != t2.size()){
         return false;
     }
     for(size_t i; i < t1.size(); ++i){
-        if (abs(t1.get<T>(i) - t2.get<T>(i)) > (absolute + (relative * abs(t2.get<T>(i))))){
+        if (static_cast<float>(std::abs(t1.get<T>(i) - t2.get<T>(i))) > (absolute + (relative * static_cast<float>(std::abs(t2.get<T>(i)))))){
             return false;
         }
     }
diff --git a/python_binding/utils/pybind_TensorUtils.cpp b/python_binding/utils/pybind_TensorUtils.cpp
index 089e8a211..07dc7e932 100644
--- a/python_binding/utils/pybind_TensorUtils.cpp
+++ b/python_binding/utils/pybind_TensorUtils.cpp
@@ -42,9 +42,9 @@ void addTensorUtilsFunction(py::module &m){
         :param t2: second tensor to test
         :type t2: :py:class:`aidge_core.Tensor`
         :param relative: relative difference allowed
-        :type relative: compatible datatype with compared :py:class:`aidge_core.Tensor`
+        :type relative: float
         :param absolute: absolute error allowed
-        :type absolute: compatible datatype with compared :py:class:`aidge_core.Tensor`
+        :type absolute: float
         )mydelimiter");
 }
 
-- 
GitLab