bindings/python/static-persistence.cpp
author Dmitriy Morozov <dmitriy@mrzv.org>
Mon, 12 Jan 2009 15:33:04 -0800
branchdev
changeset 109 75eb7a4628f2
parent 104 2cc1db3b98c6
child 127 406c6cc00b9c
permissions -rw-r--r--
Debugged ZigzagPersistence (having added heavier consistency checking) * Added DEBUG_CONTAINERS option (uses std::__debug::* containers for chains and in ZigzagPersistence) * Added SizeStorage specialization for std::deque<T> * ZigzagPersistence got a lot more consistency checking (in debug mode only, which now crawls); as a result it's been debugged (running on non-trivial examples) * examples/rips/rips-zigzag takes command-line options * added ChainWrapper::clear() * added Simplex::VertexDimensionComparison * added PairwiseDistances class (for computing distances between points in a container according to a distance functor)

#include <topology/static-persistence.h>
#include "python-filtration.h"

#include <boost/python.hpp>
using namespace boost::python;

#include "python-static-persistence.h"

boost::shared_ptr<SPersistence>     init_from_filtration(object f)
{
    ListFiltration& lf = extract<ListFiltration&>(f);
    boost::shared_ptr<SPersistence> p(new SPersistence(lf));
    return p;
}

void                                pair_simplices(SPersistence& p)
{
    p.pair_simplices(); 
}

void export_static_persistence()
{
    class_<SPersistenceNode>("StaticPersistenceNode")
        .def_readonly("pair",   &SPersistenceNode::pair)
        .def("sign",            &SPersistenceNode::sign)
        .def_readonly("cycle",  &SPersistenceNode::cycle)
    ;

    class_<SPersistence>("StaticPersistence", no_init)
        .def("__init__",        make_constructor(&init_from_filtration))

        .def("pair_simplices",  &pair_simplices)

        .def("__iter__",        range(&SPersistence::begin, &SPersistence::end))
        .def("__len__",         &SPersistence::size)
    ;
}