Skip to content

Commit

Permalink
fix C++ compilation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
SamFlt committed Nov 28, 2023
1 parent 327ed0a commit da8f55a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 8 additions & 8 deletions modules/python/bindings/include/core/arrays.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void define_get_item_2d_array(PyClass &pyClass)
{
pyClass.def("__getitem__", [](const Class &self, std::pair<int, int> 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 })
Expand All @@ -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<Item> {
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 })
Expand Down Expand Up @@ -157,7 +157,7 @@ void bindings_vpArray2D(py::class_<vpArray2D<T>> &pyArray2D)
vpArray2D<T> 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.
Expand All @@ -181,7 +181,7 @@ void bindings_vpMatrix(py::class_<vpMatrix, vpArray2D<double>> &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.
Expand All @@ -205,7 +205,7 @@ void bindings_vpColVector(py::class_<vpColVector, vpArray2D<double>> &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.
Expand All @@ -225,7 +225,7 @@ void bindings_vpRowVector(py::class_<vpRowVector, vpArray2D<double>> &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.
Expand All @@ -249,7 +249,7 @@ void bindings_vpRotationMatrix(py::class_<vpRotationMatrix, vpArray2D<double>> &
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.
Expand All @@ -276,7 +276,7 @@ void bindings_vpHomogeneousMatrix(py::class_<vpHomogeneousMatrix, vpArray2D<doub
throw std::runtime_error("Input numpy array is not a valid homogeneous matrix");
}
return result;
}), R"doc(
}), R"doc(
Construct a homogeneous matrix by **copying** a 2D numpy array.
This numpy array should be of dimensions :math:`4 \times 4` and be a valid homogeneous matrix.
If it is not a homogeneous matrix, an exception will be raised.
Expand Down
2 changes: 2 additions & 0 deletions modules/python/generator/visp_python_bindgen/doc_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def get_xml_path_if_exists(name: str, kind: DocumentationObjectKind) -> 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"'''
Expand Down

0 comments on commit da8f55a

Please sign in to comment.