multipers package
Subpackages
- multipers.data package
- Submodules
- multipers.data.MOL2 module
EF_AUC()
EF_from_distance_matrix()
Molecule2SimplexTree
apply_pipeline()
get_EF_vector_from_distances()
get_all_JC_path()
get_data_path_JC()
img_distances()
lines2bonds()
lines2bonds_MOL2()
lines2bonds_PDB()
plot_EF_from_distances()
split_multimol()
theorical_max_EF()
theorical_max_EF_from_distances()
- multipers.data.UCR module
- multipers.data.graphs module
- multipers.data.immuno_regions module
- multipers.data.minimal_presentation_to_st_bf module
- multipers.data.pytorch2simplextree module
- multipers.data.shape3d module
- multipers.data.synthetic module
- Module contents
- multipers.ml package
- Submodules
- multipers.ml.accuracies module
- multipers.ml.convolutions module
- multipers.ml.invariants_with_persistable module
- multipers.ml.kernels module
- multipers.ml.mma module
- multipers.ml.one module
Dgm2Histogram
Dgms2Image
Dgms2Landscapes
Dgms2SWK
Dgms2SignedMeasureDistance
Dgms2SignedMeasureHistogram
Dgms2SignedMeasureImage
Dgms2SlicedWassersteinDistanceMatrices
DiagramShuffle
FilvecGetter
Graph2SimplexTree
PointCloud2SimplexTree
SimplexTree2Dgm
SimplexTree2Histogram
dgm2pervec()
get_filtration_values()
get_simplextree()
get_simplextrees()
graph2filvec()
simplextree2hist()
- multipers.ml.point_clouds module
- multipers.ml.signed_betti module
- multipers.ml.signed_measures module
DegreeRips2SignedMeasure
SignedMeasure2Convolution
SignedMeasure2SlicedWassersteinDistance
SignedMeasureFormatter
SignedMeasures2SlicedWassersteinDistances
SimplexTree2RectangleDecomposition
SimplexTree2SignedMeasure
SimplexTrees2SignedMeasures
rescale_sparse_signed_measure()
tensor_möbius_inversion()
- multipers.ml.sliced_wasserstein module
- multipers.ml.tools module
- Module contents
- multipers.tests package
- Submodules
- multipers.tests.old_test_rank_invariant module
- multipers.tests.test_diff_helper module
- multipers.tests.test_hilbert_function module
- multipers.tests.test_mma module
- multipers.tests.test_point_clouds module
- multipers.tests.test_python-cpp_conversion module
- multipers.tests.test_signed_betti module
- multipers.tests.test_simplextreemulti module
- multipers.tests.test_slicer module
- Module contents
- multipers.torch package
Submodules
multipers.distances module
- multipers.distances.estimate_error(st: SimplexTreeMulti_Fi32 | SimplexTreeMulti_KFi32 | SimplexTreeMulti_Fi64 | SimplexTreeMulti_KFi64 | SimplexTreeMulti_Ff32 | SimplexTreeMulti_KFf32 | SimplexTreeMulti_Ff64 | SimplexTreeMulti_KFf64, module: PyModule_i32 | PyModule_i64 | PyModule_f32 | PyModule_f64, degree: int, nlines: int = 100, verbose: bool = False)
Given an MMA SimplexTree and PyModule, estimates the bottleneck distance using barcodes given by gudhi.
Parameters
- st:SimplexTree
The simplextree representing the n-filtered complex. Used to define the gudhi simplextrees on different lines.
- module:PyModule
The module on which to estimate approximation error, w.r.t. the original simplextree st.
- degree:int
The homology degree to consider
Returns
float:The estimation of the matching distance, i.e., the maximum of the sampled bottleneck distances.
- multipers.distances.estimate_matching(b1: PyMultiDiagrams_f32 | PyMultiDiagrams_f64, b2: PyMultiDiagrams_f32 | PyMultiDiagrams_f64)
- multipers.distances.sm2diff(sm1, sm2)
- multipers.distances.sm_distance(sm1: tuple, sm2: tuple, reg: float = 0, reg_m: float = 0, numItermax: int = 10000, p: float = 1)
Computes the wasserstein distances between two signed measures, of the form
(pts,weights)
- with
pts : (num_pts, dim) float array
weights : (num_pts,) int array
- Regularisation:
sinkhorn if reg != 0
sinkhorn unbalanced if reg_m != 0
multipers.euler_characteristic module
multipers.function_rips module
File: multipers/function_rips.pyx (starting at line 1)
- multipers.function_rips.function_rips_signed_measure(st_multi, homological_degrees: vector[indices_type], mobius_inversion: bool = True, zero_pad: bool = False, n_jobs: int = 0, reconvert: bool = True)
File: multipers/function_rips.pyx (starting at line 78)
- multipers.function_rips.function_rips_surface(st_multi, homological_degrees: vector[indices_type], mobius_inversion: bool = True, zero_pad: bool = False, n_jobs: int = 0)
File: multipers/function_rips.pyx (starting at line 59)
- multipers.function_rips.get_degree_rips(st, degrees: vector[int], grid_strategy='exact', resolution=0)
File: multipers/function_rips.pyx (starting at line 37)
multipers.grids module
File: multipers/grids.pyx (starting at line 2)
- multipers.grids.coarsen_points(signatures, args, kwargs, defaults, _fused_sigindex={})
File: multipers/grids.pyx (starting at line 230)
- multipers.grids.compute_grid(signatures, args, kwargs, defaults, _fused_sigindex={})
File: multipers/grids.pyx (starting at line 27)
Computes a grid from filtration values, using some strategy.
Input
- filtrations_values: Iterable[filtration of parameter for parameter]
where filtration_of_parameter is a array[float, ndim=1]
resolution:Optional[int|tuple[int]]
strategy: either exact, regular, regular_closest, regular_left, partition, quantile, or precomputed.
unique: if true, doesn’t repeat values in the output grid.
drop_quantiles : drop some filtration values according to these quantiles
Output
Iterable[array[float, ndim=1]] : the 1d-grid for each parameter.
- multipers.grids.push_to_grid(signatures, args, kwargs, defaults, _fused_sigindex={})
File: multipers/grids.pyx (starting at line 213)
Given points and a grid (list of one parameter grids), pushes the points onto the grid.
- multipers.grids.sm_in_grid(pts, weights, grid_conversion, num_parameters: int = -1)
File: multipers/grids.pyx (starting at line 238) Given a measure whose points are coordinates,
pushes this measure in this grid. Input —–
pts: of the form array[int, ndim=2]
weights: array[int, ndim=1]
grid_conversion of the form Iterable[array[float, ndim=1]]
num_parameters: number of parameters
- multipers.grids.sms_in_grid(sms, grid_conversion, num_parameters: int = -1)
File: multipers/grids.pyx (starting at line 271) Given a measure whose points are coordinates,
pushes this measure in this grid. Input —–
sms: of the form (signed_measure_like for num_measures) where signed_measure_like = tuple(array[int, ndim=2], array[int])
grid_conversion of the form Iterable[array[float, ndim=1]]
- multipers.grids.todense(grid)
File: multipers/grids.pyx (starting at line 172)
multipers.hilbert_function module
multipers.io module
File: multipers/io.pyx (starting at line 1)
- multipers.io.clear_io(*args)
File: multipers/io.pyx (starting at line 380) Removes temporary files
- multipers.io.function_delaunay_presentation(point_cloud: np.ndarray, function_values: np.ndarray, id: str | None = None, clear: bool = True, verbose: bool = False, degree: int = -1, multi_chunk: bool = False)
File: multipers/io.pyx (starting at line 335)
Computes a function delaunay presentation, and returns it as blocks.
points : (num_pts, n) float array grades : (num_pts,) float array degree (opt) : if given, computes a minimal presentation of this homological degree first clear:bool, removes temporary files if true degree: computes minimal presentation of this degree if given verbose : bool
- multipers.io.reduce_complex(complex, full_resolution: bool = True, dimension: int | np.int64 = 1, clear: bool = True, id: str | None = None, verbose: bool = False, backend: available_reduce_softs = 'mpfree')
File: multipers/io.pyx (starting at line 277)
Computes a minimal presentation of the file in path, using backend.
simplextree full_resolution: bool dimension: int, presentation dimension to consider clear: bool, removes temporary files if True id: str, temporary files are of this id, allowing for multiprocessing verbose: bool
- multipers.io.scc2disk(stuff, path: str | os.PathLike, num_parameters: int = -1, reverse_block: bool = False, rivet_compatible: bool = False, ignore_last_generators: bool = False, strip_comments: bool = False)
File: multipers/io.pyx (starting at line 459)
Writes a scc python format / blocks into a file.
- multipers.io.scc2disk_old(stuff, path: str | os.PathLike, num_parameters=-1, reverse_block=False, rivet_compatible=False, ignore_last_generators=False, strip_comments=False)
File: multipers/io.pyx (starting at line 513)
Writes a scc python format / blocks into a file.
- multipers.io.scc_parser(path: str | os.PathLike)
File: multipers/io.pyx (starting at line 98)
Parse an scc file into the scc python format, aka blocks.
- multipers.io.scc_parser__old(path: str)
File: multipers/io.pyx (starting at line 124)
Parse an scc file into the scc python format, aka blocks.
- multipers.io.scc_reduce_from_str(path: str | os.PathLike, full_resolution: bool = True, dimension: int | np.int64 = 1, clear: bool = True, id: str | None = None, verbose: bool = False, backend: Literal['mpfree', 'multi_chunk', 'twopac'] = 'mpfree')
File: multipers/io.pyx (starting at line 218)
Computes a minimal presentation of the file in path, using mpfree.
path:PathLike full_resolution: bool dimension: int, presentation dimension to consider clear: bool, removes temporary files if True id: str, temporary files are of this id, allowing for multiprocessing verbose: bool backend: “mpfree”, “multi_chunk” or “2pac”
multipers.mma_structures module
File: multipers/mma_structures.pyx (starting at line 1) ! @package mma @brief Files containing the C++ cythonized functions. @author David Loiseaux @copyright Copyright (c) 2022 Inria.
- class multipers.mma_structures.PyBox_f32
Bases:
object
- contains(self, x)
File: multipers/mma_structures.pyx (starting at line 798)
- dtype
- get(self)
File: multipers/mma_structures.pyx (starting at line 804)
- num_parameters
- to_multipers(self)
File: multipers/mma_structures.pyx (starting at line 806)
- class multipers.mma_structures.PyBox_f64
Bases:
object
- contains(self, x)
File: multipers/mma_structures.pyx (starting at line 1625)
- dtype
- get(self)
File: multipers/mma_structures.pyx (starting at line 1631)
- num_parameters
- to_multipers(self)
File: multipers/mma_structures.pyx (starting at line 1633)
- class multipers.mma_structures.PyBox_i32
Bases:
object
- contains(self, x)
File: multipers/mma_structures.pyx (starting at line 108)
- dtype
- get(self)
File: multipers/mma_structures.pyx (starting at line 114)
- num_parameters
- to_multipers(self)
File: multipers/mma_structures.pyx (starting at line 116)
- class multipers.mma_structures.PyBox_i64
Bases:
object
- contains(self, x)
File: multipers/mma_structures.pyx (starting at line 453)
- dtype
- get(self)
File: multipers/mma_structures.pyx (starting at line 459)
- num_parameters
- to_multipers(self)
File: multipers/mma_structures.pyx (starting at line 461)
- class multipers.mma_structures.PyModule_f32
Bases:
object
File: multipers/mma_structures.pyx (starting at line 815)
Stores a representation of a n-persistence module.
- barcode(self, basepoint, degree: int = -1, *, threshold: bool = False)
File: multipers/mma_structures.pyx (starting at line 1046) Computes the barcode of module along a lines.
- basepointvector
basepoint of the lines on which to compute the barcodes, i.e. a point on the line
- degree = -1integer
Homology degree on which to compute the bars. If negative, every dimension is computed
- box (default) :
box on which to compute the barcodes if basepoints is not specified. Default is a linspace of lines crossing that box.
- threshold = False
Thre
If the barcodes are not thresholded, essential barcodes will not be plot-able.
- PyMultiDiagrams
Structure that holds the barcodes. Barcodes can be retrieved with a .get_points() or a .to_multipers() or a .plot().
- barcode2(self, basepoint, degree: int = -1, *, threshold: bool = False)
File: multipers/mma_structures.pyx (starting at line 1075)
Compute the 1d-barcode a diagonal line based on basepoint, with direction (1,1).
- barcodes(self, degree: int, basepoints=None, num=100, box=None, threshold=False)
File: multipers/mma_structures.pyx (starting at line 1081) Computes barcodes of module along a set of lines.
- basepoints = Nonelist of vectors
basepoints of the lines on which to compute the barcodes.
- degree = -1integer
Homology degree on which to compute the bars. If negative, every dimension is computed
- box (default) :
box on which to compute the barcodes if basepoints is not specified. Default is a linspace of lines crossing that box.
- num:int=100
if basepoints is not specified, defines the number of lines to consider.
- threshold = Falsethreshold t
Resolution of the image(s).
If the barcodes are not thresholded, essential barcodes will not be plot-able.
- PyMultiDiagrams
Structure that holds the barcodes. Barcodes can be retrieved with a .get_points() or a .to_multipers() or a .plot().
- barcodes2(self, degree: int = -1, basepoints=None, num: int = 100, box=None, threshold=False)
File: multipers/mma_structures.pyx (starting at line 1124) Computes barcodes of module along a set of lines.
- basepoints = Nonelist of vectors
basepoints of the lines on which to compute the barcodes.
- degree = -1integer
Homology degree on which to compute the bars. If negative, every dimension is computed
- box (default) :
box on which to compute the barcodes if basepoints is not specified. Default is a linspace of lines crossing that box.
- num:int=100
if basepoints is not specified, defines the number of lines to consider.
- threshold = Falsethreshold t
Resolution of the image(s).
If the barcodes are not thresholded, essential barcodes will not be plot-able.
tuple of 1d barcodes, based on basepoint, with direction (1,1)
- degree_splits(self)
File: multipers/mma_structures.pyx (starting at line 1029)
- distance_to(self, pts, signed: bool = False, n_jobs: int = 1) np.ndarray
File: multipers/mma_structures.pyx (starting at line 1400)
Distance from a point to each summand’s support. Signed distance is the distance to the boundary, with negative values inside the summands.
pts of shape (num_pts, num_parameters)
output shape : (num_pts,num_summands)
- distances_idx_to(self, pts, full: bool = False, n_jobs: int = 1)
File: multipers/mma_structures.pyx (starting at line 1390)
- dtype
- dump(self, path: str | None = None)
File: multipers/mma_structures.pyx (starting at line 901)
Dumps the module into a pickle-able format.
Parameters
path:str=None (optional) saves the pickled module in specified path
Returns
list of list, encoding the module, which can be retrieved with the function from_dump.
- euler_char(self, points: list | np.ndarray) np.ndarray
File: multipers/mma_structures.pyx (starting at line 1342) Computes the Euler Characteristic of the filtered complex at given (multiparameter) time
- points: list[float] | list[list[float]] | np.ndarray
List of filtration values on which to compute the euler characteristic. WARNING FIXME : the points have to have the same dimension as the simplextree.
The list of euler characteristic values
- get_bottom(self) np.ndarray
File: multipers/mma_structures.pyx (starting at line 875)
Bottom of the box of the module
- get_bounds(self)
File: multipers/mma_structures.pyx (starting at line 936)
Computes bounds from the summands’ bounds. Useful to change this’ box.
- get_box(self) np.ndarray
File: multipers/mma_structures.pyx (starting at line 885)
Returns the current bounding box of the module.
- get_filtration_values(self, unique: bool = True)
File: multipers/mma_structures.pyx (starting at line 960)
Retrieves all filtration values of the summands of the module.
Output format
list of filtration values for parameter.
- get_interleavings(self, box=None)
File: multipers/mma_structures.pyx (starting at line 1420)
- get_module_of_degree(self, degree: int) PyModule_f32
File: multipers/mma_structures.pyx (starting at line 847)
Returns a copy of a module of fixed degree.
- get_module_of_degrees(self, degrees: Iterable[int]) PyModule_f32
File: multipers/mma_structures.pyx (starting at line 859)
Returns a copy of the summands of degrees in degrees
- get_top(self) np.ndarray
File: multipers/mma_structures.pyx (starting at line 880)
Top of the box of the module
- landscape(self, degree: int, k: int = 0, box: list | np.ndarray | None = None, resolution: List = [100, 100], plot: bool = False)
File: multipers/mma_structures.pyx (starting at line 1166) Computes the multiparameter landscape from a PyModule. Python interface only bifiltrations.
- degreeinteger
The homology degree of the landscape.
- k = 0int
the k-th landscape
- resolution = [50,50]pair of integers
Resolution of the image.
- box = Nonein the format [[a,b], [c,d]]
If nontrivial, compute the landscape of this box. Default is the PyModule box.
- plot = TrueBoolean
If true, plots the images;
The landscape of the module.
- landscapes(self, degree: int, ks: list | np.ndarray = [0], box=None, resolution: list | np.ndarray = [100, 100], plot: bool = False)
File: multipers/mma_structures.pyx (starting at line 1200) Computes the multiparameter landscape from a PyModule. Python interface only bifiltrations.
- degreeinteger
The homology degree of the landscape.
- ks = 0list of int
the k-th landscape
- resolution = [50,50]pair of integers
Resolution of the image.
- box = Nonein the format [[a,b], [c,d]]
If nontrivial, compute the landscape of this box. Default is the PyModule box.
- plot = Truebool
If true, plots the images;
The landscapes of the module with parameters ks.
- max_degree
max_degree: int
Returns the maximum degree of the module.
- merge(self, other: PyModule_f32, dim: int = -1)
File: multipers/mma_structures.pyx (starting at line 827)
Merges two modules into one
- num_parameters
num_parameters: int
- plot(self, degree: int = -1, **kwargs) None
File: multipers/mma_structures.pyx (starting at line 984) Shows the module on a plot. Each color corresponds to an apprimation summand of the module, and its shape corresponds to its support.
Only works with 2-parameter modules.
- degree = -1integer
If positive returns only the image of dimension dimension.
- box=Noneof the form [[b_x,b_y], [d_x,d_y]] where b,d are the bottom and top corner of the rectangle.
If non-None, will plot the module on this specific rectangle.
- min_persistence =0float
Only plots the summand with a persistence above this threshold.
- separated=Falsebool
If true, plot each summand in a different plot.
- alpha=1float
Transparancy parameter
- save = Falsestring
if nontrivial, will save the figure at this path
The figure of the plot.
- representation(self, degrees=None, bandwidth: float = 0.1, resolution: List[int] | int = 50, kernel: unicode = 'gaussian', signed: bool = False, normalize: bool = False, plot: bool = False, save: bool = False, dpi: int = 200, p: float = 2., box=None, flatten: bool = False, n_jobs: int = 0, coordinates=None) np.ndarray
File: multipers/mma_structures.pyx (starting at line 1235) Computes a representation of the module, using
[A Framework for Fast and Stable Representations of Multiparameter Persistent Homology Decompositions, Neurips2023]
- degrees = Noneinteger list
If given returns only the image(s) of homology degrees degrees.
- bandwidth = 0.1float
Image parameter.
- resolution = [100,100]pair of integers
Resolution of the image(s).
- normalize = TrueBoolean
Ensures that the image belongs to [0,1].
- plot = FalseBoolean
If true, plots the images;
- flatten=False :
If True, reshapes the output to a flattened shape.
kernel: Either linear, gaussian, or callable The kernel to apply to the matrix $(d(x,I), x in mathrm{pixels}, Iin mathrm{summands})$. signature should be : (distance matrix, summand_weights, bandwidth, p) -> representation
The list of images, or the image of fixed dimension.
- rescale(self, rescale_factors, degree: int = -1)
File: multipers/mma_structures.pyx (starting at line 945)
Rescales the fitlration values of the summands by this rescaling vector.
- to_flat_idx(self, grid)
File: multipers/mma_structures.pyx (starting at line 1383)
- to_idx(self, grid)
File: multipers/mma_structures.pyx (starting at line 1377)
- translate(self, translation, degree: int = -1)
File: multipers/mma_structures.pyx (starting at line 952)
Translates the module in the filtration space by this vector.
- class multipers.mma_structures.PyModule_f64
Bases:
object
File: multipers/mma_structures.pyx (starting at line 1642)
Stores a representation of a n-persistence module.
- barcode(self, basepoint, degree: int = -1, *, threshold: bool = False)
File: multipers/mma_structures.pyx (starting at line 1873) Computes the barcode of module along a lines.
- basepointvector
basepoint of the lines on which to compute the barcodes, i.e. a point on the line
- degree = -1integer
Homology degree on which to compute the bars. If negative, every dimension is computed
- box (default) :
box on which to compute the barcodes if basepoints is not specified. Default is a linspace of lines crossing that box.
- threshold = False
Thre
If the barcodes are not thresholded, essential barcodes will not be plot-able.
- PyMultiDiagrams
Structure that holds the barcodes. Barcodes can be retrieved with a .get_points() or a .to_multipers() or a .plot().
- barcode2(self, basepoint, degree: int = -1, *, threshold: bool = False)
File: multipers/mma_structures.pyx (starting at line 1902)
Compute the 1d-barcode a diagonal line based on basepoint, with direction (1,1).
- barcodes(self, degree: int, basepoints=None, num=100, box=None, threshold=False)
File: multipers/mma_structures.pyx (starting at line 1908) Computes barcodes of module along a set of lines.
- basepoints = Nonelist of vectors
basepoints of the lines on which to compute the barcodes.
- degree = -1integer
Homology degree on which to compute the bars. If negative, every dimension is computed
- box (default) :
box on which to compute the barcodes if basepoints is not specified. Default is a linspace of lines crossing that box.
- num:int=100
if basepoints is not specified, defines the number of lines to consider.
- threshold = Falsethreshold t
Resolution of the image(s).
If the barcodes are not thresholded, essential barcodes will not be plot-able.
- PyMultiDiagrams
Structure that holds the barcodes. Barcodes can be retrieved with a .get_points() or a .to_multipers() or a .plot().
- barcodes2(self, degree: int = -1, basepoints=None, num: int = 100, box=None, threshold=False)
File: multipers/mma_structures.pyx (starting at line 1951) Computes barcodes of module along a set of lines.
- basepoints = Nonelist of vectors
basepoints of the lines on which to compute the barcodes.
- degree = -1integer
Homology degree on which to compute the bars. If negative, every dimension is computed
- box (default) :
box on which to compute the barcodes if basepoints is not specified. Default is a linspace of lines crossing that box.
- num:int=100
if basepoints is not specified, defines the number of lines to consider.
- threshold = Falsethreshold t
Resolution of the image(s).
If the barcodes are not thresholded, essential barcodes will not be plot-able.
tuple of 1d barcodes, based on basepoint, with direction (1,1)
- degree_splits(self)
File: multipers/mma_structures.pyx (starting at line 1856)
- distance_to(self, pts, signed: bool = False, n_jobs: int = 1) np.ndarray
File: multipers/mma_structures.pyx (starting at line 2227)
Distance from a point to each summand’s support. Signed distance is the distance to the boundary, with negative values inside the summands.
pts of shape (num_pts, num_parameters)
output shape : (num_pts,num_summands)
- distances_idx_to(self, pts, full: bool = False, n_jobs: int = 1)
File: multipers/mma_structures.pyx (starting at line 2217)
- dtype
- dump(self, path: str | None = None)
File: multipers/mma_structures.pyx (starting at line 1728)
Dumps the module into a pickle-able format.
Parameters
path:str=None (optional) saves the pickled module in specified path
Returns
list of list, encoding the module, which can be retrieved with the function from_dump.
- euler_char(self, points: list | np.ndarray) np.ndarray
File: multipers/mma_structures.pyx (starting at line 2169) Computes the Euler Characteristic of the filtered complex at given (multiparameter) time
- points: list[float] | list[list[float]] | np.ndarray
List of filtration values on which to compute the euler characteristic. WARNING FIXME : the points have to have the same dimension as the simplextree.
The list of euler characteristic values
- get_bottom(self) np.ndarray
File: multipers/mma_structures.pyx (starting at line 1702)
Bottom of the box of the module
- get_bounds(self)
File: multipers/mma_structures.pyx (starting at line 1763)
Computes bounds from the summands’ bounds. Useful to change this’ box.
- get_box(self) np.ndarray
File: multipers/mma_structures.pyx (starting at line 1712)
Returns the current bounding box of the module.
- get_filtration_values(self, unique: bool = True)
File: multipers/mma_structures.pyx (starting at line 1787)
Retrieves all filtration values of the summands of the module.
Output format
list of filtration values for parameter.
- get_interleavings(self, box=None)
File: multipers/mma_structures.pyx (starting at line 2247)
- get_module_of_degree(self, degree: int) PyModule_f64
File: multipers/mma_structures.pyx (starting at line 1674)
Returns a copy of a module of fixed degree.
- get_module_of_degrees(self, degrees: Iterable[int]) PyModule_f64
File: multipers/mma_structures.pyx (starting at line 1686)
Returns a copy of the summands of degrees in degrees
- get_top(self) np.ndarray
File: multipers/mma_structures.pyx (starting at line 1707)
Top of the box of the module
- landscape(self, degree: int, k: int = 0, box: list | np.ndarray | None = None, resolution: List = [100, 100], plot: bool = False)
File: multipers/mma_structures.pyx (starting at line 1993) Computes the multiparameter landscape from a PyModule. Python interface only bifiltrations.
- degreeinteger
The homology degree of the landscape.
- k = 0int
the k-th landscape
- resolution = [50,50]pair of integers
Resolution of the image.
- box = Nonein the format [[a,b], [c,d]]
If nontrivial, compute the landscape of this box. Default is the PyModule box.
- plot = TrueBoolean
If true, plots the images;
The landscape of the module.
- landscapes(self, degree: int, ks: list | np.ndarray = [0], box=None, resolution: list | np.ndarray = [100, 100], plot: bool = False)
File: multipers/mma_structures.pyx (starting at line 2027) Computes the multiparameter landscape from a PyModule. Python interface only bifiltrations.
- degreeinteger
The homology degree of the landscape.
- ks = 0list of int
the k-th landscape
- resolution = [50,50]pair of integers
Resolution of the image.
- box = Nonein the format [[a,b], [c,d]]
If nontrivial, compute the landscape of this box. Default is the PyModule box.
- plot = Truebool
If true, plots the images;
The landscapes of the module with parameters ks.
- max_degree
max_degree: int
Returns the maximum degree of the module.
- merge(self, other: PyModule_f64, dim: int = -1)
File: multipers/mma_structures.pyx (starting at line 1654)
Merges two modules into one
- num_parameters
num_parameters: int
- plot(self, degree: int = -1, **kwargs) None
File: multipers/mma_structures.pyx (starting at line 1811) Shows the module on a plot. Each color corresponds to an apprimation summand of the module, and its shape corresponds to its support.
Only works with 2-parameter modules.
- degree = -1integer
If positive returns only the image of dimension dimension.
- box=Noneof the form [[b_x,b_y], [d_x,d_y]] where b,d are the bottom and top corner of the rectangle.
If non-None, will plot the module on this specific rectangle.
- min_persistence =0float
Only plots the summand with a persistence above this threshold.
- separated=Falsebool
If true, plot each summand in a different plot.
- alpha=1float
Transparancy parameter
- save = Falsestring
if nontrivial, will save the figure at this path
The figure of the plot.
- representation(self, degrees=None, bandwidth: float = 0.1, resolution: List[int] | int = 50, kernel: unicode = 'gaussian', signed: bool = False, normalize: bool = False, plot: bool = False, save: bool = False, dpi: int = 200, p: float = 2., box=None, flatten: bool = False, n_jobs: int = 0, coordinates=None) np.ndarray
File: multipers/mma_structures.pyx (starting at line 2062) Computes a representation of the module, using
[A Framework for Fast and Stable Representations of Multiparameter Persistent Homology Decompositions, Neurips2023]
- degrees = Noneinteger list
If given returns only the image(s) of homology degrees degrees.
- bandwidth = 0.1float
Image parameter.
- resolution = [100,100]pair of integers
Resolution of the image(s).
- normalize = TrueBoolean
Ensures that the image belongs to [0,1].
- plot = FalseBoolean
If true, plots the images;
- flatten=False :
If True, reshapes the output to a flattened shape.
kernel: Either linear, gaussian, or callable The kernel to apply to the matrix $(d(x,I), x in mathrm{pixels}, Iin mathrm{summands})$. signature should be : (distance matrix, summand_weights, bandwidth, p) -> representation
The list of images, or the image of fixed dimension.
- rescale(self, rescale_factors, degree: int = -1)
File: multipers/mma_structures.pyx (starting at line 1772)
Rescales the fitlration values of the summands by this rescaling vector.
- to_flat_idx(self, grid)
File: multipers/mma_structures.pyx (starting at line 2210)
- to_idx(self, grid)
File: multipers/mma_structures.pyx (starting at line 2204)
- translate(self, translation, degree: int = -1)
File: multipers/mma_structures.pyx (starting at line 1779)
Translates the module in the filtration space by this vector.
- class multipers.mma_structures.PyModule_i32
Bases:
object
File: multipers/mma_structures.pyx (starting at line 125)
Stores a representation of a n-persistence module.
- degree_splits(self)
File: multipers/mma_structures.pyx (starting at line 339)
- dtype
- dump(self, path: str | None = None)
File: multipers/mma_structures.pyx (starting at line 211)
Dumps the module into a pickle-able format.
Parameters
path:str=None (optional) saves the pickled module in specified path
Returns
list of list, encoding the module, which can be retrieved with the function from_dump.
- get_bottom(self) np.ndarray
File: multipers/mma_structures.pyx (starting at line 185)
Bottom of the box of the module
- get_bounds(self)
File: multipers/mma_structures.pyx (starting at line 246)
Computes bounds from the summands’ bounds. Useful to change this’ box.
- get_box(self) np.ndarray
File: multipers/mma_structures.pyx (starting at line 195)
Returns the current bounding box of the module.
- get_filtration_values(self, unique: bool = True)
File: multipers/mma_structures.pyx (starting at line 270)
Retrieves all filtration values of the summands of the module.
Output format
list of filtration values for parameter.
- get_module_of_degree(self, degree: int) PyModule_i32
File: multipers/mma_structures.pyx (starting at line 157)
Returns a copy of a module of fixed degree.
- get_module_of_degrees(self, degrees: Iterable[int]) PyModule_i32
File: multipers/mma_structures.pyx (starting at line 169)
Returns a copy of the summands of degrees in degrees
- get_top(self) np.ndarray
File: multipers/mma_structures.pyx (starting at line 190)
Top of the box of the module
- max_degree
max_degree: int
Returns the maximum degree of the module.
- merge(self, other: PyModule_i32, dim: int = -1)
File: multipers/mma_structures.pyx (starting at line 137)
Merges two modules into one
- num_parameters
num_parameters: int
- plot(self, degree: int = -1, **kwargs) None
File: multipers/mma_structures.pyx (starting at line 294) Shows the module on a plot. Each color corresponds to an apprimation summand of the module, and its shape corresponds to its support.
Only works with 2-parameter modules.
- degree = -1integer
If positive returns only the image of dimension dimension.
- box=Noneof the form [[b_x,b_y], [d_x,d_y]] where b,d are the bottom and top corner of the rectangle.
If non-None, will plot the module on this specific rectangle.
- min_persistence =0float
Only plots the summand with a persistence above this threshold.
- separated=Falsebool
If true, plot each summand in a different plot.
- alpha=1float
Transparancy parameter
- save = Falsestring
if nontrivial, will save the figure at this path
The figure of the plot.
- rescale(self, rescale_factors, degree: int = -1)
File: multipers/mma_structures.pyx (starting at line 255)
Rescales the fitlration values of the summands by this rescaling vector.
- translate(self, translation, degree: int = -1)
File: multipers/mma_structures.pyx (starting at line 262)
Translates the module in the filtration space by this vector.
- class multipers.mma_structures.PyModule_i64
Bases:
object
File: multipers/mma_structures.pyx (starting at line 470)
Stores a representation of a n-persistence module.
- degree_splits(self)
File: multipers/mma_structures.pyx (starting at line 684)
- dtype
- dump(self, path: str | None = None)
File: multipers/mma_structures.pyx (starting at line 556)
Dumps the module into a pickle-able format.
Parameters
path:str=None (optional) saves the pickled module in specified path
Returns
list of list, encoding the module, which can be retrieved with the function from_dump.
- get_bottom(self) np.ndarray
File: multipers/mma_structures.pyx (starting at line 530)
Bottom of the box of the module
- get_bounds(self)
File: multipers/mma_structures.pyx (starting at line 591)
Computes bounds from the summands’ bounds. Useful to change this’ box.
- get_box(self) np.ndarray
File: multipers/mma_structures.pyx (starting at line 540)
Returns the current bounding box of the module.
- get_filtration_values(self, unique: bool = True)
File: multipers/mma_structures.pyx (starting at line 615)
Retrieves all filtration values of the summands of the module.
Output format
list of filtration values for parameter.
- get_module_of_degree(self, degree: int) PyModule_i64
File: multipers/mma_structures.pyx (starting at line 502)
Returns a copy of a module of fixed degree.
- get_module_of_degrees(self, degrees: Iterable[int]) PyModule_i64
File: multipers/mma_structures.pyx (starting at line 514)
Returns a copy of the summands of degrees in degrees
- get_top(self) np.ndarray
File: multipers/mma_structures.pyx (starting at line 535)
Top of the box of the module
- max_degree
max_degree: int
Returns the maximum degree of the module.
- merge(self, other: PyModule_i64, dim: int = -1)
File: multipers/mma_structures.pyx (starting at line 482)
Merges two modules into one
- num_parameters
num_parameters: int
- plot(self, degree: int = -1, **kwargs) None
File: multipers/mma_structures.pyx (starting at line 639) Shows the module on a plot. Each color corresponds to an apprimation summand of the module, and its shape corresponds to its support.
Only works with 2-parameter modules.
- degree = -1integer
If positive returns only the image of dimension dimension.
- box=Noneof the form [[b_x,b_y], [d_x,d_y]] where b,d are the bottom and top corner of the rectangle.
If non-None, will plot the module on this specific rectangle.
- min_persistence =0float
Only plots the summand with a persistence above this threshold.
- separated=Falsebool
If true, plot each summand in a different plot.
- alpha=1float
Transparancy parameter
- save = Falsestring
if nontrivial, will save the figure at this path
The figure of the plot.
- rescale(self, rescale_factors, degree: int = -1)
File: multipers/mma_structures.pyx (starting at line 600)
Rescales the fitlration values of the summands by this rescaling vector.
- translate(self, translation, degree: int = -1)
File: multipers/mma_structures.pyx (starting at line 607)
Translates the module in the filtration space by this vector.
- class multipers.mma_structures.PyMultiDiagramPoint_f32
Bases:
object
- get_birth(self)
File: multipers/mma_structures.pyx (starting at line 1434)
- get_death(self)
File: multipers/mma_structures.pyx (starting at line 1437)
- get_degree(self)
File: multipers/mma_structures.pyx (starting at line 1432)
- class multipers.mma_structures.PyMultiDiagramPoint_f64
Bases:
object
- get_birth(self)
File: multipers/mma_structures.pyx (starting at line 2261)
- get_death(self)
File: multipers/mma_structures.pyx (starting at line 2264)
- get_degree(self)
File: multipers/mma_structures.pyx (starting at line 2259)
- class multipers.mma_structures.PyMultiDiagram_f32
Bases:
object
File: multipers/mma_structures.pyx (starting at line 1442)
Stores the diagram of a PyModule on a line
- get_points(self, degree: int = -1) np.ndarray
File: multipers/mma_structures.pyx (starting at line 1450)
- to_multipers(self, dimension: int)
File: multipers/mma_structures.pyx (starting at line 1457)
- class multipers.mma_structures.PyMultiDiagram_f64
Bases:
object
File: multipers/mma_structures.pyx (starting at line 2269)
Stores the diagram of a PyModule on a line
- get_points(self, degree: int = -1) np.ndarray
File: multipers/mma_structures.pyx (starting at line 2277)
- to_multipers(self, dimension: int)
File: multipers/mma_structures.pyx (starting at line 2284)
- class multipers.mma_structures.PyMultiDiagrams_f32
Bases:
object
File: multipers/mma_structures.pyx (starting at line 1463)
Stores the barcodes of a PyModule on multiple lines
- get_points(self, degree: int = -1)
File: multipers/mma_structures.pyx (starting at line 1481)
- plot(self, degree: int = -1, min_persistence: float = 0)
File: multipers/mma_structures.pyx (starting at line 1485)
Plots the barcodes.
Parameters
- degree:int=-1
Only plots the bars of specified homology degree. Useful when the multidiagrams contains multiple dimenions
- min_persistence:float=0
Only plot bars of length greater than this value. Useful to reduce the time to plot.
Warning
If the barcodes are not thresholded, essential barcodes will not be displayed !
- to_multipers(self)
File: multipers/mma_structures.pyx (starting at line 1471)
- class multipers.mma_structures.PyMultiDiagrams_f64
Bases:
object
File: multipers/mma_structures.pyx (starting at line 2290)
Stores the barcodes of a PyModule on multiple lines
- get_points(self, degree: int = -1)
File: multipers/mma_structures.pyx (starting at line 2308)
- plot(self, degree: int = -1, min_persistence: float = 0)
File: multipers/mma_structures.pyx (starting at line 2312)
Plots the barcodes.
Parameters
- degree:int=-1
Only plots the bars of specified homology degree. Useful when the multidiagrams contains multiple dimenions
- min_persistence:float=0
Only plot bars of length greater than this value. Useful to reduce the time to plot.
Warning
If the barcodes are not thresholded, essential barcodes will not be displayed !
- to_multipers(self)
File: multipers/mma_structures.pyx (starting at line 2298)
- class multipers.mma_structures.PySummand_f32
Bases:
object
File: multipers/mma_structures.pyx (starting at line 745)
Stores a Summand of a PyModule
- degree
degree: int
- dtype
- get_birth_list(self)
File: multipers/mma_structures.pyx (starting at line 751)
- get_bounds(self)
File: multipers/mma_structures.pyx (starting at line 765)
- get_death_list(self)
File: multipers/mma_structures.pyx (starting at line 755)
- class multipers.mma_structures.PySummand_f64
Bases:
object
File: multipers/mma_structures.pyx (starting at line 1572)
Stores a Summand of a PyModule
- degree
degree: int
- dtype
- get_birth_list(self)
File: multipers/mma_structures.pyx (starting at line 1578)
- get_bounds(self)
File: multipers/mma_structures.pyx (starting at line 1592)
- get_death_list(self)
File: multipers/mma_structures.pyx (starting at line 1582)
- class multipers.mma_structures.PySummand_i32
Bases:
object
File: multipers/mma_structures.pyx (starting at line 55)
Stores a Summand of a PyModule
- degree
degree: int
- dtype
- get_birth_list(self)
File: multipers/mma_structures.pyx (starting at line 61)
- get_bounds(self)
File: multipers/mma_structures.pyx (starting at line 75)
- get_death_list(self)
File: multipers/mma_structures.pyx (starting at line 65)
- class multipers.mma_structures.PySummand_i64
Bases:
object
File: multipers/mma_structures.pyx (starting at line 400)
Stores a Summand of a PyModule
- degree
degree: int
- dtype
- get_birth_list(self)
File: multipers/mma_structures.pyx (starting at line 406)
- get_bounds(self)
File: multipers/mma_structures.pyx (starting at line 420)
- get_death_list(self)
File: multipers/mma_structures.pyx (starting at line 410)
- multipers.mma_structures.from_dump_f32(dump) PyModule_f32
File: multipers/mma_structures.pyx (starting at line 1549) Retrieves a PyModule from a previous dump.
- dump: either the output of the dump function, or a file containing the output of a dump.
The dumped module to retrieve
- PyModule
The retrieved module.
- multipers.mma_structures.from_dump_f64(dump) PyModule_f64
File: multipers/mma_structures.pyx (starting at line 2376) Retrieves a PyModule from a previous dump.
- dump: either the output of the dump function, or a file containing the output of a dump.
The dumped module to retrieve
- PyModule
The retrieved module.
- multipers.mma_structures.from_dump_i32(dump) PyModule_i32
File: multipers/mma_structures.pyx (starting at line 377) Retrieves a PyModule from a previous dump.
- dump: either the output of the dump function, or a file containing the output of a dump.
The dumped module to retrieve
- PyModule
The retrieved module.
- multipers.mma_structures.from_dump_i64(dump) PyModule_i64
File: multipers/mma_structures.pyx (starting at line 722) Retrieves a PyModule from a previous dump.
- dump: either the output of the dump function, or a file containing the output of a dump.
The dumped module to retrieve
- PyModule
The retrieved module.
multipers.multiparameter_edge_collapse module
multipers.multiparameter_module_approximation module
File: multipers/multiparameter_module_approximation.pyx (starting at line 1) ! @package mma @brief Files containing the C++ cythonized functions. @author David Loiseaux @copyright Copyright (c) 2022 Inria.
- multipers.multiparameter_module_approximation.module_approximation(input: SimplexTreeMulti_type | Slicer_type | tuple, box: np.ndarray | None = None, max_error: float = -1, nlines: int = 500, slicer_backend: Literal['matrix', 'clement', 'graph'] = 'matrix', minpres: Literal['mpfree'] | None = None, degree: int | None = None, complete: bool = True, threshold: bool = False, verbose: bool = False, ignore_warning: bool = False, id='', direction: list = [], swap_box_coords: list = [], *, n_jobs: int = 1)
File: multipers/multiparameter_module_approximation.pyx (starting at line 84) Computes an interval module approximation of a multiparameter filtration.
- input: SimplexTreeMulti or Slicer-like.
Holds the multifiltered complex.
- max_error: positive float
Trade-off between approximation and computational complexity. Upper bound of the module approximation, in bottleneck distance, for interval-decomposable modules.
- nlines: int = 200
Alternative to max_error; specifies the number of persistence computation used for the approximation.
- box(Optional) pair of list of floats
Defines a rectangle on which to compute the approximation. Format : [x,y], This defines a rectangle on which we draw the lines, uniformly drawn (with a max_error step). The first line is x. Warning: For custom boxes, and directions, you must ensure that the first line captures a generic barcode.
- direction: float[:] = []
If given, the line are drawn with this angle. Warning: You must ensure that the first line, defined by box, captures a generic barcode.
- slicer_backend: Either “matrix”,”clement”, or “graph”.
If a simplextree is given, it is first converted to this structure, with different choices of backends.
- minpres: (Optional) “mpfree” only for the moment.
If given, and the input is a simplextree, computes a minimal presentation before starting the computation. A degree has to be given.
- degree: int Only required when minpres is given.
Homological degree of the minimal degree.
- threshold: bool
When true, intersects the module support with the box, i.e. no more infinite summands.
- verbose: bool
Prints C++ infos.
- ignore_warningbool
Unless set to true, prevents computing on more than 10k lines. Useful to prevent a segmentation fault due to “infinite” recursion.
- PyModule
An interval decomposable module approximation of the module defined by the homology of this multi-filtration.
- multipers.multiparameter_module_approximation.module_approximation_from_slicer(slicer: Slicer_type, box: np.ndarray | None = None, max_error=-1, complete: bool = True, threshold: bool = False, verbose: bool = False, direction: list = [])
File: multipers/multiparameter_module_approximation.pyx (starting at line 50)
multipers.pickle module
- multipers.pickle.get_sm_with_axis(sms, idx, axis, degree)
- multipers.pickle.get_sm_without_axis(sms, idx, degree)
- multipers.pickle.load(path: str)
- multipers.pickle.load_with_axis(sms)
- multipers.pickle.load_without_axis(sms)
- multipers.pickle.save(path: str, signed_measures)
- multipers.pickle.save_with_axis(path: str, signed_measures)
- multipers.pickle.save_without_axis(path: str, signed_measures)
multipers.plots module
- multipers.plots.plot2d_PyModule(corners, box, *, dimension=-1, separated=False, min_persistence=0, alpha=1, verbose=False, save=False, dpi=200, shapely=True, xlabel=None, ylabel=None, cmap=None)
- multipers.plots.plot_signed_measure(signed_measure, threshold=None, ax=None, **plt_kwargs)
- multipers.plots.plot_signed_measures(signed_measures, threshold=None, size=4)
- multipers.plots.plot_surface(grid, hf, fig=None, ax=None, cmap: str | None = None, discrete_surface=False, has_negative_values=False, **plt_args)
- multipers.plots.plot_surfaces(HF, size=4, **plt_args)
multipers.point_measure_integration module
File: multipers/point_measure_integration.pyx (starting at line 1)
- multipers.point_measure_integration.clean_signed_measure(signatures, args, kwargs, defaults, _fused_sigindex={})
File: multipers/point_measure_integration.pyx (starting at line 108)
Sum the diracs at the same locations. i.e., returns the minimal sized measure to represent the input. Mostly useful for, e.g., euler_characteristic from simplical complexes.
- multipers.point_measure_integration.clean_sms(sms)
File: multipers/point_measure_integration.pyx (starting at line 131)
Sum the diracs at the same locations. i.e., returns the minimal sized measure to represent the input. Mostly useful for, e.g., euler_characteristic from simplical complexes.
- multipers.point_measure_integration.integrate_measure(signatures, args, kwargs, defaults, _fused_sigindex={})
File: multipers/point_measure_integration.pyx (starting at line 27)
Integrate a point measure on a grid. Measure is a sum of diracs, based on points pts and weights weights. For instance, if the signed measure comes from the hilbert signed measure, this integration will return the hilbert function on this grid.
pts : array of points (num_pts, D)
weights : array of weights (num_pts,)
filtration_grid (optional) : list of 1d arrays
resolution : int or list of int
return_grid : return the grid of the measure
- **get_fitration_kwargsarguments to compute the grid,
if the grid is not given.
- multipers.point_measure_integration.integrate_measure_python(pts, weights, filtrations)
File: multipers/point_measure_integration.pyx (starting at line 78)
- multipers.point_measure_integration.sparsify(x)
File: multipers/point_measure_integration.pyx (starting at line 89)
Given an arbitrary dimensional numpy array, returns (coordinates,data). – cost : scipy sparse + num_points*num_parameters^2 divisions
multipers.rank_invariant module
File: multipers/rank_invariant.pyx (starting at line 1)
- multipers.rank_invariant.rank_from_slicer(slicer, degrees: vector[indices_type], verbose: bool = False, n_jobs: int = 1, mass_default=None, grid_shape=None, grid_conversion=None, plot: bool = False, return_raw: bool = False)
File: multipers/rank_invariant.pyx (starting at line 166)
multipers.simplex_tree_multi module
File: multipers/simplex_tree_multi.pyx (starting at line 1)
- multipers.simplex_tree_multi.SimplexTreeMulti(input=None, num_parameters: int = 2, dtype: type = np.float64, kcritical: bool = False, **kwargs) SimplexTreeMulti_type
File: multipers/simplex_tree_multi.pyx (starting at line 8769) SimplexTreeMulti constructor.
- param other:
If other is None (default value), an empty SimplexTreeMulti is created. If other is a SimplexTree, the SimplexTreeMulti is constructed from a deep copy of other. If other is a SimplexTreeMulti, the SimplexTreeMulti is constructed from a deep copy of other.
- type other:
SimplexTree or SimplexTreeMulti (Optional)
- param num_parameters:
The number of parameter of the multi-parameter filtration.
- type num_parameters:
int
- returns:
An empty or a copy simplex tree.
- rtype:
SimplexTreeMulti
- raises TypeError:
In case other is neither None, nor a SimplexTree, nor a SimplexTreeMulti.
- class multipers.simplex_tree_multi.SimplexTreeMulti_Ff32
Bases:
object
File: multipers/simplex_tree_multi.pyx (starting at line 4408) The simplex tree is an efficient and flexible data structure for
representing general (filtered) simplicial complexes. The data structure is described in Jean-Daniel Boissonnat and Clément Maria. The Simplex Tree: An Efficient Data Structure for General Simplicial Complexes. Algorithmica, pages 1–22, 2014.
This class is a multi-filtered, with keys, and non contiguous vertices version of the simplex tree.
- assign_all(self, filtration_values) SimplexTreeMulti_Ff32
File: multipers/simplex_tree_multi.pyx (starting at line 4763)
Updates the filtration values of all of the simplices, with filtration_values with order given by the simplextree iterator, e.g. self.get_simplices().
- assign_batch_filtration
File: multipers/simplex_tree_multi.pyx (starting at line 4792) Assign k-simplices given by a sparse array in a format similar
to torch.sparse. The n-th simplex has vertices vertex_array[0,n], …, vertex_array[k,n] and filtration value filtrations[n,num_parameters]. /!Only compatible with 1-critical filtrations. If a simplex is repeated, only one filtration value will be taken into account.
- param vertex_array:
the k-simplices to assign.
- type vertex_array:
numpy.array of shape (k+1,n)
- param filtrations:
the filtration values.
- type filtrations:
numpy.array of shape (n,num_parameters)
- assign_filtration(self, simplex: list | np.ndarray, filtration: list | np.ndarray) SimplexTreeMulti_Ff32
File: multipers/simplex_tree_multi.pyx (starting at line 4515) This function assigns a new multi-critical filtration value to a
given N-simplex.
- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int
- param filtration:
The new filtration(s) value(s), concatenated.
- type filtration:
list[float] or np.ndarray[float, ndim=1]
Note
Beware that after this operation, the structure may not be a valid filtration anymore, a simplex could have a lower filtration value than one of its faces. Callers are responsible for fixing this (with more
assign_filtration()
ormake_filtration_non_decreasing()
for instance) before callingany function that relies on the filtration property, like
persistence()
.
- collapse_edges(self, num: int = 1, max_dimension: int = 0, progress: bool = False, strong: bool = True, full: bool = False, ignore_warning: bool = False) SimplexTreeMulti_Ff32
File: multipers/simplex_tree_multi.pyx (starting at line 5120) Edge collapse for 1-critical 2-parameter clique complex (see https://arxiv.org/abs/2211.05574).
It uses the code from the github repository https://github.com/aj-alonso/filtration_domination .
- max_dimension:int
Max simplicial dimension of the complex. Unless specified, keeps the same dimension.
- num:int
The number of collapses to do.
- strong:bool
Whether to use strong collapses or standard collapses (slower, but may remove more edges)
- full:bool
Collapses the maximum number of edges if true, i.e., will do (at most) 100 strong collapses and (at most) 100 non-strong collapses afterward.
- progress:bool
If true, shows the progress of the number of collapses.
This will destroy all of the k-simplices, with k>=2. Be sure to use this with a clique complex, if you want to preserve the homology >= dimension 1.
This is for 1 critical simplices, with 2 parameter persistence.
- self:SimplexTreeMulti
A (smaller) simplex tree that has the same homology over this bifiltration.
- copy(self) SimplexTreeMulti_Ff32
File: multipers/simplex_tree_multi.pyx (starting at line 4491)
- Returns:
A simplex tree that is a deep copy of itself.
- Return type:
SimplexTreeMulti
- Note:
The persistence information is not copied. If you need it in the clone, you have to call
compute_persistence()
on it even if you had already computed it in the original.
- dimension
dimension: int This function returns the dimension of the simplicial complex.
- 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
remove_maximal_simplex()
orprune_above_filtration()
methods).
- dtype
dtype: type
- euler_characteristic(self, dtype=np.float32)
File: multipers/simplex_tree_multi.pyx (starting at line 4828) This function returns a generator with simplices and their given
filtration values.
- returns:
The simplices.
- rtype:
generator with tuples(simplex, filtration)
- expansion(self, max_dim: int) SimplexTreeMulti_Ff32
File: multipers/simplex_tree_multi.pyx (starting at line 5024) Expands the simplex tree containing only its one skeleton
until dimension max_dim.
The expanded simplicial complex until dimension \(d\) attached to a graph \(G\) is the maximal simplicial complex of dimension at most \(d\) admitting the graph \(G\) as \(1\)-skeleton. The filtration value assigned to a simplex is the maximal filtration value of one of its edges.
The simplex tree must contain no simplex of dimension bigger than 1 when calling the method.
- param max_dim:
The maximal dimension.
- type max_dim:
int
- fill_lowerstar(self, F, parameter: int) SimplexTreeMulti_Ff32
File: multipers/simplex_tree_multi.pyx (starting at line 5481) Fills the `dimension`th filtration by the lower-star filtration defined by F.
- F:1d array
The density over the vertices, that induces a lowerstar filtration.
- parameter:int
Which filtration parameter to fill. /!python starts at 0.
self:SimplexTreeMulti
- filtration(self, simplex: list | np.ndarray) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 4505) 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 :returns: The simplicial complex multi-critical filtration value. :rtype: numpy array of shape (-1, num_parameters)
- filtration_bounds(self, degrees: Iterable[int] | None = None, q: float | tuple = 0, split_dimension: bool = False) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 5464)
Returns the filtrations bounds of the finite filtration values.
- filtration_grid
filtration_grid: vector[vector[double]] File: multipers/simplex_tree_multi.pyx (starting at line 4420)
- flagify(self, dim: int = 2)
File: multipers/simplex_tree_multi.pyx (starting at line 4595)
Turns this simplicial complex into a flag complex by resetting filtration values of simplices of dimension > dim by lower-star values.
- get_boundaries(self, simplex) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 4952) This function returns a generator with the boundaries of a given N-simplex.
If you do not need the filtration values, the boundary can also be obtained as
itertools.combinations(simplex,len(simplex)-1)
.- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int.
- returns:
The (simplices of the) boundary of a simplex
- rtype:
generator with tuples(simplex, filtration)
- get_edge_list(self)
File: multipers/simplex_tree_multi.pyx (starting at line 5111)
in the filtration-domination’s format
- get_filtration_grid(self, resolution: Iterable[int] | None = None, degrees: Iterable[int] | None = None, drop_quantiles: float | tuple = 0, grid_strategy: _available_strategies = 'exact') Iterable[np.ndarray]
File: multipers/simplex_tree_multi.pyx (starting at line 5395)
Returns a grid over the n-filtration, from the simplextree. Usefull for grid_squeeze. TODO : multicritical
Parameters
- resolution: list[int]
resolution of the grid, for each parameter
- box=Nonepair[list[float]]
Grid bounds. format : [low bound, high bound] If None is given, will use the filtration bounds of the simplextree.
- grid_strategy=”regular”string
Either “regular”, “quantile”, or “exact”.
Returns
List of filtration values, for each parameter, defining the grid.
- get_simplices(self) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 4858) This function returns a generator with simplices and their given
filtration values.
- returns:
The simplices.
- rtype:
generator with tuples(simplex, filtration)
- get_simplices_of_dimension(self, dim: int) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 5213)
- get_skeleton(self, dimension) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 4884) This function returns a generator with the (simplices of the) skeleton of a maximum given dimension.
- param dimension:
The skeleton dimension value.
- type dimension:
int
- returns:
The (simplices of the) skeleton of a maximum dimension.
- rtype:
generator with tuples(simplex, filtration)
- grid_squeeze(self, filtration_grid: np.ndarray | list | None = None, coordinate_values: bool = True, force=False, grid_strategy: _available_strategies = 'exact', inplace=False, **filtration_grid_kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 5429)
Fit the filtration of the simplextree to a grid.
- Parameters:
filtration_grid (list[list[float]]) – The grid on which to squeeze. An example of grid can be given by the get_filtration_grid method.
coordinate_values (bool) – If true, the filtrations values of the simplices will be set to the coordinate of the filtration grid.
- insert(self, simplex: vector[int], filtration: list | np.ndarray | None = None) bool
File: multipers/simplex_tree_multi.pyx (starting at line 4657) This function inserts the given N-simplex and its subfaces with the
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 not yet in the complex, false otherwise (whatever its original filtration value).
- rtype:
bool
- insert_batch
File: multipers/simplex_tree_multi.pyx (starting at line 4682) Inserts k-simplices given by a sparse array in a format similar
to torch.sparse. The n-th simplex has vertices vertex_array[0,n], …, vertex_array[k,n] and filtration value filtrations[n,num_parameters]. /!Only compatible with 1-critical filtrations. If a simplex is repeated, only one filtration value will be taken into account.
- param vertex_array:
the k-simplices to insert.
- type vertex_array:
numpy.array of shape (k+1,n)
- param filtrations:
the filtration values.
- type filtrations:
numpy.array of shape (n,num_parameters)
- static is_kcritical() bool
File: multipers/simplex_tree_multi.pyx (starting at line 4449)
- key(self, simplex: list | np.ndarray)
File: multipers/simplex_tree_multi.pyx (starting at line 5215)
- linear_projections(self, linear_forms: np.ndarray) Iterable[SimplexTree]
File: multipers/simplex_tree_multi.pyx (starting at line 5547)
Compute the 1-parameter projections, w.r.t. given the linear forms, of this simplextree.
Input
Array of shape (num_linear_forms, num_parameters)
Output
List of projected (gudhi) simplextrees.
- lower_star_multi_filtration_update(self, nodes_filtrations)
File: multipers/simplex_tree_multi.pyx (starting at line 4732)
Updates the multi filtration of the simplextree to the lower-star filtration defined on the vertices, by node_filtrations.
- make_filtration_non_decreasing(self) bool
File: multipers/simplex_tree_multi.pyx (starting at line 5047) This function ensures that each simplex has a higher filtration
value than its faces by increasing the filtration values.
- returns:
True if any filtration value was modified, False if the filtration was already non-decreasing.
- rtype:
bool
- num_parameters
num_parameters: int
- num_simplices
num_simplices: int This function returns the number of simplices of the simplicial
complex.
- returns:
the simplicial complex number of simplices.
- rtype:
int
- num_vertices
num_vertices: int This function returns the number of vertices of the simplicial
complex.
- returns:
The simplicial complex number of vertices.
- rtype:
int
- persistence_approximation(self, **kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 4879)
- project_on_line(self, parameter: int = 0, basepoint: None | list | np.ndarray = None, direction: None | list | np.ndarray = None) SimplexTree
File: multipers/simplex_tree_multi.pyx (starting at line 5506) Converts an multi simplextree to a gudhi simplextree.
- parameter:int = 0
The parameter to keep. WARNING will crash if the multi simplextree is not well filled.
- basepoint:None
Instead of keeping a single parameter, will consider the filtration defined by the diagonal line crossing the basepoint.
There are no safeguard yet, it WILL crash if asking for a parameter that is not filled.
A SimplexTree with chosen 1D filtration.
- prune_above_dimension(self, dimension: int)
File: multipers/simplex_tree_multi.pyx (starting at line 5014) Remove all simplices of dimension greater than a given value.
- param dimension:
Maximum dimension value.
- type dimension:
int
- returns:
The modification information.
- rtype:
bool
- pts_to_indices(self, pts: np.ndarray, simplices_dimensions: Iterable[int]) tuple[np.ndarray, np.ndarray]
File: multipers/simplex_tree_multi.pyx (starting at line 5076)
Returns the indices of the simplex tree with corresponding filtrations.
- Args:
st: SimplexTreeMulti on which to recover the indices.
- pts: (num_pts, num_parameters,) array of points to recover.
simplices_dimensions: (num_parameters,) the simplices dimension to take into account for each parameter.
- Returns:
A (m, num_parameters) array containing the found indices (m <= num_pts).
A (m, 2) array containing the non-found indices (pt_index, parameter failing).
- remove_maximal_simplex(self, simplex) SimplexTreeMulti_Ff32
File: multipers/simplex_tree_multi.pyx (starting at line 4972) This function removes a given maximal N-simplex from the simplicial
complex.
- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int
Note
The dimension of the simplicial complex may be lower after calling remove_maximal_simplex than it was before. However,
upper_bound_dimension()
method will return the old value, which remains a valid upper bound. If you care, you can calldimension()
to recompute the exact dimension.
- reset_filtration(self, filtration, min_dim=0) SimplexTreeMulti_Ff32
File: multipers/simplex_tree_multi.pyx (starting at line 5060) This function resets the filtration value of all the simplices of dimension at least min_dim. Resets all the
simplex tree when min_dim = 0. reset_filtration may break the filtration property with min_dim > 0, and it is the user’s responsibility to make it a valid filtration (using a large enough filt_value, or calling make_filtration_non_decreasing afterwards for instance).
- param filtration:
New threshold value.
- type filtration:
float.
- param min_dim:
The minimal dimension. Default value is 0.
- type min_dim:
int.
- set_dimension(self, dimension: int) None
File: multipers/simplex_tree_multi.pyx (starting at line 4619) 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
remove_maximal_simplex()
orprune_above_filtration()
).
- set_key(self, simplex: list | np.ndarray, key: int) None
File: multipers/simplex_tree_multi.pyx (starting at line 5220)
- set_keys_to_enumerate(self) None
File: multipers/simplex_tree_multi.pyx (starting at line 5217)
- set_num_parameter(self, num: int)
File: multipers/simplex_tree_multi.pyx (starting at line 5586)
Sets the numbers of parameters. WARNING : it will resize all the filtrations to this size.
- thisptr
thisptr: int File: multipers/simplex_tree_multi.pyx (starting at line 4418)
- to_rivet(self, path='rivet_dataset.txt', degree: int | None = None, progress: bool = False, overwrite: bool = False, xbins: int | None = None, ybins: int | None = None) None
File: multipers/simplex_tree_multi.pyx (starting at line 5330) Create a file that can be imported by rivet, representing the filtration of the simplextree.
- path:str
path of the file.
- degree:int
The homological degree to ask rivet to compute.
- progress:bool = True
Shows the progress bar.
- overwrite:bool = False
If true, will overwrite the previous file if it already exists.
- to_scc(self, **kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 5321)
Returns an scc representation of the simplextree.
- to_scc_function_st(self, path='scc_dataset.scc', rivet_compatible: bool = False, strip_comments: bool = False, ignore_last_generators: bool = False, overwrite: bool = False, reverse_block: bool = True)
File: multipers/simplex_tree_multi.pyx (starting at line 5277)
- to_scc_kcritical(self, path: os.PathLike | str, rivet_compatible: bool = False, strip_comments: bool = False, ignore_last_generators: bool = False, overwrite: bool = False, reverse_block: bool = False)
File: multipers/simplex_tree_multi.pyx (starting at line 5248)
TODO: function-simplextree, from squeezed
- upper_bound_dimension(self) int
File: multipers/simplex_tree_multi.pyx (starting at line 4582) This function returns a valid dimension upper bound of the
simplicial complex.
- returns:
an upper bound on the dimension of the simplicial complex.
- rtype:
int
- class multipers.simplex_tree_multi.SimplexTreeMulti_Ff64
Bases:
object
File: multipers/simplex_tree_multi.pyx (starting at line 6573) The simplex tree is an efficient and flexible data structure for
representing general (filtered) simplicial complexes. The data structure is described in Jean-Daniel Boissonnat and Clément Maria. The Simplex Tree: An Efficient Data Structure for General Simplicial Complexes. Algorithmica, pages 1–22, 2014.
This class is a multi-filtered, with keys, and non contiguous vertices version of the simplex tree.
- assign_all(self, filtration_values) SimplexTreeMulti_Ff64
File: multipers/simplex_tree_multi.pyx (starting at line 6928)
Updates the filtration values of all of the simplices, with filtration_values with order given by the simplextree iterator, e.g. self.get_simplices().
- assign_batch_filtration
File: multipers/simplex_tree_multi.pyx (starting at line 6957) Assign k-simplices given by a sparse array in a format similar
to torch.sparse. The n-th simplex has vertices vertex_array[0,n], …, vertex_array[k,n] and filtration value filtrations[n,num_parameters]. /!Only compatible with 1-critical filtrations. If a simplex is repeated, only one filtration value will be taken into account.
- param vertex_array:
the k-simplices to assign.
- type vertex_array:
numpy.array of shape (k+1,n)
- param filtrations:
the filtration values.
- type filtrations:
numpy.array of shape (n,num_parameters)
- assign_filtration(self, simplex: list | np.ndarray, filtration: list | np.ndarray) SimplexTreeMulti_Ff64
File: multipers/simplex_tree_multi.pyx (starting at line 6680) This function assigns a new multi-critical filtration value to a
given N-simplex.
- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int
- param filtration:
The new filtration(s) value(s), concatenated.
- type filtration:
list[float] or np.ndarray[float, ndim=1]
Note
Beware that after this operation, the structure may not be a valid filtration anymore, a simplex could have a lower filtration value than one of its faces. Callers are responsible for fixing this (with more
assign_filtration()
ormake_filtration_non_decreasing()
for instance) before callingany function that relies on the filtration property, like
persistence()
.
- collapse_edges(self, num: int = 1, max_dimension: int = 0, progress: bool = False, strong: bool = True, full: bool = False, ignore_warning: bool = False) SimplexTreeMulti_Ff64
File: multipers/simplex_tree_multi.pyx (starting at line 7285) Edge collapse for 1-critical 2-parameter clique complex (see https://arxiv.org/abs/2211.05574).
It uses the code from the github repository https://github.com/aj-alonso/filtration_domination .
- max_dimension:int
Max simplicial dimension of the complex. Unless specified, keeps the same dimension.
- num:int
The number of collapses to do.
- strong:bool
Whether to use strong collapses or standard collapses (slower, but may remove more edges)
- full:bool
Collapses the maximum number of edges if true, i.e., will do (at most) 100 strong collapses and (at most) 100 non-strong collapses afterward.
- progress:bool
If true, shows the progress of the number of collapses.
This will destroy all of the k-simplices, with k>=2. Be sure to use this with a clique complex, if you want to preserve the homology >= dimension 1.
This is for 1 critical simplices, with 2 parameter persistence.
- self:SimplexTreeMulti
A (smaller) simplex tree that has the same homology over this bifiltration.
- copy(self) SimplexTreeMulti_Ff64
File: multipers/simplex_tree_multi.pyx (starting at line 6656)
- Returns:
A simplex tree that is a deep copy of itself.
- Return type:
SimplexTreeMulti
- Note:
The persistence information is not copied. If you need it in the clone, you have to call
compute_persistence()
on it even if you had already computed it in the original.
- dimension
dimension: int This function returns the dimension of the simplicial complex.
- 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
remove_maximal_simplex()
orprune_above_filtration()
methods).
- dtype
dtype: type
- euler_characteristic(self, dtype=np.float64)
File: multipers/simplex_tree_multi.pyx (starting at line 6993) This function returns a generator with simplices and their given
filtration values.
- returns:
The simplices.
- rtype:
generator with tuples(simplex, filtration)
- expansion(self, max_dim: int) SimplexTreeMulti_Ff64
File: multipers/simplex_tree_multi.pyx (starting at line 7189) Expands the simplex tree containing only its one skeleton
until dimension max_dim.
The expanded simplicial complex until dimension \(d\) attached to a graph \(G\) is the maximal simplicial complex of dimension at most \(d\) admitting the graph \(G\) as \(1\)-skeleton. The filtration value assigned to a simplex is the maximal filtration value of one of its edges.
The simplex tree must contain no simplex of dimension bigger than 1 when calling the method.
- param max_dim:
The maximal dimension.
- type max_dim:
int
- fill_lowerstar(self, F, parameter: int) SimplexTreeMulti_Ff64
File: multipers/simplex_tree_multi.pyx (starting at line 7646) Fills the `dimension`th filtration by the lower-star filtration defined by F.
- F:1d array
The density over the vertices, that induces a lowerstar filtration.
- parameter:int
Which filtration parameter to fill. /!python starts at 0.
self:SimplexTreeMulti
- filtration(self, simplex: list | np.ndarray) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 6670) 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 :returns: The simplicial complex multi-critical filtration value. :rtype: numpy array of shape (-1, num_parameters)
- filtration_bounds(self, degrees: Iterable[int] | None = None, q: float | tuple = 0, split_dimension: bool = False) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 7629)
Returns the filtrations bounds of the finite filtration values.
- filtration_grid
filtration_grid: vector[vector[double]] File: multipers/simplex_tree_multi.pyx (starting at line 6585)
- flagify(self, dim: int = 2)
File: multipers/simplex_tree_multi.pyx (starting at line 6760)
Turns this simplicial complex into a flag complex by resetting filtration values of simplices of dimension > dim by lower-star values.
- get_boundaries(self, simplex) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 7117) This function returns a generator with the boundaries of a given N-simplex.
If you do not need the filtration values, the boundary can also be obtained as
itertools.combinations(simplex,len(simplex)-1)
.- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int.
- returns:
The (simplices of the) boundary of a simplex
- rtype:
generator with tuples(simplex, filtration)
- get_edge_list(self)
File: multipers/simplex_tree_multi.pyx (starting at line 7276)
in the filtration-domination’s format
- get_filtration_grid(self, resolution: Iterable[int] | None = None, degrees: Iterable[int] | None = None, drop_quantiles: float | tuple = 0, grid_strategy: _available_strategies = 'exact') Iterable[np.ndarray]
File: multipers/simplex_tree_multi.pyx (starting at line 7560)
Returns a grid over the n-filtration, from the simplextree. Usefull for grid_squeeze. TODO : multicritical
Parameters
- resolution: list[int]
resolution of the grid, for each parameter
- box=Nonepair[list[float]]
Grid bounds. format : [low bound, high bound] If None is given, will use the filtration bounds of the simplextree.
- grid_strategy=”regular”string
Either “regular”, “quantile”, or “exact”.
Returns
List of filtration values, for each parameter, defining the grid.
- get_simplices(self) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 7023) This function returns a generator with simplices and their given
filtration values.
- returns:
The simplices.
- rtype:
generator with tuples(simplex, filtration)
- get_simplices_of_dimension(self, dim: int) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 7378)
- get_skeleton(self, dimension) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 7049) This function returns a generator with the (simplices of the) skeleton of a maximum given dimension.
- param dimension:
The skeleton dimension value.
- type dimension:
int
- returns:
The (simplices of the) skeleton of a maximum dimension.
- rtype:
generator with tuples(simplex, filtration)
- grid_squeeze(self, filtration_grid: np.ndarray | list | None = None, coordinate_values: bool = True, force=False, grid_strategy: _available_strategies = 'exact', inplace=False, **filtration_grid_kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 7594)
Fit the filtration of the simplextree to a grid.
- Parameters:
filtration_grid (list[list[float]]) – The grid on which to squeeze. An example of grid can be given by the get_filtration_grid method.
coordinate_values (bool) – If true, the filtrations values of the simplices will be set to the coordinate of the filtration grid.
- insert(self, simplex: vector[int], filtration: list | np.ndarray | None = None) bool
File: multipers/simplex_tree_multi.pyx (starting at line 6822) This function inserts the given N-simplex and its subfaces with the
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 not yet in the complex, false otherwise (whatever its original filtration value).
- rtype:
bool
- insert_batch
File: multipers/simplex_tree_multi.pyx (starting at line 6847) Inserts k-simplices given by a sparse array in a format similar
to torch.sparse. The n-th simplex has vertices vertex_array[0,n], …, vertex_array[k,n] and filtration value filtrations[n,num_parameters]. /!Only compatible with 1-critical filtrations. If a simplex is repeated, only one filtration value will be taken into account.
- param vertex_array:
the k-simplices to insert.
- type vertex_array:
numpy.array of shape (k+1,n)
- param filtrations:
the filtration values.
- type filtrations:
numpy.array of shape (n,num_parameters)
- static is_kcritical() bool
File: multipers/simplex_tree_multi.pyx (starting at line 6614)
- key(self, simplex: list | np.ndarray)
File: multipers/simplex_tree_multi.pyx (starting at line 7380)
- linear_projections(self, linear_forms: np.ndarray) Iterable[SimplexTree]
File: multipers/simplex_tree_multi.pyx (starting at line 7712)
Compute the 1-parameter projections, w.r.t. given the linear forms, of this simplextree.
Input
Array of shape (num_linear_forms, num_parameters)
Output
List of projected (gudhi) simplextrees.
- lower_star_multi_filtration_update(self, nodes_filtrations)
File: multipers/simplex_tree_multi.pyx (starting at line 6897)
Updates the multi filtration of the simplextree to the lower-star filtration defined on the vertices, by node_filtrations.
- make_filtration_non_decreasing(self) bool
File: multipers/simplex_tree_multi.pyx (starting at line 7212) This function ensures that each simplex has a higher filtration
value than its faces by increasing the filtration values.
- returns:
True if any filtration value was modified, False if the filtration was already non-decreasing.
- rtype:
bool
- num_parameters
num_parameters: int
- num_simplices
num_simplices: int This function returns the number of simplices of the simplicial
complex.
- returns:
the simplicial complex number of simplices.
- rtype:
int
- num_vertices
num_vertices: int This function returns the number of vertices of the simplicial
complex.
- returns:
The simplicial complex number of vertices.
- rtype:
int
- persistence_approximation(self, **kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 7044)
- project_on_line(self, parameter: int = 0, basepoint: None | list | np.ndarray = None, direction: None | list | np.ndarray = None) SimplexTree
File: multipers/simplex_tree_multi.pyx (starting at line 7671) Converts an multi simplextree to a gudhi simplextree.
- parameter:int = 0
The parameter to keep. WARNING will crash if the multi simplextree is not well filled.
- basepoint:None
Instead of keeping a single parameter, will consider the filtration defined by the diagonal line crossing the basepoint.
There are no safeguard yet, it WILL crash if asking for a parameter that is not filled.
A SimplexTree with chosen 1D filtration.
- prune_above_dimension(self, dimension: int)
File: multipers/simplex_tree_multi.pyx (starting at line 7179) Remove all simplices of dimension greater than a given value.
- param dimension:
Maximum dimension value.
- type dimension:
int
- returns:
The modification information.
- rtype:
bool
- pts_to_indices(self, pts: np.ndarray, simplices_dimensions: Iterable[int]) tuple[np.ndarray, np.ndarray]
File: multipers/simplex_tree_multi.pyx (starting at line 7241)
Returns the indices of the simplex tree with corresponding filtrations.
- Args:
st: SimplexTreeMulti on which to recover the indices.
- pts: (num_pts, num_parameters,) array of points to recover.
simplices_dimensions: (num_parameters,) the simplices dimension to take into account for each parameter.
- Returns:
A (m, num_parameters) array containing the found indices (m <= num_pts).
A (m, 2) array containing the non-found indices (pt_index, parameter failing).
- remove_maximal_simplex(self, simplex) SimplexTreeMulti_Ff64
File: multipers/simplex_tree_multi.pyx (starting at line 7137) This function removes a given maximal N-simplex from the simplicial
complex.
- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int
Note
The dimension of the simplicial complex may be lower after calling remove_maximal_simplex than it was before. However,
upper_bound_dimension()
method will return the old value, which remains a valid upper bound. If you care, you can calldimension()
to recompute the exact dimension.
- reset_filtration(self, filtration, min_dim=0) SimplexTreeMulti_Ff64
File: multipers/simplex_tree_multi.pyx (starting at line 7225) This function resets the filtration value of all the simplices of dimension at least min_dim. Resets all the
simplex tree when min_dim = 0. reset_filtration may break the filtration property with min_dim > 0, and it is the user’s responsibility to make it a valid filtration (using a large enough filt_value, or calling make_filtration_non_decreasing afterwards for instance).
- param filtration:
New threshold value.
- type filtration:
float.
- param min_dim:
The minimal dimension. Default value is 0.
- type min_dim:
int.
- set_dimension(self, dimension: int) None
File: multipers/simplex_tree_multi.pyx (starting at line 6784) 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
remove_maximal_simplex()
orprune_above_filtration()
).
- set_key(self, simplex: list | np.ndarray, key: int) None
File: multipers/simplex_tree_multi.pyx (starting at line 7385)
- set_keys_to_enumerate(self) None
File: multipers/simplex_tree_multi.pyx (starting at line 7382)
- set_num_parameter(self, num: int)
File: multipers/simplex_tree_multi.pyx (starting at line 7751)
Sets the numbers of parameters. WARNING : it will resize all the filtrations to this size.
- thisptr
thisptr: int File: multipers/simplex_tree_multi.pyx (starting at line 6583)
- to_rivet(self, path='rivet_dataset.txt', degree: int | None = None, progress: bool = False, overwrite: bool = False, xbins: int | None = None, ybins: int | None = None) None
File: multipers/simplex_tree_multi.pyx (starting at line 7495) Create a file that can be imported by rivet, representing the filtration of the simplextree.
- path:str
path of the file.
- degree:int
The homological degree to ask rivet to compute.
- progress:bool = True
Shows the progress bar.
- overwrite:bool = False
If true, will overwrite the previous file if it already exists.
- to_scc(self, **kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 7486)
Returns an scc representation of the simplextree.
- to_scc_function_st(self, path='scc_dataset.scc', rivet_compatible: bool = False, strip_comments: bool = False, ignore_last_generators: bool = False, overwrite: bool = False, reverse_block: bool = True)
File: multipers/simplex_tree_multi.pyx (starting at line 7442)
- to_scc_kcritical(self, path: os.PathLike | str, rivet_compatible: bool = False, strip_comments: bool = False, ignore_last_generators: bool = False, overwrite: bool = False, reverse_block: bool = False)
File: multipers/simplex_tree_multi.pyx (starting at line 7413)
TODO: function-simplextree, from squeezed
- upper_bound_dimension(self) int
File: multipers/simplex_tree_multi.pyx (starting at line 6747) This function returns a valid dimension upper bound of the
simplicial complex.
- returns:
an upper bound on the dimension of the simplicial complex.
- rtype:
int
- class multipers.simplex_tree_multi.SimplexTreeMulti_Fi32
Bases:
object
File: multipers/simplex_tree_multi.pyx (starting at line 78) The simplex tree is an efficient and flexible data structure for
representing general (filtered) simplicial complexes. The data structure is described in Jean-Daniel Boissonnat and Clément Maria. The Simplex Tree: An Efficient Data Structure for General Simplicial Complexes. Algorithmica, pages 1–22, 2014.
This class is a multi-filtered, with keys, and non contiguous vertices version of the simplex tree.
- assign_all(self, filtration_values) SimplexTreeMulti_Fi32
File: multipers/simplex_tree_multi.pyx (starting at line 433)
Updates the filtration values of all of the simplices, with filtration_values with order given by the simplextree iterator, e.g. self.get_simplices().
- assign_batch_filtration
File: multipers/simplex_tree_multi.pyx (starting at line 462) Assign k-simplices given by a sparse array in a format similar
to torch.sparse. The n-th simplex has vertices vertex_array[0,n], …, vertex_array[k,n] and filtration value filtrations[n,num_parameters]. /!Only compatible with 1-critical filtrations. If a simplex is repeated, only one filtration value will be taken into account.
- param vertex_array:
the k-simplices to assign.
- type vertex_array:
numpy.array of shape (k+1,n)
- param filtrations:
the filtration values.
- type filtrations:
numpy.array of shape (n,num_parameters)
- assign_filtration(self, simplex: list | np.ndarray, filtration: list | np.ndarray) SimplexTreeMulti_Fi32
File: multipers/simplex_tree_multi.pyx (starting at line 185) This function assigns a new multi-critical filtration value to a
given N-simplex.
- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int
- param filtration:
The new filtration(s) value(s), concatenated.
- type filtration:
list[float] or np.ndarray[float, ndim=1]
Note
Beware that after this operation, the structure may not be a valid filtration anymore, a simplex could have a lower filtration value than one of its faces. Callers are responsible for fixing this (with more
assign_filtration()
ormake_filtration_non_decreasing()
for instance) before callingany function that relies on the filtration property, like
persistence()
.
- collapse_edges(self, num: int = 1, max_dimension: int = 0, progress: bool = False, strong: bool = True, full: bool = False, ignore_warning: bool = False) SimplexTreeMulti_Fi32
File: multipers/simplex_tree_multi.pyx (starting at line 790) Edge collapse for 1-critical 2-parameter clique complex (see https://arxiv.org/abs/2211.05574).
It uses the code from the github repository https://github.com/aj-alonso/filtration_domination .
- max_dimension:int
Max simplicial dimension of the complex. Unless specified, keeps the same dimension.
- num:int
The number of collapses to do.
- strong:bool
Whether to use strong collapses or standard collapses (slower, but may remove more edges)
- full:bool
Collapses the maximum number of edges if true, i.e., will do (at most) 100 strong collapses and (at most) 100 non-strong collapses afterward.
- progress:bool
If true, shows the progress of the number of collapses.
This will destroy all of the k-simplices, with k>=2. Be sure to use this with a clique complex, if you want to preserve the homology >= dimension 1.
This is for 1 critical simplices, with 2 parameter persistence.
- self:SimplexTreeMulti
A (smaller) simplex tree that has the same homology over this bifiltration.
- copy(self) SimplexTreeMulti_Fi32
File: multipers/simplex_tree_multi.pyx (starting at line 161)
- Returns:
A simplex tree that is a deep copy of itself.
- Return type:
SimplexTreeMulti
- Note:
The persistence information is not copied. If you need it in the clone, you have to call
compute_persistence()
on it even if you had already computed it in the original.
- dimension
dimension: int This function returns the dimension of the simplicial complex.
- 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
remove_maximal_simplex()
orprune_above_filtration()
methods).
- dtype
dtype: type
- euler_characteristic(self, dtype=np.int32)
File: multipers/simplex_tree_multi.pyx (starting at line 498) This function returns a generator with simplices and their given
filtration values.
- returns:
The simplices.
- rtype:
generator with tuples(simplex, filtration)
- expansion(self, max_dim: int) SimplexTreeMulti_Fi32
File: multipers/simplex_tree_multi.pyx (starting at line 694) Expands the simplex tree containing only its one skeleton
until dimension max_dim.
The expanded simplicial complex until dimension \(d\) attached to a graph \(G\) is the maximal simplicial complex of dimension at most \(d\) admitting the graph \(G\) as \(1\)-skeleton. The filtration value assigned to a simplex is the maximal filtration value of one of its edges.
The simplex tree must contain no simplex of dimension bigger than 1 when calling the method.
- param max_dim:
The maximal dimension.
- type max_dim:
int
- fill_lowerstar(self, F, parameter: int) SimplexTreeMulti_Fi32
File: multipers/simplex_tree_multi.pyx (starting at line 1151) Fills the `dimension`th filtration by the lower-star filtration defined by F.
- F:1d array
The density over the vertices, that induces a lowerstar filtration.
- parameter:int
Which filtration parameter to fill. /!python starts at 0.
self:SimplexTreeMulti
- filtration(self, simplex: list | np.ndarray) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 175) 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 :returns: The simplicial complex multi-critical filtration value. :rtype: numpy array of shape (-1, num_parameters)
- filtration_bounds(self, degrees: Iterable[int] | None = None, q: float | tuple = 0, split_dimension: bool = False) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 1134)
Returns the filtrations bounds of the finite filtration values.
- filtration_grid
filtration_grid: vector[vector[double]] File: multipers/simplex_tree_multi.pyx (starting at line 90)
- flagify(self, dim: int = 2)
File: multipers/simplex_tree_multi.pyx (starting at line 265)
Turns this simplicial complex into a flag complex by resetting filtration values of simplices of dimension > dim by lower-star values.
- get_boundaries(self, simplex) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 622) This function returns a generator with the boundaries of a given N-simplex.
If you do not need the filtration values, the boundary can also be obtained as
itertools.combinations(simplex,len(simplex)-1)
.- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int.
- returns:
The (simplices of the) boundary of a simplex
- rtype:
generator with tuples(simplex, filtration)
- get_edge_list(self)
File: multipers/simplex_tree_multi.pyx (starting at line 781)
in the filtration-domination’s format
- get_filtration_grid(self, resolution: Iterable[int] | None = None, degrees: Iterable[int] | None = None, drop_quantiles: float | tuple = 0, grid_strategy: _available_strategies = 'exact') Iterable[np.ndarray]
File: multipers/simplex_tree_multi.pyx (starting at line 1065)
Returns a grid over the n-filtration, from the simplextree. Usefull for grid_squeeze. TODO : multicritical
Parameters
- resolution: list[int]
resolution of the grid, for each parameter
- box=Nonepair[list[float]]
Grid bounds. format : [low bound, high bound] If None is given, will use the filtration bounds of the simplextree.
- grid_strategy=”regular”string
Either “regular”, “quantile”, or “exact”.
Returns
List of filtration values, for each parameter, defining the grid.
- get_simplices(self) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 528) This function returns a generator with simplices and their given
filtration values.
- returns:
The simplices.
- rtype:
generator with tuples(simplex, filtration)
- get_simplices_of_dimension(self, dim: int) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 883)
- get_skeleton(self, dimension) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 554) This function returns a generator with the (simplices of the) skeleton of a maximum given dimension.
- param dimension:
The skeleton dimension value.
- type dimension:
int
- returns:
The (simplices of the) skeleton of a maximum dimension.
- rtype:
generator with tuples(simplex, filtration)
- grid_squeeze(self, filtration_grid: np.ndarray | list | None = None, coordinate_values: bool = True, force=False, grid_strategy: _available_strategies = 'exact', inplace=False, **filtration_grid_kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 1099)
Fit the filtration of the simplextree to a grid.
- Parameters:
filtration_grid (list[list[float]]) – The grid on which to squeeze. An example of grid can be given by the get_filtration_grid method.
coordinate_values (bool) – If true, the filtrations values of the simplices will be set to the coordinate of the filtration grid.
- insert(self, simplex: vector[int], filtration: list | np.ndarray | None = None) bool
File: multipers/simplex_tree_multi.pyx (starting at line 327) This function inserts the given N-simplex and its subfaces with the
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 not yet in the complex, false otherwise (whatever its original filtration value).
- rtype:
bool
- insert_batch
File: multipers/simplex_tree_multi.pyx (starting at line 352) Inserts k-simplices given by a sparse array in a format similar
to torch.sparse. The n-th simplex has vertices vertex_array[0,n], …, vertex_array[k,n] and filtration value filtrations[n,num_parameters]. /!Only compatible with 1-critical filtrations. If a simplex is repeated, only one filtration value will be taken into account.
- param vertex_array:
the k-simplices to insert.
- type vertex_array:
numpy.array of shape (k+1,n)
- param filtrations:
the filtration values.
- type filtrations:
numpy.array of shape (n,num_parameters)
- static is_kcritical() bool
File: multipers/simplex_tree_multi.pyx (starting at line 119)
- key(self, simplex: list | np.ndarray)
File: multipers/simplex_tree_multi.pyx (starting at line 885)
- linear_projections(self, linear_forms: np.ndarray) Iterable[SimplexTree]
File: multipers/simplex_tree_multi.pyx (starting at line 1217)
Compute the 1-parameter projections, w.r.t. given the linear forms, of this simplextree.
Input
Array of shape (num_linear_forms, num_parameters)
Output
List of projected (gudhi) simplextrees.
- lower_star_multi_filtration_update(self, nodes_filtrations)
File: multipers/simplex_tree_multi.pyx (starting at line 402)
Updates the multi filtration of the simplextree to the lower-star filtration defined on the vertices, by node_filtrations.
- make_filtration_non_decreasing(self) bool
File: multipers/simplex_tree_multi.pyx (starting at line 717) This function ensures that each simplex has a higher filtration
value than its faces by increasing the filtration values.
- returns:
True if any filtration value was modified, False if the filtration was already non-decreasing.
- rtype:
bool
- num_parameters
num_parameters: int
- num_simplices
num_simplices: int This function returns the number of simplices of the simplicial
complex.
- returns:
the simplicial complex number of simplices.
- rtype:
int
- num_vertices
num_vertices: int This function returns the number of vertices of the simplicial
complex.
- returns:
The simplicial complex number of vertices.
- rtype:
int
- persistence_approximation(self, **kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 549)
- project_on_line(self, parameter: int = 0, basepoint: None | list | np.ndarray = None, direction: None | list | np.ndarray = None) SimplexTree
File: multipers/simplex_tree_multi.pyx (starting at line 1176) Converts an multi simplextree to a gudhi simplextree.
- parameter:int = 0
The parameter to keep. WARNING will crash if the multi simplextree is not well filled.
- basepoint:None
Instead of keeping a single parameter, will consider the filtration defined by the diagonal line crossing the basepoint.
There are no safeguard yet, it WILL crash if asking for a parameter that is not filled.
A SimplexTree with chosen 1D filtration.
- prune_above_dimension(self, dimension: int)
File: multipers/simplex_tree_multi.pyx (starting at line 684) Remove all simplices of dimension greater than a given value.
- param dimension:
Maximum dimension value.
- type dimension:
int
- returns:
The modification information.
- rtype:
bool
- pts_to_indices(self, pts: np.ndarray, simplices_dimensions: Iterable[int]) tuple[np.ndarray, np.ndarray]
File: multipers/simplex_tree_multi.pyx (starting at line 746)
Returns the indices of the simplex tree with corresponding filtrations.
- Args:
st: SimplexTreeMulti on which to recover the indices.
- pts: (num_pts, num_parameters,) array of points to recover.
simplices_dimensions: (num_parameters,) the simplices dimension to take into account for each parameter.
- Returns:
A (m, num_parameters) array containing the found indices (m <= num_pts).
A (m, 2) array containing the non-found indices (pt_index, parameter failing).
- remove_maximal_simplex(self, simplex) SimplexTreeMulti_Fi32
File: multipers/simplex_tree_multi.pyx (starting at line 642) This function removes a given maximal N-simplex from the simplicial
complex.
- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int
Note
The dimension of the simplicial complex may be lower after calling remove_maximal_simplex than it was before. However,
upper_bound_dimension()
method will return the old value, which remains a valid upper bound. If you care, you can calldimension()
to recompute the exact dimension.
- reset_filtration(self, filtration, min_dim=0) SimplexTreeMulti_Fi32
File: multipers/simplex_tree_multi.pyx (starting at line 730) This function resets the filtration value of all the simplices of dimension at least min_dim. Resets all the
simplex tree when min_dim = 0. reset_filtration may break the filtration property with min_dim > 0, and it is the user’s responsibility to make it a valid filtration (using a large enough filt_value, or calling make_filtration_non_decreasing afterwards for instance).
- param filtration:
New threshold value.
- type filtration:
float.
- param min_dim:
The minimal dimension. Default value is 0.
- type min_dim:
int.
- set_dimension(self, dimension: int) None
File: multipers/simplex_tree_multi.pyx (starting at line 289) 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
remove_maximal_simplex()
orprune_above_filtration()
).
- set_key(self, simplex: list | np.ndarray, key: int) None
File: multipers/simplex_tree_multi.pyx (starting at line 890)
- set_keys_to_enumerate(self) None
File: multipers/simplex_tree_multi.pyx (starting at line 887)
- set_num_parameter(self, num: int)
File: multipers/simplex_tree_multi.pyx (starting at line 1256)
Sets the numbers of parameters. WARNING : it will resize all the filtrations to this size.
- thisptr
thisptr: int File: multipers/simplex_tree_multi.pyx (starting at line 88)
- to_rivet(self, path='rivet_dataset.txt', degree: int | None = None, progress: bool = False, overwrite: bool = False, xbins: int | None = None, ybins: int | None = None) None
File: multipers/simplex_tree_multi.pyx (starting at line 1000) Create a file that can be imported by rivet, representing the filtration of the simplextree.
- path:str
path of the file.
- degree:int
The homological degree to ask rivet to compute.
- progress:bool = True
Shows the progress bar.
- overwrite:bool = False
If true, will overwrite the previous file if it already exists.
- to_scc(self, **kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 991)
Returns an scc representation of the simplextree.
- to_scc_function_st(self, path='scc_dataset.scc', rivet_compatible: bool = False, strip_comments: bool = False, ignore_last_generators: bool = False, overwrite: bool = False, reverse_block: bool = True)
File: multipers/simplex_tree_multi.pyx (starting at line 947)
- to_scc_kcritical(self, path: os.PathLike | str, rivet_compatible: bool = False, strip_comments: bool = False, ignore_last_generators: bool = False, overwrite: bool = False, reverse_block: bool = False)
File: multipers/simplex_tree_multi.pyx (starting at line 918)
TODO: function-simplextree, from squeezed
- upper_bound_dimension(self) int
File: multipers/simplex_tree_multi.pyx (starting at line 252) This function returns a valid dimension upper bound of the
simplicial complex.
- returns:
an upper bound on the dimension of the simplicial complex.
- rtype:
int
- class multipers.simplex_tree_multi.SimplexTreeMulti_Fi64
Bases:
object
File: multipers/simplex_tree_multi.pyx (starting at line 2243) The simplex tree is an efficient and flexible data structure for
representing general (filtered) simplicial complexes. The data structure is described in Jean-Daniel Boissonnat and Clément Maria. The Simplex Tree: An Efficient Data Structure for General Simplicial Complexes. Algorithmica, pages 1–22, 2014.
This class is a multi-filtered, with keys, and non contiguous vertices version of the simplex tree.
- assign_all(self, filtration_values) SimplexTreeMulti_Fi64
File: multipers/simplex_tree_multi.pyx (starting at line 2598)
Updates the filtration values of all of the simplices, with filtration_values with order given by the simplextree iterator, e.g. self.get_simplices().
- assign_batch_filtration
File: multipers/simplex_tree_multi.pyx (starting at line 2627) Assign k-simplices given by a sparse array in a format similar
to torch.sparse. The n-th simplex has vertices vertex_array[0,n], …, vertex_array[k,n] and filtration value filtrations[n,num_parameters]. /!Only compatible with 1-critical filtrations. If a simplex is repeated, only one filtration value will be taken into account.
- param vertex_array:
the k-simplices to assign.
- type vertex_array:
numpy.array of shape (k+1,n)
- param filtrations:
the filtration values.
- type filtrations:
numpy.array of shape (n,num_parameters)
- assign_filtration(self, simplex: list | np.ndarray, filtration: list | np.ndarray) SimplexTreeMulti_Fi64
File: multipers/simplex_tree_multi.pyx (starting at line 2350) This function assigns a new multi-critical filtration value to a
given N-simplex.
- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int
- param filtration:
The new filtration(s) value(s), concatenated.
- type filtration:
list[float] or np.ndarray[float, ndim=1]
Note
Beware that after this operation, the structure may not be a valid filtration anymore, a simplex could have a lower filtration value than one of its faces. Callers are responsible for fixing this (with more
assign_filtration()
ormake_filtration_non_decreasing()
for instance) before callingany function that relies on the filtration property, like
persistence()
.
- collapse_edges(self, num: int = 1, max_dimension: int = 0, progress: bool = False, strong: bool = True, full: bool = False, ignore_warning: bool = False) SimplexTreeMulti_Fi64
File: multipers/simplex_tree_multi.pyx (starting at line 2955) Edge collapse for 1-critical 2-parameter clique complex (see https://arxiv.org/abs/2211.05574).
It uses the code from the github repository https://github.com/aj-alonso/filtration_domination .
- max_dimension:int
Max simplicial dimension of the complex. Unless specified, keeps the same dimension.
- num:int
The number of collapses to do.
- strong:bool
Whether to use strong collapses or standard collapses (slower, but may remove more edges)
- full:bool
Collapses the maximum number of edges if true, i.e., will do (at most) 100 strong collapses and (at most) 100 non-strong collapses afterward.
- progress:bool
If true, shows the progress of the number of collapses.
This will destroy all of the k-simplices, with k>=2. Be sure to use this with a clique complex, if you want to preserve the homology >= dimension 1.
This is for 1 critical simplices, with 2 parameter persistence.
- self:SimplexTreeMulti
A (smaller) simplex tree that has the same homology over this bifiltration.
- copy(self) SimplexTreeMulti_Fi64
File: multipers/simplex_tree_multi.pyx (starting at line 2326)
- Returns:
A simplex tree that is a deep copy of itself.
- Return type:
SimplexTreeMulti
- Note:
The persistence information is not copied. If you need it in the clone, you have to call
compute_persistence()
on it even if you had already computed it in the original.
- dimension
dimension: int This function returns the dimension of the simplicial complex.
- 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
remove_maximal_simplex()
orprune_above_filtration()
methods).
- dtype
dtype: type
- euler_characteristic(self, dtype=np.int64)
File: multipers/simplex_tree_multi.pyx (starting at line 2663) This function returns a generator with simplices and their given
filtration values.
- returns:
The simplices.
- rtype:
generator with tuples(simplex, filtration)
- expansion(self, max_dim: int) SimplexTreeMulti_Fi64
File: multipers/simplex_tree_multi.pyx (starting at line 2859) Expands the simplex tree containing only its one skeleton
until dimension max_dim.
The expanded simplicial complex until dimension \(d\) attached to a graph \(G\) is the maximal simplicial complex of dimension at most \(d\) admitting the graph \(G\) as \(1\)-skeleton. The filtration value assigned to a simplex is the maximal filtration value of one of its edges.
The simplex tree must contain no simplex of dimension bigger than 1 when calling the method.
- param max_dim:
The maximal dimension.
- type max_dim:
int
- fill_lowerstar(self, F, parameter: int) SimplexTreeMulti_Fi64
File: multipers/simplex_tree_multi.pyx (starting at line 3316) Fills the `dimension`th filtration by the lower-star filtration defined by F.
- F:1d array
The density over the vertices, that induces a lowerstar filtration.
- parameter:int
Which filtration parameter to fill. /!python starts at 0.
self:SimplexTreeMulti
- filtration(self, simplex: list | np.ndarray) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 2340) 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 :returns: The simplicial complex multi-critical filtration value. :rtype: numpy array of shape (-1, num_parameters)
- filtration_bounds(self, degrees: Iterable[int] | None = None, q: float | tuple = 0, split_dimension: bool = False) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 3299)
Returns the filtrations bounds of the finite filtration values.
- filtration_grid
filtration_grid: vector[vector[double]] File: multipers/simplex_tree_multi.pyx (starting at line 2255)
- flagify(self, dim: int = 2)
File: multipers/simplex_tree_multi.pyx (starting at line 2430)
Turns this simplicial complex into a flag complex by resetting filtration values of simplices of dimension > dim by lower-star values.
- get_boundaries(self, simplex) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 2787) This function returns a generator with the boundaries of a given N-simplex.
If you do not need the filtration values, the boundary can also be obtained as
itertools.combinations(simplex,len(simplex)-1)
.- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int.
- returns:
The (simplices of the) boundary of a simplex
- rtype:
generator with tuples(simplex, filtration)
- get_edge_list(self)
File: multipers/simplex_tree_multi.pyx (starting at line 2946)
in the filtration-domination’s format
- get_filtration_grid(self, resolution: Iterable[int] | None = None, degrees: Iterable[int] | None = None, drop_quantiles: float | tuple = 0, grid_strategy: _available_strategies = 'exact') Iterable[np.ndarray]
File: multipers/simplex_tree_multi.pyx (starting at line 3230)
Returns a grid over the n-filtration, from the simplextree. Usefull for grid_squeeze. TODO : multicritical
Parameters
- resolution: list[int]
resolution of the grid, for each parameter
- box=Nonepair[list[float]]
Grid bounds. format : [low bound, high bound] If None is given, will use the filtration bounds of the simplextree.
- grid_strategy=”regular”string
Either “regular”, “quantile”, or “exact”.
Returns
List of filtration values, for each parameter, defining the grid.
- get_simplices(self) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 2693) This function returns a generator with simplices and their given
filtration values.
- returns:
The simplices.
- rtype:
generator with tuples(simplex, filtration)
- get_simplices_of_dimension(self, dim: int) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 3048)
- get_skeleton(self, dimension) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 2719) This function returns a generator with the (simplices of the) skeleton of a maximum given dimension.
- param dimension:
The skeleton dimension value.
- type dimension:
int
- returns:
The (simplices of the) skeleton of a maximum dimension.
- rtype:
generator with tuples(simplex, filtration)
- grid_squeeze(self, filtration_grid: np.ndarray | list | None = None, coordinate_values: bool = True, force=False, grid_strategy: _available_strategies = 'exact', inplace=False, **filtration_grid_kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 3264)
Fit the filtration of the simplextree to a grid.
- Parameters:
filtration_grid (list[list[float]]) – The grid on which to squeeze. An example of grid can be given by the get_filtration_grid method.
coordinate_values (bool) – If true, the filtrations values of the simplices will be set to the coordinate of the filtration grid.
- insert(self, simplex: vector[int], filtration: list | np.ndarray | None = None) bool
File: multipers/simplex_tree_multi.pyx (starting at line 2492) This function inserts the given N-simplex and its subfaces with the
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 not yet in the complex, false otherwise (whatever its original filtration value).
- rtype:
bool
- insert_batch
File: multipers/simplex_tree_multi.pyx (starting at line 2517) Inserts k-simplices given by a sparse array in a format similar
to torch.sparse. The n-th simplex has vertices vertex_array[0,n], …, vertex_array[k,n] and filtration value filtrations[n,num_parameters]. /!Only compatible with 1-critical filtrations. If a simplex is repeated, only one filtration value will be taken into account.
- param vertex_array:
the k-simplices to insert.
- type vertex_array:
numpy.array of shape (k+1,n)
- param filtrations:
the filtration values.
- type filtrations:
numpy.array of shape (n,num_parameters)
- static is_kcritical() bool
File: multipers/simplex_tree_multi.pyx (starting at line 2284)
- key(self, simplex: list | np.ndarray)
File: multipers/simplex_tree_multi.pyx (starting at line 3050)
- linear_projections(self, linear_forms: np.ndarray) Iterable[SimplexTree]
File: multipers/simplex_tree_multi.pyx (starting at line 3382)
Compute the 1-parameter projections, w.r.t. given the linear forms, of this simplextree.
Input
Array of shape (num_linear_forms, num_parameters)
Output
List of projected (gudhi) simplextrees.
- lower_star_multi_filtration_update(self, nodes_filtrations)
File: multipers/simplex_tree_multi.pyx (starting at line 2567)
Updates the multi filtration of the simplextree to the lower-star filtration defined on the vertices, by node_filtrations.
- make_filtration_non_decreasing(self) bool
File: multipers/simplex_tree_multi.pyx (starting at line 2882) This function ensures that each simplex has a higher filtration
value than its faces by increasing the filtration values.
- returns:
True if any filtration value was modified, False if the filtration was already non-decreasing.
- rtype:
bool
- num_parameters
num_parameters: int
- num_simplices
num_simplices: int This function returns the number of simplices of the simplicial
complex.
- returns:
the simplicial complex number of simplices.
- rtype:
int
- num_vertices
num_vertices: int This function returns the number of vertices of the simplicial
complex.
- returns:
The simplicial complex number of vertices.
- rtype:
int
- persistence_approximation(self, **kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 2714)
- project_on_line(self, parameter: int = 0, basepoint: None | list | np.ndarray = None, direction: None | list | np.ndarray = None) SimplexTree
File: multipers/simplex_tree_multi.pyx (starting at line 3341) Converts an multi simplextree to a gudhi simplextree.
- parameter:int = 0
The parameter to keep. WARNING will crash if the multi simplextree is not well filled.
- basepoint:None
Instead of keeping a single parameter, will consider the filtration defined by the diagonal line crossing the basepoint.
There are no safeguard yet, it WILL crash if asking for a parameter that is not filled.
A SimplexTree with chosen 1D filtration.
- prune_above_dimension(self, dimension: int)
File: multipers/simplex_tree_multi.pyx (starting at line 2849) Remove all simplices of dimension greater than a given value.
- param dimension:
Maximum dimension value.
- type dimension:
int
- returns:
The modification information.
- rtype:
bool
- pts_to_indices(self, pts: np.ndarray, simplices_dimensions: Iterable[int]) tuple[np.ndarray, np.ndarray]
File: multipers/simplex_tree_multi.pyx (starting at line 2911)
Returns the indices of the simplex tree with corresponding filtrations.
- Args:
st: SimplexTreeMulti on which to recover the indices.
- pts: (num_pts, num_parameters,) array of points to recover.
simplices_dimensions: (num_parameters,) the simplices dimension to take into account for each parameter.
- Returns:
A (m, num_parameters) array containing the found indices (m <= num_pts).
A (m, 2) array containing the non-found indices (pt_index, parameter failing).
- remove_maximal_simplex(self, simplex) SimplexTreeMulti_Fi64
File: multipers/simplex_tree_multi.pyx (starting at line 2807) This function removes a given maximal N-simplex from the simplicial
complex.
- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int
Note
The dimension of the simplicial complex may be lower after calling remove_maximal_simplex than it was before. However,
upper_bound_dimension()
method will return the old value, which remains a valid upper bound. If you care, you can calldimension()
to recompute the exact dimension.
- reset_filtration(self, filtration, min_dim=0) SimplexTreeMulti_Fi64
File: multipers/simplex_tree_multi.pyx (starting at line 2895) This function resets the filtration value of all the simplices of dimension at least min_dim. Resets all the
simplex tree when min_dim = 0. reset_filtration may break the filtration property with min_dim > 0, and it is the user’s responsibility to make it a valid filtration (using a large enough filt_value, or calling make_filtration_non_decreasing afterwards for instance).
- param filtration:
New threshold value.
- type filtration:
float.
- param min_dim:
The minimal dimension. Default value is 0.
- type min_dim:
int.
- set_dimension(self, dimension: int) None
File: multipers/simplex_tree_multi.pyx (starting at line 2454) 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
remove_maximal_simplex()
orprune_above_filtration()
).
- set_key(self, simplex: list | np.ndarray, key: int) None
File: multipers/simplex_tree_multi.pyx (starting at line 3055)
- set_keys_to_enumerate(self) None
File: multipers/simplex_tree_multi.pyx (starting at line 3052)
- set_num_parameter(self, num: int)
File: multipers/simplex_tree_multi.pyx (starting at line 3421)
Sets the numbers of parameters. WARNING : it will resize all the filtrations to this size.
- thisptr
thisptr: int File: multipers/simplex_tree_multi.pyx (starting at line 2253)
- to_rivet(self, path='rivet_dataset.txt', degree: int | None = None, progress: bool = False, overwrite: bool = False, xbins: int | None = None, ybins: int | None = None) None
File: multipers/simplex_tree_multi.pyx (starting at line 3165) Create a file that can be imported by rivet, representing the filtration of the simplextree.
- path:str
path of the file.
- degree:int
The homological degree to ask rivet to compute.
- progress:bool = True
Shows the progress bar.
- overwrite:bool = False
If true, will overwrite the previous file if it already exists.
- to_scc(self, **kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 3156)
Returns an scc representation of the simplextree.
- to_scc_function_st(self, path='scc_dataset.scc', rivet_compatible: bool = False, strip_comments: bool = False, ignore_last_generators: bool = False, overwrite: bool = False, reverse_block: bool = True)
File: multipers/simplex_tree_multi.pyx (starting at line 3112)
- to_scc_kcritical(self, path: os.PathLike | str, rivet_compatible: bool = False, strip_comments: bool = False, ignore_last_generators: bool = False, overwrite: bool = False, reverse_block: bool = False)
File: multipers/simplex_tree_multi.pyx (starting at line 3083)
TODO: function-simplextree, from squeezed
- upper_bound_dimension(self) int
File: multipers/simplex_tree_multi.pyx (starting at line 2417) This function returns a valid dimension upper bound of the
simplicial complex.
- returns:
an upper bound on the dimension of the simplicial complex.
- rtype:
int
- class multipers.simplex_tree_multi.SimplexTreeMulti_KFf32
Bases:
object
File: multipers/simplex_tree_multi.pyx (starting at line 5655) The simplex tree is an efficient and flexible data structure for
representing general (filtered) simplicial complexes. The data structure is described in Jean-Daniel Boissonnat and Clément Maria. The Simplex Tree: An Efficient Data Structure for General Simplicial Complexes. Algorithmica, pages 1–22, 2014.
This class is a multi-filtered, with keys, and non contiguous vertices version of the simplex tree.
- assign_filtration(self, simplex: list | np.ndarray, filtration: list | np.ndarray) SimplexTreeMulti_KFf32
File: multipers/simplex_tree_multi.pyx (starting at line 5762) This function assigns a new multi-critical filtration value to a
given N-simplex.
- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int
- param filtration:
The new filtration(s) value(s), concatenated.
- type filtration:
list[float] or np.ndarray[float, ndim=1]
Note
Beware that after this operation, the structure may not be a valid filtration anymore, a simplex could have a lower filtration value than one of its faces. Callers are responsible for fixing this (with more
assign_filtration()
ormake_filtration_non_decreasing()
for instance) before callingany function that relies on the filtration property, like
persistence()
.
- copy(self) SimplexTreeMulti_KFf32
File: multipers/simplex_tree_multi.pyx (starting at line 5738)
- Returns:
A simplex tree that is a deep copy of itself.
- Return type:
SimplexTreeMulti
- Note:
The persistence information is not copied. If you need it in the clone, you have to call
compute_persistence()
on it even if you had already computed it in the original.
- dimension
dimension: int This function returns the dimension of the simplicial complex.
- 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
remove_maximal_simplex()
orprune_above_filtration()
methods).
- dtype
dtype: type
- fill_lowerstar(self, F, parameter: int) SimplexTreeMulti_KFf32
File: multipers/simplex_tree_multi.pyx (starting at line 6399) Fills the `dimension`th filtration by the lower-star filtration defined by F.
- F:1d array
The density over the vertices, that induces a lowerstar filtration.
- parameter:int
Which filtration parameter to fill. /!python starts at 0.
self:SimplexTreeMulti
- filtration(self, simplex: list | np.ndarray) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 5752) 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 :returns: The simplicial complex multi-critical filtration value. :rtype: numpy array of shape (-1, num_parameters)
- filtration_bounds(self, degrees: Iterable[int] | None = None, q: float | tuple = 0, split_dimension: bool = False) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 6382)
Returns the filtrations bounds of the finite filtration values.
- filtration_grid
filtration_grid: vector[vector[double]] File: multipers/simplex_tree_multi.pyx (starting at line 5667)
- flagify(self, dim: int = 2)
File: multipers/simplex_tree_multi.pyx (starting at line 5842)
Turns this simplicial complex into a flag complex by resetting filtration values of simplices of dimension > dim by lower-star values.
- get_boundaries(self, simplex) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 6038) This function returns a generator with the boundaries of a given N-simplex.
If you do not need the filtration values, the boundary can also be obtained as
itertools.combinations(simplex,len(simplex)-1)
.- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int.
- returns:
The (simplices of the) boundary of a simplex
- rtype:
generator with tuples(simplex, filtration)
- get_filtration_grid(self, resolution: Iterable[int] | None = None, degrees: Iterable[int] | None = None, drop_quantiles: float | tuple = 0, grid_strategy: _available_strategies = 'exact') Iterable[np.ndarray]
File: multipers/simplex_tree_multi.pyx (starting at line 6313)
Returns a grid over the n-filtration, from the simplextree. Usefull for grid_squeeze. TODO : multicritical
Parameters
- resolution: list[int]
resolution of the grid, for each parameter
- box=Nonepair[list[float]]
Grid bounds. format : [low bound, high bound] If None is given, will use the filtration bounds of the simplextree.
- grid_strategy=”regular”string
Either “regular”, “quantile”, or “exact”.
Returns
List of filtration values, for each parameter, defining the grid.
- get_simplices(self) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 5944) This function returns a generator with simplices and their given
filtration values.
- returns:
The simplices.
- rtype:
generator with tuples(simplex, filtration)
- get_simplices_of_dimension(self, dim: int) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 6131)
- get_skeleton(self, dimension) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 5970) This function returns a generator with the (simplices of the) skeleton of a maximum given dimension.
- param dimension:
The skeleton dimension value.
- type dimension:
int
- returns:
The (simplices of the) skeleton of a maximum dimension.
- rtype:
generator with tuples(simplex, filtration)
- grid_squeeze(self, filtration_grid: np.ndarray | list | None = None, coordinate_values: bool = True, force=False, grid_strategy: _available_strategies = 'exact', inplace=False, **filtration_grid_kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 6347)
Fit the filtration of the simplextree to a grid.
- Parameters:
filtration_grid (list[list[float]]) – The grid on which to squeeze. An example of grid can be given by the get_filtration_grid method.
coordinate_values (bool) – If true, the filtrations values of the simplices will be set to the coordinate of the filtration grid.
- insert(self, simplex: vector[int], filtration: list | np.ndarray | None = None) bool
File: multipers/simplex_tree_multi.pyx (starting at line 5904) This function inserts the given N-simplex and its subfaces with the
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 not yet in the complex, false otherwise (whatever its original filtration value).
- rtype:
bool
- static is_kcritical() bool
File: multipers/simplex_tree_multi.pyx (starting at line 5696)
- key(self, simplex: list | np.ndarray)
File: multipers/simplex_tree_multi.pyx (starting at line 6133)
- linear_projections(self, linear_forms: np.ndarray) Iterable[SimplexTree]
File: multipers/simplex_tree_multi.pyx (starting at line 6465)
Compute the 1-parameter projections, w.r.t. given the linear forms, of this simplextree.
Input
Array of shape (num_linear_forms, num_parameters)
Output
List of projected (gudhi) simplextrees.
- num_parameters
num_parameters: int
- num_simplices
num_simplices: int This function returns the number of simplices of the simplicial
complex.
- returns:
the simplicial complex number of simplices.
- rtype:
int
- num_vertices
num_vertices: int This function returns the number of vertices of the simplicial
complex.
- returns:
The simplicial complex number of vertices.
- rtype:
int
- persistence_approximation(self, **kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 5965)
- project_on_line(self, parameter: int = 0, basepoint: None | list | np.ndarray = None, direction: None | list | np.ndarray = None) SimplexTree
File: multipers/simplex_tree_multi.pyx (starting at line 6424) Converts an multi simplextree to a gudhi simplextree.
- parameter:int = 0
The parameter to keep. WARNING will crash if the multi simplextree is not well filled.
- basepoint:None
Instead of keeping a single parameter, will consider the filtration defined by the diagonal line crossing the basepoint.
There are no safeguard yet, it WILL crash if asking for a parameter that is not filled.
A SimplexTree with chosen 1D filtration.
- prune_above_dimension(self, dimension: int)
File: multipers/simplex_tree_multi.pyx (starting at line 6100) Remove all simplices of dimension greater than a given value.
- param dimension:
Maximum dimension value.
- type dimension:
int
- returns:
The modification information.
- rtype:
bool
- remove_maximal_simplex(self, simplex) SimplexTreeMulti_KFf32
File: multipers/simplex_tree_multi.pyx (starting at line 6058) This function removes a given maximal N-simplex from the simplicial
complex.
- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int
Note
The dimension of the simplicial complex may be lower after calling remove_maximal_simplex than it was before. However,
upper_bound_dimension()
method will return the old value, which remains a valid upper bound. If you care, you can calldimension()
to recompute the exact dimension.
- reset_filtration(self, filtration, min_dim=0) SimplexTreeMulti_KFf32
File: multipers/simplex_tree_multi.pyx (starting at line 6111) This function resets the filtration value of all the simplices of dimension at least min_dim. Resets all the
simplex tree when min_dim = 0. reset_filtration may break the filtration property with min_dim > 0, and it is the user’s responsibility to make it a valid filtration (using a large enough filt_value, or calling make_filtration_non_decreasing afterwards for instance).
- param filtration:
New threshold value.
- type filtration:
float.
- param min_dim:
The minimal dimension. Default value is 0.
- type min_dim:
int.
- set_dimension(self, dimension: int) None
File: multipers/simplex_tree_multi.pyx (starting at line 5866) 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
remove_maximal_simplex()
orprune_above_filtration()
).
- set_key(self, simplex: list | np.ndarray, key: int) None
File: multipers/simplex_tree_multi.pyx (starting at line 6138)
- set_keys_to_enumerate(self) None
File: multipers/simplex_tree_multi.pyx (starting at line 6135)
- set_num_parameter(self, num: int)
File: multipers/simplex_tree_multi.pyx (starting at line 6504)
Sets the numbers of parameters. WARNING : it will resize all the filtrations to this size.
- thisptr
thisptr: int File: multipers/simplex_tree_multi.pyx (starting at line 5665)
- to_rivet(self, path='rivet_dataset.txt', degree: int | None = None, progress: bool = False, overwrite: bool = False, xbins: int | None = None, ybins: int | None = None) None
File: multipers/simplex_tree_multi.pyx (starting at line 6248) Create a file that can be imported by rivet, representing the filtration of the simplextree.
- path:str
path of the file.
- degree:int
The homological degree to ask rivet to compute.
- progress:bool = True
Shows the progress bar.
- overwrite:bool = False
If true, will overwrite the previous file if it already exists.
- to_scc(self, **kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 6239)
Returns an scc representation of the simplextree.
- to_scc_function_st(self, path='scc_dataset.scc', rivet_compatible: bool = False, strip_comments: bool = False, ignore_last_generators: bool = False, overwrite: bool = False, reverse_block: bool = True)
File: multipers/simplex_tree_multi.pyx (starting at line 6195)
- to_scc_kcritical(self, path: os.PathLike | str, rivet_compatible: bool = False, strip_comments: bool = False, ignore_last_generators: bool = False, overwrite: bool = False, reverse_block: bool = False)
File: multipers/simplex_tree_multi.pyx (starting at line 6166)
TODO: function-simplextree, from squeezed
- upper_bound_dimension(self) int
File: multipers/simplex_tree_multi.pyx (starting at line 5829) This function returns a valid dimension upper bound of the
simplicial complex.
- returns:
an upper bound on the dimension of the simplicial complex.
- rtype:
int
- class multipers.simplex_tree_multi.SimplexTreeMulti_KFf64
Bases:
object
File: multipers/simplex_tree_multi.pyx (starting at line 7820) The simplex tree is an efficient and flexible data structure for
representing general (filtered) simplicial complexes. The data structure is described in Jean-Daniel Boissonnat and Clément Maria. The Simplex Tree: An Efficient Data Structure for General Simplicial Complexes. Algorithmica, pages 1–22, 2014.
This class is a multi-filtered, with keys, and non contiguous vertices version of the simplex tree.
- assign_filtration(self, simplex: list | np.ndarray, filtration: list | np.ndarray) SimplexTreeMulti_KFf64
File: multipers/simplex_tree_multi.pyx (starting at line 7927) This function assigns a new multi-critical filtration value to a
given N-simplex.
- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int
- param filtration:
The new filtration(s) value(s), concatenated.
- type filtration:
list[float] or np.ndarray[float, ndim=1]
Note
Beware that after this operation, the structure may not be a valid filtration anymore, a simplex could have a lower filtration value than one of its faces. Callers are responsible for fixing this (with more
assign_filtration()
ormake_filtration_non_decreasing()
for instance) before callingany function that relies on the filtration property, like
persistence()
.
- copy(self) SimplexTreeMulti_KFf64
File: multipers/simplex_tree_multi.pyx (starting at line 7903)
- Returns:
A simplex tree that is a deep copy of itself.
- Return type:
SimplexTreeMulti
- Note:
The persistence information is not copied. If you need it in the clone, you have to call
compute_persistence()
on it even if you had already computed it in the original.
- dimension
dimension: int This function returns the dimension of the simplicial complex.
- 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
remove_maximal_simplex()
orprune_above_filtration()
methods).
- dtype
dtype: type
- fill_lowerstar(self, F, parameter: int) SimplexTreeMulti_KFf64
File: multipers/simplex_tree_multi.pyx (starting at line 8564) Fills the `dimension`th filtration by the lower-star filtration defined by F.
- F:1d array
The density over the vertices, that induces a lowerstar filtration.
- parameter:int
Which filtration parameter to fill. /!python starts at 0.
self:SimplexTreeMulti
- filtration(self, simplex: list | np.ndarray) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 7917) 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 :returns: The simplicial complex multi-critical filtration value. :rtype: numpy array of shape (-1, num_parameters)
- filtration_bounds(self, degrees: Iterable[int] | None = None, q: float | tuple = 0, split_dimension: bool = False) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 8547)
Returns the filtrations bounds of the finite filtration values.
- filtration_grid
filtration_grid: vector[vector[double]] File: multipers/simplex_tree_multi.pyx (starting at line 7832)
- flagify(self, dim: int = 2)
File: multipers/simplex_tree_multi.pyx (starting at line 8007)
Turns this simplicial complex into a flag complex by resetting filtration values of simplices of dimension > dim by lower-star values.
- get_boundaries(self, simplex) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 8203) This function returns a generator with the boundaries of a given N-simplex.
If you do not need the filtration values, the boundary can also be obtained as
itertools.combinations(simplex,len(simplex)-1)
.- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int.
- returns:
The (simplices of the) boundary of a simplex
- rtype:
generator with tuples(simplex, filtration)
- get_filtration_grid(self, resolution: Iterable[int] | None = None, degrees: Iterable[int] | None = None, drop_quantiles: float | tuple = 0, grid_strategy: _available_strategies = 'exact') Iterable[np.ndarray]
File: multipers/simplex_tree_multi.pyx (starting at line 8478)
Returns a grid over the n-filtration, from the simplextree. Usefull for grid_squeeze. TODO : multicritical
Parameters
- resolution: list[int]
resolution of the grid, for each parameter
- box=Nonepair[list[float]]
Grid bounds. format : [low bound, high bound] If None is given, will use the filtration bounds of the simplextree.
- grid_strategy=”regular”string
Either “regular”, “quantile”, or “exact”.
Returns
List of filtration values, for each parameter, defining the grid.
- get_simplices(self) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 8109) This function returns a generator with simplices and their given
filtration values.
- returns:
The simplices.
- rtype:
generator with tuples(simplex, filtration)
- get_simplices_of_dimension(self, dim: int) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 8296)
- get_skeleton(self, dimension) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 8135) This function returns a generator with the (simplices of the) skeleton of a maximum given dimension.
- param dimension:
The skeleton dimension value.
- type dimension:
int
- returns:
The (simplices of the) skeleton of a maximum dimension.
- rtype:
generator with tuples(simplex, filtration)
- grid_squeeze(self, filtration_grid: np.ndarray | list | None = None, coordinate_values: bool = True, force=False, grid_strategy: _available_strategies = 'exact', inplace=False, **filtration_grid_kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 8512)
Fit the filtration of the simplextree to a grid.
- Parameters:
filtration_grid (list[list[float]]) – The grid on which to squeeze. An example of grid can be given by the get_filtration_grid method.
coordinate_values (bool) – If true, the filtrations values of the simplices will be set to the coordinate of the filtration grid.
- insert(self, simplex: vector[int], filtration: list | np.ndarray | None = None) bool
File: multipers/simplex_tree_multi.pyx (starting at line 8069) This function inserts the given N-simplex and its subfaces with the
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 not yet in the complex, false otherwise (whatever its original filtration value).
- rtype:
bool
- static is_kcritical() bool
File: multipers/simplex_tree_multi.pyx (starting at line 7861)
- key(self, simplex: list | np.ndarray)
File: multipers/simplex_tree_multi.pyx (starting at line 8298)
- linear_projections(self, linear_forms: np.ndarray) Iterable[SimplexTree]
File: multipers/simplex_tree_multi.pyx (starting at line 8630)
Compute the 1-parameter projections, w.r.t. given the linear forms, of this simplextree.
Input
Array of shape (num_linear_forms, num_parameters)
Output
List of projected (gudhi) simplextrees.
- num_parameters
num_parameters: int
- num_simplices
num_simplices: int This function returns the number of simplices of the simplicial
complex.
- returns:
the simplicial complex number of simplices.
- rtype:
int
- num_vertices
num_vertices: int This function returns the number of vertices of the simplicial
complex.
- returns:
The simplicial complex number of vertices.
- rtype:
int
- persistence_approximation(self, **kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 8130)
- project_on_line(self, parameter: int = 0, basepoint: None | list | np.ndarray = None, direction: None | list | np.ndarray = None) SimplexTree
File: multipers/simplex_tree_multi.pyx (starting at line 8589) Converts an multi simplextree to a gudhi simplextree.
- parameter:int = 0
The parameter to keep. WARNING will crash if the multi simplextree is not well filled.
- basepoint:None
Instead of keeping a single parameter, will consider the filtration defined by the diagonal line crossing the basepoint.
There are no safeguard yet, it WILL crash if asking for a parameter that is not filled.
A SimplexTree with chosen 1D filtration.
- prune_above_dimension(self, dimension: int)
File: multipers/simplex_tree_multi.pyx (starting at line 8265) Remove all simplices of dimension greater than a given value.
- param dimension:
Maximum dimension value.
- type dimension:
int
- returns:
The modification information.
- rtype:
bool
- remove_maximal_simplex(self, simplex) SimplexTreeMulti_KFf64
File: multipers/simplex_tree_multi.pyx (starting at line 8223) This function removes a given maximal N-simplex from the simplicial
complex.
- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int
Note
The dimension of the simplicial complex may be lower after calling remove_maximal_simplex than it was before. However,
upper_bound_dimension()
method will return the old value, which remains a valid upper bound. If you care, you can calldimension()
to recompute the exact dimension.
- reset_filtration(self, filtration, min_dim=0) SimplexTreeMulti_KFf64
File: multipers/simplex_tree_multi.pyx (starting at line 8276) This function resets the filtration value of all the simplices of dimension at least min_dim. Resets all the
simplex tree when min_dim = 0. reset_filtration may break the filtration property with min_dim > 0, and it is the user’s responsibility to make it a valid filtration (using a large enough filt_value, or calling make_filtration_non_decreasing afterwards for instance).
- param filtration:
New threshold value.
- type filtration:
float.
- param min_dim:
The minimal dimension. Default value is 0.
- type min_dim:
int.
- set_dimension(self, dimension: int) None
File: multipers/simplex_tree_multi.pyx (starting at line 8031) 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
remove_maximal_simplex()
orprune_above_filtration()
).
- set_key(self, simplex: list | np.ndarray, key: int) None
File: multipers/simplex_tree_multi.pyx (starting at line 8303)
- set_keys_to_enumerate(self) None
File: multipers/simplex_tree_multi.pyx (starting at line 8300)
- set_num_parameter(self, num: int)
File: multipers/simplex_tree_multi.pyx (starting at line 8669)
Sets the numbers of parameters. WARNING : it will resize all the filtrations to this size.
- thisptr
thisptr: int File: multipers/simplex_tree_multi.pyx (starting at line 7830)
- to_rivet(self, path='rivet_dataset.txt', degree: int | None = None, progress: bool = False, overwrite: bool = False, xbins: int | None = None, ybins: int | None = None) None
File: multipers/simplex_tree_multi.pyx (starting at line 8413) Create a file that can be imported by rivet, representing the filtration of the simplextree.
- path:str
path of the file.
- degree:int
The homological degree to ask rivet to compute.
- progress:bool = True
Shows the progress bar.
- overwrite:bool = False
If true, will overwrite the previous file if it already exists.
- to_scc(self, **kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 8404)
Returns an scc representation of the simplextree.
- to_scc_function_st(self, path='scc_dataset.scc', rivet_compatible: bool = False, strip_comments: bool = False, ignore_last_generators: bool = False, overwrite: bool = False, reverse_block: bool = True)
File: multipers/simplex_tree_multi.pyx (starting at line 8360)
- to_scc_kcritical(self, path: os.PathLike | str, rivet_compatible: bool = False, strip_comments: bool = False, ignore_last_generators: bool = False, overwrite: bool = False, reverse_block: bool = False)
File: multipers/simplex_tree_multi.pyx (starting at line 8331)
TODO: function-simplextree, from squeezed
- upper_bound_dimension(self) int
File: multipers/simplex_tree_multi.pyx (starting at line 7994) This function returns a valid dimension upper bound of the
simplicial complex.
- returns:
an upper bound on the dimension of the simplicial complex.
- rtype:
int
- class multipers.simplex_tree_multi.SimplexTreeMulti_KFi32
Bases:
object
File: multipers/simplex_tree_multi.pyx (starting at line 1325) The simplex tree is an efficient and flexible data structure for
representing general (filtered) simplicial complexes. The data structure is described in Jean-Daniel Boissonnat and Clément Maria. The Simplex Tree: An Efficient Data Structure for General Simplicial Complexes. Algorithmica, pages 1–22, 2014.
This class is a multi-filtered, with keys, and non contiguous vertices version of the simplex tree.
- assign_filtration(self, simplex: list | np.ndarray, filtration: list | np.ndarray) SimplexTreeMulti_KFi32
File: multipers/simplex_tree_multi.pyx (starting at line 1432) This function assigns a new multi-critical filtration value to a
given N-simplex.
- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int
- param filtration:
The new filtration(s) value(s), concatenated.
- type filtration:
list[float] or np.ndarray[float, ndim=1]
Note
Beware that after this operation, the structure may not be a valid filtration anymore, a simplex could have a lower filtration value than one of its faces. Callers are responsible for fixing this (with more
assign_filtration()
ormake_filtration_non_decreasing()
for instance) before callingany function that relies on the filtration property, like
persistence()
.
- copy(self) SimplexTreeMulti_KFi32
File: multipers/simplex_tree_multi.pyx (starting at line 1408)
- Returns:
A simplex tree that is a deep copy of itself.
- Return type:
SimplexTreeMulti
- Note:
The persistence information is not copied. If you need it in the clone, you have to call
compute_persistence()
on it even if you had already computed it in the original.
- dimension
dimension: int This function returns the dimension of the simplicial complex.
- 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
remove_maximal_simplex()
orprune_above_filtration()
methods).
- dtype
dtype: type
- fill_lowerstar(self, F, parameter: int) SimplexTreeMulti_KFi32
File: multipers/simplex_tree_multi.pyx (starting at line 2069) Fills the `dimension`th filtration by the lower-star filtration defined by F.
- F:1d array
The density over the vertices, that induces a lowerstar filtration.
- parameter:int
Which filtration parameter to fill. /!python starts at 0.
self:SimplexTreeMulti
- filtration(self, simplex: list | np.ndarray) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 1422) 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 :returns: The simplicial complex multi-critical filtration value. :rtype: numpy array of shape (-1, num_parameters)
- filtration_bounds(self, degrees: Iterable[int] | None = None, q: float | tuple = 0, split_dimension: bool = False) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 2052)
Returns the filtrations bounds of the finite filtration values.
- filtration_grid
filtration_grid: vector[vector[double]] File: multipers/simplex_tree_multi.pyx (starting at line 1337)
- flagify(self, dim: int = 2)
File: multipers/simplex_tree_multi.pyx (starting at line 1512)
Turns this simplicial complex into a flag complex by resetting filtration values of simplices of dimension > dim by lower-star values.
- get_boundaries(self, simplex) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 1708) This function returns a generator with the boundaries of a given N-simplex.
If you do not need the filtration values, the boundary can also be obtained as
itertools.combinations(simplex,len(simplex)-1)
.- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int.
- returns:
The (simplices of the) boundary of a simplex
- rtype:
generator with tuples(simplex, filtration)
- get_filtration_grid(self, resolution: Iterable[int] | None = None, degrees: Iterable[int] | None = None, drop_quantiles: float | tuple = 0, grid_strategy: _available_strategies = 'exact') Iterable[np.ndarray]
File: multipers/simplex_tree_multi.pyx (starting at line 1983)
Returns a grid over the n-filtration, from the simplextree. Usefull for grid_squeeze. TODO : multicritical
Parameters
- resolution: list[int]
resolution of the grid, for each parameter
- box=Nonepair[list[float]]
Grid bounds. format : [low bound, high bound] If None is given, will use the filtration bounds of the simplextree.
- grid_strategy=”regular”string
Either “regular”, “quantile”, or “exact”.
Returns
List of filtration values, for each parameter, defining the grid.
- get_simplices(self) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 1614) This function returns a generator with simplices and their given
filtration values.
- returns:
The simplices.
- rtype:
generator with tuples(simplex, filtration)
- get_simplices_of_dimension(self, dim: int) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 1801)
- get_skeleton(self, dimension) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 1640) This function returns a generator with the (simplices of the) skeleton of a maximum given dimension.
- param dimension:
The skeleton dimension value.
- type dimension:
int
- returns:
The (simplices of the) skeleton of a maximum dimension.
- rtype:
generator with tuples(simplex, filtration)
- grid_squeeze(self, filtration_grid: np.ndarray | list | None = None, coordinate_values: bool = True, force=False, grid_strategy: _available_strategies = 'exact', inplace=False, **filtration_grid_kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 2017)
Fit the filtration of the simplextree to a grid.
- Parameters:
filtration_grid (list[list[float]]) – The grid on which to squeeze. An example of grid can be given by the get_filtration_grid method.
coordinate_values (bool) – If true, the filtrations values of the simplices will be set to the coordinate of the filtration grid.
- insert(self, simplex: vector[int], filtration: list | np.ndarray | None = None) bool
File: multipers/simplex_tree_multi.pyx (starting at line 1574) This function inserts the given N-simplex and its subfaces with the
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 not yet in the complex, false otherwise (whatever its original filtration value).
- rtype:
bool
- static is_kcritical() bool
File: multipers/simplex_tree_multi.pyx (starting at line 1366)
- key(self, simplex: list | np.ndarray)
File: multipers/simplex_tree_multi.pyx (starting at line 1803)
- linear_projections(self, linear_forms: np.ndarray) Iterable[SimplexTree]
File: multipers/simplex_tree_multi.pyx (starting at line 2135)
Compute the 1-parameter projections, w.r.t. given the linear forms, of this simplextree.
Input
Array of shape (num_linear_forms, num_parameters)
Output
List of projected (gudhi) simplextrees.
- num_parameters
num_parameters: int
- num_simplices
num_simplices: int This function returns the number of simplices of the simplicial
complex.
- returns:
the simplicial complex number of simplices.
- rtype:
int
- num_vertices
num_vertices: int This function returns the number of vertices of the simplicial
complex.
- returns:
The simplicial complex number of vertices.
- rtype:
int
- persistence_approximation(self, **kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 1635)
- project_on_line(self, parameter: int = 0, basepoint: None | list | np.ndarray = None, direction: None | list | np.ndarray = None) SimplexTree
File: multipers/simplex_tree_multi.pyx (starting at line 2094) Converts an multi simplextree to a gudhi simplextree.
- parameter:int = 0
The parameter to keep. WARNING will crash if the multi simplextree is not well filled.
- basepoint:None
Instead of keeping a single parameter, will consider the filtration defined by the diagonal line crossing the basepoint.
There are no safeguard yet, it WILL crash if asking for a parameter that is not filled.
A SimplexTree with chosen 1D filtration.
- prune_above_dimension(self, dimension: int)
File: multipers/simplex_tree_multi.pyx (starting at line 1770) Remove all simplices of dimension greater than a given value.
- param dimension:
Maximum dimension value.
- type dimension:
int
- returns:
The modification information.
- rtype:
bool
- remove_maximal_simplex(self, simplex) SimplexTreeMulti_KFi32
File: multipers/simplex_tree_multi.pyx (starting at line 1728) This function removes a given maximal N-simplex from the simplicial
complex.
- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int
Note
The dimension of the simplicial complex may be lower after calling remove_maximal_simplex than it was before. However,
upper_bound_dimension()
method will return the old value, which remains a valid upper bound. If you care, you can calldimension()
to recompute the exact dimension.
- reset_filtration(self, filtration, min_dim=0) SimplexTreeMulti_KFi32
File: multipers/simplex_tree_multi.pyx (starting at line 1781) This function resets the filtration value of all the simplices of dimension at least min_dim. Resets all the
simplex tree when min_dim = 0. reset_filtration may break the filtration property with min_dim > 0, and it is the user’s responsibility to make it a valid filtration (using a large enough filt_value, or calling make_filtration_non_decreasing afterwards for instance).
- param filtration:
New threshold value.
- type filtration:
float.
- param min_dim:
The minimal dimension. Default value is 0.
- type min_dim:
int.
- set_dimension(self, dimension: int) None
File: multipers/simplex_tree_multi.pyx (starting at line 1536) 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
remove_maximal_simplex()
orprune_above_filtration()
).
- set_key(self, simplex: list | np.ndarray, key: int) None
File: multipers/simplex_tree_multi.pyx (starting at line 1808)
- set_keys_to_enumerate(self) None
File: multipers/simplex_tree_multi.pyx (starting at line 1805)
- set_num_parameter(self, num: int)
File: multipers/simplex_tree_multi.pyx (starting at line 2174)
Sets the numbers of parameters. WARNING : it will resize all the filtrations to this size.
- thisptr
thisptr: int File: multipers/simplex_tree_multi.pyx (starting at line 1335)
- to_rivet(self, path='rivet_dataset.txt', degree: int | None = None, progress: bool = False, overwrite: bool = False, xbins: int | None = None, ybins: int | None = None) None
File: multipers/simplex_tree_multi.pyx (starting at line 1918) Create a file that can be imported by rivet, representing the filtration of the simplextree.
- path:str
path of the file.
- degree:int
The homological degree to ask rivet to compute.
- progress:bool = True
Shows the progress bar.
- overwrite:bool = False
If true, will overwrite the previous file if it already exists.
- to_scc(self, **kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 1909)
Returns an scc representation of the simplextree.
- to_scc_function_st(self, path='scc_dataset.scc', rivet_compatible: bool = False, strip_comments: bool = False, ignore_last_generators: bool = False, overwrite: bool = False, reverse_block: bool = True)
File: multipers/simplex_tree_multi.pyx (starting at line 1865)
- to_scc_kcritical(self, path: os.PathLike | str, rivet_compatible: bool = False, strip_comments: bool = False, ignore_last_generators: bool = False, overwrite: bool = False, reverse_block: bool = False)
File: multipers/simplex_tree_multi.pyx (starting at line 1836)
TODO: function-simplextree, from squeezed
- upper_bound_dimension(self) int
File: multipers/simplex_tree_multi.pyx (starting at line 1499) This function returns a valid dimension upper bound of the
simplicial complex.
- returns:
an upper bound on the dimension of the simplicial complex.
- rtype:
int
- class multipers.simplex_tree_multi.SimplexTreeMulti_KFi64
Bases:
object
File: multipers/simplex_tree_multi.pyx (starting at line 3490) The simplex tree is an efficient and flexible data structure for
representing general (filtered) simplicial complexes. The data structure is described in Jean-Daniel Boissonnat and Clément Maria. The Simplex Tree: An Efficient Data Structure for General Simplicial Complexes. Algorithmica, pages 1–22, 2014.
This class is a multi-filtered, with keys, and non contiguous vertices version of the simplex tree.
- assign_filtration(self, simplex: list | np.ndarray, filtration: list | np.ndarray) SimplexTreeMulti_KFi64
File: multipers/simplex_tree_multi.pyx (starting at line 3597) This function assigns a new multi-critical filtration value to a
given N-simplex.
- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int
- param filtration:
The new filtration(s) value(s), concatenated.
- type filtration:
list[float] or np.ndarray[float, ndim=1]
Note
Beware that after this operation, the structure may not be a valid filtration anymore, a simplex could have a lower filtration value than one of its faces. Callers are responsible for fixing this (with more
assign_filtration()
ormake_filtration_non_decreasing()
for instance) before callingany function that relies on the filtration property, like
persistence()
.
- copy(self) SimplexTreeMulti_KFi64
File: multipers/simplex_tree_multi.pyx (starting at line 3573)
- Returns:
A simplex tree that is a deep copy of itself.
- Return type:
SimplexTreeMulti
- Note:
The persistence information is not copied. If you need it in the clone, you have to call
compute_persistence()
on it even if you had already computed it in the original.
- dimension
dimension: int This function returns the dimension of the simplicial complex.
- 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
remove_maximal_simplex()
orprune_above_filtration()
methods).
- dtype
dtype: type
- fill_lowerstar(self, F, parameter: int) SimplexTreeMulti_KFi64
File: multipers/simplex_tree_multi.pyx (starting at line 4234) Fills the `dimension`th filtration by the lower-star filtration defined by F.
- F:1d array
The density over the vertices, that induces a lowerstar filtration.
- parameter:int
Which filtration parameter to fill. /!python starts at 0.
self:SimplexTreeMulti
- filtration(self, simplex: list | np.ndarray) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 3587) 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 :returns: The simplicial complex multi-critical filtration value. :rtype: numpy array of shape (-1, num_parameters)
- filtration_bounds(self, degrees: Iterable[int] | None = None, q: float | tuple = 0, split_dimension: bool = False) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 4217)
Returns the filtrations bounds of the finite filtration values.
- filtration_grid
filtration_grid: vector[vector[double]] File: multipers/simplex_tree_multi.pyx (starting at line 3502)
- flagify(self, dim: int = 2)
File: multipers/simplex_tree_multi.pyx (starting at line 3677)
Turns this simplicial complex into a flag complex by resetting filtration values of simplices of dimension > dim by lower-star values.
- get_boundaries(self, simplex) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 3873) This function returns a generator with the boundaries of a given N-simplex.
If you do not need the filtration values, the boundary can also be obtained as
itertools.combinations(simplex,len(simplex)-1)
.- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int.
- returns:
The (simplices of the) boundary of a simplex
- rtype:
generator with tuples(simplex, filtration)
- get_filtration_grid(self, resolution: Iterable[int] | None = None, degrees: Iterable[int] | None = None, drop_quantiles: float | tuple = 0, grid_strategy: _available_strategies = 'exact') Iterable[np.ndarray]
File: multipers/simplex_tree_multi.pyx (starting at line 4148)
Returns a grid over the n-filtration, from the simplextree. Usefull for grid_squeeze. TODO : multicritical
Parameters
- resolution: list[int]
resolution of the grid, for each parameter
- box=Nonepair[list[float]]
Grid bounds. format : [low bound, high bound] If None is given, will use the filtration bounds of the simplextree.
- grid_strategy=”regular”string
Either “regular”, “quantile”, or “exact”.
Returns
List of filtration values, for each parameter, defining the grid.
- get_simplices(self) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 3779) This function returns a generator with simplices and their given
filtration values.
- returns:
The simplices.
- rtype:
generator with tuples(simplex, filtration)
- get_simplices_of_dimension(self, dim: int) np.ndarray
File: multipers/simplex_tree_multi.pyx (starting at line 3966)
- get_skeleton(self, dimension) Iterable[tuple[np.ndarray, np.ndarray]]
File: multipers/simplex_tree_multi.pyx (starting at line 3805) This function returns a generator with the (simplices of the) skeleton of a maximum given dimension.
- param dimension:
The skeleton dimension value.
- type dimension:
int
- returns:
The (simplices of the) skeleton of a maximum dimension.
- rtype:
generator with tuples(simplex, filtration)
- grid_squeeze(self, filtration_grid: np.ndarray | list | None = None, coordinate_values: bool = True, force=False, grid_strategy: _available_strategies = 'exact', inplace=False, **filtration_grid_kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 4182)
Fit the filtration of the simplextree to a grid.
- Parameters:
filtration_grid (list[list[float]]) – The grid on which to squeeze. An example of grid can be given by the get_filtration_grid method.
coordinate_values (bool) – If true, the filtrations values of the simplices will be set to the coordinate of the filtration grid.
- insert(self, simplex: vector[int], filtration: list | np.ndarray | None = None) bool
File: multipers/simplex_tree_multi.pyx (starting at line 3739) This function inserts the given N-simplex and its subfaces with the
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 not yet in the complex, false otherwise (whatever its original filtration value).
- rtype:
bool
- static is_kcritical() bool
File: multipers/simplex_tree_multi.pyx (starting at line 3531)
- key(self, simplex: list | np.ndarray)
File: multipers/simplex_tree_multi.pyx (starting at line 3968)
- linear_projections(self, linear_forms: np.ndarray) Iterable[SimplexTree]
File: multipers/simplex_tree_multi.pyx (starting at line 4300)
Compute the 1-parameter projections, w.r.t. given the linear forms, of this simplextree.
Input
Array of shape (num_linear_forms, num_parameters)
Output
List of projected (gudhi) simplextrees.
- num_parameters
num_parameters: int
- num_simplices
num_simplices: int This function returns the number of simplices of the simplicial
complex.
- returns:
the simplicial complex number of simplices.
- rtype:
int
- num_vertices
num_vertices: int This function returns the number of vertices of the simplicial
complex.
- returns:
The simplicial complex number of vertices.
- rtype:
int
- persistence_approximation(self, **kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 3800)
- project_on_line(self, parameter: int = 0, basepoint: None | list | np.ndarray = None, direction: None | list | np.ndarray = None) SimplexTree
File: multipers/simplex_tree_multi.pyx (starting at line 4259) Converts an multi simplextree to a gudhi simplextree.
- parameter:int = 0
The parameter to keep. WARNING will crash if the multi simplextree is not well filled.
- basepoint:None
Instead of keeping a single parameter, will consider the filtration defined by the diagonal line crossing the basepoint.
There are no safeguard yet, it WILL crash if asking for a parameter that is not filled.
A SimplexTree with chosen 1D filtration.
- prune_above_dimension(self, dimension: int)
File: multipers/simplex_tree_multi.pyx (starting at line 3935) Remove all simplices of dimension greater than a given value.
- param dimension:
Maximum dimension value.
- type dimension:
int
- returns:
The modification information.
- rtype:
bool
- remove_maximal_simplex(self, simplex) SimplexTreeMulti_KFi64
File: multipers/simplex_tree_multi.pyx (starting at line 3893) This function removes a given maximal N-simplex from the simplicial
complex.
- param simplex:
The N-simplex, represented by a list of vertex.
- type simplex:
list of int
Note
The dimension of the simplicial complex may be lower after calling remove_maximal_simplex than it was before. However,
upper_bound_dimension()
method will return the old value, which remains a valid upper bound. If you care, you can calldimension()
to recompute the exact dimension.
- reset_filtration(self, filtration, min_dim=0) SimplexTreeMulti_KFi64
File: multipers/simplex_tree_multi.pyx (starting at line 3946) This function resets the filtration value of all the simplices of dimension at least min_dim. Resets all the
simplex tree when min_dim = 0. reset_filtration may break the filtration property with min_dim > 0, and it is the user’s responsibility to make it a valid filtration (using a large enough filt_value, or calling make_filtration_non_decreasing afterwards for instance).
- param filtration:
New threshold value.
- type filtration:
float.
- param min_dim:
The minimal dimension. Default value is 0.
- type min_dim:
int.
- set_dimension(self, dimension: int) None
File: multipers/simplex_tree_multi.pyx (starting at line 3701) 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
remove_maximal_simplex()
orprune_above_filtration()
).
- set_key(self, simplex: list | np.ndarray, key: int) None
File: multipers/simplex_tree_multi.pyx (starting at line 3973)
- set_keys_to_enumerate(self) None
File: multipers/simplex_tree_multi.pyx (starting at line 3970)
- set_num_parameter(self, num: int)
File: multipers/simplex_tree_multi.pyx (starting at line 4339)
Sets the numbers of parameters. WARNING : it will resize all the filtrations to this size.
- thisptr
thisptr: int File: multipers/simplex_tree_multi.pyx (starting at line 3500)
- to_rivet(self, path='rivet_dataset.txt', degree: int | None = None, progress: bool = False, overwrite: bool = False, xbins: int | None = None, ybins: int | None = None) None
File: multipers/simplex_tree_multi.pyx (starting at line 4083) Create a file that can be imported by rivet, representing the filtration of the simplextree.
- path:str
path of the file.
- degree:int
The homological degree to ask rivet to compute.
- progress:bool = True
Shows the progress bar.
- overwrite:bool = False
If true, will overwrite the previous file if it already exists.
- to_scc(self, **kwargs)
File: multipers/simplex_tree_multi.pyx (starting at line 4074)
Returns an scc representation of the simplextree.
- to_scc_function_st(self, path='scc_dataset.scc', rivet_compatible: bool = False, strip_comments: bool = False, ignore_last_generators: bool = False, overwrite: bool = False, reverse_block: bool = True)
File: multipers/simplex_tree_multi.pyx (starting at line 4030)
- to_scc_kcritical(self, path: os.PathLike | str, rivet_compatible: bool = False, strip_comments: bool = False, ignore_last_generators: bool = False, overwrite: bool = False, reverse_block: bool = False)
File: multipers/simplex_tree_multi.pyx (starting at line 4001)
TODO: function-simplextree, from squeezed
- upper_bound_dimension(self) int
File: multipers/simplex_tree_multi.pyx (starting at line 3664) This function returns a valid dimension upper bound of the
simplicial complex.
- returns:
an upper bound on the dimension of the simplicial complex.
- rtype:
int
- multipers.simplex_tree_multi.is_simplextree_multi(input) bool
File: multipers/simplex_tree_multi.pyx (starting at line 8753)
multipers.slicer module
File: multipers/slicer.pyx (starting at line 1)
- multipers.slicer.from_function_delaunay(points, grades, degree: int = -1, backend: Literal['matrix', 'clement'] = 'matrix', vineyard: bool = True, verbose: bool = False, clear: bool = True)
File: multipers/slicer.pyx (starting at line 26708)
Given points in $mathbb R^n$ and function grades, compute the function-delaunay bifiltration as a in an scc format, and converts it into a slicer.
points : (num_pts, n) float array grades : (num_pts,) float array degree (opt) : if given, computes a minimal presentation of this homological degree first backend : slicer backend, e.g. “matrix”, “clement” vineyard : bool, use a vineyard-compatible backend
- multipers.slicer.get_matrix_slicer(is_vineyard: bool, is_k_critical: bool, dtype: type, col: unicode)
File: multipers/slicer.pyx (starting at line 27107)
- multipers.slicer.is_slicer(input) bool
File: multipers/slicer.pyx (starting at line 26822)
- multipers.slicer.minimal_presentation(slicer, degree: int = 1, degrees: list = [], backend: Literal['mpfree', '2pac'] = 'mpfree', slicer_backend: Literal['matrix', 'clement', 'graph'] = 'matrix', vineyard: bool = True, id: str | None = None, dtype=None, **minpres_kwargs)
File: multipers/slicer.pyx (starting at line 26750)
Computes a minimal presentation of the multifiltered complex given by the slicer, and returns it as a slicer. Only works for mpfree for the moment.
- multipers.slicer.slicer2blocks(slicer, degree: int = -1, reverse: bool = True)
File: multipers/slicer.pyx (starting at line 26730)
Convert any slicer to the block format a.k.a. scc format for python
- multipers.slicer.to_blocks(input)
File: multipers/slicer.pyx (starting at line 26959)
Converts input to blocks, if possible.
- multipers.slicer.to_simplextree(s: Slicer_type, max_dim: int = -1)
File: multipers/slicer.pyx (starting at line 26784)
Turns a –simplicial– slicer into a simplextree.
Warning: Won’t work for non-simplicial complexes, i.e., complexes $K$ not satisfying $
orall sigma in K,, mathrm{dim}(sigma) = |\partial \sigma|-1$