removed unneeded install commands and updated README
parent
59968fddc5
commit
a6908cd1cb
|
@ -197,13 +197,3 @@ function(install_cython_scripts source_directory dest_directory patterns)
|
||||||
file(COPY "${source_directory}" DESTINATION "${dest_directory}"
|
file(COPY "${source_directory}" DESTINATION "${dest_directory}"
|
||||||
FILES_MATCHING ${patterns_args} PATTERN "${exclude_patterns}" EXCLUDE)
|
FILES_MATCHING ${patterns_args} PATTERN "${exclude_patterns}" EXCLUDE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Helper function to install specific files and handle multiple build types where the scripts
|
|
||||||
# should be installed to all build type toolboxes
|
|
||||||
#
|
|
||||||
# Arguments:
|
|
||||||
# source_files: The source files to be installed.
|
|
||||||
# dest_directory: The destination directory to install to.
|
|
||||||
function(install_cython_files source_files dest_directory)
|
|
||||||
file(COPY "${source_files}" DESTINATION "${dest_directory}")
|
|
||||||
endfunction()
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ if (GTSAM_INSTALL_CYTHON_TOOLBOX)
|
||||||
configure_file(${PROJECT_SOURCE_DIR}/cython/gtsam/__init__.py ${GTSAM_CYTHON_INSTALL_PATH}/gtsam/__init__.py COPYONLY)
|
configure_file(${PROJECT_SOURCE_DIR}/cython/gtsam/__init__.py ${GTSAM_CYTHON_INSTALL_PATH}/gtsam/__init__.py COPYONLY)
|
||||||
configure_file(${PROJECT_SOURCE_DIR}/cython/gtsam_unstable/__init__.py ${GTSAM_CYTHON_INSTALL_PATH}/gtsam_unstable/__init__.py COPYONLY)
|
configure_file(${PROJECT_SOURCE_DIR}/cython/gtsam_unstable/__init__.py ${GTSAM_CYTHON_INSTALL_PATH}/gtsam_unstable/__init__.py COPYONLY)
|
||||||
configure_file(${PROJECT_SOURCE_DIR}/cython/setup.py.in ${GTSAM_CYTHON_INSTALL_PATH}/setup.py)
|
configure_file(${PROJECT_SOURCE_DIR}/cython/setup.py.in ${GTSAM_CYTHON_INSTALL_PATH}/setup.py)
|
||||||
install_cython_files("${PROJECT_BINARY_DIR}/cython/setup.py" "${GTSAM_CYTHON_INSTALL_PATH}")
|
|
||||||
|
|
||||||
# Wrap gtsam
|
# Wrap gtsam
|
||||||
add_custom_target(gtsam_header DEPENDS "../gtsam.h")
|
add_custom_target(gtsam_header DEPENDS "../gtsam.h")
|
||||||
|
|
|
@ -4,43 +4,48 @@ This is the Python wrapper around the GTSAM C++ library. We use Cython to genera
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- If you want to build the gtsam python library for a specific python version (eg 2.7), use the `-DGTSAM_PYTHON_VERSION=2.7` option when running `cmake` otherwise the default interpreter will be used.
|
- If you want to build the GTSAM python library for a specific python version (eg 3.6),
|
||||||
- If the interpreter is inside an environment (such as an anaconda environment or virtualenv environment) then the environment should be active while building gtsam.
|
use the `-DGTSAM_PYTHON_VERSION=3.6` option when running `cmake` otherwise the default interpreter will be used.
|
||||||
|
- If the interpreter is inside an environment (such as an anaconda environment or virtualenv environment),
|
||||||
|
then the environment should be active while building GTSAM.
|
||||||
- This wrapper needs `Cython(>=0.25.2)`, `backports_abc(>=0.5)`, and `numpy(>=1.11.0)`. These can be installed as follows:
|
- This wrapper needs `Cython(>=0.25.2)`, `backports_abc(>=0.5)`, and `numpy(>=1.11.0)`. These can be installed as follows:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install -r <gtsam_folder>/cython/requirements.txt
|
pip install -r <gtsam_folder>/cython/requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
- For compatibility with gtsam's Eigen version, it contains its own cloned version of [Eigency](https://github.com/wouterboomsma/eigency.git),
|
- For compatibility with GTSAM's Eigen version, it contains its own cloned version of [Eigency](https://github.com/wouterboomsma/eigency.git),
|
||||||
named `gtsam_eigency`, to interface between C++'s Eigen and Python's numpy.
|
named `gtsam_eigency`, to interface between C++'s Eigen and Python's numpy.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
- Run cmake with the `GTSAM_INSTALL_CYTHON_TOOLBOX` cmake flag enabled to configure building the wrapper. The wrapped module will be built and copied to the directory defined by `GTSAM_CYTHON_INSTALL_PATH`, which is by default: `<CMAKE_INSTALL_PREFIX>/cython.build`.
|
- Run cmake with the `GTSAM_INSTALL_CYTHON_TOOLBOX` cmake flag enabled to configure building the wrapper. The wrapped module will be built and copied to the directory defined by `GTSAM_CYTHON_INSTALL_PATH`, which is by default `<PROJECT_BINARY_DIR>/cython` in Release mode and `<PROJECT_BINARY_DIR>/cython<CMAKE_BUILD_TYPE>` for other modes.
|
||||||
|
|
||||||
- To use the library without installing system-wide: modify your `PYTHONPATH` to include the `GTSAM_CYTHON_INSTALL_PATH`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
export PYTHONPATH=$PYTHONPATH:<GTSAM_CYTHON_INSTALL_PATH>
|
|
||||||
```
|
|
||||||
|
|
||||||
- Build GTSAM and the wrapper with `make`.
|
- Build GTSAM and the wrapper with `make`.
|
||||||
|
|
||||||
- To install system-wide, simply run `make install`.
|
- To install, simply run `make python-install`.
|
||||||
- The same command can be used to install into a virtual environment if it is active.
|
- The same command can be used to install into a virtual environment if it is active.
|
||||||
- **NOTE**: if you don't want gtsam to install to a system directory such as `/usr/local`, pass `-DCMAKE_INSTALL_PREFIX="./install"` to cmake to install gtsam to a subdirectory of the build directory.
|
- **NOTE**: if you don't want GTSAM to install to a system directory such as `/usr/local`, pass `-DCMAKE_INSTALL_PREFIX="./install"` to cmake to install GTSAM to a subdirectory of the build directory.
|
||||||
- If you run `setup.py` from the build directory rather than the installation directory, the script will warn you with the message: `setup.py is being run from an unexpected location`.
|
|
||||||
|
- You can also directly run `make python-install` without running `make`, and it will compile all the dependencies accordingly.
|
||||||
|
|
||||||
## Unit Tests
|
## Unit Tests
|
||||||
|
|
||||||
The Cython toolbox also has a small set of unit tests located in the
|
The Cython toolbox also has a small set of unit tests located in the
|
||||||
test directory. To run them:
|
test directory. To run them:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd <your GTSAM_CYTHON_INSTALL_PATH>
|
cd <GTSAM_CYTHON_INSTALL_PATH>
|
||||||
python -m unittest discover
|
python -m unittest discover
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Utils
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
## Writing Your Own Scripts
|
## Writing Your Own Scripts
|
||||||
|
|
||||||
|
@ -49,25 +54,27 @@ See the tests for examples.
|
||||||
### Some Important Notes:
|
### Some Important Notes:
|
||||||
|
|
||||||
- Vector/Matrix:
|
- Vector/Matrix:
|
||||||
+ GTSAM expects double-precision floating point vectors and matrices.
|
|
||||||
|
- GTSAM expects double-precision floating point vectors and matrices.
|
||||||
Hence, you should pass numpy matrices with `dtype=float`, or `float64`.
|
Hence, you should pass numpy matrices with `dtype=float`, or `float64`.
|
||||||
+ Also, GTSAM expects *column-major* matrices, unlike the default storage
|
- Also, GTSAM expects _column-major_ matrices, unlike the default storage
|
||||||
scheme in numpy. Hence, you should pass column-major matrices to gtsam using
|
scheme in numpy. Hence, you should pass column-major matrices to GTSAM using
|
||||||
the flag order='F'. And you always get column-major matrices back.
|
the flag order='F'. And you always get column-major matrices back.
|
||||||
For more details, see [this link](https://github.com/wouterboomsma/eigency#storage-layout---why-arrays-are-sometimes-transposed).
|
For more details, see [this link](https://github.com/wouterboomsma/eigency#storage-layout---why-arrays-are-sometimes-transposed).
|
||||||
+ Passing row-major matrices of different dtype, e.g. `int`, will also work
|
- Passing row-major matrices of different dtype, e.g. `int`, will also work
|
||||||
as the wrapper converts them to column-major and dtype float for you,
|
as the wrapper converts them to column-major and dtype float for you,
|
||||||
using numpy.array.astype(float, order='F', copy=False).
|
using numpy.array.astype(float, order='F', copy=False).
|
||||||
However, this will result a copy if your matrix is not in the expected type
|
However, this will result a copy if your matrix is not in the expected type
|
||||||
and storage order.
|
and storage order.
|
||||||
|
|
||||||
- Inner namespace: Classes in inner namespace will be prefixed by <innerNamespace>_ in Python.
|
- Inner namespace: Classes in inner namespace will be prefixed by <innerNamespace>\_ in Python.
|
||||||
|
|
||||||
Examples: `noiseModel_Gaussian`, `noiseModel_mEstimator_Tukey`
|
Examples: `noiseModel_Gaussian`, `noiseModel_mEstimator_Tukey`
|
||||||
|
|
||||||
- Casting from a base class to a derive class must be done explicitly.
|
- Casting from a base class to a derive class must be done explicitly.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
noiseBase = factor.noiseModel()
|
noiseBase = factor.noiseModel()
|
||||||
noiseGaussian = dynamic_cast_noiseModel_Gaussian_noiseModel_Base(noiseBase)
|
noiseGaussian = dynamic_cast_noiseModel_Gaussian_noiseModel_Base(noiseBase)
|
||||||
|
@ -75,37 +82,35 @@ See the tests for examples.
|
||||||
|
|
||||||
## Wrapping Custom GTSAM-based Project
|
## Wrapping Custom GTSAM-based Project
|
||||||
|
|
||||||
Please refer to the template project and the corresponding tutorial available [here](https://github.com/borglab/gtsam-project-python).
|
Please refer to the template project and the corresponding tutorial available [here](https://github.com/borglab/GTSAM-project-python).
|
||||||
|
|
||||||
## KNOWN ISSUES
|
## KNOWN ISSUES
|
||||||
|
|
||||||
- Doesn't work with python3 installed from homebrew
|
- Doesn't work with python3 installed from homebrew
|
||||||
- size-related issue: can only wrap up to a certain number of classes: up to mEstimator!
|
- size-related issue: can only wrap up to a certain number of classes: up to mEstimator!
|
||||||
- Guess: 64 vs 32b? disutils Compiler flags?
|
- Guess: 64 vs 32b? disutils Compiler flags?
|
||||||
- Bug with Cython 0.24: instantiated factor classes return FastVector<size_t> for keys(), which can't be casted to FastVector<Key>
|
- Bug with Cython 0.24: instantiated factor classes return FastVector<size_t> for keys(), which can't be casted to FastVector<Key>
|
||||||
- Upgrading to 0.25 solves the problem
|
- Upgrading to 0.25 solves the problem
|
||||||
- Need default constructor and default copy constructor for almost every classes... :(
|
- Need default constructor and default copy constructor for almost every classes... :(
|
||||||
- support these constructors by default and declare "delete" for special classes?
|
- support these constructors by default and declare "delete" for special classes?
|
||||||
|
|
||||||
|
|
||||||
### TODO
|
### TODO
|
||||||
|
|
||||||
- [ ] allow duplication of parent' functions in child classes. Not allowed for now due to conflicts in Cython.
|
- [ ] allow duplication of parent' functions in child classes. Not allowed for now due to conflicts in Cython.
|
||||||
- [ ] a common header for boost shared_ptr? (Or wait until everything is switched to std::shared_ptr in gtsam?)
|
- [ ] a common header for boost shared_ptr? (Or wait until everything is switched to std::shared_ptr in GTSAM?)
|
||||||
- [ ] inner namespaces ==> inner packages?
|
- [ ] inner namespaces ==> inner packages?
|
||||||
- [ ] Wrap fixed-size Matrices/Vectors?
|
- [ ] Wrap fixed-size Matrices/Vectors?
|
||||||
|
|
||||||
|
|
||||||
### Completed/Cancelled:
|
### Completed/Cancelled:
|
||||||
|
|
||||||
- [x] Fix Python tests: don't use " import <package> * ": Bad style!!! (18-03-17 19:50)
|
- [x] Fix Python tests: don't use " import <package> \* ": Bad style!!! (18-03-17 19:50)
|
||||||
- [x] Unit tests for cython wrappers @done (18-03-17 18:45) -- simply compare generated files
|
- [x] Unit tests for cython wrappers @done (18-03-17 18:45) -- simply compare generated files
|
||||||
- [x] Wrap unstable @done (18-03-17 15:30)
|
- [x] Wrap unstable @done (18-03-17 15:30)
|
||||||
- [x] Unify cython/gtsam.h and the original gtsam.h @done (18-03-17 15:30)
|
- [x] Unify cython/GTSAM.h and the original GTSAM.h @done (18-03-17 15:30)
|
||||||
- [x] 18-03-17: manage to unify the two versions by removing std container stubs from the matlab version,and keeping KeyList/KeyVector/KeySet as in the matlab version. Probably Cython 0.25 fixes the casting problem.
|
- [x] 18-03-17: manage to unify the two versions by removing std container stubs from the matlab version,and keeping KeyList/KeyVector/KeySet as in the matlab version. Probably Cython 0.25 fixes the casting problem.
|
||||||
- [x] 06-03-17: manage to remove the requirements for default and copy constructors
|
- [x] 06-03-17: manage to remove the requirements for default and copy constructors
|
||||||
- [ ] 25-11-16: Try to unify but failed. Main reasons are: Key/size_t, std containers, KeyVector/KeyList/KeySet. Matlab doesn't need to know about Key, but I can't make Cython to ignore Key as it couldn't cast KeyVector, i.e. FastVector<Key>, to FastVector<size_t>.
|
- [ ] 25-11-16: Try to unify but failed. Main reasons are: Key/size_t, std containers, KeyVector/KeyList/KeySet. Matlab doesn't need to know about Key, but I can't make Cython to ignore Key as it couldn't cast KeyVector, i.e. FastVector<Key>, to FastVector<size_t>.
|
||||||
- [ ] Marginal and JointMarginal: revert changes @failed (17-03-17 11:00) -- Cython does need a default constructor! It produces cpp code like this: ```gtsam::JointMarginal __pyx_t_1;``` Users don't have to wrap this constructor, however.
|
- [ ] Marginal and JointMarginal: revert changes @failed (17-03-17 11:00) -- Cython does need a default constructor! It produces cpp code like this: `GTSAM::JointMarginal __pyx_t_1;` Users don't have to wrap this constructor, however.
|
||||||
- [x] Convert input numpy Matrix/Vector to float dtype and storage order 'F' automatically, cannot crash! @done (15-03-17 13:00)
|
- [x] Convert input numpy Matrix/Vector to float dtype and storage order 'F' automatically, cannot crash! @done (15-03-17 13:00)
|
||||||
- [x] Remove requirements.txt - Frank: don't bother with only 2 packages and a special case for eigency! @done (08-03-17 10:30)
|
- [x] Remove requirements.txt - Frank: don't bother with only 2 packages and a special case for eigency! @done (08-03-17 10:30)
|
||||||
- [x] CMake install script @done (25-11-16 02:30)
|
- [x] CMake install script @done (25-11-16 02:30)
|
||||||
|
@ -119,7 +124,7 @@ Please refer to the template project and the corresponding tutorial available [h
|
||||||
- [x] Casting from parent and grandparents @done (16-11-16 17:00)
|
- [x] Casting from parent and grandparents @done (16-11-16 17:00)
|
||||||
- [x] Allow overloading constructors. The current solution is annoying!!! @done (16-11-16 17:00)
|
- [x] Allow overloading constructors. The current solution is annoying!!! @done (16-11-16 17:00)
|
||||||
- [x] Support "print obj" @done (16-11-16 17:00)
|
- [x] Support "print obj" @done (16-11-16 17:00)
|
||||||
- [x] methods for FastVector: at, [], ... @done (16-11-16 17:00)
|
- [x] methods for FastVector: at, [], ... @done (16-11-16 17:00)
|
||||||
- [x] Cython: Key and size_t: traits<size_t> doesn't exist @done (16-09-12 18:34)
|
- [x] Cython: Key and size_t: traits<size_t> doesn't exist @done (16-09-12 18:34)
|
||||||
- [x] KeyVector, KeyList, KeySet... @done (16-09-13 17:19)
|
- [x] KeyVector, KeyList, KeySet... @done (16-09-13 17:19)
|
||||||
- [x] [Nice to have] parse typedef @done (16-09-13 17:19)
|
- [x] [Nice to have] parse typedef @done (16-09-13 17:19)
|
||||||
|
|
Loading…
Reference in New Issue