Added docs for StaticCohomologyPersistence + ImagePersistence + circular.smooth + minor fixes in adaptor.py
--- a/bindings/python/dionysus/__init__.py Mon Jun 04 09:05:45 2012 -0700
+++ b/bindings/python/dionysus/__init__.py Tue Jun 05 14:50:58 2012 -0700
@@ -2,8 +2,7 @@
from distances import l2, ExplicitDistances, points_file
from zigzag import *
from adaptor import *
-from circular import smooth
-
+import circular
def init_with_none(self, iter, data = None): # convenience: data defaults to None
self._cpp_init_(iter, data)
--- a/bindings/python/dionysus/adaptor.py Mon Jun 04 09:05:45 2012 -0700
+++ b/bindings/python/dionysus/adaptor.py Tue Jun 05 14:50:58 2012 -0700
@@ -23,6 +23,11 @@
cocycle = self.persistence.__iter__().next()
self.pairs[-1][2] = [(n.coefficient, n.si.order) for n in cocycle]
+ def __call__(self, n):
+ return n.i
+
+ def __len__(self):
+ return len(self.pairs)
def __iter__(self):
for i, (pair, subcomplex, cocycle) in enumerate(self.pairs):
@@ -69,6 +74,7 @@
def pair(self):
return APNode(self._pair(), self.pairs)
+ @property
def cocycle(self):
return self.pairs[self.i][2]
--- a/doc/python/cohomology-persistence.rst Mon Jun 04 09:05:45 2012 -0700
+++ b/doc/python/cohomology-persistence.rst Tue Jun 05 14:50:58 2012 -0700
@@ -12,18 +12,18 @@
coming from :math:`\mathbb{Z}/prime \mathbb{Z}`.
.. method:: add(boundary, birth, [store = True], [image = True], [coefficients = []])
-
- Adds a simplex with the given `boundary` to the complex, i.e.
+
+ Adds a simplex with the given `boundary` to the complex, i.e.
:math:`K_{i+1} = K_i \cup \sigma` and `boundary` = :math:`\partial \sigma`.
- If a new class is born as a result of the addition, `birth` is stored with
- it for future reference.
-
+ If a new class is born as a result of the addition, `birth` is stored with
+ it for future reference.
+
If `store` is ``False`` and a class is born, it will not be stored in
:class:`CohomologyPersistence`. This is useful to not waste space on the
classes of the dimension equal to the maximum-dimensional simplices of
the complex since such classes will never die.
- The `image` parameter allows one to work with a case of a space
+ The `image` parameter allows one to work with a case of a space
:math:`L \subseteq K` where the filtration of :math:`K` induces a
filtration of :math:`L`. In this case, one may want to compute **image
persistence** (i.e. the persistence of the sequences of the images given
@@ -34,7 +34,7 @@
coefficients for the corresponding boundary elements. If empty, it is
assumed to be :math:`(-1)^i`.
- :returns: a pair (`i`, `d`). The first element is the index `i`.
+ :returns: a pair (`i`, `d`). The first element is the index `i`.
It is the internal representation of the newly added simplex,
and should be used later for removal or when constructing the
boundaries of its cofaces. In other words, `boundary` must
@@ -50,8 +50,8 @@
:class:`CohomologyPersistence`. The returned elements are of the type
:class:`Cocycle` below.
-
-.. class:: Cocycle
+
+.. class:: Cocycle
.. attribute:: birth
@@ -82,3 +82,91 @@
The count associated with the simplex when it is inserted into
:class:`CohomologyPersistence`.
+
+
+Adaptor
+-------
+
+:class:`StaticCohomologyPersistence` provides a wrapper around
+class :class:`CohomologyPersistence` that's compatible with :class:`StaticPersistence`.
+See the documentation of the latter class for details.
+
+
+.. class:: StaticCohomologyPersistence
+
+ .. method:: __init__(filtration, prime = 2)
+
+ Initializes :class:`StaticCohomologyPersistence` with the given
+ :class:`Filtration`. `prime` is passed straight to the wrapped
+ :class:`CohomologyPersistence` class.
+
+ .. method:: pair_simplices()
+
+ Pairs simplices using :class:`CohomologyPersistence` class.
+
+ .. method:: __call__(i)
+
+ Given a node in the internal representation, the method returns its
+ integer offset from the beginning of the filtration.
+
+ .. method:: make_simplex_map(filtration)
+
+ Creates an auxilliary map from the nodes to the simplices::
+
+ smap = persistence.make_simplex_map(filtration)
+ for i in persistence:
+ if i.unpaired(): print smap[i]
+
+ .. method:: __iter__()
+
+ Iterator over the nodes (representing individual simplices). See
+ :class:`APNode`.
+
+ .. method:: __len__()
+
+ Returns the number of nodes (i.e. the number of simplices).
+
+.. class:: APNode
+
+ The following methods behave the same way as they do in :class:`SPNode`.
+
+ .. method:: sign()
+
+ .. method:: pair()
+
+ .. method:: unpaired()
+
+ The only crucial distinction in the behavior comes with the attribute
+ :attr:`cocycle`.
+
+ .. attribute:: cocycle
+
+ If the simplex is positive, this attribute stores a cocycle it created.
+ The 1-dimensional cocycles can be used with the :func:`circular.smooth` function to turn
+ them into circle-valued maps.
+ ::
+
+ for i in persistence:
+ if i.sign(): print i.cocycle
+
+
+.. class:: ImagePersistence
+
+ This class is another wrapper around :class:`CohomologyPersistence` that can
+ compute image persistence induced by inclusion of a subcomplex. Its
+ interface is the same as :class:`StaticCohomologyPersistence` above, except
+ for the constructor:
+
+ .. method:: __init__(filtration, subcomplex)
+
+ `subcomplex` is a function called with every simplex. It should return
+ ``True`` if the simplex belong to the subcomplex; ``False`` otherwise.
+
+
+Circular coordinates
+--------------------
+
+.. function:: circular.smooth(filtration, cocycle)
+
+ Returns a map from the vertices of the simplicial complex `filtration` to a circle :math:`[-.5, .5]`,
+ where the opposite ends of the interval are identified.