From da8f55ad9fe7ff1fc7d19cacec5cc6ec9c0fe2c2 Mon Sep 17 00:00:00 2001 From: Samuel Felton Date: Tue, 28 Nov 2023 18:06:44 +0100 Subject: [PATCH] fix C++ compilation warnings --- modules/python/bindings/include/core/arrays.hpp | 16 ++++++++-------- .../generator/visp_python_bindgen/doc_parser.py | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/python/bindings/include/core/arrays.hpp b/modules/python/bindings/include/core/arrays.hpp index e54be92cd8..4e776ceff5 100644 --- a/modules/python/bindings/include/core/arrays.hpp +++ b/modules/python/bindings/include/core/arrays.hpp @@ -95,7 +95,7 @@ void define_get_item_2d_array(PyClass &pyClass) { pyClass.def("__getitem__", [](const Class &self, std::pair pair) -> Item { int i = pair.first, j = pair.second; - const unsigned int rows = self.getRows(), cols = self.getCols(); + const int rows = (int)self.getRows(), cols = (int)self.getCols(); if (abs(i) > rows || abs(j) > cols) { std::stringstream ss; ss << "Invalid indexing into a 2D array: got indices " << shape_to_string({ i, j }) @@ -111,7 +111,7 @@ void define_get_item_2d_array(PyClass &pyClass) return self[i][j]; }); pyClass.def("__getitem__", [](const Class &self, int i) -> np_array_cf { - const unsigned int rows = self.getRows(); + const int rows = (int)self.getRows(); if (abs(i) > rows) { std::stringstream ss; ss << "Invalid indexing into a 2D array: got row index " << shape_to_string({ i }) @@ -157,7 +157,7 @@ void bindings_vpArray2D(py::class_> &pyArray2D) vpArray2D result(shape[0], shape[1]); copy_data_from_np(np_array, result.data); return result; - }), R"doc( + }), R"doc( Construct a 2D ViSP array by **copying** a 2D numpy array. :param np_array: The numpy array to copy. @@ -181,7 +181,7 @@ void bindings_vpMatrix(py::class_> &pyMatrix) vpMatrix result(shape[0], shape[1]); copy_data_from_np(np_array, result.data); return result; - }), R"doc( + }), R"doc( Construct a matrix by **copying** a 2D numpy array. :param np_array: The numpy array to copy. @@ -205,7 +205,7 @@ void bindings_vpColVector(py::class_> &pyColVecto vpColVector result(shape[0]); copy_data_from_np(np_array, result.data); return result; - }), R"doc( + }), R"doc( Construct a column vector by **copying** a 1D numpy array. :param np_array: The numpy 1D array to copy. @@ -225,7 +225,7 @@ void bindings_vpRowVector(py::class_> &pyRowVecto vpRowVector result(shape[0]); copy_data_from_np(np_array, result.data); return result; - }), R"doc( + }), R"doc( Construct a row vector by **copying** a 1D numpy array. :param np_array: The numpy 1D array to copy. @@ -249,7 +249,7 @@ void bindings_vpRotationMatrix(py::class_> & throw std::runtime_error("Input numpy array is not a valid rotation matrix"); } return result; - }), R"doc( + }), R"doc( Construct a rotation matrix by **copying** a 2D numpy array. This numpy array should be of dimensions :math:`3 \times 3` and be a valid rotation matrix. If it is not a rotation matrix, an exception will be raised. @@ -276,7 +276,7 @@ void bindings_vpHomogeneousMatrix(py::class_ Optional def to_cstring(s: str) -> str: s = s.replace('\t', ' ') s = re.sub('\n\n\n+', '\n\n', s) + s = re.sub('\\\\ +', '\\\\', s) + return f'''R"doc( {s} )doc"'''