bindings/python/rips.cpp
author Aravindakshan Babu <akshan@stanford.edu>
Tue, 17 Aug 2010 22:19:19 -0700
branchdev
changeset 219 5311343eb2f5
parent 130 580eaa850c4f
permissions -rw-r--r--
Added documentation for the python classes Point and PersistenceDiagram. Removed the __sub__ method for PersistenceDiagram. Minor renaming. Renamed BottleneckDistance to bottleneck_distance. Renamed intervals iterator for PersistenceDiagram to points. Seems in better conformance with usage.

#include <topology/rips.h>
#include <boost/python.hpp>
namespace bp = boost::python;

#include "rips.h"                   // defines RipsWithDistances
namespace dp = dionysus::python;

#include <iostream>


/* Various wrappers for exposing Rips to Python */
// Constructor from distances
boost::shared_ptr<dp::RipsWithDistances>        init_from_distances(bp::object distances)
{ 
    boost::shared_ptr<dp::RipsWithDistances>    p(new dp::RipsWithDistances(distances));
    return p;
}

void export_rips()
{
    bp::class_<dp::RipsWithDistances>("Rips", bp::no_init)
        .def("__init__",            bp::make_constructor(&init_from_distances))
        .def("generate",            &dp::RipsWithDistances::generate)
        .def("generate",            &dp::RipsWithDistances::generate_candidates)
        .def("vertex_cofaces",      &dp::RipsWithDistances::vertex_cofaces)
        .def("vertex_cofaces",      &dp::RipsWithDistances::vertex_cofaces_candidate)
        .def("edge_cofaces",        &dp::RipsWithDistances::edge_cofaces)
        .def("edge_cofaces",        &dp::RipsWithDistances::edge_cofaces_candidates)

        .def("cmp",                 &dp::RipsWithDistances::cmp)
        .def("cmp",                 &dp::RipsWithDistances::cmp_native)
        .def("eval",                &dp::RipsWithDistances::eval)
        .def("eval",                &dp::RipsWithDistances::eval_native)
    ;
}