Skip to content

Commit

Permalink
added python bindings to the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
crvs committed Jun 28, 2018
1 parent e2c5a15 commit 242bba5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ make timing-test

to run the timing tests, the files for the other tests, are still not provided.

### Using Python bindings

In the python bindings we provide bindings for the `simplicial_complex` which uses only cells to for construction, and provides also bindings for the functions `cell_to_index` and `index_to_cell`. Furthermore we provide bindings for `coeff_flow` and `coeff_flow_embedded`. Below is a toy example run:

```{python}
>>> import coeffflow
>>> a = coeffflow.simplicial_complex([[0,1,2]])
>>> a.cell_to_index([0,2])
1
>>> a.index_to_cell(0,1)
[1]
>>> a.index_to_cell(1,2)
[2, 1]
>>> coeffflow.coeff_flow_embedded(a ,(1, [1,-1,1]))
(2, [1.0])
```

### References/links

[1]: Carvalho JF, Vejdemo-Johansson M, Kragic D, Pokorny FT. _An algorithm for calculating top-dimensional bounding chains._ 2017 [PeerJ Preprints 5:e3151v1](https://doi.org/10.7287/peerj.preprints.3151v1)
Expand Down
9 changes: 5 additions & 4 deletions python/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ using namespace gsimp;
namespace py = pybind11;

PYBIND11_MODULE(coeffflow, m) {
py::class_< simplicial_complex >(m, "simplicial_complex") //
.def(py::init< std::vector< cell_t >& >()) //
.def("cell_to_index", &simplicial_complex::cell_to_index);
py::class_< simplicial_complex >(m, "simplicial_complex") //
.def(py::init< std::vector< cell_t >& >()) //
.def("cell_to_index", &simplicial_complex::cell_to_index) //
.def("index_to_cell", &simplicial_complex::index_to_cell);

m.def("coeff_flow", coeff_flow);

m.def("coeff_flow_embedded",coeff_flow_embedded);
m.def("coeff_flow_embedded", coeff_flow_embedded);
};

0 comments on commit 242bba5

Please sign in to comment.