summaryrefslogtreecommitdiff
path: root/cython
diff options
context:
space:
mode:
authorGard Spreemann <gspreemann@gmail.com>2018-02-02 13:51:45 +0100
committerGard Spreemann <gspreemann@gmail.com>2018-02-02 13:51:45 +0100
commit9899ae167f281d10b1684dfcd02c6838c5bf28df (patch)
treeceda62a40a9a8f731298832b1b4ab44ab0dd3a10 /cython
parent866f6ce614e9c09c97fed12c8c0c2c9fb84fad3f (diff)
GUDHI 2.1.0 as released by upstream in a tarball.upstream/2.1.0
Diffstat (limited to 'cython')
-rw-r--r--cython/cython/periodic_cubical_complex.pyx14
-rw-r--r--cython/cython/simplex_tree.pyx141
-rw-r--r--cython/doc/_templates/layout.html6
-rwxr-xr-xcython/doc/conf.py4
-rw-r--r--cython/doc/cubical_complex_user.rst45
-rw-r--r--cython/doc/fileformats.rst55
-rwxr-xr-xcython/doc/python3-sphinx-build.py2
-rw-r--r--cython/doc/witness_complex_user.rst2
-rwxr-xr-xcython/example/simplex_tree_example.py2
-rw-r--r--cython/include/Cubical_complex_interface.h6
-rw-r--r--cython/include/Simplex_tree_interface.h4
-rw-r--r--cython/include/Tangential_complex_interface.h4
-rw-r--r--cython/setup.py.in4
-rwxr-xr-xcython/test/test_cubical_complex.py10
-rwxr-xr-xcython/test/test_simplex_tree.py38
15 files changed, 262 insertions, 75 deletions
diff --git a/cython/cython/periodic_cubical_complex.pyx b/cython/cython/periodic_cubical_complex.pyx
index 581c7b69..3025f125 100644
--- a/cython/cython/periodic_cubical_complex.pyx
+++ b/cython/cython/periodic_cubical_complex.pyx
@@ -33,7 +33,7 @@ __license__ = "GPL v3"
cdef extern from "Cubical_complex_interface.h" namespace "Gudhi":
cdef cppclass Periodic_cubical_complex_base_interface "Gudhi::Cubical_complex::Cubical_complex_interface<Gudhi::cubical_complex::Bitmap_cubical_complex_periodic_boundary_conditions_base<double>>":
- Periodic_cubical_complex_base_interface(vector[unsigned] dimensions, vector[double] top_dimensional_cells)
+ Periodic_cubical_complex_base_interface(vector[unsigned] dimensions, vector[double] top_dimensional_cells, vector[bool] periodic_dimensions)
Periodic_cubical_complex_base_interface(string perseus_file)
int num_simplices()
int dimension()
@@ -58,7 +58,7 @@ cdef class PeriodicCubicalComplex:
# Fake constructor that does nothing but documenting the constructor
def __init__(self, dimensions=None, top_dimensional_cells=None,
- perseus_file=''):
+ periodic_dimensions=None, perseus_file=''):
"""PeriodicCubicalComplex constructor from dimensions and
top_dimensional_cells or from a Perseus-style file name.
@@ -66,6 +66,8 @@ cdef class PeriodicCubicalComplex:
:type dimensions: list of int
:param top_dimensional_cells: A list of cells filtration values.
:type top_dimensional_cells: list of double
+ :param periodic_dimensions: A list of top dimensional cells periodicity value.
+ :type periodic_dimensions: list of boolean
Or
@@ -75,10 +77,10 @@ cdef class PeriodicCubicalComplex:
# The real cython constructor
def __cinit__(self, dimensions=None, top_dimensional_cells=None,
- perseus_file=''):
- if (dimensions is not None) and (top_dimensional_cells is not None) and (perseus_file is ''):
- self.thisptr = new Periodic_cubical_complex_base_interface(dimensions, top_dimensional_cells)
- elif (dimensions is None) and (top_dimensional_cells is None) and (perseus_file is not ''):
+ periodic_dimensions=None, perseus_file=''):
+ if (dimensions is not None) and (top_dimensional_cells is not None) and (periodic_dimensions is not None) and (perseus_file is ''):
+ self.thisptr = new Periodic_cubical_complex_base_interface(dimensions, top_dimensional_cells, periodic_dimensions)
+ elif (dimensions is None) and (top_dimensional_cells is None) and (periodic_dimensions is None) and (perseus_file is not ''):
if os.path.isfile(perseus_file):
self.thisptr = new Periodic_cubical_complex_base_interface(str.encode(perseus_file))
else:
diff --git a/cython/cython/simplex_tree.pyx b/cython/cython/simplex_tree.pyx
index 45487158..0cb575d2 100644
--- a/cython/cython/simplex_tree.pyx
+++ b/cython/cython/simplex_tree.pyx
@@ -37,11 +37,13 @@ cdef extern from "Simplex_tree_interface.h" namespace "Gudhi":
cdef cppclass Simplex_tree_interface_full_featured "Gudhi::Simplex_tree_interface<Gudhi::Simplex_tree_options_full_featured>":
Simplex_tree()
double simplex_filtration(vector[int] simplex)
+ void assign_simplex_filtration(vector[int] simplex, double filtration)
void initialize_filtration()
int num_vertices()
int num_simplices()
void set_dimension(int dimension)
int dimension()
+ int upper_bound_dimension()
bint find_simplex(vector[int] simplex)
bint insert_simplex_and_subfaces(vector[int] simplex,
double filtration)
@@ -50,8 +52,9 @@ cdef extern from "Simplex_tree_interface.h" namespace "Gudhi":
vector[pair[vector[int], double]] get_star(vector[int] simplex)
vector[pair[vector[int], double]] get_cofaces(vector[int] simplex,
int dimension)
- void remove_maximal_simplex(vector[int] simplex)
void expansion(int max_dim)
+ void remove_maximal_simplex(vector[int] simplex)
+ bool prune_above_filtration(double filtration)
cdef extern from "Persistent_cohomology_interface.h" namespace "Gudhi":
cdef cppclass Simplex_tree_persistence_interface "Gudhi::Persistent_cohomology_interface<Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_full_featured>>":
@@ -103,8 +106,8 @@ cdef class SimplexTree:
return self.pcohptr != NULL
def filtration(self, simplex):
- """This function returns the simplicial complex filtration value for a
- given N-simplex.
+ """This function returns the filtration value for a given N-simplex in
+ this simplicial complex, or +infinity if it is not in the complex.
:param simplex: The N-simplex, represented by a list of vertex.
:type simplex: list of int.
@@ -113,15 +116,31 @@ cdef class SimplexTree:
"""
return self.thisptr.simplex_filtration(simplex)
+ def assign_filtration(self, simplex, filtration):
+ """This function assigns the simplicial complex filtration value for a
+ given N-simplex.
+
+ :param simplex: The N-simplex, represented by a list of vertex.
+ :type simplex: list of int.
+ :param filtration: The simplicial complex filtration value.
+ :type filtration: float
+ """
+ self.thisptr.assign_simplex_filtration(simplex, filtration)
+
def initialize_filtration(self):
"""This function initializes and sorts the simplicial complex
filtration vector.
.. note::
- This function must be launched before persistence, betti_numbers,
- persistent_betti_numbers or get_filtration after inserting or
- removing simplices.
+ This function must be launched before
+ :func:`persistence()<gudhi.SimplexTree.persistence>`,
+ :func:`betti_numbers()<gudhi.SimplexTree.betti_numbers>`,
+ :func:`persistent_betti_numbers()<gudhi.SimplexTree.persistent_betti_numbers>`,
+ or :func:`get_filtration()<gudhi.SimplexTree.get_filtration>`
+ after :func:`inserting<gudhi.SimplexTree.insert>` or
+ :func:`removing<gudhi.SimplexTree.remove_maximal_simplex>`
+ simplices.
"""
self.thisptr.initialize_filtration()
@@ -148,21 +167,42 @@ cdef class SimplexTree:
:returns: the simplicial complex dimension.
:rtype: int
+
+ .. note::
+
+ This function is not constant time because it can recompute
+ dimension if required (can be triggered by
+ :func:`remove_maximal_simplex()<gudhi.SimplexTree.remove_maximal_simplex>`
+ or
+ :func:`prune_above_filtration()<gudhi.SimplexTree.prune_above_filtration>`
+ methods).
"""
return self.thisptr.dimension()
- def set_dimension(self, dimension):
- """This function sets the dimension of the simplicial complex.
+ def upper_bound_dimension(self):
+ """This function returns a valid dimension upper bound of the
+ simplicial complex.
- insert and remove_maximal_simplex functions do not update dimension
- value of the `SimplexTree`.
+ :returns: an upper bound on the dimension of the simplicial complex.
+ :rtype: int
+ """
+ return self.thisptr.upper_bound_dimension()
- `AlphaComplex`, `RipsComplex`, `TangentialComplex` and `WitnessComplex`
- automatically sets the correct dimension in their `create_simplex_tree`
- functions.
+ def set_dimension(self, dimension):
+ """This function sets the dimension of the simplicial complex.
:param dimension: The new dimension value.
:type dimension: int.
+
+ .. note::
+
+ This function must be used with caution because it disables
+ dimension recomputation when required
+ (this recomputation can be triggered by
+ :func:`remove_maximal_simplex()<gudhi.SimplexTree.remove_maximal_simplex>`
+ or
+ :func:`prune_above_filtration()<gudhi.SimplexTree.prune_above_filtration>`
+ ).
"""
self.thisptr.set_dimension(<int>dimension)
@@ -182,14 +222,17 @@ cdef class SimplexTree:
def insert(self, simplex, filtration=0.0):
"""This function inserts the given N-simplex and its subfaces with the
- given filtration value (default value is '0.0').
+ given filtration value (default value is '0.0'). If some of those
+ simplices are already present with a higher filtration value, their
+ filtration value is lowered.
:param simplex: The N-simplex to insert, represented by a list of
vertex.
:type simplex: list of int.
:param filtration: The filtration value of the simplex.
:type filtration: float.
- :returns: true if the simplex was found, false otherwise.
+ :returns: true if the simplex was not yet in the complex, false
+ otherwise (whatever its original filtration value).
:rtype: bool
"""
cdef vector[int] csimplex
@@ -286,9 +329,57 @@ cdef class SimplexTree:
:param simplex: The N-simplex, represented by a list of vertex.
:type simplex: list of int.
+
+ .. note::
+
+ Be aware that removing is shifting data in a flat_map
+ (:func:`initialize_filtration()<gudhi.SimplexTree.initialize_filtration>` to be done).
+
+ .. note::
+
+ The dimension of the simplicial complex may be lower after calling
+ remove_maximal_simplex than it was before. However,
+ :func:`upper_bound_dimension()<gudhi.SimplexTree.upper_bound_dimension>`
+ method will return the old value, which
+ remains a valid upper bound. If you care, you can call
+ :func:`dimension()<gudhi.SimplexTree.dimension>`
+ to recompute the exact dimension.
"""
self.thisptr.remove_maximal_simplex(simplex)
+ def prune_above_filtration(self, filtration):
+ """Prune above filtration value given as parameter.
+
+ :param filtration: Maximum threshold value.
+ :type filtration: float.
+ :returns: The filtration modification information.
+ :rtype: bint
+
+
+ .. note::
+
+ Some simplex tree functions require the filtration to be valid.
+ prune_above_filtration function is not launching
+ :func:`initialize_filtration()<gudhi.SimplexTree.initialize_filtration>`
+ but returns the filtration modification
+ information. If the complex has changed , please call
+ :func:`initialize_filtration()<gudhi.SimplexTree.initialize_filtration>`
+ to recompute it.
+
+ .. note::
+
+ Note that the dimension of the simplicial complex may be lower
+ after calling
+ :func:`prune_above_filtration()<gudhi.SimplexTree.prune_above_filtration>`
+ than it was before. However,
+ :func:`upper_bound_dimension()<gudhi.SimplexTree.upper_bound_dimension>`
+ will return the old value, which remains a
+ valid upper bound. If you care, you can call
+ :func:`dimension()<gudhi.SimplexTree.dimension>`
+ method to recompute the exact dimension.
+ """
+ return self.thisptr.prune_above_filtration(filtration)
+
def expansion(self, max_dim):
"""Expands the Simplex_tree containing only its one skeleton
until dimension max_dim.
@@ -312,7 +403,7 @@ cdef class SimplexTree:
"""This function returns the persistence of the simplicial complex.
:param homology_coeff_field: The homology coefficient field. Must be a
- prime number
+ prime number. Default value is 11.
:type homology_coeff_field: int.
:param min_persistence: The minimum persistence value to take into
account (strictly greater than min_persistence). Default value is
@@ -336,8 +427,9 @@ cdef class SimplexTree:
:returns: The Betti numbers ([B0, B1, ..., Bn]).
:rtype: list of int
- :note: betti_numbers function requires persistence function to be
- launched first.
+ :note: betti_numbers function requires
+ :func:`persistence()<gudhi.SimplexTree.persistence>`
+ function to be launched first.
"""
cdef vector[int] bn_result
if self.pcohptr != NULL:
@@ -361,7 +453,8 @@ cdef class SimplexTree:
:returns: The persistent Betti numbers ([B0, B1, ..., Bn]).
:rtype: list of int
- :note: persistent_betti_numbers function requires persistence
+ :note: persistent_betti_numbers function requires
+ :func:`persistence()<gudhi.SimplexTree.persistence>`
function to be launched first.
"""
cdef vector[int] pbn_result
@@ -381,8 +474,9 @@ cdef class SimplexTree:
:returns: The persistence intervals.
:rtype: list of pair of float
- :note: intervals_in_dim function requires persistence function to be
- launched first.
+ :note: intervals_in_dim function requires
+ :func:`persistence()<gudhi.SimplexTree.persistence>`
+ function to be launched first.
"""
cdef vector[pair[double,double]] intervals_result
if self.pcohptr != NULL:
@@ -399,8 +493,9 @@ cdef class SimplexTree:
:param persistence_file: The specific dimension.
:type persistence_file: string.
- :note: intervals_in_dim function requires persistence function to be
- launched first.
+ :note: intervals_in_dim function requires
+ :func:`persistence()<gudhi.SimplexTree.persistence>`
+ function to be launched first.
"""
if self.pcohptr != NULL:
if persistence_file != '':
diff --git a/cython/doc/_templates/layout.html b/cython/doc/_templates/layout.html
index 243f33c6..8e4eba40 100644
--- a/cython/doc/_templates/layout.html
+++ b/cython/doc/_templates/layout.html
@@ -198,6 +198,8 @@
<ul class="dropdown">
<li><a href="http://gudhi.gforge.inria.fr/licensing/">Licensing</a></li>
<li><a href="https://gforge.inria.fr/frs/?group_id=3865" target="_blank">Get the sources</a></li>
+ <li><a href="https://gforge.inria.fr/frs/download.php/file/37113/GUDHI_2.0.0_OSX_UTILS.beta.tar.gz" target="_blank">Utils for Mac OSx</a></li>
+ <li><a href="https://gforge.inria.fr/frs/download.php/file/37112/GUDHI_2.0.0_WIN64_UTILS.beta.zip" target="_blank">Utils for Win x64</a></li>
</ul>
</li>
<li class="divider"></li>
@@ -208,6 +210,8 @@
<li><a href="http://gudhi.gforge.inria.fr/doc/latest/installation.html">C++ installation manual</a></li>
<li><a href="http://gudhi.gforge.inria.fr/python/latest/">Python documentation</a></li>
<li><a href="http://gudhi.gforge.inria.fr/python/latest/installation.html">Python installation manual</a></li>
+ <li><a href="http://gudhi.gforge.inria.fr/utils/">Utilities</a></li>
+ <li><a href="http://bertrand.michel.perso.math.cnrs.fr/Enseignements/TDA-Gudhi-Python.html" target="_blank">Tutorial</a></li>
</ul>
</li>
<li class="divider"></li>
@@ -255,7 +259,7 @@
{%- if hasdoc('copyright') %}
{% trans path=pathto('copyright'), copyright=copyright|e %}&copy; <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}
{%- else %}
- {% trans copyright=copyright|e %}&copy; Copyright {{ copyright }}.{% endtrans %}
+ {% trans copyright=copyright|e %} {{ copyright }}.{% endtrans %}
{%- endif %}
{%- endif %}
{%- if last_updated %}
diff --git a/cython/doc/conf.py b/cython/doc/conf.py
index 19a880d4..a13c9751 100755
--- a/cython/doc/conf.py
+++ b/cython/doc/conf.py
@@ -62,7 +62,7 @@ import gudhi
# General information about the project.
project = gudhi.__name__
-copyright = gudhi.__copyright__
+copyright = gudhi.__copyright__ + ' - ' + gudhi.__license__
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -158,7 +158,7 @@ html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
+html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
diff --git a/cython/doc/cubical_complex_user.rst b/cython/doc/cubical_complex_user.rst
index 2bfac62a..34598f02 100644
--- a/cython/doc/cubical_complex_user.rst
+++ b/cython/doc/cubical_complex_user.rst
@@ -81,23 +81,7 @@ filtration to all cubes. There are a number of constructors that can be used to
who want to use the code directly. They can be found in the :doc:`cubical_complex_ref`.
Currently one input from a text file is used. It uses a format used already in
`Perseus software <http://www.sas.upenn.edu/~vnanda/perseus/>`_ by Vidit Nanda.
-Below we are providing a description of the format. The first line contains a number d begin the dimension of the
-bitmap (2 in the example below). Next d lines are the numbers of top dimensional cubes in each dimensions (3 and 3
-in the example below). Next, in lexicographical order, the filtration of top dimensional cubes is given (1 4 6 8
-20 4 7 6 5 in the example below).
-
-.. figure::
- ../../doc/Bitmap_cubical_complex/exampleBitmap.png
- :alt: Example of a input data.
- :figclass: align-center
-
- Example of a input data.
-
-The input file for the following complex is:
-
-.. literalinclude:: ../../data/bitmap/cubicalcomplexdoc.txt
-
-.. centered:: ../../data/bitmap/cubicalcomplexdoc.txt
+The file format is described here: :doc:`Perseus <fileformats>`.
.. testcode::
@@ -124,15 +108,9 @@ Imposing periodic boundary conditions in the direction i, means that the left an
:math:`\mathcal{K}` are considered the same. In particular, if for a bitmap :math:`\mathcal{K}` periodic boundary
conditions are imposed in all directions, then complex :math:`\mathcal{K}` became n-dimensional torus. One can use
various constructors from the file Bitmap_cubical_complex_periodic_boundary_conditions_base.h to construct cubical
-complex with periodic boundary conditions. One can also use Perseus style input files. To indicate periodic boundary
-conditions in a given direction, then number of top dimensional cells in this direction have to be multiplied by -1.
-For instance:
-
-.. literalinclude:: ../../data/bitmap/periodiccubicalcomplexdoc.txt
-
-.. centered:: ../../data/bitmap/periodiccubicalcomplexdoc.txt
+complex with periodic boundary conditions.
-Indicate that we have imposed periodic boundary conditions in the direction x, but not in the direction y.
+One can also use Perseus style input files (see :doc:`Perseus <fileformats>`) for the specific periodic case:
.. testcode::
@@ -149,6 +127,23 @@ the program output is:
Periodic cubical complex is of dimension 2 - 42 simplices.
+Or it can be defined as follows:
+
+.. testcode::
+
+ from gudhi import PeriodicCubicalComplex as pcc
+ periodic_cc = pcc(dimensions=[3,3],
+ top_dimensional_cells= [0, 0, 0, 0, 1, 0, 0, 0, 0],
+ periodic_dimensions=[True, False])
+ result_str = 'Periodic cubical complex is of dimension ' + repr(periodic_cc.dimension()) + ' - ' + \
+ repr(periodic_cc.num_simplices()) + ' simplices.'
+ print(result_str)
+
+the program output is:
+
+.. testoutput::
+
+ Periodic cubical complex is of dimension 2 - 42 simplices.
Examples.
---------
diff --git a/cython/doc/fileformats.rst b/cython/doc/fileformats.rst
index 156ef4e4..4f0b6f6d 100644
--- a/cython/doc/fileformats.rst
+++ b/cython/doc/fileformats.rst
@@ -23,7 +23,7 @@ Here is a simple sample file::
3 34.2 34.974
4 3. inf
-Other sample files can be found in the data/persistence_diagram folder.
+Other sample files can be found in the `data/persistence_diagram` folder.
Such files can be generated with
:meth:`gudhi.SimplexTree.write_persistence_diagram`, read with
@@ -31,3 +31,56 @@ Such files can be generated with
:meth:`gudhi.read_persistence_intervals_in_dimension` and displayed with
:meth:`gudhi.plot_persistence_barcode` or
:meth:`gudhi.plot_persistence_diagram`.
+
+Iso-cuboid
+**********
+
+Such a file describes an iso-oriented cuboid with diagonal opposite vertices
+(min_x, min_y, min_z,...) and (max_x, max_y, max_z, ...). The format is::
+
+ min_x min_y [min_z ...]
+ max_x max_y [max_z ...]
+
+Here is a simple sample file in the 3D case::
+
+ -1. -1. -1.
+ 1. 1. 1.
+
+
+Perseus
+*******
+
+This file format is the format used by the
+`Perseus software <http://www.sas.upenn.edu/~vnanda/perseus/>`_ by Vidit Nanda.
+The first line contains a number d begin the dimension of the bitmap (2 in the
+example below). Next d lines are the numbers of top dimensional cubes in each
+dimensions (3 and 3 in the example below). Next, in lexicographical order, the
+filtration of top dimensional cubes is given (1 4 6 8 20 4 7 6 5 in the example
+below).
+
+.. figure::
+ ../../doc/Bitmap_cubical_complex/exampleBitmap.png
+ :alt: Example of a input data.
+ :figclass: align-center
+
+ Example of a input data.
+
+The input file for the following complex is:
+
+.. literalinclude:: ../../data/bitmap/cubicalcomplexdoc.txt
+
+.. centered:: ../../data/bitmap/cubicalcomplexdoc.txt
+
+To indicate periodic boundary conditions in a given direction, then number of
+top dimensional cells in this direction have to be multiplied by -1. For
+instance:
+
+.. literalinclude:: ../../data/bitmap/periodiccubicalcomplexdoc.txt
+
+.. centered:: ../../data/bitmap/periodiccubicalcomplexdoc.txt
+
+
+Indicate that we have imposed periodic boundary conditions in the direction x,
+but not in the direction y.
+
+Other sample files can be found in the `data/bitmap` folder.
diff --git a/cython/doc/python3-sphinx-build.py b/cython/doc/python3-sphinx-build.py
index 44b94169..84d158cf 100755
--- a/cython/doc/python3-sphinx-build.py
+++ b/cython/doc/python3-sphinx-build.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
"""
Emulate sphinx-build for python3
diff --git a/cython/doc/witness_complex_user.rst b/cython/doc/witness_complex_user.rst
index 29413269..99be5185 100644
--- a/cython/doc/witness_complex_user.rst
+++ b/cython/doc/witness_complex_user.rst
@@ -121,7 +121,7 @@ Example2: Computing persistence using strong relaxed witness complex
Here is an example of constructing a strong witness complex filtration and computing persistence on it:
-* :download:`euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py <../example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py>`
+* :download:`euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py <../example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py>`
Bibliography
============
diff --git a/cython/example/simplex_tree_example.py b/cython/example/simplex_tree_example.py
index 831d9da8..51a60e73 100755
--- a/cython/example/simplex_tree_example.py
+++ b/cython/example/simplex_tree_example.py
@@ -48,8 +48,6 @@ if st.insert([0, 1, 2], filtration=4.0):
else:
print("Not inserted...")
-# FIXME: Remove this line
-st.set_dimension(3)
print("dimension=", st.dimension())
st.initialize_filtration()
diff --git a/cython/include/Cubical_complex_interface.h b/cython/include/Cubical_complex_interface.h
index 7c0148f1..fad92c2c 100644
--- a/cython/include/Cubical_complex_interface.h
+++ b/cython/include/Cubical_complex_interface.h
@@ -43,6 +43,12 @@ class Cubical_complex_interface : public Bitmap_cubical_complex<CubicalComplexOp
: Bitmap_cubical_complex<CubicalComplexOptions>(dimensions, top_dimensional_cells) {
}
+ Cubical_complex_interface(const std::vector<unsigned>& dimensions,
+ const std::vector<double>& top_dimensional_cells,
+ const std::vector<bool>& periodic_dimensions)
+ : Bitmap_cubical_complex<CubicalComplexOptions>(dimensions, top_dimensional_cells, periodic_dimensions) {
+ }
+
Cubical_complex_interface(const std::string& perseus_file)
: Bitmap_cubical_complex<CubicalComplexOptions>(perseus_file.c_str()) {
}
diff --git a/cython/include/Simplex_tree_interface.h b/cython/include/Simplex_tree_interface.h
index 09e7e992..54a4f824 100644
--- a/cython/include/Simplex_tree_interface.h
+++ b/cython/include/Simplex_tree_interface.h
@@ -52,6 +52,10 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> {
return (Base::find(vh) != Base::null_simplex());
}
+ void assign_simplex_filtration(const Simplex& vh, Filtration_value filtration) {
+ Base::assign_filtration(Base::find(vh), filtration);
+ }
+
bool insert(const Simplex& simplex, Filtration_value filtration = 0) {
Insertion_result result = Base::insert_simplex_and_subfaces(simplex, filtration);
return (result.second);
diff --git a/cython/include/Tangential_complex_interface.h b/cython/include/Tangential_complex_interface.h
index 5e9dc0e4..0c3a510e 100644
--- a/cython/include/Tangential_complex_interface.h
+++ b/cython/include/Tangential_complex_interface.h
@@ -105,9 +105,7 @@ class Tangential_complex_interface {
}
void create_simplex_tree(Simplex_tree<>* simplex_tree) {
- int max_dim = tangential_complex_->create_complex<Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_full_featured>>(*simplex_tree);
- // FIXME
- simplex_tree->set_dimension(max_dim);
+ tangential_complex_->create_complex<Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_full_featured>>(*simplex_tree);
simplex_tree->initialize_filtration();
}
diff --git a/cython/setup.py.in b/cython/setup.py.in
index fefa36bb..c767e93d 100644
--- a/cython/setup.py.in
+++ b/cython/setup.py.in
@@ -23,7 +23,7 @@ from Cython.Build import cythonize
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
-__author__ = "Vincent Rouvreau"
+__author__ = "GUDHI Editorial Board"
__copyright__ = "Copyright (C) 2016 INRIA"
__license__ = "GPL v3"
@@ -41,7 +41,7 @@ gudhi = Extension(
setup(
name = 'gudhi',
- author='Vincent Rouvreau',
+ author='GUDHI Editorial Board',
author_email='gudhi-contact@lists.gforge.inria.fr',
version='@GUDHI_VERSION@',
url='http://gudhi.gforge.inria.fr/',
diff --git a/cython/test/test_cubical_complex.py b/cython/test/test_cubical_complex.py
index 9a365823..0e81554d 100755
--- a/cython/test/test_cubical_complex.py
+++ b/cython/test/test_cubical_complex.py
@@ -62,17 +62,17 @@ def test_dimension_or_perseus_file_constructor():
assert cub.__is_defined() == False
assert cub.__is_persistence_defined() == False
-def test_dimension_constructor():
+def test_dimension_simple_constructor():
cub = CubicalComplex(dimensions=[3, 3],
top_dimensional_cells = [1,2,3,4,5,6,7,8,9])
assert cub.__is_defined() == True
assert cub.__is_persistence_defined() == False
- assert cub.persistence() == [(1, (0.0, 100.0)), (0, (0.0, float('inf')))]
+ assert cub.persistence() == [(0, (1.0, float('inf')))]
assert cub.__is_persistence_defined() == True
- assert cub.betti_numbers() == [1, 0]
- assert cub.persistent_betti_numbers(0, 1000) == [0, 0]
+ assert cub.betti_numbers() == [1, 0, 0]
+ assert cub.persistent_betti_numbers(0, 1000) == [0, 0, 0]
-def test_dimension_constructor():
+def test_dimension_file_constructor():
# Create test file
test_file = open('CubicalOneSphere.txt', 'w')
test_file.write('2\n3\n3\n0\n0\n0\n0\n100\n0\n0\n0\n0\n')
diff --git a/cython/test/test_simplex_tree.py b/cython/test/test_simplex_tree.py
index 4d452d7d..6dec5d94 100755
--- a/cython/test/test_simplex_tree.py
+++ b/cython/test/test_simplex_tree.py
@@ -34,9 +34,13 @@ def test_insertion():
# insert test
assert st.insert([0, 1]) == True
+
+ assert st.dimension() == 1
+
assert st.insert([0, 1, 2], filtration=4.0) == True
- # FIXME: Remove this line
- st.set_dimension(2)
+
+ assert st.dimension() == 2
+
assert st.num_simplices() == 7
assert st.num_vertices() == 3
@@ -86,8 +90,9 @@ def test_insertion():
assert st.find([2]) == True
st.initialize_filtration()
- assert st.persistence() == [(1, (4.0, float('inf'))), (0, (0.0, float('inf')))]
+ assert st.persistence(persistence_dim_max = True) == [(1, (4.0, float('inf'))), (0, (0.0, float('inf')))]
assert st.__is_persistence_defined() == True
+
assert st.betti_numbers() == [1, 1]
assert st.persistent_betti_numbers(-0.1, 10000.0) == [0, 0]
assert st.persistent_betti_numbers(0.0, 10000.0) == [1, 0]
@@ -129,3 +134,30 @@ def test_expansion():
([1, 2], 0.5), ([0, 1, 2], 0.5), ([1, 2, 3], 0.5), ([5], 0.6), ([6], 0.6),
([5, 6], 0.6), ([4], 0.7), ([2, 4], 0.7), ([0, 3], 0.8), ([0, 1, 3], 0.8),
([0, 2, 3], 0.8), ([0, 1, 2, 3], 0.8), ([4, 6], 0.9), ([3, 6], 1.0)]
+
+def test_automatic_dimension():
+ st = SimplexTree()
+ assert st.__is_defined() == True
+ assert st.__is_persistence_defined() == False
+
+ # insert test
+ assert st.insert([0,1,3], filtration=0.5) == True
+ assert st.insert([0,1,2], filtration=1.) == True
+
+ assert st.num_vertices() == 4
+ assert st.num_simplices() == 11
+
+ assert st.dimension() == 2
+ assert st.upper_bound_dimension() == 2
+
+ assert st.prune_above_filtration(0.6) == True
+ assert st.dimension() == 2
+ assert st.upper_bound_dimension() == 2
+
+ st.assign_filtration([0, 1, 3], 0.7)
+ assert st.filtration([0, 1, 3]) == 0.7
+
+ st.remove_maximal_simplex([0, 1, 3])
+ assert st.upper_bound_dimension() == 2
+ assert st.dimension() == 1
+ assert st.upper_bound_dimension() == 1