From ddd38abe6b591baf265d99c03909f1cd8a3c5064 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 3 Jan 2024 12:19:45 -0500 Subject: [PATCH 01/15] add Cephes README and License --- gtsam/3rdparty/cephes/LICENSE.txt | 7 +++++++ gtsam/3rdparty/cephes/README.md | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 gtsam/3rdparty/cephes/LICENSE.txt create mode 100644 gtsam/3rdparty/cephes/README.md diff --git a/gtsam/3rdparty/cephes/LICENSE.txt b/gtsam/3rdparty/cephes/LICENSE.txt new file mode 100644 index 000000000..6c2842a96 --- /dev/null +++ b/gtsam/3rdparty/cephes/LICENSE.txt @@ -0,0 +1,7 @@ +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/gtsam/3rdparty/cephes/README.md b/gtsam/3rdparty/cephes/README.md new file mode 100644 index 000000000..63e3a6c8c --- /dev/null +++ b/gtsam/3rdparty/cephes/README.md @@ -0,0 +1,22 @@ +# README + +This is a vendored version of the Cephes Mathematical Library. The source code can be found on [netlib.org](https://www.netlib.org/cephes/). + +The software is provided with an [MIT License](https://smath.com/en-US/view/CephesMathLibrary/license). + +## Original Readme + +Some software in this archive may be from the book _Methods and +Programs for Mathematical Functions_ (Prentice-Hall or Simon & Schuster +International, 1989) or from the Cephes Mathematical Library, a +commercial product. In either event, it is copyrighted by the author. +What you see here may be used freely but it comes with no support or +guarantee. + +The two known misprints in the book are repaired here in the +source listings for the gamma function and the incomplete beta +integral. + + +Stephen L. Moshier +moshier@na-net.ornl.gov From 04bee2b8738ea193a453e37f7ed47cd48f94bd49 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 3 Jan 2024 12:37:50 -0500 Subject: [PATCH 02/15] add cross platform extern marking to cephes.h --- gtsam/3rdparty/cephes/cephes.h | 235 +++++++++++++++--------------- gtsam/3rdparty/cephes/dllexport.h | 25 ++++ 2 files changed, 146 insertions(+), 114 deletions(-) create mode 100644 gtsam/3rdparty/cephes/dllexport.h diff --git a/gtsam/3rdparty/cephes/cephes.h b/gtsam/3rdparty/cephes/cephes.h index 629733eef..d5b59d895 100644 --- a/gtsam/3rdparty/cephes/cephes.h +++ b/gtsam/3rdparty/cephes/cephes.h @@ -2,159 +2,166 @@ #define CEPHES_H #include "cephes/cephes_names.h" +#include "dllexport.h" #ifdef __cplusplus extern "C" { #endif -extern int airy(double x, double *ai, double *aip, double *bi, double *bip); +CEPHES_EXTERN_EXPORT int airy(double x, double *ai, double *aip, double *bi, + double *bip); -extern double bdtrc(double k, int n, double p); -extern double bdtr(double k, int n, double p); -extern double bdtri(double k, int n, double y); +CEPHES_EXTERN_EXPORT double bdtrc(double k, int n, double p); +CEPHES_EXTERN_EXPORT double bdtr(double k, int n, double p); +CEPHES_EXTERN_EXPORT double bdtri(double k, int n, double y); -extern double besselpoly(double a, double lambda, double nu); +CEPHES_EXTERN_EXPORT double besselpoly(double a, double lambda, double nu); -extern double beta(double a, double b); -extern double lbeta(double a, double b); +CEPHES_EXTERN_EXPORT double beta(double a, double b); +CEPHES_EXTERN_EXPORT double lbeta(double a, double b); -extern double btdtr(double a, double b, double x); +CEPHES_EXTERN_EXPORT double btdtr(double a, double b, double x); -extern double cbrt(double x); -extern double chbevl(double x, double array[], int n); -extern double chdtrc(double df, double x); -extern double chdtr(double df, double x); -extern double chdtri(double df, double y); -extern double dawsn(double xx); +CEPHES_EXTERN_EXPORT double cbrt(double x); +CEPHES_EXTERN_EXPORT double chbevl(double x, double array[], int n); +CEPHES_EXTERN_EXPORT double chdtrc(double df, double x); +CEPHES_EXTERN_EXPORT double chdtr(double df, double x); +CEPHES_EXTERN_EXPORT double chdtri(double df, double y); +CEPHES_EXTERN_EXPORT double dawsn(double xx); -extern double ellie(double phi, double m); -extern double ellik(double phi, double m); -extern double ellpe(double x); +CEPHES_EXTERN_EXPORT double ellie(double phi, double m); +CEPHES_EXTERN_EXPORT double ellik(double phi, double m); +CEPHES_EXTERN_EXPORT double ellpe(double x); -extern int ellpj(double u, double m, double *sn, double *cn, double *dn, double *ph); -extern double ellpk(double x); -extern double exp10(double x); -extern double exp2(double x); +CEPHES_EXTERN_EXPORT int ellpj(double u, double m, double *sn, double *cn, + double *dn, double *ph); +CEPHES_EXTERN_EXPORT double ellpk(double x); +CEPHES_EXTERN_EXPORT double exp10(double x); +CEPHES_EXTERN_EXPORT double exp2(double x); -extern double expn(int n, double x); +CEPHES_EXTERN_EXPORT double expn(int n, double x); -extern double fdtrc(double a, double b, double x); -extern double fdtr(double a, double b, double x); -extern double fdtri(double a, double b, double y); +CEPHES_EXTERN_EXPORT double fdtrc(double a, double b, double x); +CEPHES_EXTERN_EXPORT double fdtr(double a, double b, double x); +CEPHES_EXTERN_EXPORT double fdtri(double a, double b, double y); -extern int fresnl(double xxa, double *ssa, double *cca); -extern double Gamma(double x); -extern double lgam(double x); -extern double lgam_sgn(double x, int *sign); -extern double gammasgn(double x); +CEPHES_EXTERN_EXPORT int fresnl(double xxa, double *ssa, double *cca); +CEPHES_EXTERN_EXPORT double Gamma(double x); +CEPHES_EXTERN_EXPORT double lgam(double x); +CEPHES_EXTERN_EXPORT double lgam_sgn(double x, int *sign); +CEPHES_EXTERN_EXPORT double gammasgn(double x); -extern double gdtr(double a, double b, double x); -extern double gdtrc(double a, double b, double x); -extern double gdtri(double a, double b, double y); +CEPHES_EXTERN_EXPORT double gdtr(double a, double b, double x); +CEPHES_EXTERN_EXPORT double gdtrc(double a, double b, double x); +CEPHES_EXTERN_EXPORT double gdtri(double a, double b, double y); -extern double hyp2f1(double a, double b, double c, double x); -extern double hyperg(double a, double b, double x); -extern double threef0(double a, double b, double c, double x, double *err); +CEPHES_EXTERN_EXPORT double hyp2f1(double a, double b, double c, double x); +CEPHES_EXTERN_EXPORT double hyperg(double a, double b, double x); +CEPHES_EXTERN_EXPORT double threef0(double a, double b, double c, double x, + double *err); -extern double i0(double x); -extern double i0e(double x); -extern double i1(double x); -extern double i1e(double x); -extern double igamc(double a, double x); -extern double igam(double a, double x); -extern double igam_fac(double a, double x); -extern double igamci(double a, double q); -extern double igami(double a, double p); +CEPHES_EXTERN_EXPORT double i0(double x); +CEPHES_EXTERN_EXPORT double i0e(double x); +CEPHES_EXTERN_EXPORT double i1(double x); +CEPHES_EXTERN_EXPORT double i1e(double x); +CEPHES_EXTERN_EXPORT double igamc(double a, double x); +CEPHES_EXTERN_EXPORT double igam(double a, double x); +CEPHES_EXTERN_EXPORT double igam_fac(double a, double x); +CEPHES_EXTERN_EXPORT double igamci(double a, double q); +CEPHES_EXTERN_EXPORT double igami(double a, double p); -extern double incbet(double aa, double bb, double xx); -extern double incbi(double aa, double bb, double yy0); +CEPHES_EXTERN_EXPORT double incbet(double aa, double bb, double xx); +CEPHES_EXTERN_EXPORT double incbi(double aa, double bb, double yy0); -extern double iv(double v, double x); -extern double j0(double x); -extern double y0(double x); -extern double j1(double x); -extern double y1(double x); +CEPHES_EXTERN_EXPORT double iv(double v, double x); +CEPHES_EXTERN_EXPORT double j0(double x); +CEPHES_EXTERN_EXPORT double y0(double x); +CEPHES_EXTERN_EXPORT double j1(double x); +CEPHES_EXTERN_EXPORT double y1(double x); -extern double jn(int n, double x); -extern double jv(double n, double x); -extern double k0(double x); -extern double k0e(double x); -extern double k1(double x); -extern double k1e(double x); -extern double kn(int nn, double x); +CEPHES_EXTERN_EXPORT double jn(int n, double x); +CEPHES_EXTERN_EXPORT double jv(double n, double x); +CEPHES_EXTERN_EXPORT double k0(double x); +CEPHES_EXTERN_EXPORT double k0e(double x); +CEPHES_EXTERN_EXPORT double k1(double x); +CEPHES_EXTERN_EXPORT double k1e(double x); +CEPHES_EXTERN_EXPORT double kn(int nn, double x); -extern double nbdtrc(int k, int n, double p); -extern double nbdtr(int k, int n, double p); -extern double nbdtri(int k, int n, double p); +CEPHES_EXTERN_EXPORT double nbdtrc(int k, int n, double p); +CEPHES_EXTERN_EXPORT double nbdtr(int k, int n, double p); +CEPHES_EXTERN_EXPORT double nbdtri(int k, int n, double p); -extern double ndtr(double a); -extern double log_ndtr(double a); -extern double erfc(double a); -extern double erf(double x); -extern double erfinv(double y); -extern double erfcinv(double y); -extern double ndtri(double y0); +CEPHES_EXTERN_EXPORT double ndtr(double a); +CEPHES_EXTERN_EXPORT double log_ndtr(double a); +CEPHES_EXTERN_EXPORT double erfc(double a); +CEPHES_EXTERN_EXPORT double erf(double x); +CEPHES_EXTERN_EXPORT double erfinv(double y); +CEPHES_EXTERN_EXPORT double erfcinv(double y); +CEPHES_EXTERN_EXPORT double ndtri(double y0); -extern double pdtrc(double k, double m); -extern double pdtr(double k, double m); -extern double pdtri(int k, double y); +CEPHES_EXTERN_EXPORT double pdtrc(double k, double m); +CEPHES_EXTERN_EXPORT double pdtr(double k, double m); +CEPHES_EXTERN_EXPORT double pdtri(int k, double y); -extern double poch(double x, double m); +CEPHES_EXTERN_EXPORT double poch(double x, double m); -extern double psi(double x); +CEPHES_EXTERN_EXPORT double psi(double x); -extern double rgamma(double x); -extern double round(double x); +CEPHES_EXTERN_EXPORT double rgamma(double x); +CEPHES_EXTERN_EXPORT double round(double x); -extern int shichi(double x, double *si, double *ci); -extern int sici(double x, double *si, double *ci); +CEPHES_EXTERN_EXPORT int shichi(double x, double *si, double *ci); +CEPHES_EXTERN_EXPORT int sici(double x, double *si, double *ci); -extern double radian(double d, double m, double s); -extern double sindg(double x); -extern double sinpi(double x); -extern double cosdg(double x); -extern double cospi(double x); +CEPHES_EXTERN_EXPORT double radian(double d, double m, double s); +CEPHES_EXTERN_EXPORT double sindg(double x); +CEPHES_EXTERN_EXPORT double sinpi(double x); +CEPHES_EXTERN_EXPORT double cosdg(double x); +CEPHES_EXTERN_EXPORT double cospi(double x); -extern double spence(double x); +CEPHES_EXTERN_EXPORT double spence(double x); -extern double stdtr(int k, double t); -extern double stdtri(int k, double p); +CEPHES_EXTERN_EXPORT double stdtr(int k, double t); +CEPHES_EXTERN_EXPORT double stdtri(int k, double p); -extern double struve_h(double v, double x); -extern double struve_l(double v, double x); -extern double struve_power_series(double v, double x, int is_h, double *err); -extern double struve_asymp_large_z(double v, double z, int is_h, double *err); -extern double struve_bessel_series(double v, double z, int is_h, double *err); +CEPHES_EXTERN_EXPORT double struve_h(double v, double x); +CEPHES_EXTERN_EXPORT double struve_l(double v, double x); +CEPHES_EXTERN_EXPORT double struve_power_series(double v, double x, int is_h, + double *err); +CEPHES_EXTERN_EXPORT double struve_asymp_large_z(double v, double z, int is_h, + double *err); +CEPHES_EXTERN_EXPORT double struve_bessel_series(double v, double z, int is_h, + double *err); -extern double yv(double v, double x); +CEPHES_EXTERN_EXPORT double yv(double v, double x); -extern double tandg(double x); -extern double cotdg(double x); +CEPHES_EXTERN_EXPORT double tandg(double x); +CEPHES_EXTERN_EXPORT double cotdg(double x); -extern double log1p(double x); -extern double log1pmx(double x); -extern double expm1(double x); -extern double cosm1(double x); -extern double lgam1p(double x); +CEPHES_EXTERN_EXPORT double log1p(double x); +CEPHES_EXTERN_EXPORT double log1pmx(double x); +CEPHES_EXTERN_EXPORT double expm1(double x); +CEPHES_EXTERN_EXPORT double cosm1(double x); +CEPHES_EXTERN_EXPORT double lgam1p(double x); -extern double yn(int n, double x); -extern double zeta(double x, double q); -extern double zetac(double x); +CEPHES_EXTERN_EXPORT double yn(int n, double x); +CEPHES_EXTERN_EXPORT double zeta(double x, double q); +CEPHES_EXTERN_EXPORT double zetac(double x); -extern double smirnov(int n, double d); -extern double smirnovi(int n, double p); -extern double smirnovp(int n, double d); -extern double smirnovc(int n, double d); -extern double smirnovci(int n, double p); -extern double kolmogorov(double x); -extern double kolmogi(double p); -extern double kolmogp(double x); -extern double kolmogc(double x); -extern double kolmogci(double p); +CEPHES_EXTERN_EXPORT double smirnov(int n, double d); +CEPHES_EXTERN_EXPORT double smirnovi(int n, double p); +CEPHES_EXTERN_EXPORT double smirnovp(int n, double d); +CEPHES_EXTERN_EXPORT double smirnovc(int n, double d); +CEPHES_EXTERN_EXPORT double smirnovci(int n, double p); +CEPHES_EXTERN_EXPORT double kolmogorov(double x); +CEPHES_EXTERN_EXPORT double kolmogi(double p); +CEPHES_EXTERN_EXPORT double kolmogp(double x); +CEPHES_EXTERN_EXPORT double kolmogc(double x); +CEPHES_EXTERN_EXPORT double kolmogci(double p); -extern double lanczos_sum_expg_scaled(double x); +CEPHES_EXTERN_EXPORT double lanczos_sum_expg_scaled(double x); -extern double owens_t(double h, double a); +CEPHES_EXTERN_EXPORT double owens_t(double h, double a); #ifdef __cplusplus } diff --git a/gtsam/3rdparty/cephes/dllexport.h b/gtsam/3rdparty/cephes/dllexport.h new file mode 100644 index 000000000..525587164 --- /dev/null +++ b/gtsam/3rdparty/cephes/dllexport.h @@ -0,0 +1,25 @@ +// Macros for exporting DLL symbols on Windows +// Usage example: +// In header file: +// class CEPHES_EXPORT MyClass { ... }; +// +// Results in the following declarations: +// When included while compiling the library itself: +// class __declspec(dllexport) MyClass { ... }; +// When included while compiling other code against the library: +// class __declspec(dllimport) MyClass { ... }; + +#pragma once + +#ifdef _WIN32 +# define CEPHES_EXPORT __declspec(dllimport) +# define CEPHES_EXTERN_EXPORT __declspec(dllimport) +#else +#ifdef __APPLE__ +# define CEPHES_EXPORT __attribute__((visibility("default"))) +# define CEPHES_EXTERN_EXPORT extern +#else +# define CEPHES_EXPORT +# define CEPHES_EXTERN_EXPORT extern +#endif +#endif From a4a0fefd84418fedbe89834b8f78541523661032 Mon Sep 17 00:00:00 2001 From: Bernd Pfrommer Date: Fri, 12 Jan 2024 17:28:12 -0500 Subject: [PATCH 03/15] libcephes only needs 3.10, allowing build on ubuntu 18.04 --- gtsam/3rdparty/cephes/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtsam/3rdparty/cephes/CMakeLists.txt b/gtsam/3rdparty/cephes/CMakeLists.txt index e840e9e49..946448160 100644 --- a/gtsam/3rdparty/cephes/CMakeLists.txt +++ b/gtsam/3rdparty/cephes/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.10) enable_testing() project( cephes From 2971d9e74ebac099e7741b78612fd5a69ece4035 Mon Sep 17 00:00:00 2001 From: Tal Regev Date: Fri, 8 Dec 2023 01:25:41 +0200 Subject: [PATCH 04/15] Compile gtsam python for windows --- .github/scripts/python.sh | 7 ++-- .github/workflows/build-python.yml | 55 +++++++++++++++++++++++++-- gtsam/base/utilities.h | 4 +- gtsam/discrete/DiscreteValues.h | 4 +- gtsam/geometry/Rot3.h | 2 +- gtsam/nonlinear/CustomFactor.h | 2 +- gtsam/sfm/DsfTrackGenerator.h | 2 +- python/CMakeLists.txt | 60 ++++++++++++++++++++++++++++-- python/setup.py.in | 3 +- 9 files changed, 121 insertions(+), 18 deletions(-) diff --git a/.github/scripts/python.sh b/.github/scripts/python.sh index 08b8084a0..c851c7e36 100644 --- a/.github/scripts/python.sh +++ b/.github/scripts/python.sh @@ -65,14 +65,13 @@ function build() # Set to 2 cores so that Actions does not error out during resource provisioning. cmake --build build -j2 - $PYTHON -m pip install --user build/python + cmake --build build --target python-install } function test() { - cd $GITHUB_WORKSPACE/python/gtsam/tests - $PYTHON -m unittest discover -v - cd $GITHUB_WORKSPACE + cmake --build build --target python-test + cmake --build build --target python-test-unstable } # select between build or test diff --git a/.github/workflows/build-python.yml b/.github/workflows/build-python.yml index 91bc4e80a..676fe8ea0 100644 --- a/.github/workflows/build-python.yml +++ b/.github/workflows/build-python.yml @@ -18,9 +18,11 @@ jobs: CTEST_PARALLEL_LEVEL: 2 CMAKE_BUILD_TYPE: ${{ matrix.build_type }} PYTHON_VERSION: ${{ matrix.python_version }} + BOOST_VERSION: 1.72.0 + BOOST_EXE: boost_1_72_0-msvc-14.2 strategy: - fail-fast: true + fail-fast: false matrix: # Github Actions requires a single row to be added to the build matrix. # See https://help.github.com/en/articles/workflow-syntax-for-github-actions. @@ -30,6 +32,7 @@ jobs: ubuntu-20.04-gcc-9-tbb, ubuntu-20.04-clang-9, macOS-11-xcode-13.4.1, + windows-2019-msbuild, ] build_type: [Release] @@ -56,6 +59,10 @@ jobs: compiler: xcode version: "13.4.1" + - name: windows-2019-msbuild + os: windows-2019 + platform: 64 + steps: - name: Checkout uses: actions/checkout@v3 @@ -97,29 +104,71 @@ jobs: echo "CC=clang" >> $GITHUB_ENV echo "CXX=clang++" >> $GITHUB_ENV + - name: Setup msbuild (Windows) + if: runner.os == 'Windows' + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x${{matrix.platform}} + + - name: Setup python (Windows) + uses: actions/setup-python@v4 + if: runner.os == 'Windows' + with: + python-version: ${{ matrix.python_version }} + + - name: Install ninja (Windows) + if: runner.os == 'Windows' + shell: bash + run: | + choco install ninja + ninja --version + where ninja + + - name: Install Boost (Windows) + if: runner.os == 'Windows' + shell: powershell + run: | + # Snippet from: https://github.com/actions/virtual-environments/issues/2667 + $BOOST_PATH = "C:\hostedtoolcache\windows\Boost\$env:BOOST_VERSION\x86_64" + + # Use the prebuilt binary for Windows + $Url = "https://sourceforge.net/projects/boost/files/boost-binaries/$env:BOOST_VERSION/$env:BOOST_EXE-${{matrix.platform}}.exe" + (New-Object System.Net.WebClient).DownloadFile($Url, "$env:TEMP\boost.exe") + Start-Process -Wait -FilePath "$env:TEMP\boost.exe" "/SILENT","/SP-","/SUPPRESSMSGBOXES","/DIR=$BOOST_PATH" + + # Set the BOOST_ROOT variable + echo "BOOST_ROOT=$BOOST_PATH" >> $env:GITHUB_ENV + - name: Set GTSAM_WITH_TBB Flag if: matrix.flag == 'tbb' run: | echo "GTSAM_WITH_TBB=ON" >> $GITHUB_ENV echo "GTSAM Uses TBB" - - name: Set Swap Space + - name: Set Swap Space (Linux) if: runner.os == 'Linux' uses: pierotofy/set-swap-space@master with: swap-size-gb: 6 - - name: Install System Dependencies + - name: Install System Dependencies (Linux, macOS) + if: runner.os != 'Windows' run: | bash .github/scripts/python.sh -d - name: Install Python Dependencies + shell: bash run: python$PYTHON_VERSION -m pip install -r python/dev_requirements.txt - name: Build + shell: bash run: | bash .github/scripts/python.sh -b - name: Test + # Disable running tests for windows because some of them are failing. + # Remove this condition when you want to run tests on windows CI. + if: runner.os != 'Windows' + shell: bash run: | bash .github/scripts/python.sh -t diff --git a/gtsam/base/utilities.h b/gtsam/base/utilities.h index 03e9636da..a67c5d1b6 100644 --- a/gtsam/base/utilities.h +++ b/gtsam/base/utilities.h @@ -4,6 +4,8 @@ #include #include +#include + namespace gtsam { /** * For Python __str__(). @@ -11,7 +13,7 @@ namespace gtsam { * of an object when it prints to cout. * https://stackoverflow.com/questions/5419356/redirect-stdout-stderr-to-a-string */ -struct RedirectCout { +struct GTSAM_EXPORT RedirectCout { /// constructor -- redirect stdout buffer to a stringstream buffer RedirectCout() : ssBuffer_(), coutBuffer_(std::cout.rdbuf(ssBuffer_.rdbuf())) {} diff --git a/gtsam/discrete/DiscreteValues.h b/gtsam/discrete/DiscreteValues.h index 9ec08302b..9fdff014c 100644 --- a/gtsam/discrete/DiscreteValues.h +++ b/gtsam/discrete/DiscreteValues.h @@ -126,12 +126,12 @@ inline std::vector cartesianProduct(const DiscreteKeys& keys) { } /// Free version of markdown. -std::string markdown(const DiscreteValues& values, +std::string GTSAM_EXPORT markdown(const DiscreteValues& values, const KeyFormatter& keyFormatter = DefaultKeyFormatter, const DiscreteValues::Names& names = {}); /// Free version of html. -std::string html(const DiscreteValues& values, +std::string GTSAM_EXPORT html(const DiscreteValues& values, const KeyFormatter& keyFormatter = DefaultKeyFormatter, const DiscreteValues::Names& names = {}); diff --git a/gtsam/geometry/Rot3.h b/gtsam/geometry/Rot3.h index 2b9c5a45a..7e05ee4da 100644 --- a/gtsam/geometry/Rot3.h +++ b/gtsam/geometry/Rot3.h @@ -396,7 +396,7 @@ class GTSAM_EXPORT Rot3 : public LieGroup { Matrix3 AdjointMap() const { return matrix(); } // Chart at origin, depends on compile-time flag ROT3_DEFAULT_COORDINATES_MODE - struct ChartAtOrigin { + struct GTSAM_EXPORT ChartAtOrigin { static Rot3 Retract(const Vector3& v, ChartJacobian H = {}); static Vector3 Local(const Rot3& r, ChartJacobian H = {}); }; diff --git a/gtsam/nonlinear/CustomFactor.h b/gtsam/nonlinear/CustomFactor.h index ac2942032..c4015db37 100644 --- a/gtsam/nonlinear/CustomFactor.h +++ b/gtsam/nonlinear/CustomFactor.h @@ -42,7 +42,7 @@ using CustomErrorFunction = std::function; * correspondence indices, from each image. * @param Length-N list of keypoints, for N images/cameras. */ -std::vector tracksFromPairwiseMatches( +std::vector GTSAM_EXPORT tracksFromPairwiseMatches( const MatchIndicesMap& matches, const KeypointsVector& keypoints, bool verbose = false); diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index f874c2f21..ba55ac2af 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -94,6 +94,14 @@ set(interface_headers set(GTSAM_PYTHON_TARGET gtsam_py) set(GTSAM_PYTHON_UNSTABLE_TARGET gtsam_unstable_py) +set(GTSAM_OUTPUT_NAME "gtsam") +set(GTSAM_UNSTABLE_OUTPUT_NAME "gtsam_unstable") + +if(MSVC) + set(GTSAM_OUTPUT_NAME "gtsam_py") + set(GTSAM_UNSTABLE_OUTPUT_NAME "gtsam_unstable_py") +endif() + pybind_wrap(${GTSAM_PYTHON_TARGET} # target "${interface_headers}" # interface_headers "gtsam.cpp" # generated_cpp @@ -109,12 +117,30 @@ pybind_wrap(${GTSAM_PYTHON_TARGET} # target set_target_properties(${GTSAM_PYTHON_TARGET} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" INSTALL_RPATH_USE_LINK_PATH TRUE - OUTPUT_NAME "gtsam" + OUTPUT_NAME "${GTSAM_OUTPUT_NAME}" LIBRARY_OUTPUT_DIRECTORY "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam" DEBUG_POSTFIX "" # Otherwise you will have a wrong name RELWITHDEBINFO_POSTFIX "" # Otherwise you will have a wrong name ) +if(WIN32) + set_target_properties(${GTSAM_PYTHON_TARGET} PROPERTIES + SUFFIX ".pyd" + ) + ADD_CUSTOM_COMMAND(TARGET ${GTSAM_PYTHON_TARGET} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam/${GTSAM_OUTPUT_NAME}.pyd" + "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam/gtsam.pyd" + ) + ADD_CUSTOM_COMMAND(TARGET ${GTSAM_PYTHON_TARGET} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "$;$" + "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam/" + COMMAND_EXPAND_LISTS + VERBATIM + ) +endif() + # Set the path for the GTSAM python module set(GTSAM_MODULE_PATH ${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam) @@ -188,7 +214,7 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) set_target_properties(${GTSAM_PYTHON_UNSTABLE_TARGET} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" INSTALL_RPATH_USE_LINK_PATH TRUE - OUTPUT_NAME "gtsam_unstable" + OUTPUT_NAME "${GTSAM_UNSTABLE_OUTPUT_NAME}" LIBRARY_OUTPUT_DIRECTORY "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam_unstable" DEBUG_POSTFIX "" # Otherwise you will have a wrong name RELWITHDEBINFO_POSTFIX "" # Otherwise you will have a wrong name @@ -208,13 +234,39 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) # Add gtsam_unstable to the install target list(APPEND GTSAM_PYTHON_DEPENDENCIES ${GTSAM_PYTHON_UNSTABLE_TARGET}) - + if(WIN32) + set_target_properties(${GTSAM_PYTHON_UNSTABLE_TARGET} PROPERTIES + SUFFIX ".pyd" + ) + ADD_CUSTOM_COMMAND(TARGET ${GTSAM_PYTHON_UNSTABLE_TARGET} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam_unstable/${GTSAM_UNSTABLE_OUTPUT_NAME}.pyd" + "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam_unstable/gtsam_unstable.pyd" + ) + ADD_CUSTOM_COMMAND(TARGET ${GTSAM_PYTHON_UNSTABLE_TARGET} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "$;$" + "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam_unstable/" + COMMAND_EXPAND_LISTS + VERBATIM + ) + endif() + # Custom make command to run all GTSAM_UNSTABLE Python tests + add_custom_target( + python-test-unstable + COMMAND + ${CMAKE_COMMAND} -E env # add package to python path so no need to install + "PYTHONPATH=${GTSAM_PYTHON_BUILD_DIRECTORY}/$ENV{PYTHONPATH}" + ${PYTHON_EXECUTABLE} -m unittest discover -v -s . + DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} ${GTSAM_PYTHON_TEST_FILES} + WORKING_DIRECTORY "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam_unstable/tests" + ) endif() # Add custom target so we can install with `make python-install` set(GTSAM_PYTHON_INSTALL_TARGET python-install) add_custom_target(${GTSAM_PYTHON_INSTALL_TARGET} - COMMAND ${PYTHON_EXECUTABLE} -m pip install . + COMMAND ${PYTHON_EXECUTABLE} -m pip install --user . DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} WORKING_DIRECTORY ${GTSAM_PYTHON_BUILD_DIRECTORY}) diff --git a/python/setup.py.in b/python/setup.py.in index e15e39075..824a6656e 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -11,7 +11,8 @@ print("PACKAGES: ", packages) package_data = { '': [ "./*.so", - "./*.dll" + "./*.dll", + "./*.pyd", ] } From 8023df456d9a4c59ce23979a2ab32953dfc520e3 Mon Sep 17 00:00:00 2001 From: Tal Regev Date: Sun, 31 Dec 2023 23:19:29 +0200 Subject: [PATCH 05/15] add windows template specialization --- .github/workflows/build-python.yml | 3 -- gtsam/nonlinear/Values-inl.h | 53 ++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-python.yml b/.github/workflows/build-python.yml index 676fe8ea0..bb10b27c3 100644 --- a/.github/workflows/build-python.yml +++ b/.github/workflows/build-python.yml @@ -166,9 +166,6 @@ jobs: bash .github/scripts/python.sh -b - name: Test - # Disable running tests for windows because some of them are failing. - # Remove this condition when you want to run tests on windows CI. - if: runner.os != 'Windows' shell: bash run: | bash .github/scripts/python.sh -t diff --git a/gtsam/nonlinear/Values-inl.h b/gtsam/nonlinear/Values-inl.h index a93f9570e..6da87d71c 100644 --- a/gtsam/nonlinear/Values-inl.h +++ b/gtsam/nonlinear/Values-inl.h @@ -197,6 +197,59 @@ namespace gtsam { } }; +#ifdef _WIN32 + // Handle dynamic matrices + template + struct handle_matrix, true> { + inline Eigen::Matrix operator()(Key j, const Value* const pointer) { + auto ptr = dynamic_cast>*>(pointer); + if (ptr) { + // value returns a const Matrix&, and the return makes a copy !!!!! + return ptr->value(); + } else { + // If a fixed matrix was stored, we end up here as well. + throw ValuesIncorrectType(j, typeid(*pointer), typeid(Eigen::Matrix)); + } + } + }; + + // Handle fixed matrices + template + struct handle_matrix, false> { + inline Eigen::Matrix operator()(Key j, const Value* const pointer) { + auto ptr = dynamic_cast>*>(pointer); + if (ptr) { + // value returns a const MatrixMN&, and the return makes a copy !!!!! + return ptr->value(); + } else { + Matrix A; + // Check if a dynamic matrix was stored + auto ptr = dynamic_cast*>(pointer); + if (ptr) { + A = ptr->value(); + } else { + // Or a dynamic vector + A = handle_matrix()(j, pointer); // will throw if not.... + } + // Yes: check size, and throw if not a match + if (A.rows() != M || A.cols() != N) + throw NoMatchFoundForFixed(M, N, A.rows(), A.cols()); + else + return A; // copy but not malloc + } + } + }; + + // Handle matrices + template + struct handle> { + Eigen::Matrix operator()(Key j, const Value* const pointer) { + return handle_matrix, + (M == Eigen::Dynamic || N == Eigen::Dynamic)>()(j, pointer); + } + }; +#endif // #ifdef _WIN32 + } // internal /* ************************************************************************* */ From 85cae70cefe58d5ffb336e8fb77f73fc83c8b753 Mon Sep 17 00:00:00 2001 From: Tal Regev Date: Thu, 4 Jan 2024 08:51:19 +0200 Subject: [PATCH 06/15] revert lines according to review comments. --- .github/scripts/python.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/scripts/python.sh b/.github/scripts/python.sh index c851c7e36..0c04eeec3 100644 --- a/.github/scripts/python.sh +++ b/.github/scripts/python.sh @@ -70,8 +70,16 @@ function build() function test() { - cmake --build build --target python-test - cmake --build build --target python-test-unstable + cd $GITHUB_WORKSPACE/python/gtsam/tests + $PYTHON -m unittest discover -v + cd $GITHUB_WORKSPACE + + cd $GITHUB_WORKSPACE/python/gtsam_unstable/tests + $PYTHON -m unittest discover -v + cd $GITHUB_WORKSPACE + + # cmake --build build --target python-test + # cmake --build build --target python-test-unstable } # select between build or test From d1ab94f51c979652b924b2323dd3e3e4a2f58655 Mon Sep 17 00:00:00 2001 From: Tal Regev Date: Fri, 5 Jan 2024 11:05:03 +0200 Subject: [PATCH 07/15] Add comments explain the windows workaround. --- gtsam/nonlinear/Values-inl.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtsam/nonlinear/Values-inl.h b/gtsam/nonlinear/Values-inl.h index 6da87d71c..1fe909a11 100644 --- a/gtsam/nonlinear/Values-inl.h +++ b/gtsam/nonlinear/Values-inl.h @@ -197,6 +197,8 @@ namespace gtsam { } }; +// Added this section for compile gtsam python on windows. +// msvc don't deduct the template arguments correctly, due possible bug in msvc. #ifdef _WIN32 // Handle dynamic matrices template From 3b969bf94c2e562c07e3e7c118d43dd82627cf4c Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Tue, 16 Jan 2024 15:04:09 -0500 Subject: [PATCH 08/15] Squashed 'wrap/' changes from bd57210d9..cdcf23207 cdcf23207 Merge pull request #163 from borglab/dunder-methods 22d429cc2 use STL functions instead of container methods abe8818ab update pyparsing to 3.1.1 a9e896d0c add unit tests 535fe4f14 wrap supported dunder methods 079687eac parse dunder methods in interface file git-subtree-dir: wrap git-subtree-split: cdcf23207fbb03457c5d9dbfc2b0b57e515b5f3d --- gtwrap/interface_parser/classes.py | 48 +++++++++++--- gtwrap/interface_parser/function.py | 2 +- gtwrap/interface_parser/tokens.py | 1 + gtwrap/pybind_wrapper.py | 64 +++++++++++++++++++ gtwrap/template_instantiator/classes.py | 3 + requirements.txt | 2 +- tests/expected/matlab/FastSet.m | 36 +++++++++++ tests/expected/matlab/MyFactorPosePoint2.m | 12 ++-- tests/expected/matlab/class_wrapper.cpp | 74 ++++++++++++++++++---- tests/expected/python/class_pybind.cpp | 6 ++ tests/fixtures/class.i | 9 +++ tests/test_interface_parser.py | 22 +++++-- 12 files changed, 245 insertions(+), 34 deletions(-) create mode 100644 tests/expected/matlab/FastSet.m diff --git a/gtwrap/interface_parser/classes.py b/gtwrap/interface_parser/classes.py index b63a0b5eb..8967bea93 100644 --- a/gtwrap/interface_parser/classes.py +++ b/gtwrap/interface_parser/classes.py @@ -12,13 +12,14 @@ Author: Duy Nguyen Ta, Fan Jiang, Matthew Sklar, Varun Agrawal, and Frank Dellae from typing import Any, Iterable, List, Union -from pyparsing import Literal, Optional, ZeroOrMore # type: ignore +from pyparsing import ZeroOrMore # type: ignore +from pyparsing import Literal, Optional, Word, alphas from .enum import Enum from .function import ArgumentList, ReturnType from .template import Template -from .tokens import (CLASS, COLON, CONST, IDENT, LBRACE, LPAREN, OPERATOR, - RBRACE, RPAREN, SEMI_COLON, STATIC, VIRTUAL) +from .tokens import (CLASS, COLON, CONST, DUNDER, IDENT, LBRACE, LPAREN, + OPERATOR, RBRACE, RPAREN, SEMI_COLON, STATIC, VIRTUAL) from .type import TemplatedType, Typename from .utils import collect_namespaces from .variable import Variable @@ -212,6 +213,26 @@ class Operator: ) +class DunderMethod: + """Special Python double-underscore (dunder) methods, e.g. __iter__, __contains__""" + rule = ( + DUNDER # + + (Word(alphas))("name") # + + DUNDER # + + LPAREN # + + ArgumentList.rule("args_list") # + + RPAREN # + + SEMI_COLON # BR + ).setParseAction(lambda t: DunderMethod(t.name, t.args_list)) + + def __init__(self, name: str, args: ArgumentList): + self.name = name + self.args = args + + def __repr__(self) -> str: + return f"DunderMethod: __{self.name}__({self.args})" + + class Class: """ Rule to parse a class defined in the interface file. @@ -223,11 +244,13 @@ class Class: }; ``` """ + class Members: """ Rule for all the members within a class. """ - rule = ZeroOrMore(Constructor.rule # + rule = ZeroOrMore(DunderMethod.rule # + ^ Constructor.rule # ^ Method.rule # ^ StaticMethod.rule # ^ Variable.rule # @@ -235,11 +258,12 @@ class Class: ^ Enum.rule # ).setParseAction(lambda t: Class.Members(t.asList())) - def __init__(self, - members: List[Union[Constructor, Method, StaticMethod, - Variable, Operator]]): + def __init__(self, members: List[Union[Constructor, Method, + StaticMethod, Variable, + Operator, Enum, DunderMethod]]): self.ctors = [] self.methods = [] + self.dunder_methods = [] self.static_methods = [] self.properties = [] self.operators = [] @@ -251,6 +275,8 @@ class Class: self.methods.append(m) elif isinstance(m, StaticMethod): self.static_methods.append(m) + elif isinstance(m, DunderMethod): + self.dunder_methods.append(m) elif isinstance(m, Variable): self.properties.append(m) elif isinstance(m, Operator): @@ -271,8 +297,8 @@ class Class: + SEMI_COLON # BR ).setParseAction(lambda t: Class( t.template, t.is_virtual, t.name, t.parent_class, t.members.ctors, t. - members.methods, t.members.static_methods, t.members.properties, t. - members.operators, t.members.enums)) + members.methods, t.members.static_methods, t.members.dunder_methods, t. + members.properties, t.members.operators, t.members.enums)) def __init__( self, @@ -283,6 +309,7 @@ class Class: ctors: List[Constructor], methods: List[Method], static_methods: List[StaticMethod], + dunder_methods: List[DunderMethod], properties: List[Variable], operators: List[Operator], enums: List[Enum], @@ -308,6 +335,7 @@ class Class: self.ctors = ctors self.methods = methods self.static_methods = static_methods + self.dunder_methods = dunder_methods self.properties = properties self.operators = operators self.enums = enums @@ -326,6 +354,8 @@ class Class: method.parent = self for static_method in self.static_methods: static_method.parent = self + for dunder_method in self.dunder_methods: + dunder_method.parent = self for _property in self.properties: _property.parent = self diff --git a/gtwrap/interface_parser/function.py b/gtwrap/interface_parser/function.py index b40884488..5385c744f 100644 --- a/gtwrap/interface_parser/function.py +++ b/gtwrap/interface_parser/function.py @@ -82,7 +82,7 @@ class ArgumentList: return ArgumentList([]) def __repr__(self) -> str: - return repr(tuple(self.args_list)) + return ",".join([repr(x) for x in self.args_list]) def __len__(self) -> int: return len(self.args_list) diff --git a/gtwrap/interface_parser/tokens.py b/gtwrap/interface_parser/tokens.py index 02e6d82f8..11c99d19c 100644 --- a/gtwrap/interface_parser/tokens.py +++ b/gtwrap/interface_parser/tokens.py @@ -22,6 +22,7 @@ RAW_POINTER, SHARED_POINTER, REF = map(Literal, "@*&") LPAREN, RPAREN, LBRACE, RBRACE, COLON, SEMI_COLON = map(Suppress, "(){}:;") LOPBRACK, ROPBRACK, COMMA, EQUAL = map(Suppress, "<>,=") +DUNDER = Suppress(Literal("__")) # Default argument passed to functions/methods. # Allow anything up to ',' or ';' except when they diff --git a/gtwrap/pybind_wrapper.py b/gtwrap/pybind_wrapper.py index 78730a909..479c2d67d 100755 --- a/gtwrap/pybind_wrapper.py +++ b/gtwrap/pybind_wrapper.py @@ -45,6 +45,8 @@ class PybindWrapper: 'continue', 'global', 'pass' ] + self.dunder_methods = ('len', 'contains', 'iter') + # amount of indentation to add before each function/method declaration. self.method_indent = '\n' + (' ' * 8) @@ -153,6 +155,51 @@ class PybindWrapper: suffix=suffix) return ret + def _wrap_dunder(self, + method, + cpp_class, + prefix, + suffix, + method_suffix=""): + """ + Wrap a Python double-underscore (dunder) method. + + E.g. __len__() gets wrapped as `.def("__len__", [](gtsam::KeySet* self) {return self->size();})` + + Supported methods are: + - __contains__(T x) + - __len__() + - __iter__() + """ + py_method = method.name + method_suffix + args_names = method.args.names() + py_args_names = self._py_args_names(method.args) + args_signature_with_names = self._method_args_signature(method.args) + + if method.name == 'len': + function_call = "return std::distance(self->begin(), self->end());" + elif method.name == 'contains': + function_call = f"return std::find(self->begin(), self->end(), {method.args.args_list[0].name}) != self->end();" + elif method.name == 'iter': + function_call = "return py::make_iterator(self->begin(), self->end());" + + ret = ('{prefix}.def("__{py_method}__",' + '[]({self}{opt_comma}{args_signature_with_names}){{' + '{function_call}' + '}}' + '{py_args_names}){suffix}'.format( + prefix=prefix, + py_method=py_method, + self=f"{cpp_class}* self", + opt_comma=', ' if args_names else '', + args_signature_with_names=args_signature_with_names, + function_call=function_call, + py_args_names=py_args_names, + suffix=suffix, + )) + + return ret + def _wrap_method(self, method, cpp_class, @@ -235,6 +282,20 @@ class PybindWrapper: return ret + def wrap_dunder_methods(self, + methods, + cpp_class, + prefix='\n' + ' ' * 8, + suffix=''): + res = "" + for method in methods: + res += self._wrap_dunder(method=method, + cpp_class=cpp_class, + prefix=prefix, + suffix=suffix) + + return res + def wrap_methods(self, methods, cpp_class, @@ -398,6 +459,7 @@ class PybindWrapper: '{wrapped_ctors}' '{wrapped_methods}' '{wrapped_static_methods}' + '{wrapped_dunder_methods}' '{wrapped_properties}' '{wrapped_operators};\n'.format( class_declaration=class_declaration, @@ -406,6 +468,8 @@ class PybindWrapper: instantiated_class.methods, cpp_class), wrapped_static_methods=self.wrap_methods( instantiated_class.static_methods, cpp_class), + wrapped_dunder_methods=self.wrap_dunder_methods( + instantiated_class.dunder_methods, cpp_class), wrapped_properties=self.wrap_properties( instantiated_class.properties, cpp_class), wrapped_operators=self.wrap_operators( diff --git a/gtwrap/template_instantiator/classes.py b/gtwrap/template_instantiator/classes.py index ce51d5b96..702654678 100644 --- a/gtwrap/template_instantiator/classes.py +++ b/gtwrap/template_instantiator/classes.py @@ -57,6 +57,8 @@ class InstantiatedClass(parser.Class): # Instantiate all instance methods self.methods = self.instantiate_methods(typenames) + + self.dunder_methods = original.dunder_methods super().__init__( self.template, @@ -66,6 +68,7 @@ class InstantiatedClass(parser.Class): self.ctors, self.methods, self.static_methods, + self.dunder_methods, self.properties, self.operators, self.enums, diff --git a/requirements.txt b/requirements.txt index 0aac9302e..f43fdda61 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -pyparsing==2.4.7 +pyparsing==3.1.1 pytest>=6.2.4 diff --git a/tests/expected/matlab/FastSet.m b/tests/expected/matlab/FastSet.m new file mode 100644 index 000000000..4d2a1813e --- /dev/null +++ b/tests/expected/matlab/FastSet.m @@ -0,0 +1,36 @@ +%class FastSet, see Doxygen page for details +%at https://gtsam.org/doxygen/ +% +%-------Constructors------- +%FastSet() +% +classdef FastSet < handle + properties + ptr_FastSet = 0 + end + methods + function obj = FastSet(varargin) + if nargin == 2 && isa(varargin{1}, 'uint64') && varargin{1} == uint64(5139824614673773682) + my_ptr = varargin{2}; + class_wrapper(73, my_ptr); + elseif nargin == 0 + my_ptr = class_wrapper(74); + else + error('Arguments do not match any overload of FastSet constructor'); + end + obj.ptr_FastSet = my_ptr; + end + + function delete(obj) + class_wrapper(75, obj.ptr_FastSet); + end + + function display(obj), obj.print(''); end + %DISPLAY Calls print on the object + function disp(obj), obj.display; end + %DISP Calls print on the object + end + + methods(Static = true) + end +end diff --git a/tests/expected/matlab/MyFactorPosePoint2.m b/tests/expected/matlab/MyFactorPosePoint2.m index 4a30bd489..ac5b134f9 100644 --- a/tests/expected/matlab/MyFactorPosePoint2.m +++ b/tests/expected/matlab/MyFactorPosePoint2.m @@ -15,9 +15,9 @@ classdef MyFactorPosePoint2 < handle function obj = MyFactorPosePoint2(varargin) if nargin == 2 && isa(varargin{1}, 'uint64') && varargin{1} == uint64(5139824614673773682) my_ptr = varargin{2}; - class_wrapper(73, my_ptr); + class_wrapper(76, my_ptr); elseif nargin == 4 && isa(varargin{1},'numeric') && isa(varargin{2},'numeric') && isa(varargin{3},'double') && isa(varargin{4},'gtsam.noiseModel.Base') - my_ptr = class_wrapper(74, varargin{1}, varargin{2}, varargin{3}, varargin{4}); + my_ptr = class_wrapper(77, varargin{1}, varargin{2}, varargin{3}, varargin{4}); else error('Arguments do not match any overload of MyFactorPosePoint2 constructor'); end @@ -25,7 +25,7 @@ classdef MyFactorPosePoint2 < handle end function delete(obj) - class_wrapper(75, obj.ptr_MyFactorPosePoint2); + class_wrapper(78, obj.ptr_MyFactorPosePoint2); end function display(obj), obj.print(''); end @@ -36,19 +36,19 @@ classdef MyFactorPosePoint2 < handle % PRINT usage: print(string s, KeyFormatter keyFormatter) : returns void % Doxygen can be found at https://gtsam.org/doxygen/ if length(varargin) == 2 && isa(varargin{1},'char') && isa(varargin{2},'gtsam.KeyFormatter') - class_wrapper(76, this, varargin{:}); + class_wrapper(79, this, varargin{:}); return end % PRINT usage: print(string s) : returns void % Doxygen can be found at https://gtsam.org/doxygen/ if length(varargin) == 1 && isa(varargin{1},'char') - class_wrapper(77, this, varargin{:}); + class_wrapper(80, this, varargin{:}); return end % PRINT usage: print() : returns void % Doxygen can be found at https://gtsam.org/doxygen/ if length(varargin) == 0 - class_wrapper(78, this, varargin{:}); + class_wrapper(81, this, varargin{:}); return end error('Arguments do not match any overload of function MyFactorPosePoint2.print'); diff --git a/tests/expected/matlab/class_wrapper.cpp b/tests/expected/matlab/class_wrapper.cpp index c4be52018..e33f14238 100644 --- a/tests/expected/matlab/class_wrapper.cpp +++ b/tests/expected/matlab/class_wrapper.cpp @@ -31,6 +31,8 @@ typedef std::set*> Collector_ForwardKinematic static Collector_ForwardKinematics collector_ForwardKinematics; typedef std::set*> Collector_TemplatedConstructor; static Collector_TemplatedConstructor collector_TemplatedConstructor; +typedef std::set*> Collector_FastSet; +static Collector_FastSet collector_FastSet; typedef std::set*> Collector_MyFactorPosePoint2; static Collector_MyFactorPosePoint2 collector_MyFactorPosePoint2; @@ -101,6 +103,12 @@ void _deleteAllObjects() collector_TemplatedConstructor.erase(iter++); anyDeleted = true; } } + { for(Collector_FastSet::iterator iter = collector_FastSet.begin(); + iter != collector_FastSet.end(); ) { + delete *iter; + collector_FastSet.erase(iter++); + anyDeleted = true; + } } { for(Collector_MyFactorPosePoint2::iterator iter = collector_MyFactorPosePoint2.begin(); iter != collector_MyFactorPosePoint2.end(); ) { delete *iter; @@ -844,7 +852,40 @@ void TemplatedConstructor_deconstructor_72(int nargout, mxArray *out[], int narg delete self; } -void MyFactorPosePoint2_collectorInsertAndMakeBase_73(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +void FastSet_collectorInsertAndMakeBase_73(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +{ + mexAtExit(&_deleteAllObjects); + typedef std::shared_ptr Shared; + + Shared *self = *reinterpret_cast (mxGetData(in[0])); + collector_FastSet.insert(self); +} + +void FastSet_constructor_74(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +{ + mexAtExit(&_deleteAllObjects); + typedef std::shared_ptr Shared; + + Shared *self = new Shared(new FastSet()); + collector_FastSet.insert(self); + out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL); + *reinterpret_cast (mxGetData(out[0])) = self; +} + +void FastSet_deconstructor_75(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +{ + typedef std::shared_ptr Shared; + checkArguments("delete_FastSet",nargout,nargin,1); + Shared *self = *reinterpret_cast(mxGetData(in[0])); + Collector_FastSet::iterator item; + item = collector_FastSet.find(self); + if(item != collector_FastSet.end()) { + collector_FastSet.erase(item); + } + delete self; +} + +void MyFactorPosePoint2_collectorInsertAndMakeBase_76(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { mexAtExit(&_deleteAllObjects); typedef std::shared_ptr> Shared; @@ -853,7 +894,7 @@ void MyFactorPosePoint2_collectorInsertAndMakeBase_73(int nargout, mxArray *out[ collector_MyFactorPosePoint2.insert(self); } -void MyFactorPosePoint2_constructor_74(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +void MyFactorPosePoint2_constructor_77(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { mexAtExit(&_deleteAllObjects); typedef std::shared_ptr> Shared; @@ -868,7 +909,7 @@ void MyFactorPosePoint2_constructor_74(int nargout, mxArray *out[], int nargin, *reinterpret_cast (mxGetData(out[0])) = self; } -void MyFactorPosePoint2_deconstructor_75(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +void MyFactorPosePoint2_deconstructor_78(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { typedef std::shared_ptr> Shared; checkArguments("delete_MyFactorPosePoint2",nargout,nargin,1); @@ -881,7 +922,7 @@ void MyFactorPosePoint2_deconstructor_75(int nargout, mxArray *out[], int nargin delete self; } -void MyFactorPosePoint2_print_76(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +void MyFactorPosePoint2_print_79(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { checkArguments("print",nargout,nargin-1,2); auto obj = unwrap_shared_ptr>(in[0], "ptr_MyFactorPosePoint2"); @@ -890,7 +931,7 @@ void MyFactorPosePoint2_print_76(int nargout, mxArray *out[], int nargin, const obj->print(s,keyFormatter); } -void MyFactorPosePoint2_print_77(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +void MyFactorPosePoint2_print_80(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { checkArguments("print",nargout,nargin-1,1); auto obj = unwrap_shared_ptr>(in[0], "ptr_MyFactorPosePoint2"); @@ -898,7 +939,7 @@ void MyFactorPosePoint2_print_77(int nargout, mxArray *out[], int nargin, const obj->print(s,gtsam::DefaultKeyFormatter); } -void MyFactorPosePoint2_print_78(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +void MyFactorPosePoint2_print_81(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { checkArguments("print",nargout,nargin-1,0); auto obj = unwrap_shared_ptr>(in[0], "ptr_MyFactorPosePoint2"); @@ -1137,22 +1178,31 @@ void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[]) TemplatedConstructor_deconstructor_72(nargout, out, nargin-1, in+1); break; case 73: - MyFactorPosePoint2_collectorInsertAndMakeBase_73(nargout, out, nargin-1, in+1); + FastSet_collectorInsertAndMakeBase_73(nargout, out, nargin-1, in+1); break; case 74: - MyFactorPosePoint2_constructor_74(nargout, out, nargin-1, in+1); + FastSet_constructor_74(nargout, out, nargin-1, in+1); break; case 75: - MyFactorPosePoint2_deconstructor_75(nargout, out, nargin-1, in+1); + FastSet_deconstructor_75(nargout, out, nargin-1, in+1); break; case 76: - MyFactorPosePoint2_print_76(nargout, out, nargin-1, in+1); + MyFactorPosePoint2_collectorInsertAndMakeBase_76(nargout, out, nargin-1, in+1); break; case 77: - MyFactorPosePoint2_print_77(nargout, out, nargin-1, in+1); + MyFactorPosePoint2_constructor_77(nargout, out, nargin-1, in+1); break; case 78: - MyFactorPosePoint2_print_78(nargout, out, nargin-1, in+1); + MyFactorPosePoint2_deconstructor_78(nargout, out, nargin-1, in+1); + break; + case 79: + MyFactorPosePoint2_print_79(nargout, out, nargin-1, in+1); + break; + case 80: + MyFactorPosePoint2_print_80(nargout, out, nargin-1, in+1); + break; + case 81: + MyFactorPosePoint2_print_81(nargout, out, nargin-1, in+1); break; } } catch(const std::exception& e) { diff --git a/tests/expected/python/class_pybind.cpp b/tests/expected/python/class_pybind.cpp index 86d69c2e0..2292f46be 100644 --- a/tests/expected/python/class_pybind.cpp +++ b/tests/expected/python/class_pybind.cpp @@ -91,6 +91,12 @@ PYBIND11_MODULE(class_py, m_) { .def(py::init(), py::arg("arg")) .def(py::init(), py::arg("arg")); + py::class_>(m_, "FastSet") + .def(py::init<>()) + .def("__len__",[](FastSet* self){return std::distance(self->begin(), self->end());}) + .def("__contains__",[](FastSet* self, size_t key){return std::find(self->begin(), self->end(), key) != self->end();}, py::arg("key")) + .def("__iter__",[](FastSet* self){return py::make_iterator(self->begin(), self->end());}); + py::class_, std::shared_ptr>>(m_, "MyFactorPosePoint2") .def(py::init>(), py::arg("key1"), py::arg("key2"), py::arg("measured"), py::arg("noiseModel")) .def("print",[](MyFactor* self, const string& s, const gtsam::KeyFormatter& keyFormatter){ py::scoped_ostream_redirect output; self->print(s, keyFormatter);}, py::arg("s") = "factor: ", py::arg("keyFormatter") = gtsam::DefaultKeyFormatter) diff --git a/tests/fixtures/class.i b/tests/fixtures/class.i index 766f55329..775bbc737 100644 --- a/tests/fixtures/class.i +++ b/tests/fixtures/class.i @@ -145,3 +145,12 @@ class TemplatedConstructor { class SuperCoolFactor; typedef SuperCoolFactor SuperCoolFactorPose3; + +/// @brief class with dunder methods for container behavior +class FastSet { + FastSet(); + + __len__(); + __contains__(size_t key); + __iter__(); +}; \ No newline at end of file diff --git a/tests/test_interface_parser.py b/tests/test_interface_parser.py index 45415995f..2a923b3c5 100644 --- a/tests/test_interface_parser.py +++ b/tests/test_interface_parser.py @@ -18,11 +18,12 @@ import unittest sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from gtwrap.interface_parser import (ArgumentList, Class, Constructor, Enum, - Enumerator, ForwardDeclaration, - GlobalFunction, Include, Method, Module, - Namespace, Operator, ReturnType, - StaticMethod, TemplatedType, Type, +from gtwrap.interface_parser import (ArgumentList, Class, Constructor, + DunderMethod, Enum, Enumerator, + ForwardDeclaration, GlobalFunction, + Include, Method, Module, Namespace, + Operator, ReturnType, StaticMethod, + TemplatedType, Type, TypedefTemplateInstantiation, Typename, Variable) from gtwrap.template_instantiator.classes import InstantiatedClass @@ -344,6 +345,17 @@ class TestInterfaceParser(unittest.TestCase): self.assertEqual(1, len(ret.args)) self.assertEqual("const T & name", ret.args.args_list[0].to_cpp()) + def test_dunder_method(self): + """Test for special python dunder methods.""" + iter_string = "__iter__();" + ret = DunderMethod.rule.parse_string(iter_string)[0] + self.assertEqual("iter", ret.name) + + contains_string = "__contains__(size_t key);" + ret = DunderMethod.rule.parse_string(contains_string)[0] + self.assertEqual("contains", ret.name) + self.assertTrue(len(ret.args) == 1) + def test_operator_overload(self): """Test for operator overloading.""" # Unary operator From f4ea5511535b21b203d9c540bceb4d2c0c80145c Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Tue, 16 Jan 2024 15:17:16 -0500 Subject: [PATCH 09/15] add dunder methods to interface file --- gtsam/gtsam.i | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gtsam/gtsam.i b/gtsam/gtsam.i index 834d5a147..9cead2a1c 100644 --- a/gtsam/gtsam.i +++ b/gtsam/gtsam.i @@ -39,6 +39,11 @@ class KeyList { void remove(size_t key); void serialize() const; + + // Specual dunder methods for Python wrapping + __len__(); + __contains__(size_t key); + __iter__(); }; // Actually a FastSet @@ -64,6 +69,11 @@ class KeySet { bool count(size_t key) const; // returns true if value exists void serialize() const; + + // Specual dunder methods for Python wrapping + __len__(); + __contains__(size_t key); + __iter__(); }; // Actually a vector, needed for Matlab @@ -85,6 +95,11 @@ class KeyVector { void push_back(size_t key) const; void serialize() const; + + // Specual dunder methods for Python wrapping + __len__(); + __contains__(size_t key); + __iter__(); }; // Actually a FastMap From b2e4fa2112397f5120e113e90670dea6c84d6d07 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Tue, 16 Jan 2024 15:17:26 -0500 Subject: [PATCH 10/15] tests for dunder methods --- python/gtsam/tests/test_Utilities.py | 36 +++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/python/gtsam/tests/test_Utilities.py b/python/gtsam/tests/test_Utilities.py index 851684f12..3dd472c75 100644 --- a/python/gtsam/tests/test_Utilities.py +++ b/python/gtsam/tests/test_Utilities.py @@ -12,13 +12,14 @@ Author: Varun Agrawal import unittest import numpy as np +from gtsam.utils.test_case import GtsamTestCase import gtsam -from gtsam.utils.test_case import GtsamTestCase class TestUtilites(GtsamTestCase): """Test various GTSAM utilities.""" + def test_createKeyList(self): """Test createKeyList.""" I = [0, 1, 2] @@ -28,6 +29,17 @@ class TestUtilites(GtsamTestCase): kl = gtsam.utilities.createKeyList("s", I) self.assertEqual(kl.size(), 3) + def test_KeyList_iteration(self): + """Tests for KeyList iteration""" + I = [0, 1, 2] + kl = gtsam.utilities.createKeyList(I) + + self.assertEqual(len(kl), len(I)) + + for i, key in enumerate(kl): + self.assertTrue(key in kl) + self.assertEqual(I[i], key) + def test_createKeyVector(self): """Test createKeyVector.""" I = [0, 1, 2] @@ -37,6 +49,17 @@ class TestUtilites(GtsamTestCase): kl = gtsam.utilities.createKeyVector("s", I) self.assertEqual(len(kl), 3) + def test_KeyVector_iteration(self): + """Tests for KeyVector iteration""" + I = [0, 1, 2] + kv = gtsam.utilities.createKeyVector(I) + + self.assertEqual(len(kv), len(I)) + + for i, key in enumerate(kv): + self.assertTrue(key in kv) + self.assertEqual(I[i], key) + def test_createKeySet(self): """Test createKeySet.""" I = [0, 1, 2] @@ -46,6 +69,17 @@ class TestUtilites(GtsamTestCase): kl = gtsam.utilities.createKeySet("s", I) self.assertEqual(kl.size(), 3) + def test_KeySet_iteration(self): + """Tests for KeySet iteration""" + I = [0, 1, 2] + ks = gtsam.utilities.createKeySet(I) + + self.assertEqual(len(ks), len(I)) + + for i, key in enumerate(ks): + self.assertTrue(key in ks) + self.assertEqual(I[i], key) + def test_extractPoint2(self): """Test extractPoint2.""" initial = gtsam.Values() From b104fd66901d63ce27949a311bf2b720d78e9d75 Mon Sep 17 00:00:00 2001 From: Tal Regev Date: Tue, 16 Jan 2024 22:36:08 +0200 Subject: [PATCH 11/15] fail-fast: true --- .github/workflows/build-python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-python.yml b/.github/workflows/build-python.yml index bb10b27c3..520e94c09 100644 --- a/.github/workflows/build-python.yml +++ b/.github/workflows/build-python.yml @@ -22,7 +22,7 @@ jobs: BOOST_EXE: boost_1_72_0-msvc-14.2 strategy: - fail-fast: false + fail-fast: true matrix: # Github Actions requires a single row to be added to the build matrix. # See https://help.github.com/en/articles/workflow-syntax-for-github-actions. From 1979f027d5994893e952906e8e2d80428cac90a1 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Tue, 16 Jan 2024 15:46:01 -0500 Subject: [PATCH 12/15] fix comment typo --- gtsam/gtsam.i | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gtsam/gtsam.i b/gtsam/gtsam.i index 9cead2a1c..6d77e8eda 100644 --- a/gtsam/gtsam.i +++ b/gtsam/gtsam.i @@ -40,7 +40,7 @@ class KeyList { void serialize() const; - // Specual dunder methods for Python wrapping + // Special dunder methods for Python wrapping __len__(); __contains__(size_t key); __iter__(); @@ -70,7 +70,7 @@ class KeySet { void serialize() const; - // Specual dunder methods for Python wrapping + // Special dunder methods for Python wrapping __len__(); __contains__(size_t key); __iter__(); @@ -96,7 +96,7 @@ class KeyVector { void serialize() const; - // Specual dunder methods for Python wrapping + // Special dunder methods for Python wrapping __len__(); __contains__(size_t key); __iter__(); From 6cc16a3943f48992c0090e9ebe88f8c13ac7407c Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Tue, 16 Jan 2024 19:32:20 -0500 Subject: [PATCH 13/15] delete cephes_names.h to remove collisions --- gtsam/3rdparty/cephes/CMakeLists.txt | 1 - gtsam/3rdparty/cephes/cephes.h | 1 - gtsam/3rdparty/cephes/cephes/cephes_names.h | 114 -------------------- gtsam/3rdparty/cephes/cephes/mconf.h | 1 - 4 files changed, 117 deletions(-) delete mode 100644 gtsam/3rdparty/cephes/cephes/cephes_names.h diff --git a/gtsam/3rdparty/cephes/CMakeLists.txt b/gtsam/3rdparty/cephes/CMakeLists.txt index 946448160..5940d39d2 100644 --- a/gtsam/3rdparty/cephes/CMakeLists.txt +++ b/gtsam/3rdparty/cephes/CMakeLists.txt @@ -8,7 +8,6 @@ project( set(CEPHES_HEADER_FILES cephes.h - cephes/cephes_names.h cephes/dd_idefs.h cephes/dd_real.h cephes/dd_real_idefs.h diff --git a/gtsam/3rdparty/cephes/cephes.h b/gtsam/3rdparty/cephes/cephes.h index d5b59d895..ed53e521b 100644 --- a/gtsam/3rdparty/cephes/cephes.h +++ b/gtsam/3rdparty/cephes/cephes.h @@ -1,7 +1,6 @@ #ifndef CEPHES_H #define CEPHES_H -#include "cephes/cephes_names.h" #include "dllexport.h" #ifdef __cplusplus diff --git a/gtsam/3rdparty/cephes/cephes/cephes_names.h b/gtsam/3rdparty/cephes/cephes/cephes_names.h deleted file mode 100644 index 94be8c880..000000000 --- a/gtsam/3rdparty/cephes/cephes/cephes_names.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef CEPHES_NAMES_H -#define CEPHES_NAMES_H - -#define airy cephes_airy -#define bdtrc cephes_bdtrc -#define bdtr cephes_bdtr -#define bdtri cephes_bdtri -#define besselpoly cephes_besselpoly -#define beta cephes_beta -#define lbeta cephes_lbeta -#define btdtr cephes_btdtr -#define cbrt cephes_cbrt -#define chdtrc cephes_chdtrc -#define chbevl cephes_chbevl -#define chdtr cephes_chdtr -#define chdtri cephes_chdtri -#define dawsn cephes_dawsn -#define ellie cephes_ellie -#define ellik cephes_ellik -#define ellpe cephes_ellpe -#define ellpj cephes_ellpj -#define ellpk cephes_ellpk -#define exp10 cephes_exp10 -#define exp2 cephes_exp2 -#define expn cephes_expn -#define fdtrc cephes_fdtrc -#define fdtr cephes_fdtr -#define fdtri cephes_fdtri -#define fresnl cephes_fresnl -#define Gamma cephes_Gamma -#define lgam cephes_lgam -#define lgam_sgn cephes_lgam_sgn -#define gammasgn cephes_gammasgn -#define gdtr cephes_gdtr -#define gdtrc cephes_gdtrc -#define gdtri cephes_gdtri -#define hyp2f1 cephes_hyp2f1 -#define hyperg cephes_hyperg -#define i0 cephes_i0 -#define i0e cephes_i0e -#define i1 cephes_i1 -#define i1e cephes_i1e -#define igamc cephes_igamc -#define igam cephes_igam -#define igami cephes_igami -#define incbet cephes_incbet -#define incbi cephes_incbi -#define iv cephes_iv -#define j0 cephes_j0 -#define y0 cephes_y0 -#define j1 cephes_j1 -#define y1 cephes_y1 -#define jn cephes_jn -#define jv cephes_jv -#define k0 cephes_k0 -#define k0e cephes_k0e -#define k1 cephes_k1 -#define k1e cephes_k1e -#define kn cephes_kn -#define nbdtrc cephes_nbdtrc -#define nbdtr cephes_nbdtr -#define nbdtri cephes_nbdtri -#define ndtr cephes_ndtr -#define erfc cephes_erfc -#define erf cephes_erf -#define erfinv cephes_erfinv -#define erfcinv cephes_erfcinv -#define ndtri cephes_ndtri -#define pdtrc cephes_pdtrc -#define pdtr cephes_pdtr -#define pdtri cephes_pdtri -#define poch cephes_poch -#define psi cephes_psi -#define rgamma cephes_rgamma -#define riemann_zeta cephes_riemann_zeta -// #define round cephes_round // Commented out since it clashes with std::round -#define shichi cephes_shichi -#define sici cephes_sici -#define radian cephes_radian -#define sindg cephes_sindg -#define sinpi cephes_sinpi -#define cosdg cephes_cosdg -#define cospi cephes_cospi -#define sincos cephes_sincos -#define spence cephes_spence -#define stdtr cephes_stdtr -#define stdtri cephes_stdtri -#define struve_h cephes_struve_h -#define struve_l cephes_struve_l -#define struve_power_series cephes_struve_power_series -#define struve_asymp_large_z cephes_struve_asymp_large_z -#define struve_bessel_series cephes_struve_bessel_series -#define yv cephes_yv -#define tandg cephes_tandg -#define cotdg cephes_cotdg -#define log1p cephes_log1p -#define expm1 cephes_expm1 -#define cosm1 cephes_cosm1 -#define yn cephes_yn -#define zeta cephes_zeta -#define zetac cephes_zetac -#define smirnov cephes_smirnov -#define smirnovc cephes_smirnovc -#define smirnovi cephes_smirnovi -#define smirnovci cephes_smirnovci -#define smirnovp cephes_smirnovp -#define kolmogorov cephes_kolmogorov -#define kolmogi cephes_kolmogi -#define kolmogp cephes_kolmogp -#define kolmogc cephes_kolmogc -#define kolmogci cephes_kolmogci -#define owens_t cephes_owens_t - -#endif diff --git a/gtsam/3rdparty/cephes/cephes/mconf.h b/gtsam/3rdparty/cephes/cephes/mconf.h index c59d17a47..5e971afad 100644 --- a/gtsam/3rdparty/cephes/cephes/mconf.h +++ b/gtsam/3rdparty/cephes/cephes/mconf.h @@ -56,7 +56,6 @@ #include #include -#include "cephes_names.h" #include "cephes.h" #include "polevl.h" #include "sf_error.h" From 6680d7de4cdc8dd5ed3222cec4aad19d26da893d Mon Sep 17 00:00:00 2001 From: Tal Regev Date: Wed, 17 Jan 2024 08:03:39 +0200 Subject: [PATCH 14/15] remove swap from python ci --- .github/workflows/build-python.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/build-python.yml b/.github/workflows/build-python.yml index 520e94c09..de9d755ba 100644 --- a/.github/workflows/build-python.yml +++ b/.github/workflows/build-python.yml @@ -145,12 +145,6 @@ jobs: echo "GTSAM_WITH_TBB=ON" >> $GITHUB_ENV echo "GTSAM Uses TBB" - - name: Set Swap Space (Linux) - if: runner.os == 'Linux' - uses: pierotofy/set-swap-space@master - with: - swap-size-gb: 6 - - name: Install System Dependencies (Linux, macOS) if: runner.os != 'Windows' run: | From 046a9f5b436a206fecc356fb36456fe1bb4c3df8 Mon Sep 17 00:00:00 2001 From: Tal Regev Date: Fri, 26 Jan 2024 11:58:14 +0200 Subject: [PATCH 15/15] Ubuntu 22.04 for python tbb. hopefully will solve the hang problem. --- .github/workflows/build-python.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-python.yml b/.github/workflows/build-python.yml index de9d755ba..d8dfce0ee 100644 --- a/.github/workflows/build-python.yml +++ b/.github/workflows/build-python.yml @@ -29,7 +29,7 @@ jobs: name: [ ubuntu-20.04-gcc-9, - ubuntu-20.04-gcc-9-tbb, + ubuntu-22.04-gcc-9-tbb, ubuntu-20.04-clang-9, macOS-11-xcode-13.4.1, windows-2019-msbuild, @@ -43,8 +43,8 @@ jobs: compiler: gcc version: "9" - - name: ubuntu-20.04-gcc-9-tbb - os: ubuntu-20.04 + - name: ubuntu-22.04-gcc-9-tbb + os: ubuntu-22.04 compiler: gcc version: "9" flag: tbb