From 053db4e03ef28c933ba29d8373ae1864927fadd8 Mon Sep 17 00:00:00 2001 From: ManifoldFR Date: Fri, 25 Apr 2025 11:45:01 +0200 Subject: [PATCH 1/3] Add user-defined literal _a as a shortcut for --- include/eigenpy/fwd.hpp | 10 ++++++++++ unittest/user_type.cpp | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/eigenpy/fwd.hpp b/include/eigenpy/fwd.hpp index 2b348a70c..c0fe4c75f 100644 --- a/include/eigenpy/fwd.hpp +++ b/include/eigenpy/fwd.hpp @@ -196,6 +196,16 @@ struct has_operator_equal_impl { template struct has_operator_equal : internal::has_operator_equal_impl::type {}; +namespace literals { +/// \brief A string literal returning a boost::python::arg. +/// +/// Using-declare this operator or do `using namespace eigenpy::literals`. Then +/// `bp::arg("matrix")` can be replaced by the literal `"matrix"_a`. +inline boost::python::arg operator"" _a(const char *name, std::size_t) { + return boost::python::arg(name); +} +} // namespace literals + } // namespace eigenpy #include "eigenpy/alignment.hpp" diff --git a/unittest/user_type.cpp b/unittest/user_type.cpp index 2adbac43e..dee189001 100644 --- a/unittest/user_type.cpp +++ b/unittest/user_type.cpp @@ -150,12 +150,13 @@ Eigen::Matrix build_matrix(int rows, template void expose_custom_type(const std::string& name) { using namespace Eigen; + using eigenpy::literals::operator"" _a; namespace bp = boost::python; typedef CustomType Type; - bp::class_(name.c_str(), bp::init(bp::arg("value"))) - + // use ""_a literal + bp::class_(name.c_str(), bp::init("value"_a)) .def(bp::self + bp::self) .def(bp::self - bp::self) .def(bp::self * bp::self) From d43b83c7864b89cd71b0d1dd776c634f68d80edf Mon Sep 17 00:00:00 2001 From: ManifoldFR Date: Fri, 25 Apr 2025 11:51:28 +0200 Subject: [PATCH 2/3] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c7546e64..1ddae3fa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Added + +- Add user-defined literal ""_a for bp::arg ([#545)(https://github.com/stack-of-tasks/eigenpy/pull/545)) + ### Fixed - Fix handling of non sorted sparse matrix ([#538](https://github.com/stack-of-tasks/eigenpy/pull/538)) From 2792847d1d5186315f765d9a19743e6ecf1f138c Mon Sep 17 00:00:00 2001 From: ManifoldFR Date: Fri, 25 Apr 2025 14:59:33 +0200 Subject: [PATCH 3/3] remove ubuntu 20.04, add 24.04 --- .github/workflows/linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 572714726..3fbfff38f 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -30,7 +30,7 @@ jobs: strategy: matrix: python: [3] - ubuntu: [20, 22] + ubuntu: [22, 24] steps: - uses: actions/checkout@v3 with: