From bf7840febd146d8570106bce4f1a3026bd83d896 Mon Sep 17 00:00:00 2001
From: ManifoldFR <wilson.jallet@polytechnique.org>
Date: Tue, 29 Nov 2022 18:31:56 +0100
Subject: [PATCH] unittest/eigen_ref: rename asRef overload to "getRefToStatic"

& update its docstring
---
 unittest/eigen_ref.cpp            | 9 ++++-----
 unittest/python/test_eigen_ref.py | 5 +++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/unittest/eigen_ref.cpp b/unittest/eigen_ref.cpp
index 2813e00b..66249edb 100644
--- a/unittest/eigen_ref.cpp
+++ b/unittest/eigen_ref.cpp
@@ -58,8 +58,9 @@ void fill(Eigen::Ref<MatType> mat, const typename MatType::Scalar& value) {
   mat.fill(value);
 }
 
+/// Get ref to a static matrix of size ( @p rows, @p cols )
 template <typename MatType>
-Eigen::Ref<MatType> asRef(const int rows, const int cols) {
+Eigen::Ref<MatType> getRefToStatic(const int rows, const int cols) {
   static MatType mat(rows, cols);
   std::cout << "create ref to matrix of size (" << rows << "," << cols << ")\n";
   return mat;
@@ -113,10 +114,8 @@ BOOST_PYTHON_MODULE(eigen_ref) {
   bp::def("fillVec", fill<VectorXd>);
   bp::def("fill", fill<MatrixXd>);
 
-  bp::def<Eigen::Ref<MatrixXd> (*)(const int, const int)>("asRef",
-                                                          asRef<MatrixXd>);
-  bp::def<Eigen::Ref<MatrixXd> (*)(Eigen::Ref<MatrixXd>)>("asRef",
-                                                          asRef<MatrixXd>);
+  bp::def("getRefToStatic", getRefToStatic<MatrixXd>);
+  bp::def("asRef", asRef<MatrixXd>);
   bp::def("asConstRef", asConstRef<MatrixXd>);
 
   bp::def("getBlock", &getBlock<MatrixXd>);
diff --git a/unittest/python/test_eigen_ref.py b/unittest/python/test_eigen_ref.py
index 0ed65834..fe43e501 100644
--- a/unittest/python/test_eigen_ref.py
+++ b/unittest/python/test_eigen_ref.py
@@ -1,6 +1,7 @@
 import numpy as np
 from eigen_ref import (
     printMatrix,
+    getRefToStatic,
     asRef,
     asConstRef,
     fill,
@@ -30,11 +31,11 @@ def test_create_ref_to_static(mat):
     # create ref to static:
     print()
     print("[asRef(int, int)]")
-    A_ref = asRef(mat.shape[0], mat.shape[1])
+    A_ref = getRefToStatic(mat.shape[0], mat.shape[1])
     A_ref.fill(1.0)
     A_ref[0, 1] = -1.0
     print("make second reference:")
-    A_ref2 = asRef(mat.shape[0], mat.shape[1])
+    A_ref2 = getRefToStatic(mat.shape[0], mat.shape[1])
     print(A_ref2)
 
     assert np.array_equal(A_ref, A_ref2)
-- 
GitLab