Placed all Python bindings code into dionysus::python namespace dev
authorDmitriy Morozov <dmitriy@mrzv.org>
Wed Apr 15 14:17:21 2009 -0700 (2009-04-15)
branchdev
changeset 130580eaa850c4f
parent 129 95454ea3f9c0
child 131 d9e050258358
Placed all Python bindings code into dionysus::python namespace
bindings/python/chain.cpp
bindings/python/chain.h
bindings/python/filtration.cpp
bindings/python/filtration.h
bindings/python/rips.cpp
bindings/python/rips.h
bindings/python/simplex.cpp
bindings/python/simplex.h
bindings/python/static-persistence.cpp
bindings/python/static-persistence.h
bindings/python/utils.h
bindings/python/zigzag-persistence.cpp
bindings/python/zigzag-persistence.h
examples/rips/rips.py
     1.1 --- a/bindings/python/chain.cpp	Tue Apr 14 14:38:08 2009 -0700
     1.2 +++ b/bindings/python/chain.cpp	Wed Apr 15 14:17:21 2009 -0700
     1.3 @@ -1,15 +1,15 @@
     1.4  #include <boost/python.hpp>
     1.5  #include <boost/python/iterator.hpp>
     1.6 -
     1.7  namespace bp = boost::python;
     1.8  
     1.9  #include "chain.h"
    1.10 +namespace dp = dionysus::python;
    1.11  
    1.12  
    1.13  void export_chain()
    1.14  {
    1.15 -    bp::class_<VChain>("Chain")
    1.16 -        .def("__iter__",    bp::iterator<VChain>())
    1.17 -        .def("__len__",     &VChain::size)
    1.18 +    bp::class_<dp::VChain>("Chain")
    1.19 +        .def("__iter__",    bp::iterator<dp::VChain>())
    1.20 +        .def("__len__",     &dp::VChain::size)
    1.21      ;
    1.22  }
     2.1 --- a/bindings/python/chain.h	Tue Apr 14 14:38:08 2009 -0700
     2.2 +++ b/bindings/python/chain.h	Wed Apr 15 14:17:21 2009 -0700
     2.3 @@ -1,4 +1,9 @@
     2.4  #include <topology/chain.h>
     2.5  #include "static-persistence.h"
     2.6  
     2.7 +namespace dionysus { 
     2.8 +namespace python   {
     2.9 +
    2.10  typedef     SPersistence::Chain                     VChain;
    2.11 +
    2.12 +} }     // namespace dionysus::python
     3.1 --- a/bindings/python/filtration.cpp	Tue Apr 14 14:38:08 2009 -0700
     3.2 +++ b/bindings/python/filtration.cpp	Wed Apr 15 14:17:21 2009 -0700
     3.3 @@ -4,40 +4,41 @@
     3.4  #include <iostream>
     3.5  
     3.6  #include <boost/python.hpp>
     3.7 -using namespace boost::python;
     3.8 +namespace bp = boost::python;
     3.9  
    3.10  
    3.11  #include "filtration.h"      // defines ListFiltration, ListTraits, ListRandomAccessIterator
    3.12  #include "utils.h"           // defines PythonCmp
    3.13 +namespace dp = dionysus::python;
    3.14  
    3.15 -boost::shared_ptr<ListFiltration>  init_from_list(list lst, object cmp)
    3.16 +boost::shared_ptr<dp::ListFiltration>  init_from_list(bp::list lst, bp::object cmp)
    3.17  {
    3.18 -    boost::shared_ptr<ListFiltration>  p(new ListFiltration(ListTraits::begin(lst),
    3.19 -                                                            ListTraits::end(lst),
    3.20 -                                                            PythonCmp(cmp)));
    3.21 +    boost::shared_ptr<dp::ListFiltration>  p(new dp::ListFiltration(dp::ListTraits::begin(lst),
    3.22 +                                                                    dp::ListTraits::end(lst),
    3.23 +                                                                    dp::PythonCmp(cmp)));
    3.24      return p;
    3.25  }
    3.26  
    3.27 -FiltrationPythonIterator
    3.28 -lf_begin(const ListFiltration& lf)
    3.29 +dp::FiltrationPythonIterator
    3.30 +lf_begin(const dp::ListFiltration& lf)
    3.31  { return lf.begin(); }
    3.32  
    3.33 -FiltrationPythonIterator
    3.34 -lf_end(const ListFiltration& lf)
    3.35 +dp::FiltrationPythonIterator
    3.36 +lf_end(const dp::ListFiltration& lf)
    3.37  { return lf.end(); }
    3.38  
    3.39  unsigned
    3.40 -lf_getitem(const ListFiltration& lf, unsigned i)       
    3.41 +lf_getitem(const dp::ListFiltration& lf, unsigned i)       
    3.42  { return *(lf_begin(lf) + i); }
    3.43  
    3.44  
    3.45  void export_filtration()
    3.46  {
    3.47 -    class_<ListFiltration>("Filtration", no_init)
    3.48 -        .def("__init__",        make_constructor(&init_from_list))
    3.49 +    bp::class_<dp::ListFiltration>("Filtration", bp::no_init)
    3.50 +        .def("__init__",        bp::make_constructor(&init_from_list))
    3.51  
    3.52          .def("__getitem__",     &lf_getitem)
    3.53 -        .def("__iter__",        range(&lf_begin, &lf_end))
    3.54 -        .def("__len__",         &ListFiltration::size)
    3.55 +        .def("__iter__",        bp::range(&lf_begin, &lf_end))
    3.56 +        .def("__len__",         &dp::ListFiltration::size)
    3.57      ;
    3.58  }
     4.1 --- a/bindings/python/filtration.h	Tue Apr 14 14:38:08 2009 -0700
     4.2 +++ b/bindings/python/filtration.h	Wed Apr 15 14:17:21 2009 -0700
     4.3 @@ -7,6 +7,9 @@
     4.4  
     4.5  namespace bp = boost::python;
     4.6  
     4.7 +namespace dionysus { 
     4.8 +namespace python   {
     4.9 +
    4.10  // Random access iterator into python's list (using integer indices)
    4.11  class ListRandomAccessIterator:
    4.12      public boost::iterator_adaptor<ListRandomAccessIterator,                // Derived
    4.13 @@ -84,4 +87,6 @@
    4.14          }
    4.15  };
    4.16  
    4.17 +} } // namespace dionysus::python
    4.18 +
    4.19  #endif
     5.1 --- a/bindings/python/rips.cpp	Tue Apr 14 14:38:08 2009 -0700
     5.2 +++ b/bindings/python/rips.cpp	Wed Apr 15 14:17:21 2009 -0700
     5.3 @@ -1,33 +1,35 @@
     5.4  #include <topology/rips.h>
     5.5  #include <boost/python.hpp>
     5.6 +namespace bp = boost::python;
     5.7 +
     5.8  #include "rips.h"                   // defines RipsWithDistances
     5.9 +namespace dp = dionysus::python;
    5.10  
    5.11  #include <iostream>
    5.12  
    5.13 -namespace bp = boost::python;
    5.14  
    5.15  /* Various wrappers for exposing Rips to Python */
    5.16  // Constructor from distances
    5.17 -boost::shared_ptr<RipsWithDistances>        init_from_distances(bp::object distances)
    5.18 +boost::shared_ptr<dp::RipsWithDistances>        init_from_distances(bp::object distances)
    5.19  { 
    5.20 -    boost::shared_ptr<RipsWithDistances>    p(new RipsWithDistances(distances));
    5.21 +    boost::shared_ptr<dp::RipsWithDistances>    p(new dp::RipsWithDistances(distances));
    5.22      return p;
    5.23  }
    5.24  
    5.25  void export_rips()
    5.26  {
    5.27 -    bp::class_<RipsWithDistances>("Rips", bp::no_init)
    5.28 -        .def("__init__",            make_constructor(&init_from_distances))
    5.29 -        .def("generate",            &RipsWithDistances::generate)
    5.30 -        .def("generate",            &RipsWithDistances::generate_candidates)
    5.31 -        .def("vertex_cofaces",      &RipsWithDistances::vertex_cofaces)
    5.32 -        .def("vertex_cofaces",      &RipsWithDistances::vertex_cofaces_candidate)
    5.33 -        .def("edge_cofaces",        &RipsWithDistances::edge_cofaces)
    5.34 -        .def("edge_cofaces",        &RipsWithDistances::edge_cofaces_candidates)
    5.35 +    bp::class_<dp::RipsWithDistances>("Rips", bp::no_init)
    5.36 +        .def("__init__",            bp::make_constructor(&init_from_distances))
    5.37 +        .def("generate",            &dp::RipsWithDistances::generate)
    5.38 +        .def("generate",            &dp::RipsWithDistances::generate_candidates)
    5.39 +        .def("vertex_cofaces",      &dp::RipsWithDistances::vertex_cofaces)
    5.40 +        .def("vertex_cofaces",      &dp::RipsWithDistances::vertex_cofaces_candidate)
    5.41 +        .def("edge_cofaces",        &dp::RipsWithDistances::edge_cofaces)
    5.42 +        .def("edge_cofaces",        &dp::RipsWithDistances::edge_cofaces_candidates)
    5.43  
    5.44 -        .def("cmp",                 &RipsWithDistances::cmp)
    5.45 -        .def("cmp",                 &RipsWithDistances::cmp_native)
    5.46 -        .def("eval",                &RipsWithDistances::eval)
    5.47 -        .def("eval",                &RipsWithDistances::eval_native)
    5.48 +        .def("cmp",                 &dp::RipsWithDistances::cmp)
    5.49 +        .def("cmp",                 &dp::RipsWithDistances::cmp_native)
    5.50 +        .def("eval",                &dp::RipsWithDistances::eval)
    5.51 +        .def("eval",                &dp::RipsWithDistances::eval_native)
    5.52      ;
    5.53  }
     6.1 --- a/bindings/python/rips.h	Tue Apr 14 14:38:08 2009 -0700
     6.2 +++ b/bindings/python/rips.h	Wed Apr 15 14:17:21 2009 -0700
     6.3 @@ -13,6 +13,8 @@
     6.4  namespace bp = boost::python;
     6.5  
     6.6  
     6.7 +namespace dionysus { 
     6.8 +namespace python   {
     6.9  
    6.10  // This strange wrapper is necessary because Rips<...> stores only a const reference to the distances. 
    6.11  // Something on the C++ side of things must store the actual DistancesWrapper object, and that's the 
    6.12 @@ -105,4 +107,6 @@
    6.13          Evaluator                                   eval_;
    6.14  };
    6.15  
    6.16 +} } // namespace dionysus::python
    6.17 +
    6.18  #endif
     7.1 --- a/bindings/python/simplex.cpp	Tue Apr 14 14:38:08 2009 -0700
     7.2 +++ b/bindings/python/simplex.cpp	Wed Apr 15 14:17:21 2009 -0700
     7.3 @@ -6,9 +6,10 @@
     7.4  #include <boost/python/stl_iterator.hpp>
     7.5  #include <boost/shared_ptr.hpp>
     7.6  #include <boost/functional/hash.hpp>
     7.7 -using namespace boost::python;
     7.8 +namespace bp = boost::python;
     7.9  
    7.10  #include "simplex.h"                // defines SimplexVD, Vertex, and Data
    7.11 +namespace dp = dionysus::python;
    7.12  
    7.13  
    7.14  /* Various wrappers for exposing Simplex to Python */
    7.15 @@ -22,9 +23,9 @@
    7.16  
    7.17  // Constructor from iterator
    7.18  template<class V, class T>
    7.19 -boost::shared_ptr<Simplex<V,T> >    init_from_iterator(object iter)                      
    7.20 +boost::shared_ptr<Simplex<V,T> >    init_from_iterator(bp::object iter)                      
    7.21  { 
    7.22 -    boost::shared_ptr<Simplex<V,T> > p(new Simplex<V,T>(stl_input_iterator<V>(iter), stl_input_iterator<V>()));
    7.23 +    boost::shared_ptr<Simplex<V,T> > p(new Simplex<V,T>(bp::stl_input_iterator<V>(iter), bp::stl_input_iterator<V>()));
    7.24      return p;
    7.25  }
    7.26  
    7.27 @@ -53,25 +54,25 @@
    7.28  
    7.29  void export_simplex()
    7.30  {
    7.31 -    class_<SimplexVD>("Simplex")
    7.32 -        .def("__init__",            make_constructor(&init_from_iterator<Vertex, Data>))
    7.33 +    bp::class_<dp::SimplexVD>("Simplex")
    7.34 +        .def("__init__",            bp::make_constructor(&init_from_iterator<dp::Vertex, dp::Data>))
    7.35  
    7.36 -        .def("add",                 &SimplexVD::add)
    7.37 -        .add_property("boundary",   range(&SimplexVD::boundary_begin, &SimplexVD::boundary_end))
    7.38 -        .def("contains",            &SimplexVD::contains)
    7.39 -        .def("join",                (void (SimplexVD::*)(const SimplexVD&)) &SimplexVD::join)
    7.40 -        .def("dimension",           &SimplexVD::dimension)
    7.41 +        .def("add",                 &dp::SimplexVD::add)
    7.42 +        .add_property("boundary",   bp::range(&dp::SimplexVD::boundary_begin, &dp::SimplexVD::boundary_end))
    7.43 +        .def("contains",            &dp::SimplexVD::contains)
    7.44 +        .def("join",                (void (dp::SimplexVD::*)(const dp::SimplexVD&)) &dp::SimplexVD::join)
    7.45 +        .def("dimension",           &dp::SimplexVD::dimension)
    7.46          
    7.47 -        .add_property("vertices",   range(&vertices_begin<Vertex,Data>, &vertices_end<Vertex,Data>))
    7.48 -        .def(repr(self))
    7.49 +        .add_property("vertices",   bp::range(&vertices_begin<dp::Vertex, dp::Data>, &vertices_end<dp::Vertex, dp::Data>))
    7.50 +        .def(repr(bp::self))
    7.51  
    7.52 -        .def("__hash__",            &hash_simplex<Vertex, Data>)
    7.53 -        .def("__eq__",              &eq_simplex<Vertex, Data>)
    7.54 +        .def("__hash__",            &hash_simplex<dp::Vertex, dp::Data>)
    7.55 +        .def("__eq__",              &eq_simplex<dp::Vertex, dp::Data>)
    7.56      ;
    7.57  
    7.58 -    class_<SimplexObject>("SimplexObject")
    7.59 -        .def("__getattribute__",    &SimplexObject::getattribute)
    7.60 +    bp::class_<dp::SimplexObject>("SimplexObject")
    7.61 +        .def("__getattribute__",    &dp::SimplexObject::getattribute)
    7.62      ;
    7.63  
    7.64 -    def("vertex_cmp",               &vertex_comparison<Vertex, Data>);
    7.65 +    bp::def("vertex_cmp",           &vertex_comparison<dp::Vertex, dp::Data>);
    7.66  }
     8.1 --- a/bindings/python/simplex.h	Tue Apr 14 14:38:08 2009 -0700
     8.2 +++ b/bindings/python/simplex.h	Wed Apr 15 14:17:21 2009 -0700
     8.3 @@ -8,6 +8,9 @@
     8.4  namespace bp = boost::python;
     8.5  
     8.6  
     8.7 +namespace dionysus {
     8.8 +namespace python   {
     8.9 +
    8.10  /**
    8.11   * SimplexVD is a base class for Python simplices (it's exposed to python as Simplex)
    8.12   *
    8.13 @@ -58,4 +61,6 @@
    8.14      }
    8.15  };
    8.16  
    8.17 +} } // namespace dionysus::python
    8.18 +
    8.19  #endif
     9.1 --- a/bindings/python/static-persistence.cpp	Tue Apr 14 14:38:08 2009 -0700
     9.2 +++ b/bindings/python/static-persistence.cpp	Wed Apr 15 14:17:21 2009 -0700
     9.3 @@ -3,51 +3,52 @@
     9.4  #include <boost/python.hpp>
     9.5  #include <boost/python/iterator.hpp>
     9.6  #include <boost/python/return_internal_reference.hpp>
     9.7 -using namespace boost::python;
     9.8 +namespace bp = boost::python;
     9.9  
    9.10  #include "filtration.h"
    9.11  #include "static-persistence.h"
    9.12  #include "chain.h"
    9.13 +namespace dp = dionysus::python;
    9.14  
    9.15  
    9.16  /* SPersistence */
    9.17 -boost::shared_ptr<SPersistence>     init_from_filtration(object f)
    9.18 +boost::shared_ptr<dp::SPersistence>     init_from_filtration(bp::object f)
    9.19  {
    9.20 -    ListFiltration& lf = extract<ListFiltration&>(f);
    9.21 -    boost::shared_ptr<SPersistence> p(new SPersistence(lf));
    9.22 +    dp::ListFiltration& lf = bp::extract<dp::ListFiltration&>(f);
    9.23 +    boost::shared_ptr<dp::SPersistence> p(new dp::SPersistence(lf));
    9.24      return p;
    9.25  }
    9.26  
    9.27 -boost::counting_iterator<SPersistenceIndex>     py_sp_begin(SPersistence& sp)                   { return sp.begin(); }
    9.28 -boost::counting_iterator<SPersistenceIndex>     py_sp_end(SPersistence& sp)                     { return sp.end(); }
    9.29 -unsigned                                        distance(SPersistence& sp, 
    9.30 -                                                         const SPersistenceIndex& i)            { return i - sp.begin(); }
    9.31 +boost::counting_iterator<dp::SPersistenceIndex>     py_sp_begin(dp::SPersistence& sp)                   { return sp.begin(); }
    9.32 +boost::counting_iterator<dp::SPersistenceIndex>     py_sp_end(dp::SPersistence& sp)                     { return sp.end(); }
    9.33 +unsigned                                            distance(dp::SPersistence& sp, 
    9.34 +                                                             const dp::SPersistenceIndex& i)            { return i - sp.begin(); }
    9.35  
    9.36  
    9.37  /* SPersistenceIndex */
    9.38 -SPersistenceIndex                               pair(const SPersistenceIndex& i)                { return i->pair; }
    9.39 -bool                                            sign(const SPersistenceIndex& i)                { return i->sign(); }
    9.40 -const VChain&                                   cycle(const SPersistenceIndex& i)               { return i->cycle; }
    9.41 -bool                                            index_eq(const SPersistenceIndex& i, 
    9.42 -                                                         const SPersistenceIndex& j)            { return i == j; }
    9.43 +dp::SPersistenceIndex                               pair(const dp::SPersistenceIndex& i)                { return i->pair; }
    9.44 +bool                                                sign(const dp::SPersistenceIndex& i)                { return i->sign(); }
    9.45 +const dp::VChain&                                   cycle(const dp::SPersistenceIndex& i)               { return i->cycle; }
    9.46 +bool                                                index_eq(const dp::SPersistenceIndex& i, 
    9.47 +                                                             const dp::SPersistenceIndex& j)            { return i == j; }
    9.48  
    9.49  
    9.50  void export_static_persistence()
    9.51  {
    9.52 -    class_<SPersistenceIndex>("SPNode")
    9.53 +    bp::class_<dp::SPersistenceIndex>("SPNode")
    9.54          .add_property("pair",   &pair)
    9.55          .def("sign",            &sign)
    9.56          .def("cycle",           &cycle,         bp::return_internal_reference<1>())
    9.57          .def("__eq__",          index_eq)
    9.58      ;
    9.59  
    9.60 -    class_<SPersistence>("StaticPersistence", no_init)
    9.61 -        .def("__init__",        make_constructor(&init_from_filtration))
    9.62 +    bp::class_<dp::SPersistence>("StaticPersistence", bp::no_init)
    9.63 +        .def("__init__",        bp::make_constructor(&init_from_filtration))
    9.64          
    9.65 -        .def("pair_simplices",  (void (SPersistence::*)())  &SPersistence::pair_simplices)
    9.66 +        .def("pair_simplices",  (void (dp::SPersistence::*)())  &dp::SPersistence::pair_simplices)
    9.67          .def("__call__",        &distance)
    9.68  
    9.69 -        .def("__iter__",        range(&py_sp_begin, &py_sp_end))
    9.70 -        .def("__len__",         &SPersistence::size)
    9.71 +        .def("__iter__",        bp::range(&py_sp_begin, &py_sp_end))
    9.72 +        .def("__len__",         &dp::SPersistence::size)
    9.73      ;
    9.74  }
    10.1 --- a/bindings/python/static-persistence.h	Tue Apr 14 14:38:08 2009 -0700
    10.2 +++ b/bindings/python/static-persistence.h	Wed Apr 15 14:17:21 2009 -0700
    10.3 @@ -3,8 +3,13 @@
    10.4  
    10.5  #include <topology/static-persistence.h>
    10.6  
    10.7 +namespace dionysus {
    10.8 +namespace python   {
    10.9 +
   10.10  typedef         StaticPersistence<>             SPersistence;
   10.11  typedef         SPersistence::OrderElement      SPersistenceNode;
   10.12  typedef         SPersistence::OrderIndex        SPersistenceIndex;
   10.13  
   10.14 +} } // namespace dionysus::python
   10.15 +
   10.16  #endif
    11.1 --- a/bindings/python/utils.h	Tue Apr 14 14:38:08 2009 -0700
    11.2 +++ b/bindings/python/utils.h	Wed Apr 15 14:17:21 2009 -0700
    11.3 @@ -1,14 +1,22 @@
    11.4  #ifndef __PYTHON_UTILS_H__
    11.5  #define __PYTHON_UTILS_H__
    11.6  
    11.7 +#include <boost/python.hpp>
    11.8 +namespace bp = boost::python;
    11.9 +
   11.10 +namespace dionysus {
   11.11 +namespace python   {
   11.12 +
   11.13  struct PythonCmp
   11.14  {
   11.15      template<class T>
   11.16 -    bool            operator()(T x1, T x2) const        { return cmp_(x1, x2) < 0; }
   11.17 +    bool            operator()(T x1, T x2) const            { return cmp_(x1, x2) < 0; }
   11.18  
   11.19 -                    PythonCmp(object cmp): cmp_(cmp)    {}
   11.20 +                    PythonCmp(bp::object cmp): cmp_(cmp)    {}
   11.21  
   11.22 -    object cmp_;
   11.23 +    bp::object cmp_;
   11.24  };
   11.25  
   11.26 +} } // namespace dionysus::python
   11.27 +
   11.28  #endif
    12.1 --- a/bindings/python/zigzag-persistence.cpp	Tue Apr 14 14:38:08 2009 -0700
    12.2 +++ b/bindings/python/zigzag-persistence.cpp	Wed Apr 15 14:17:21 2009 -0700
    12.3 @@ -8,49 +8,50 @@
    12.4  
    12.5  #include "zigzag-persistence.h"             // defines ZZPersistence, IZZPersistence
    12.6  #include "optional.h"
    12.7 +namespace dp = dionysus::python;
    12.8  
    12.9  
   12.10  // ZigzagPersistence
   12.11 -bp::tuple                           zzp_add(ZZPersistence& zzp, bp::object bdry, BirthID birth)
   12.12 +bp::tuple                           zzp_add(dp::ZZPersistence& zzp, bp::object bdry, dp::BirthID birth)
   12.13  {
   12.14      // Make ZColumn    
   12.15      // NB: it's extremely weird that I have to do it this way, 
   12.16      //     but for some reason I cannot just create boundary on the stack
   12.17 -    boost::shared_ptr<ZZPersistence::ZColumn> 
   12.18 -                                            boundary(new ZZPersistence::ZColumn(bp::stl_input_iterator<ZZPersistence::SimplexIndex>(bdry), 
   12.19 -                                                                                bp::stl_input_iterator<ZZPersistence::SimplexIndex>()));
   12.20 +    boost::shared_ptr<dp::ZZPersistence::ZColumn> 
   12.21 +                                            boundary(new dp::ZZPersistence::ZColumn(bp::stl_input_iterator<dp::ZZPersistence::SimplexIndex>(bdry), 
   12.22 +                                                                                    bp::stl_input_iterator<dp::ZZPersistence::SimplexIndex>()));
   12.23      boundary->sort(zzp.cmp);
   12.24  
   12.25 -    ZZPersistence::SimplexIndex             i;
   12.26 -    ZZPersistence::Death                    d;
   12.27 +    dp::ZZPersistence::SimplexIndex         i;
   12.28 +    dp::ZZPersistence::Death                d;
   12.29      boost::tie(i,d)                                 = zzp.add(*boundary, birth); 
   12.30      return bp::make_tuple(i,d);
   12.31  }
   12.32  
   12.33 -ZZPersistence::Death                zzp_remove(ZZPersistence& zzp, ZZPersistence::SimplexIndex s, ZZPersistence::BirthID birth)
   12.34 +dp::ZZPersistence::Death            zzp_remove(dp::ZZPersistence& zzp, dp::ZZPersistence::SimplexIndex s, dp::ZZPersistence::BirthID birth)
   12.35  {
   12.36      return zzp.remove(s, birth); 
   12.37  }
   12.38  
   12.39  
   12.40  // ImageZigzagPersistence
   12.41 -bp::tuple                           izzp_add(IZZPersistence& izzp, bp::object bdry, bool subcomplex, BirthID birth)
   12.42 +bp::tuple                           izzp_add(dp::IZZPersistence& izzp, bp::object bdry, bool subcomplex, dp::BirthID birth)
   12.43  {
   12.44      // Make ZColumn    
   12.45      // NB: it's extremely weird that I have to do it this way, 
   12.46      //     but for some reason I cannot just create boundary on the stack
   12.47 -    boost::shared_ptr<IZZPersistence::ZColumn> 
   12.48 -                                            boundary(new IZZPersistence::ZColumn(bp::stl_input_iterator<IZZPersistence::SimplexIndex>(bdry), 
   12.49 -                                                                                 bp::stl_input_iterator<IZZPersistence::SimplexIndex>()));
   12.50 +    boost::shared_ptr<dp::IZZPersistence::ZColumn> 
   12.51 +                                            boundary(new dp::IZZPersistence::ZColumn(bp::stl_input_iterator<dp::IZZPersistence::SimplexIndex>(bdry), 
   12.52 +                                                                                     bp::stl_input_iterator<dp::IZZPersistence::SimplexIndex>()));
   12.53      boundary->sort(izzp.cmp);
   12.54  
   12.55 -    IZZPersistence::SimplexIndex            i;
   12.56 -    IZZPersistence::Death                   d;
   12.57 +    dp::IZZPersistence::SimplexIndex            i;
   12.58 +    dp::IZZPersistence::Death                   d;
   12.59      boost::tie(i,d)                                 = izzp.add(*boundary, subcomplex, birth); 
   12.60      return bp::make_tuple(i,d);
   12.61  }
   12.62  
   12.63 -IZZPersistence::Death               izzp_remove(IZZPersistence& izzp, IZZPersistence::SimplexIndex s, IZZPersistence::BirthID birth)
   12.64 +dp::IZZPersistence::Death           izzp_remove(dp::IZZPersistence& izzp, dp::IZZPersistence::SimplexIndex s, dp::IZZPersistence::BirthID birth)
   12.65  {
   12.66      return izzp.remove(s, birth); 
   12.67  }
   12.68 @@ -66,20 +67,20 @@
   12.69  
   12.70  void export_zigzag_persistence()
   12.71  {
   12.72 -    python_optional<BirthID>();   
   12.73 +    python_optional<dp::BirthID>();   
   12.74  
   12.75 -    bp::class_<ZZPersistence::SimplexIndex>("SimplexIndex")
   12.76 -        .def("order",           &si_order<ZZPersistence::SimplexIndex>);
   12.77 +    bp::class_<dp::ZZPersistence::SimplexIndex>("SimplexIndex")
   12.78 +        .def("order",           &si_order<dp::ZZPersistence::SimplexIndex>);
   12.79      
   12.80 -    bp::class_<IZZPersistence::SimplexIndex>("ISimplexIndex")
   12.81 -        .def("order",           &si_order<IZZPersistence::SimplexIndex>);
   12.82 +    bp::class_<dp::IZZPersistence::SimplexIndex>("ISimplexIndex")
   12.83 +        .def("order",           &si_order<dp::IZZPersistence::SimplexIndex>);
   12.84  
   12.85 -    bp::class_<ZZPersistence>("ZigzagPersistence")
   12.86 +    bp::class_<dp::ZZPersistence>("ZigzagPersistence")
   12.87          .def("add",             &zzp_add)
   12.88          .def("remove",          &zzp_remove)
   12.89      ;
   12.90      
   12.91 -    bp::class_<IZZPersistence>("ImageZigzagPersistence")
   12.92 +    bp::class_<dp::IZZPersistence>("ImageZigzagPersistence")
   12.93          .def("add",             &izzp_add)
   12.94          .def("remove",          &izzp_remove)
   12.95      ;
    13.1 --- a/bindings/python/zigzag-persistence.h	Tue Apr 14 14:38:08 2009 -0700
    13.2 +++ b/bindings/python/zigzag-persistence.h	Wed Apr 15 14:17:21 2009 -0700
    13.3 @@ -5,6 +5,9 @@
    13.4  #include <topology/image-zigzag-persistence.h>
    13.5  #include <boost/python.hpp>
    13.6  
    13.7 +namespace dionysus {
    13.8 +namespace python   {
    13.9 +
   13.10  //typedef         int                             BirthID;
   13.11  //typedef         boost::python::long_            BirthID;
   13.12  typedef         boost::python::object           BirthID;
   13.13 @@ -12,4 +15,6 @@
   13.14  typedef         ZigzagPersistence<BirthID>      ZZPersistence;
   13.15  typedef         ImageZigzagPersistence<BirthID> IZZPersistence;
   13.16  
   13.17 +} } // namespace dionysus::python
   13.18 +
   13.19  #endif
    14.1 --- a/examples/rips/rips.py	Tue Apr 14 14:38:08 2009 -0700
    14.2 +++ b/examples/rips/rips.py	Wed Apr 15 14:17:21 2009 -0700
    14.3 @@ -37,4 +37,4 @@
    14.4  p = StaticPersistence(f)
    14.5  p.pair_simplices()
    14.6  for s in p:
    14.7 -    print s, s.sign()
    14.8 +    print lst[f[p(s)]], s.sign()