From 02a219973d61d4602317bae9e0bf24b8677b59d7 Mon Sep 17 00:00:00 2001
From: Justin Carpentier <justin.carpentier@inria.fr>
Date: Fri, 21 Apr 2023 20:31:47 +0200
Subject: [PATCH] all: remove useless and non tested files

---
 unittest/alpha/bnpy.cpp          |  35 ------
 unittest/alpha/eigen.cpp         |  91 ----------------
 unittest/alpha/eigenc.cpp        | 131 ----------------------
 unittest/alpha/eigentemplate.cpp | 181 -------------------------------
 unittest/alpha/mystring.cpp      |  70 ------------
 unittest/alpha/simple.cpp        |  24 ----
 6 files changed, 532 deletions(-)
 delete mode 100644 unittest/alpha/bnpy.cpp
 delete mode 100644 unittest/alpha/eigen.cpp
 delete mode 100644 unittest/alpha/eigenc.cpp
 delete mode 100644 unittest/alpha/eigentemplate.cpp
 delete mode 100644 unittest/alpha/mystring.cpp
 delete mode 100644 unittest/alpha/simple.cpp

diff --git a/unittest/alpha/bnpy.cpp b/unittest/alpha/bnpy.cpp
deleted file mode 100644
index 9f4e3ea9..00000000
--- a/unittest/alpha/bnpy.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Simple test using the boost::numpy interface: return an array and a matrix.
- */
-
-#include "boost/numpy.hpp"
-#include "eigenpy/fwd.hpp"
-
-namespace bp = boost::python;
-namespace bn = boost::numpy;
-
-/* Return an dim-1 array with 5 elements. */
-bn::ndarray array() {
-  std::vector<double> v(5);
-  v[0] = 56;
-  Py_intptr_t shape[1] = {v.size()};
-  bn::ndarray result = bn::zeros(1, shape, bn::dtype::get_builtin<double>());
-  std::copy(v.begin(), v.end(), reinterpret_cast<double*>(result.get_data()));
-  return result;
-}
-
-/* Return a dim-1 matrix with five elements. */
-boost::python::object matrix() {
-  std::vector<double> v(5);
-  v[0] = 56;
-  Py_intptr_t shape[1] = {v.size()};
-  bn::matrix t(bn::zeros(1, shape, bn::dtype::get_builtin<double>()));
-  std::copy(v.begin(), v.end(), reinterpret_cast<double*>(t.get_data()));
-
-  return t;
-}
-
-BOOST_PYTHON_MODULE(libbnpy) {
-  bn::initialize();
-  bp::def("array", array);
-  bp::def("matrix", matrix);
-}
diff --git a/unittest/alpha/eigen.cpp b/unittest/alpha/eigen.cpp
deleted file mode 100644
index 0e856f72..00000000
--- a/unittest/alpha/eigen.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-#include <boost/numpy.hpp>
-
-#include "eigenpy/fwd.hpp"
-
-namespace boopy {
-namespace bpn = boost::numpy;
-namespace bp = boost::python;
-
-struct Eigenvec_to_python_matrix {
-  static PyObject* convert(Eigen::VectorXd const& v) {
-    Py_intptr_t shape[1] = {v.size()};
-    bpn::matrix result(bpn::zeros(1, shape, bpn::dtype::get_builtin<double>()));
-    std::copy(v.data(), v.data() + v.size(),
-              reinterpret_cast<double*>(result.get_data()));
-    return bp::incref(result.ptr());
-  }
-};
-
-struct Eigenvec_from_python_array {
-  Eigenvec_from_python_array() {
-    bp::converter::registry ::push_back(&convertible, &construct,
-                                        bp::type_id<Eigen::VectorXd>());
-  }
-
-  // Determine if obj_ptr can be converted in a Eigenvec
-  static void* convertible(PyObject* obj_ptr) {
-    try {
-      bp::object obj(bp::handle<>(bp::borrowed(obj_ptr)));
-      std::auto_ptr<bpn::ndarray> array(new bpn::ndarray(bpn::from_object(
-          obj, bpn::dtype::get_builtin<double>(), bpn::ndarray::V_CONTIGUOUS)));
-
-      if ((array->get_nd() == 1) ||
-          ((array->get_nd() == 2) && (array->get_shape()[1] == 1)))
-        return array.release();
-      else
-        return 0;
-    } catch (bp::error_already_set& err) {
-      bp::handle_exception();
-      return 0;
-    }
-  }
-
-  // Convert obj_ptr into a Eigenvec
-  static void construct(PyObject*,
-                        bp::converter::rvalue_from_python_stage1_data* memory) {
-    // Recover the pointer created in <convertible>
-    std::auto_ptr<bpn::ndarray> array(
-        reinterpret_cast<bpn::ndarray*>(memory->convertible));
-    const int nrow = array->get_shape()[0];
-    std::cout << "nrow = " << nrow << std::endl;
-
-    // Get the memory where to create the vector
-    void* storage =
-        ((bp::converter::rvalue_from_python_storage<Eigen::VectorXd>*)memory)
-            ->storage.bytes;
-
-    // Create the vector
-    Eigen::VectorXd& res = *new (storage) Eigen::VectorXd(nrow);
-
-    // Copy the data
-    double* data = (double*)array->get_data();
-    for (int i = 0; i < nrow; ++i) res[i] = data[i];
-
-    // Stash the memory chunk pointer for later use by boost.python
-    memory->convertible = storage;
-  }
-};
-}  // namespace boopy
-
-Eigen::VectorXd test() {
-  Eigen::VectorXd v = Eigen::VectorXd::Random(5);
-  std::cout << v.transpose() << std::endl;
-  return v;
-}
-
-void test2(Eigen::VectorXd v) {
-  std::cout << "test2: dim = " << v.size() << " ||| v[0] = " << v[0]
-            << std::endl;
-}
-
-BOOST_PYTHON_MODULE(libeigen) {
-  namespace bpn = boost::numpy;
-  namespace bp = boost::python;
-
-  bpn::initialize();
-  bp::to_python_converter<Eigen::VectorXd, boopy::Eigenvec_to_python_matrix>();
-  boopy::Eigenvec_from_python_array();
-
-  bp::def("test", test);
-  bp::def("test2", test2);
-}
diff --git a/unittest/alpha/eigenc.cpp b/unittest/alpha/eigenc.cpp
deleted file mode 100644
index ad4fdf26..00000000
--- a/unittest/alpha/eigenc.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-#include <numpy/arrayobject.h>
-
-#include "eigenpy/fwd.hpp"
-
-namespace boopy {
-namespace bp = boost::python;
-
-template <typename SCALAR>
-struct NumpyEquivalentType {};
-template <>
-struct NumpyEquivalentType<double> {
-  enum { type_code = NPY_DOUBLE };
-};
-template <>
-struct NumpyEquivalentType<int> {
-  enum { type_code = NPY_INT };
-};
-template <>
-struct NumpyEquivalentType<float> {
-  enum { type_code = NPY_FLOAT };
-};
-
-struct EigenMatrix_to_python_matrix {
-  static PyObject* convert(Eigen::MatrixXd const& mat) {
-    typedef Eigen::MatrixXd::Scalar T;
-
-    npy_intp shape[2] = {mat.rows(), mat.cols()};
-    PyArrayObject* pyArray = (PyArrayObject*)PyArray_SimpleNew(
-        2, shape, NumpyEquivalentType<T>::type_code);
-
-    T* pyData = (T*)PyArray_DATA(pyArray);
-    for (int i = 0; i < mat.rows(); ++i)
-      for (int j = 0; j < mat.cols(); ++j)
-        pyData[i * mat.cols() + j] = mat(i, j);
-
-    return ((PyObject*)pyArray);
-  }
-};
-
-struct EigenMatrix_from_python_array {
-  EigenMatrix_from_python_array() {
-    bp::converter::registry ::push_back(&convertible, &construct,
-                                        bp::type_id<Eigen::MatrixXd>());
-  }
-
-  // Determine if obj_ptr can be converted in a Eigenvec
-  static void* convertible(PyObject* obj_ptr) {
-    typedef Eigen::MatrixXd::Scalar T;
-
-    if (!PyArray_Check(obj_ptr)) {
-      return 0;
-    }
-    if (PyArray_NDIM(obj_ptr) > 2) {
-      return 0;
-    }
-    if (PyArray_ObjectType(obj_ptr, 0) != NumpyEquivalentType<T>::type_code) {
-      return 0;
-    }
-    int flags = PyArray_FLAGS(obj_ptr);
-    if (!(flags & NPY_C_CONTIGUOUS)) {
-      return 0;
-    }
-    if (!(flags & NPY_ALIGNED)) {
-      return 0;
-    }
-
-    return obj_ptr;
-  }
-
-  // Convert obj_ptr into a Eigenvec
-  static void construct(PyObject* pyObj,
-                        bp::converter::rvalue_from_python_stage1_data* memory) {
-    typedef Eigen::MatrixXd::Scalar T;
-    using namespace Eigen;
-
-    PyArrayObject* pyArray = reinterpret_cast<PyArrayObject*>(pyObj);
-    int ndims = PyArray_NDIM(pyArray);
-    assert(ndims == 2);
-
-    int dtype_size = (PyArray_DESCR(pyArray))->elsize;
-    int s1 = PyArray_STRIDE(pyArray, 0);
-    assert(s1 % dtype_size == 0);
-
-    int R = MatrixXd::RowsAtCompileTime;
-    int C = MatrixXd::ColsAtCompileTime;
-    if (R == Eigen::Dynamic)
-      R = PyArray_DIMS(pyArray)[0];
-    else
-      assert(PyArray_DIMS(pyArray)[0] == R);
-
-    if (C == Eigen::Dynamic)
-      C = PyArray_DIMS(pyArray)[1];
-    else
-      assert(PyArray_DIMS(pyArray)[1] == C);
-
-    T* pyData = reinterpret_cast<T*>(PyArray_DATA(pyArray));
-
-    void* storage =
-        ((bp::converter::rvalue_from_python_storage<MatrixXd>*)(memory))
-            ->storage.bytes;
-    MatrixXd& mat = *new (storage) MatrixXd(R, C);
-    for (int i = 0; i < R; ++i)
-      for (int j = 0; j < C; ++j) mat(i, j) = pyData[i * C + j];
-
-    memory->convertible = storage;
-  }
-};
-
-}  // namespace boopy
-
-Eigen::MatrixXd test() {
-  Eigen::MatrixXd mat = Eigen::MatrixXd::Random(5, 5);
-  std::cout << "EigenMAt = " << mat << std::endl;
-  return mat;
-}
-
-void test2(Eigen::MatrixXd mat) {
-  std::cout << "test2: dim = " << mat.rows() << " ||| m[0,0] = " << mat(0, 0)
-            << std::endl;
-}
-
-BOOST_PYTHON_MODULE(libeigenc) {
-  import_array();
-  namespace bp = boost::python;
-  bp::to_python_converter<Eigen::MatrixXd,
-                          boopy::EigenMatrix_to_python_matrix>();
-  boopy::EigenMatrix_from_python_array();
-
-  bp::def("test", test);
-  bp::def("test2", test2);
-}
diff --git a/unittest/alpha/eigentemplate.cpp b/unittest/alpha/eigentemplate.cpp
deleted file mode 100644
index 408e3d5c..00000000
--- a/unittest/alpha/eigentemplate.cpp
+++ /dev/null
@@ -1,181 +0,0 @@
-#include <numpy/arrayobject.h>
-
-#include "eigenpy/fwd.hpp"
-
-namespace boopy {
-namespace bp = boost::python;
-
-template <typename SCALAR>
-struct NumpyEquivalentType {};
-template <>
-struct NumpyEquivalentType<double> {
-  enum { type_code = NPY_DOUBLE };
-};
-template <>
-struct NumpyEquivalentType<int> {
-  enum { type_code = NPY_INT };
-};
-template <>
-struct NumpyEquivalentType<float> {
-  enum { type_code = NPY_FLOAT };
-};
-
-/* --- TO PYTHON --------------------------------------------------------------
- */
-template <typename MatType>
-struct EigenMatrix_to_python_matrix {
-  static PyObject* convert(MatType const& mat) {
-    typedef typename MatType::Scalar T;
-    const int R = mat.rows(), C = mat.cols();
-
-    npy_intp shape[2] = {R, C};
-    PyArrayObject* pyArray = (PyArrayObject*)PyArray_SimpleNew(
-        2, shape, NumpyEquivalentType<T>::type_code);
-
-    T* pyData = (T*)PyArray_DATA(pyArray);
-    Eigen::Map<
-        Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> >
-        pyMatrix(pyData, R, C);
-    pyMatrix = mat;
-
-    return (PyObject*)pyArray;
-  }
-};
-
-/* --- FROM PYTHON ------------------------------------------------------------
- */
-template <typename MatType>
-struct EigenMatrix_from_python_array {
-  EigenMatrix_from_python_array() {
-    bp::converter::registry ::push_back(&convertible, &construct,
-                                        bp::type_id<MatType>());
-  }
-
-  // Determine if obj_ptr can be converted in a Eigenvec
-  static void* convertible(PyObject* obj_ptr) {
-    typedef typename MatType::Scalar T;
-
-    if (!PyArray_Check(obj_ptr)) return 0;
-
-    std::cout << "Until here ok.   ndim = " << PyArray_NDIM(obj_ptr)
-              << " isvec " << MatType::IsVectorAtCompileTime << std::endl;
-    if (PyArray_NDIM(obj_ptr) != 2)
-      if ((PyArray_NDIM(obj_ptr) != 1) || (!MatType::IsVectorAtCompileTime))
-        return 0;
-    std::cout << "Until here ok." << std::endl;
-
-    if (PyArray_ObjectType(obj_ptr, 0) != NumpyEquivalentType<T>::type_code)
-      return 0;
-
-    if (!(PyArray_FLAGS(obj_ptr) & NPY_ALIGNED)) {
-      std::cerr << "NPY non-aligned matrices are not implemented." << std::endl;
-      return 0;
-    }
-
-    return obj_ptr;
-  }
-
-  // Convert obj_ptr into a Eigenvec
-  static void construct(PyObject* pyObj,
-                        bp::converter::rvalue_from_python_stage1_data* memory) {
-    typedef typename MatType::Scalar T;
-    using namespace Eigen;
-
-    std::cout << "Until here ok. Constructing..." << std::endl;
-    PyArrayObject* pyArray = reinterpret_cast<PyArrayObject*>(pyObj);
-
-    if (PyArray_NDIM(pyArray) == 2) {
-      int R = MatType::RowsAtCompileTime;
-      int C = MatType::ColsAtCompileTime;
-      if (R == Eigen::Dynamic)
-        R = PyArray_DIMS(pyArray)[0];
-      else
-        assert(PyArray_DIMS(pyArray)[0] == R);
-
-      if (C == Eigen::Dynamic)
-        C = PyArray_DIMS(pyArray)[1];
-      else
-        assert(PyArray_DIMS(pyArray)[1] == C);
-
-      T* pyData = reinterpret_cast<T*>(PyArray_DATA(pyArray));
-
-      int itemsize = PyArray_ITEMSIZE(pyArray);
-      int stride1 = PyArray_STRIDE(pyArray, 0) / itemsize;
-      int stride2 = PyArray_STRIDE(pyArray, 1) / itemsize;
-      std::cout << "STRIDE = " << stride1 << " x " << stride2 << std::endl;
-      Eigen::Map<MatType, 0, Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> >
-          pyMap(
-              pyData, R, C,
-              Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>(stride2, stride1));
-      std::cout << "Map = " << pyMap << std::endl;
-
-      void* storage =
-          ((bp::converter::rvalue_from_python_storage<MatType>*)(memory))
-              ->storage.bytes;
-      MatType& mat = *new (storage) MatType(R, C);
-      mat = pyMap;
-
-      memory->convertible = storage;
-    } else {
-      int R = MatType::MaxSizeAtCompileTime, C = 1;
-      if (R == Eigen::Dynamic)
-        R = PyArray_DIMS(pyArray)[0];
-      else
-        assert(PyArray_DIMS(pyArray)[0] == R);
-
-      T* pyData = reinterpret_cast<T*>(PyArray_DATA(pyArray));
-
-      int itemsize = PyArray_ITEMSIZE(pyArray);
-      int stride = PyArray_STRIDE(pyArray, 0) / itemsize;
-      Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> s(stride, 0);
-      Eigen::Map<MatType, 0, Eigen::InnerStride<Eigen::Dynamic> > pyMap(
-          pyData, R, 1, Eigen::InnerStride<Eigen::Dynamic>(stride));
-      std::cout << "Map = " << pyMap << std::endl;
-
-      void* storage =
-          ((bp::converter::rvalue_from_python_storage<MatType>*)(memory))
-              ->storage.bytes;
-      MatType& mat = *new (storage) MatType(R, C);
-      mat = pyMap;
-
-      memory->convertible = storage;
-    }
-  }
-};
-
-}  // namespace boopy
-
-Eigen::MatrixXd test() {
-  Eigen::MatrixXd mat = Eigen::MatrixXd::Random(3, 6);
-  std::cout << "EigenMAt = " << mat << std::endl;
-  return mat;
-}
-Eigen::VectorXd testVec() {
-  Eigen::VectorXd mat = Eigen::VectorXd::Random(6);
-  std::cout << "EigenVec = " << mat << std::endl;
-  return mat;
-}
-
-void test2(Eigen::MatrixXd mat) {
-  std::cout << "Test2 mat = " << mat << std::endl;
-}
-void test2Vec(Eigen::VectorXd v) {
-  std::cout << "Test2 vec = " << v << std::endl;
-}
-
-BOOST_PYTHON_MODULE(libeigentemplate) {
-  import_array();
-  namespace bp = boost::python;
-  bp::to_python_converter<
-      Eigen::MatrixXd, boopy::EigenMatrix_to_python_matrix<Eigen::MatrixXd> >();
-  boopy::EigenMatrix_from_python_array<Eigen::MatrixXd>();
-
-  bp::to_python_converter<
-      Eigen::VectorXd, boopy::EigenMatrix_to_python_matrix<Eigen::VectorXd> >();
-  boopy::EigenMatrix_from_python_array<Eigen::VectorXd>();
-
-  bp::def("test", test);
-  bp::def("testVec", testVec);
-  bp::def("test2", test2);
-  bp::def("test2Vec", test2Vec);
-}
diff --git a/unittest/alpha/mystring.cpp b/unittest/alpha/mystring.cpp
deleted file mode 100644
index 843e553c..00000000
--- a/unittest/alpha/mystring.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Tutorial with boost::python. Using the converter to access a home-made
- * string class and bind it to the python strings. */
-
-#include <boost/python/def.hpp>
-#include <boost/python/module.hpp>
-#include <boost/python/to_python_converter.hpp>
-
-namespace homemadestring {
-
-/* This is the home-made string class. */
-class custom_string {
- public:
-  custom_string() {}
-  custom_string(std::string const& value) : value_(value) {}
-  std::string const& value() const { return value_; }
-
- private:
-  std::string value_;
-};
-
-/* Two simple functions with this class */
-custom_string hello() { return custom_string("Hello world."); }
-std::size_t size(custom_string const& s) { return s.value().size(); }
-
-/* From c to python converter */
-struct custom_string_to_python_str {
-  static PyObject* convert(custom_string const& s) {
-    return boost::python::incref(boost::python::object(s.value()).ptr());
-  }
-};
-
-struct custom_string_from_python_str {
-  custom_string_from_python_str() {
-    boost::python::converter::registry ::push_back(
-        &convertible, &construct, boost::python::type_id<custom_string>());
-  }
-
-  static void* convertible(PyObject* obj_ptr) {
-    if (!PyString_Check(obj_ptr)) return 0;
-    return obj_ptr;
-  }
-
-  static void construct(
-      PyObject* obj_ptr,
-      boost::python::converter::rvalue_from_python_stage1_data* data) {
-    const char* value = PyString_AsString(obj_ptr);
-    if (value == 0) boost::python::throw_error_already_set();
-    void* storage =
-        ((boost::python::converter::rvalue_from_python_storage<custom_string>*)
-             data)
-            ->storage.bytes;
-    new (storage) custom_string(value);
-    data->convertible = storage;
-  }
-};
-
-void init_module() {
-  using namespace boost::python;
-
-  boost::python::to_python_converter<custom_string,
-                                     custom_string_to_python_str>();
-  custom_string_from_python_str();
-
-  def("hello", hello);
-  def("size", size);
-}
-
-}  // namespace homemadestring
-
-BOOST_PYTHON_MODULE(libmystring) { homemadestring::init_module(); }
diff --git a/unittest/alpha/simple.cpp b/unittest/alpha/simple.cpp
deleted file mode 100644
index 02c21aa7..00000000
--- a/unittest/alpha/simple.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Simple test with boost::python.
- * Declare and bind three function, returning char*, string, and Eigen::Vector.
- * The last function raises and error at runtime due to inadequate binding.
- */
-
-#include <string>
-
-#include "eigenpy/fwd.hpp"
-
-char const* testchar() { return "Yay char!"; }
-
-std::string teststr() { return "Yay str!"; }
-
-Eigen::VectorXd testeigenvec() {
-  Eigen::VectorXd v(555);
-  return v;
-}
-
-BOOST_PYTHON_MODULE(libsimple) {
-  using namespace boost::python;
-  def("char", testchar);
-  def("str", teststr);
-  def("eigenvec", testeigenvec);
-}
-- 
GitLab