Skip to main content

gtsam-nb: nanobind bindings for GTSAM

PyPI - Version Static Badge GitHub Actions Workflow Status

This repository provides Python bindings for GTSAM using nanobind.

Most of the code, tests, data, etc. are originally from the official GTSAM repository, just slightly modified to work with nanobind and clean up python typing.

Installation

It's all available via pip!

pip install gtsam-nb  # if using pip
uv add gtsam-nb       # if using uv

Then use as you would the official gtsam Python bindings:

import gtsam

gtsam-nb should be a near drop-in replacement for the official gtsam python package, with the following (mostly minor) exceptions:

  • Unlike pybind11, nanobind doesn't accept python lists in place of numpy arrays for function arguments. So wrapping lists in np.array(...) is necessary.
  • OrderingType enum values are now accessed as gtsam.OrderingType.XXX instead of gtsam.Ordering.OrderingType.XXX.
  • lambda_ is now lambda_a in gtsam.LevenbergMarquardtOptimizer due to how nanobind handles private methods.
  • [FEAT] NonlinearFactorGraph and Values interface more like a python list and dict, respectively including constructors and [] usage.

There are likely other tweaks required (please let us know if you find any), but they should all be fairly minor.

Why?

There's a handful of reasons why I decided to make this (most of which should hopefully be resolved when gtsam 4.3 is released):

  • As of the writing of this README, gtsam's most recent python release only supports up to python 3.11. This has restricted the python version for a number of my projects.
  • In addition, the current stable gtsam on pypi are incompatible with numpy>=2.0.
  • The gtsam python bindings don't include type stubs, making development in an IDE and type checking more difficult.
  • A switch to nanobind over pybind11 for a number of reasons, including
    • nanobind results in faster compilation, smaller binaries, and a smaller overhead. See benchmarks for more details.
    • nanobind has built-in stub generation, make setting up type stubs a cakewalk.
    • Based on my knowledge, nanobind has a more permissive ABI compatibility story than pybind11, which makes it easier to extend gtsam with custom C++ code that will just work together. See here and here.
    • Since all my projects now use nanobind, if I want to add new C++ factors to GTSAM from python, I need nanobind bindings.
  • I often have found the gtsam bindings to be missing a method or two that I need. This then requires me to build the bindings from source. By having my own version, I can easily add in any missing methods I need, and get them merged and released on PyPI quickly. This is more difficult for the official gtsam bindings since they are released alongside GTSAM itself.

Hopefully in the future these issues will be resolved in the official gtsam bindings, and this repository will no longer be necessary. But for now, this is a useful stopgap.

Building

Building is all piped through scikit-build-core (which we use behind uv). The only dependency is GTSAM 4.2, which will be resolved in the following order:

  1. If vcpkg.sh was ran to clone vcpkg into the .vcpkg folder, then GTSAM will be built and installed via vcpkg.
  2. If not, GTSAM is searched for in the system paths.
  3. If not found, GTSAM will be cloned and built from source in the build process.

To actually perform the building from source, clone the repository and run:

pip install -e .   # if using pip
uv sync --verbose  # if using uv

This will build the C++ extension and install the package in editable mode in whatever environment you have activated.

Contributing

There is likely a hidden bug or two, and definitely still some missing methods. Please feel free to open issues or PRs! I imagine most PRs will be to add missing methods or classes from GTSAM so they can be merged and released quickly (especially since it's all automated through our CI setup).

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

gtsam_nb-0.1.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.4 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

gtsam_nb-0.1.4-cp314-cp314-macosx_11_0_arm64.whl (15.4 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

gtsam_nb-0.1.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

gtsam_nb-0.1.4-cp313-cp313-macosx_11_0_arm64.whl (15.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

gtsam_nb-0.1.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

gtsam_nb-0.1.4-cp312-cp312-macosx_11_0_arm64.whl (15.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

gtsam_nb-0.1.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

gtsam_nb-0.1.4-cp311-cp311-macosx_11_0_arm64.whl (15.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file gtsam_nb-0.1.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gtsam_nb-0.1.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ce13d78a4333520afa3c743c77f0f80f3debe85f75c16ab9400754a53001a3f8
MD5 e31e2da634eae3e981a1fc7fc169688f
BLAKE2b-256 3627ebf2d655256d0f6453de85aea4ad0003c6a294d68ce181bef3eea42496cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtsam_nb-0.1.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: on_main.yml on contagon/gtsam-nb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtsam_nb-0.1.4-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gtsam_nb-0.1.4-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0374051f9d6cc67edd547122429a1c9924775d19e353a77b792e6737478b2658
MD5 be52701b48768c5a20dfb8056637b64b
BLAKE2b-256 44f227862ba0e2e0db18fe6dae03195cd5c69735087900af4f455ee84c999660

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtsam_nb-0.1.4-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: on_main.yml on contagon/gtsam-nb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtsam_nb-0.1.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gtsam_nb-0.1.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e39664c6532e5e610f2d246455f0a66cbc445025be5f932b028f63f6cf04f199
MD5 314eda51ff25558c4e29fb209e6c36c4
BLAKE2b-256 809841460ae7958b44bbb655c1b709d61894ace8aa48b907e4d4213b8fc830a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtsam_nb-0.1.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: on_main.yml on contagon/gtsam-nb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtsam_nb-0.1.4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gtsam_nb-0.1.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a9f3e09db8e661b5aeb6871a96c7cf68540b0f9398cd41a26075d9bbf0251beb
MD5 a1725a4a6b1ddc682c41ff2f6db55694
BLAKE2b-256 0aa48c0c86674b7e4de26d97511778796e8064d32f7dbc04cb34a77a38117817

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtsam_nb-0.1.4-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: on_main.yml on contagon/gtsam-nb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtsam_nb-0.1.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gtsam_nb-0.1.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a8eb8bd095957a2c7a04a5628f3b262de849c4922720fed6fedad433d373ca37
MD5 80b90b377abef535d36648e93c985e15
BLAKE2b-256 f291efe5dc7e4502bfbeaaeb677b68f86b6c9abc7a5c191119e88043f9592004

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtsam_nb-0.1.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: on_main.yml on contagon/gtsam-nb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtsam_nb-0.1.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gtsam_nb-0.1.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bedea298637036d65f954a03385e6ff614d5a26db3206a60e52d50af4b11a8d9
MD5 1e62537530cea0962d2b3cb4e033198b
BLAKE2b-256 426e3482539b2a5080d21aa7db17f84c2102c4948242f4cd6edf98d358555ed2

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtsam_nb-0.1.4-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: on_main.yml on contagon/gtsam-nb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtsam_nb-0.1.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gtsam_nb-0.1.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 03287e05b0a1c8638fb55beee6be803aab42bbc23def9fb41c2db574260ed011
MD5 8664c933028b0623d7c9f067f186fffe
BLAKE2b-256 0bc2e3d2c7a3486bbbf4281b63f3399a52384932e9f2d62e321f8402bdd26d88

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtsam_nb-0.1.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: on_main.yml on contagon/gtsam-nb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtsam_nb-0.1.4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gtsam_nb-0.1.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b69e69c43f2d4585684c715ccf623cef657d7a0871e7124ac0e4b14e64aa3798
MD5 f17c481371b0ee88d7bbaf3eaf8c0707
BLAKE2b-256 49b42e0ab7d015d468d6080ca158553702da326f1f873e48f934558abff6a7ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtsam_nb-0.1.4-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: on_main.yml on contagon/gtsam-nb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page