Skip to content

Example project showing how to interface C/C++ arrays and classes with Numpy using SWIG

License

Notifications You must be signed in to change notification settings

AUK1939/swig-numpy-example

 
 

Repository files navigation

Python/Numpy Wrapper Example

A simple project showing how to wrap a C/C++ library in Numpy using SWIG.

The examples in the documentation are good, but simple, and don't make clear the subtleties associated with wrapping realistic functions using Numpy arrays (e.g., what if we want to take in two arrays as arguments?). This project contains a collection of example functions for several common function signatures, both inside and outside of classes. It also contains notes on steps I found necessary in getting all of this working.

Other resources for SWIG + Python include the Scipy SWIG documentation, the Numpy SWIG tests, this example of wrapping C++ in Numpy, limix, Eigen3Swig, and Swig-Eigen-Numpy.

To run the tests, do:

$ python test.py

If you need additional functionality, consider prototyping it using this project and submitting a pull request once it's working. This way others can use it as well (and you will be my hero).

About

Example project showing how to interface C/C++ arrays and classes with Numpy using SWIG

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 86.3%
  • C++ 7.6%
  • Python 6.1%