multipers package

Subpackages

Submodules

multipers._signed_measure_meta module

multipers._signed_measure_meta._signed_measure_from_scc(minimal_presentation)
Return type:

list[tuple[ndarray, ndarray]]

multipers._signed_measure_meta._signed_measure_from_slicer(slicer, shift=0)
Parameters:
  • slicer (_KSlicer_Matrix0_vine_i32 | _KSlicer_Matrix1_vine_i32 | _KSlicer_Matrix2_vine_i32 | _KSlicer_Matrix0_vine_i64 | _KSlicer_Matrix1_vine_i64 | _KSlicer_Matrix2_vine_i64 | _KSlicer_Matrix0_vine_f32 | _KSlicer_Matrix1_vine_f32 | _KSlicer_Matrix2_vine_f32 | _KSlicer_Matrix0_vine_f64 | _KSlicer_Matrix1_vine_f64 | _KSlicer_Matrix2_vine_f64 | _Slicer_Matrix0_vine_i32 | _Slicer_Matrix1_vine_i32 | _Slicer_Matrix2_vine_i32 | _Slicer_Matrix0_vine_i64 | _Slicer_Matrix1_vine_i64 | _Slicer_Matrix2_vine_i64 | _Slicer_Matrix0_vine_f32 | _Slicer_Matrix1_vine_f32 | _Slicer_Matrix2_vine_f32 | _Slicer_Matrix0_vine_f64 | _Slicer_Matrix1_vine_f64 | _Slicer_Matrix2_vine_f64 | _KSlicer_Matrix0_i32 | _KSlicer_Matrix1_i32 | _KSlicer_Matrix2_i32 | _KSlicer_Matrix0_i64 | _KSlicer_Matrix1_i64 | _KSlicer_Matrix2_i64 | _KSlicer_Matrix0_f32 | _KSlicer_Matrix1_f32 | _KSlicer_Matrix2_f32 | _KSlicer_Matrix0_f64 | _KSlicer_Matrix1_f64 | _KSlicer_Matrix2_f64 | _Slicer_Matrix0_i32 | _Slicer_Matrix1_i32 | _Slicer_Matrix2_i32 | _Slicer_Matrix0_i64 | _Slicer_Matrix1_i64 | _Slicer_Matrix2_i64 | _Slicer_Matrix0_f32 | _Slicer_Matrix1_f32 | _Slicer_Matrix2_f32 | _Slicer_Matrix0_f64 | _Slicer_Matrix1_f64 | _Slicer_Matrix2_f64 | _KSlicer_GudhiCohomology0_i32 | _KSlicer_GudhiCohomology0_i64 | _KSlicer_GudhiCohomology0_f32 | _KSlicer_GudhiCohomology0_f64 | _Slicer_GudhiCohomology0_i32 | _Slicer_GudhiCohomology0_i64 | _Slicer_GudhiCohomology0_f32 | _Slicer_GudhiCohomology0_f64)

  • shift (int)

Return type:

list[tuple[ndarray, ndarray]]

multipers._signed_measure_meta.signed_measure(filtered_complex, degree=None, degrees=[], mass_default=None, grid_strategy='exact', invariant=None, plot=False, verbose=False, n_jobs=-1, expand_collapse=False, backend=None, thread_id='', grid=None, coordinate_measure=False, num_collapses=0, clean=None, vineyard=False, grid_conversion=None, **infer_grid_kwargs)

Computes the signed measures given by the decomposition of the hilbert function or the euler characteristic, or the rank invariant.

Input

  • filtered_complex: given by a simplextree or a slicer.

  • degree:int|None / degrees:list[int] the degrees to compute. None represents the euler characteristic.

  • mass_default: Either None, or ‘auto’ or ‘inf’, or array-like of floats. Where to put the default mass to get a zero-mass measure. This corresponds to zero-out the filtered complex outside of ${ xin mathbb R^n mid xle mass_default}$

  • invariant: The invariant to use, either “hilbert”, “rank”, or “euler”.

  • plot:bool, plots the computed measures if true.

  • n_jobs:int, number of jobs. Defaults to #cpu.

  • verbose:bool, prints c++ logs.

  • expand_collapse: when the input is a simplextree, only expands the complex when computing 1-dimensional slices. Meant to reduce memory footprint at some computational expense.

  • backend:str reduces first the filtered complex using an external library backend,

    see backend in multipers.io.reduce_complex().

  • grid: If given, the computations will be done on the restriction of the filtered complex to this grid.

    It can also be used for auto-differentiation, i.e., if the grid is a list of pytorch tensors, then the output measure will be pytorch-differentiable.

  • grid_strategy: If not squeezed yet, and no grid is given, the strategy to coarsen the grid; see strategy in multipers.grids.compute_grid().

  • coordinate_measure: bool, if True, compute the signed measure as a coordinates given in grid.

  • num_collapses: int, if filtered_complex is a simplextree, does some collapses if possible.

  • clean: if True, reduces the measure. It is not necessary in general.

Output

[signed_measure_of_degree for degree in degrees] with signed_measure_of_degree of the form (dirac location, dirac weights).

Notes on computational backends

There are several backends for each of these computations. The backend for computations used can be displayed with verbose=True, use it! Also note that if backend is given, then the input will be converted to a slicer.

  • Euler: is always computed by summing the weights of the simplices

  • Hilbert: is computed by computing persistence on slices, and a Möbius inversion, unless the detected input is a minimal presentation (i.e., filtered_complex.is_minpres), which in that case, doesn’t need any computation. - If the input is a simplextree, this is done via a the standard Gudhi implementation,

    with parallel (TBB) computations of slices.

    • If the input is a slicer then - If the input is vineyard-capable, then slices are computed via vineyards updates.

      It is slower in general, but faster if single threaded. In particular, it is usually faster to use this backend if you want to compute the signed measure of multiple datasets in a parallel context.

      • Otherwise, slices are computed in parallel. It is usually faster to use this backend if not in a parallel context.

  • Rank: Same as Hilbert.

Parameters:
  • filtered_complex (SimplexTreeMulti_KFi32 | SimplexTreeMulti_Fi32 | SimplexTreeMulti_KFi64 | SimplexTreeMulti_Fi64 | SimplexTreeMulti_KFf32 | SimplexTreeMulti_Ff32 | SimplexTreeMulti_KFf64 | SimplexTreeMulti_Ff64 | _KSlicer_Matrix0_vine_i32 | _KSlicer_Matrix1_vine_i32 | _KSlicer_Matrix2_vine_i32 | _KSlicer_Matrix0_vine_i64 | _KSlicer_Matrix1_vine_i64 | _KSlicer_Matrix2_vine_i64 | _KSlicer_Matrix0_vine_f32 | _KSlicer_Matrix1_vine_f32 | _KSlicer_Matrix2_vine_f32 | _KSlicer_Matrix0_vine_f64 | _KSlicer_Matrix1_vine_f64 | _KSlicer_Matrix2_vine_f64 | _Slicer_Matrix0_vine_i32 | _Slicer_Matrix1_vine_i32 | _Slicer_Matrix2_vine_i32 | _Slicer_Matrix0_vine_i64 | _Slicer_Matrix1_vine_i64 | _Slicer_Matrix2_vine_i64 | _Slicer_Matrix0_vine_f32 | _Slicer_Matrix1_vine_f32 | _Slicer_Matrix2_vine_f32 | _Slicer_Matrix0_vine_f64 | _Slicer_Matrix1_vine_f64 | _Slicer_Matrix2_vine_f64 | _KSlicer_Matrix0_i32 | _KSlicer_Matrix1_i32 | _KSlicer_Matrix2_i32 | _KSlicer_Matrix0_i64 | _KSlicer_Matrix1_i64 | _KSlicer_Matrix2_i64 | _KSlicer_Matrix0_f32 | _KSlicer_Matrix1_f32 | _KSlicer_Matrix2_f32 | _KSlicer_Matrix0_f64 | _KSlicer_Matrix1_f64 | _KSlicer_Matrix2_f64 | _Slicer_Matrix0_i32 | _Slicer_Matrix1_i32 | _Slicer_Matrix2_i32 | _Slicer_Matrix0_i64 | _Slicer_Matrix1_i64 | _Slicer_Matrix2_i64 | _Slicer_Matrix0_f32 | _Slicer_Matrix1_f32 | _Slicer_Matrix2_f32 | _Slicer_Matrix0_f64 | _Slicer_Matrix1_f64 | _Slicer_Matrix2_f64 | _KSlicer_GudhiCohomology0_i32 | _KSlicer_GudhiCohomology0_i64 | _KSlicer_GudhiCohomology0_f32 | _KSlicer_GudhiCohomology0_f64 | _Slicer_GudhiCohomology0_i32 | _Slicer_GudhiCohomology0_i64 | _Slicer_GudhiCohomology0_f32 | _Slicer_GudhiCohomology0_f64)

  • degree (int | None)

  • degrees (Sequence[int | None])

  • grid_strategy (Literal['regular', 'regular_closest', 'regular_left', 'partition', 'quantile', 'precomputed'])

  • invariant (str | None)

  • plot (bool)

  • verbose (bool)

  • n_jobs (int)

  • expand_collapse (bool)

  • backend (str | None)

  • thread_id (str)

  • grid (Iterable | None)

  • coordinate_measure (bool)

  • num_collapses (int)

  • clean (bool | None)

  • vineyard (bool)

  • grid_conversion (Iterable | None)

Return type:

list[tuple[ndarray, ndarray]]

multipers._slicer_meta module

multipers._slicer_meta.Slicer(st=None, vineyard=None, reduce=False, reduce_backend=None, dtype=None, is_kcritical=None, column_type=None, backend=None, max_dim=None, return_type_only=False)

Given a simplextree or blocks (a.k.a scc for python), returns a structure that can compute persistence on line (or more) slices, eventually vineyard update, etc.

This can be used to compute interval-decomposable module approximations or signed measures, using, e.g.

  • multipers.module_approximation(this, *args)

  • multipers.signed_measure(this, *args)

Noteit is recommended and sometime required to apply

a minimal presentation before computing these functions !

mp.slicer.minimal_presentation(slicer, *args, **kwargs)

Input

  • st : SimplexTreeMulti or scc-like blocks or path to scc file

  • backend: slicer backend, e.g, “matrix”, “clement”, “graph”

  • vineyard: vineyard capable (may slow down computations if true)

Output

The corresponding slicer.

Parameters:
  • vineyard (bool | None)

  • reduce (bool)

  • reduce_backend (str | None)

  • dtype (int32 | int64 | float32 | float64 | None)

  • is_kcritical (bool | None)

  • column_type (Literal['INTRUSIVE_SET', 'HEAP', 'NAIVE_VECTOR'] | None)

  • backend (Literal['Matrix', 'GudhiCohomology'] | None)

  • max_dim (int | None)

  • return_type_only (bool)

Return type:

_KSlicer_Matrix0_vine_i32 | _KSlicer_Matrix1_vine_i32 | _KSlicer_Matrix2_vine_i32 | _KSlicer_Matrix0_vine_i64 | _KSlicer_Matrix1_vine_i64 | _KSlicer_Matrix2_vine_i64 | _KSlicer_Matrix0_vine_f32 | _KSlicer_Matrix1_vine_f32 | _KSlicer_Matrix2_vine_f32 | _KSlicer_Matrix0_vine_f64 | _KSlicer_Matrix1_vine_f64 | _KSlicer_Matrix2_vine_f64 | _Slicer_Matrix0_vine_i32 | _Slicer_Matrix1_vine_i32 | _Slicer_Matrix2_vine_i32 | _Slicer_Matrix0_vine_i64 | _Slicer_Matrix1_vine_i64 | _Slicer_Matrix2_vine_i64 | _Slicer_Matrix0_vine_f32 | _Slicer_Matrix1_vine_f32 | _Slicer_Matrix2_vine_f32 | _Slicer_Matrix0_vine_f64 | _Slicer_Matrix1_vine_f64 | _Slicer_Matrix2_vine_f64 | _KSlicer_Matrix0_i32 | _KSlicer_Matrix1_i32 | _KSlicer_Matrix2_i32 | _KSlicer_Matrix0_i64 | _KSlicer_Matrix1_i64 | _KSlicer_Matrix2_i64 | _KSlicer_Matrix0_f32 | _KSlicer_Matrix1_f32 | _KSlicer_Matrix2_f32 | _KSlicer_Matrix0_f64 | _KSlicer_Matrix1_f64 | _KSlicer_Matrix2_f64 | _Slicer_Matrix0_i32 | _Slicer_Matrix1_i32 | _Slicer_Matrix2_i32 | _Slicer_Matrix0_i64 | _Slicer_Matrix1_i64 | _Slicer_Matrix2_i64 | _Slicer_Matrix0_f32 | _Slicer_Matrix1_f32 | _Slicer_Matrix2_f32 | _Slicer_Matrix0_f64 | _Slicer_Matrix1_f64 | _Slicer_Matrix2_f64 | _KSlicer_GudhiCohomology0_i32 | _KSlicer_GudhiCohomology0_i64 | _KSlicer_GudhiCohomology0_f32 | _KSlicer_GudhiCohomology0_f64 | _Slicer_GudhiCohomology0_i32 | _Slicer_GudhiCohomology0_i64 | _Slicer_GudhiCohomology0_f32 | _Slicer_GudhiCohomology0_f64

multipers._slicer_meta._blocks2boundary_dimension_grades(blocks, filtration_type=<class 'numpy.float64'>, num_parameters=-1, inplace=False, is_kcritical=False)

Turns blocks, aka scc, into the input of non-simplicial slicers.

Parameters:
  • num_parameters (int)

  • inplace (bool)

  • is_kcritical (bool)

multipers._slicer_meta._slicer_from_blocks(blocks, pers_backend, vineyard, is_kcritical, dtype, col)
Parameters:
  • pers_backend (Literal['Matrix', 'GudhiCohomology'])

  • vineyard (bool)

  • is_kcritical (bool)

  • dtype (type)

  • col (Literal['INTRUSIVE_SET', 'HEAP', 'NAIVE_VECTOR'])

multipers._slicer_meta._slicer_from_simplextree(st, backend, vineyard)

multipers.distances module

multipers.distances.estimate_error(st, module, degree, nlines=100, verbose=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.

Parameters:
  • st (SimplexTreeMulti_KFi32 | SimplexTreeMulti_Fi32 | SimplexTreeMulti_KFi64 | SimplexTreeMulti_Fi64 | SimplexTreeMulti_KFf32 | SimplexTreeMulti_Ff32 | SimplexTreeMulti_KFf64 | SimplexTreeMulti_Ff64)

  • module (PyModule_f32 | PyModule_f64)

  • degree (int)

  • nlines (int)

  • verbose (bool)

multipers.distances.estimate_matching(b1, b2)
Parameters:
  • b1 (PyMultiDiagrams_f32 | PyMultiDiagrams_f64)

  • b2 (PyMultiDiagrams_f32 | PyMultiDiagrams_f64)

multipers.distances.sm2diff(sm1, sm2)
multipers.distances.sm_distance(sm1, sm2, reg=0, reg_m=0, numItermax=10000, p=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

Parameters:
  • sm1 (tuple)

  • sm2 (tuple)

  • reg (float)

  • reg_m (float)

  • numItermax (int)

  • p (float)

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._compute_grid_numpy(signatures, args, kwargs, defaults, _fused_sigindex={})

File: multipers/grids.pyx (starting at line 115)

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._todo_partition(signatures, args, kwargs, defaults, _fused_sigindex={})

File: multipers/grids.pyx (starting at line 230)

multipers.grids._todo_regular_closest(signatures, args, kwargs, defaults, _fused_sigindex={})

File: multipers/grids.pyx (starting at line 209)

multipers.grids._todo_regular_left(signatures, args, kwargs, defaults, _fused_sigindex={})

File: multipers/grids.pyx (starting at line 216)

multipers.grids._torch_regular_closest(f, r: int, unique: bool = True)

File: multipers/grids.pyx (starting at line 223)

multipers.grids.coarsen_points(signatures, args, kwargs, defaults, _fused_sigindex={})

File: multipers/grids.pyx (starting at line 265)

multipers.grids.compute_bounding_box(stuff)

File: multipers/grids.pyx (starting at line 239)

Returns a array of shape (2, num_parameters) such that for any filtration value $y$ of something in stuff, then if (x,z) is the output of this function, we have $xle y le z$.

multipers.grids.compute_grid(signatures, args, kwargs, defaults, _fused_sigindex={})

File: multipers/grids.pyx (starting at line 28)

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.evaluate_in_grid(pts, grid, mass_default=None)

File: multipers/grids.pyx (starting at line 273)

Input

  • pts: of the form array[int, ndim=2]

  • grid of the form Iterable[array[float, ndim=1]]

multipers.grids.push_to_grid(signatures, args, kwargs, defaults, _fused_sigindex={})

File: multipers/grids.pyx (starting at line 248)

Given points and a grid (list of one parameter grids), pushes the points onto the grid.

multipers.grids.sm_in_grid(pts, weights, grid, num_parameters: int = -1, mass_default=None)

File: multipers/grids.pyx (starting at line 300) 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 of the form Iterable[array[float, ndim=1]]

  • num_parameters: number of parameters

multipers.grids.sms_in_grid(sms, grid, num_parameters: int = -1, mass_default=None)

File: multipers/grids.pyx (starting at line 337) 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 of the form Iterable[array[float, ndim=1]]

multipers.grids.todense(grid, product_order: bool = False)

File: multipers/grids.pyx (starting at line 191)

multipers.io module

File: multipers/io.pyx (starting at line 1)

multipers.io._check_available(soft: str)

File: multipers/io.pyx (starting at line 232)

Parameters:

soft (str)

multipers.io._init_external_softwares(requires=[])

File: multipers/io.pyx (starting at line 212)

multipers.io._path_init(soft: str | os.PathLike)

File: multipers/io.pyx (starting at line 70)

Parameters:

soft (str | PathLike)

multipers.io._put_temp_files_to_ram()

File: multipers/io.pyx (starting at line 205)

multipers.io.clear_io(*args)

File: multipers/io.pyx (starting at line 517) 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 423)

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

Parameters:
  • point_cloud (ndarray)

  • function_values (ndarray)

  • id (str | None)

  • clear (bool)

  • verbose (bool)

multipers.io.function_delaunay_presentation_to_slicer(slicer, 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 470)

Computes a function delaunay presentation, and returns it as a slicer.

slicer: empty slicer to fill 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

Parameters:
  • point_cloud (ndarray)

  • function_values (ndarray)

  • id (str | None)

  • clear (bool)

  • 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 365)

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

Parameters:
  • full_resolution (bool)

  • dimension (int | int64)

  • clear (bool)

  • id (str | None)

  • verbose (bool)

  • backend (Literal['mpfree', 'multi_chunk', '2pac'])

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 596)

Writes a scc python format / blocks into a file.

Parameters:

path (str | PathLike)

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 653)

Writes a scc python format / blocks into a file.

Parameters:

path (str | PathLike)

multipers.io.scc_parser(path: str | os.PathLike)

File: multipers/io.pyx (starting at line 111)

Parse an scc file into the scc python format, aka blocks.

Parameters:

path (str | PathLike)

multipers.io.scc_parser__old(path: str)

File: multipers/io.pyx (starting at line 139)

Parse an scc file into the scc python format, aka blocks.

Parameters:

path (str)

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 237)

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”

Parameters:
  • path (str | PathLike)

  • dimension (int | int64)

  • clear (bool)

  • id (str | None)

  • verbose (bool)

  • backend (Literal['mpfree', 'multi_chunk', 'twopac'])

multipers.io.scc_reduce_from_str_to_slicer(path: str | os.PathLike, slicer, 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', shift_dimension=0)

File: multipers/io.pyx (starting at line 302)

Computes a minimal presentation of the file in path, using mpfree.

path:PathLike slicer: empty slicer to fill 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”

Parameters:
  • path (str | PathLike)

  • dimension (int | int64)

  • clear (bool)

  • id (str | None)

  • verbose (bool)

  • backend (Literal['mpfree', 'multi_chunk', 'twopac'])

multipers.multiparameter_edge_collapse module

multipers.multiparameter_edge_collapse._collapse_edge_list(edges, num=0, full=False, strong=False, progress=False)

Given an edge list defining a 1 critical 2 parameter 1 dimensional simplicial complex, simplificates this filtered simplicial complex, using filtration-domination’s edge collapser.

Parameters:
  • num (int)

  • full (bool)

  • strong (bool)

  • progress (bool)

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) PyModule_type

File: multipers/multiparameter_module_approximation.pyx (starting at line 90) 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.

Parameters:
  • input (SimplexTreeMulti_KFi32 | SimplexTreeMulti_Fi32 | SimplexTreeMulti_KFi64 | SimplexTreeMulti_Fi64 | SimplexTreeMulti_KFf32 | SimplexTreeMulti_Ff32 | SimplexTreeMulti_KFf64 | SimplexTreeMulti_Ff64 | _KSlicer_Matrix0_vine_i32 | _KSlicer_Matrix1_vine_i32 | _KSlicer_Matrix2_vine_i32 | _KSlicer_Matrix0_vine_i64 | _KSlicer_Matrix1_vine_i64 | _KSlicer_Matrix2_vine_i64 | _KSlicer_Matrix0_vine_f32 | _KSlicer_Matrix1_vine_f32 | _KSlicer_Matrix2_vine_f32 | _KSlicer_Matrix0_vine_f64 | _KSlicer_Matrix1_vine_f64 | _KSlicer_Matrix2_vine_f64 | _Slicer_Matrix0_vine_i32 | _Slicer_Matrix1_vine_i32 | _Slicer_Matrix2_vine_i32 | _Slicer_Matrix0_vine_i64 | _Slicer_Matrix1_vine_i64 | _Slicer_Matrix2_vine_i64 | _Slicer_Matrix0_vine_f32 | _Slicer_Matrix1_vine_f32 | _Slicer_Matrix2_vine_f32 | _Slicer_Matrix0_vine_f64 | _Slicer_Matrix1_vine_f64 | _Slicer_Matrix2_vine_f64 | _KSlicer_Matrix0_i32 | _KSlicer_Matrix1_i32 | _KSlicer_Matrix2_i32 | _KSlicer_Matrix0_i64 | _KSlicer_Matrix1_i64 | _KSlicer_Matrix2_i64 | _KSlicer_Matrix0_f32 | _KSlicer_Matrix1_f32 | _KSlicer_Matrix2_f32 | _KSlicer_Matrix0_f64 | _KSlicer_Matrix1_f64 | _KSlicer_Matrix2_f64 | _Slicer_Matrix0_i32 | _Slicer_Matrix1_i32 | _Slicer_Matrix2_i32 | _Slicer_Matrix0_i64 | _Slicer_Matrix1_i64 | _Slicer_Matrix2_i64 | _Slicer_Matrix0_f32 | _Slicer_Matrix1_f32 | _Slicer_Matrix2_f32 | _Slicer_Matrix0_f64 | _Slicer_Matrix1_f64 | _Slicer_Matrix2_f64 | _KSlicer_GudhiCohomology0_i32 | _KSlicer_GudhiCohomology0_i64 | _KSlicer_GudhiCohomology0_f32 | _KSlicer_GudhiCohomology0_f64 | _Slicer_GudhiCohomology0_i32 | _Slicer_GudhiCohomology0_i64 | _Slicer_GudhiCohomology0_f32 | _Slicer_GudhiCohomology0_f64 | tuple)

  • box (ndarray | None)

  • slicer_backend (Literal['matrix', 'clement', 'graph'])

  • minpres (Literal['mpfree'] | None)

  • degree (int | None)

Return type:

PyModule_f32 | PyModule_f64

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 = []) PyModule_type

File: multipers/multiparameter_module_approximation.pyx (starting at line 54)

Parameters:
  • slicer (_KSlicer_Matrix0_vine_i32 | _KSlicer_Matrix1_vine_i32 | _KSlicer_Matrix2_vine_i32 | _KSlicer_Matrix0_vine_i64 | _KSlicer_Matrix1_vine_i64 | _KSlicer_Matrix2_vine_i64 | _KSlicer_Matrix0_vine_f32 | _KSlicer_Matrix1_vine_f32 | _KSlicer_Matrix2_vine_f32 | _KSlicer_Matrix0_vine_f64 | _KSlicer_Matrix1_vine_f64 | _KSlicer_Matrix2_vine_f64 | _Slicer_Matrix0_vine_i32 | _Slicer_Matrix1_vine_i32 | _Slicer_Matrix2_vine_i32 | _Slicer_Matrix0_vine_i64 | _Slicer_Matrix1_vine_i64 | _Slicer_Matrix2_vine_i64 | _Slicer_Matrix0_vine_f32 | _Slicer_Matrix1_vine_f32 | _Slicer_Matrix2_vine_f32 | _Slicer_Matrix0_vine_f64 | _Slicer_Matrix1_vine_f64 | _Slicer_Matrix2_vine_f64 | _KSlicer_Matrix0_i32 | _KSlicer_Matrix1_i32 | _KSlicer_Matrix2_i32 | _KSlicer_Matrix0_i64 | _KSlicer_Matrix1_i64 | _KSlicer_Matrix2_i64 | _KSlicer_Matrix0_f32 | _KSlicer_Matrix1_f32 | _KSlicer_Matrix2_f32 | _KSlicer_Matrix0_f64 | _KSlicer_Matrix1_f64 | _KSlicer_Matrix2_f64 | _Slicer_Matrix0_i32 | _Slicer_Matrix1_i32 | _Slicer_Matrix2_i32 | _Slicer_Matrix0_i64 | _Slicer_Matrix1_i64 | _Slicer_Matrix2_i64 | _Slicer_Matrix0_f32 | _Slicer_Matrix1_f32 | _Slicer_Matrix2_f32 | _Slicer_Matrix0_f64 | _Slicer_Matrix1_f64 | _Slicer_Matrix2_f64 | _KSlicer_GudhiCohomology0_i32 | _KSlicer_GudhiCohomology0_i64 | _KSlicer_GudhiCohomology0_f32 | _KSlicer_GudhiCohomology0_f64 | _Slicer_GudhiCohomology0_i32 | _Slicer_GudhiCohomology0_i64 | _Slicer_GudhiCohomology0_f32 | _Slicer_GudhiCohomology0_f64)

  • box (ndarray | None)

Return type:

PyModule_f32 | PyModule_f64

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)
Parameters:

path (str)

multipers.pickle.load_with_axis(sms)
multipers.pickle.load_without_axis(sms)
multipers.pickle.save(path, signed_measures)
Parameters:

path (str)

multipers.pickle.save_with_axis(path, signed_measures)
Parameters:

path (str)

multipers.pickle.save_without_axis(path, signed_measures)
Parameters:

path (str)

multipers.plots module

multipers.plots._d_inf(a, b)
multipers.plots._plot_rectangle(rectangle, weight, **plt_kwargs)
Parameters:

rectangle (ndarray)

multipers.plots._plot_signed_measure_2(pts, weights, temp_alpha=0.7, threshold=(inf, inf), **plt_kwargs)
multipers.plots._plot_signed_measure_4(pts, weights, x_smoothing=1, area_alpha=True, threshold=(inf, inf), alpha=None, **plt_kwargs)
Parameters:
  • x_smoothing (float)

  • area_alpha (bool)

multipers.plots._rectangle(x, y, color, alpha)

Defines a rectangle patch in the format {z | x  ≤ z ≤ y} with color and alpha

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=None, discrete_surface=False, has_negative_values=False, **plt_args)
Parameters:

cmap (str | None)

multipers.plots.plot_surfaces(HF, size=4, **plt_args)

multipers.point_measure module

File: multipers/point_measure.pyx (starting at line 1)

multipers.point_measure.barcode_from_rank_sm(sm: tuple[np.ndarray, np.ndarray], basepoint: np.ndarray, direction: np.ndarray | None = None, full: bool = False)

File: multipers/point_measure.pyx (starting at line 179)

Given a rank signed measure sm and a line with basepoint basepoint (1darray) and direction direction (1darray), projects the rank signed measure on the given line, and returns the associated estimated barcode. If full is True, the barcode is given as coordinates in R^{num_parameters} instead of coordinates w.r.t. the line.

Parameters:
  • sm (tuple[ndarray, ndarray])

  • basepoint (ndarray)

  • direction (ndarray | None)

multipers.point_measure.clean_signed_measure(signatures, args, kwargs, defaults, _fused_sigindex={})

File: multipers/point_measure.pyx (starting at line 113)

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.clean_sms(sms)

File: multipers/point_measure.pyx (starting at line 136)

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.estimate_rank_from_rank_sm(sm: tuple, a, b) int

File: multipers/point_measure.pyx (starting at line 249)

Given a rank signed measure (sm) and two points (a) and (b), estimates the rank between these two points.

Parameters:

sm (tuple)

Return type:

int

multipers.point_measure.integrate_measure(signatures, args, kwargs, defaults, _fused_sigindex={})

File: multipers/point_measure.pyx (starting at line 32)

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.integrate_measure_python(pts, weights, filtrations)

File: multipers/point_measure.pyx (starting at line 83)

multipers.point_measure.sparsify(x)

File: multipers/point_measure.pyx (starting at line 94)

Given an arbitrary dimensional numpy array, returns (coordinates,data). – cost : scipy sparse + num_points*num_parameters^2 divisions

multipers.point_measure.zero_out_sm(pts, weights, mass_default)

File: multipers/point_measure.pyx (starting at line 144)

Zeros out the modules outside of

$ { xin mathbb R^n mid x le mathrm{mass_default}} $.

multipers.point_measure.zero_out_sms(sms, mass_default)

File: multipers/point_measure.pyx (starting at line 173)

Zeros out the modules outside of

$ { xin mathbb R^n mid x le mathrm{mass_default}} $.

multipers.test module

Module contents

multipers.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 9713) 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.

Parameters:

dtype (type)

Return type:

SimplexTreeMulti_KFi32 | SimplexTreeMulti_Fi32 | SimplexTreeMulti_KFi64 | SimplexTreeMulti_Fi64 | SimplexTreeMulti_KFf32 | SimplexTreeMulti_Ff32 | SimplexTreeMulti_KFf64 | SimplexTreeMulti_Ff64

multipers.Slicer(st=None, vineyard=None, reduce=False, reduce_backend=None, dtype=None, is_kcritical=None, column_type=None, backend=None, max_dim=None, return_type_only=False)

Given a simplextree or blocks (a.k.a scc for python), returns a structure that can compute persistence on line (or more) slices, eventually vineyard update, etc.

This can be used to compute interval-decomposable module approximations or signed measures, using, e.g.

  • multipers.module_approximation(this, *args)

  • multipers.signed_measure(this, *args)

Noteit is recommended and sometime required to apply

a minimal presentation before computing these functions !

mp.slicer.minimal_presentation(slicer, *args, **kwargs)

Input

  • st : SimplexTreeMulti or scc-like blocks or path to scc file

  • backend: slicer backend, e.g, “matrix”, “clement”, “graph”

  • vineyard: vineyard capable (may slow down computations if true)

Output

The corresponding slicer.

Parameters:
  • vineyard (bool | None)

  • reduce (bool)

  • reduce_backend (str | None)

  • dtype (int32 | int64 | float32 | float64 | None)

  • is_kcritical (bool | None)

  • column_type (Literal['INTRUSIVE_SET', 'HEAP', 'NAIVE_VECTOR'] | None)

  • backend (Literal['Matrix', 'GudhiCohomology'] | None)

  • max_dim (int | None)

  • return_type_only (bool)

Return type:

_KSlicer_Matrix0_vine_i32 | _KSlicer_Matrix1_vine_i32 | _KSlicer_Matrix2_vine_i32 | _KSlicer_Matrix0_vine_i64 | _KSlicer_Matrix1_vine_i64 | _KSlicer_Matrix2_vine_i64 | _KSlicer_Matrix0_vine_f32 | _KSlicer_Matrix1_vine_f32 | _KSlicer_Matrix2_vine_f32 | _KSlicer_Matrix0_vine_f64 | _KSlicer_Matrix1_vine_f64 | _KSlicer_Matrix2_vine_f64 | _Slicer_Matrix0_vine_i32 | _Slicer_Matrix1_vine_i32 | _Slicer_Matrix2_vine_i32 | _Slicer_Matrix0_vine_i64 | _Slicer_Matrix1_vine_i64 | _Slicer_Matrix2_vine_i64 | _Slicer_Matrix0_vine_f32 | _Slicer_Matrix1_vine_f32 | _Slicer_Matrix2_vine_f32 | _Slicer_Matrix0_vine_f64 | _Slicer_Matrix1_vine_f64 | _Slicer_Matrix2_vine_f64 | _KSlicer_Matrix0_i32 | _KSlicer_Matrix1_i32 | _KSlicer_Matrix2_i32 | _KSlicer_Matrix0_i64 | _KSlicer_Matrix1_i64 | _KSlicer_Matrix2_i64 | _KSlicer_Matrix0_f32 | _KSlicer_Matrix1_f32 | _KSlicer_Matrix2_f32 | _KSlicer_Matrix0_f64 | _KSlicer_Matrix1_f64 | _KSlicer_Matrix2_f64 | _Slicer_Matrix0_i32 | _Slicer_Matrix1_i32 | _Slicer_Matrix2_i32 | _Slicer_Matrix0_i64 | _Slicer_Matrix1_i64 | _Slicer_Matrix2_i64 | _Slicer_Matrix0_f32 | _Slicer_Matrix1_f32 | _Slicer_Matrix2_f32 | _Slicer_Matrix0_f64 | _Slicer_Matrix1_f64 | _Slicer_Matrix2_f64 | _KSlicer_GudhiCohomology0_i32 | _KSlicer_GudhiCohomology0_i64 | _KSlicer_GudhiCohomology0_f32 | _KSlicer_GudhiCohomology0_f64 | _Slicer_GudhiCohomology0_i32 | _Slicer_GudhiCohomology0_i64 | _Slicer_GudhiCohomology0_f32 | _Slicer_GudhiCohomology0_f64

multipers.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) PyModule_type

File: multipers/multiparameter_module_approximation.pyx (starting at line 90) 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.

Parameters:
  • input (SimplexTreeMulti_KFi32 | SimplexTreeMulti_Fi32 | SimplexTreeMulti_KFi64 | SimplexTreeMulti_Fi64 | SimplexTreeMulti_KFf32 | SimplexTreeMulti_Ff32 | SimplexTreeMulti_KFf64 | SimplexTreeMulti_Ff64 | _KSlicer_Matrix0_vine_i32 | _KSlicer_Matrix1_vine_i32 | _KSlicer_Matrix2_vine_i32 | _KSlicer_Matrix0_vine_i64 | _KSlicer_Matrix1_vine_i64 | _KSlicer_Matrix2_vine_i64 | _KSlicer_Matrix0_vine_f32 | _KSlicer_Matrix1_vine_f32 | _KSlicer_Matrix2_vine_f32 | _KSlicer_Matrix0_vine_f64 | _KSlicer_Matrix1_vine_f64 | _KSlicer_Matrix2_vine_f64 | _Slicer_Matrix0_vine_i32 | _Slicer_Matrix1_vine_i32 | _Slicer_Matrix2_vine_i32 | _Slicer_Matrix0_vine_i64 | _Slicer_Matrix1_vine_i64 | _Slicer_Matrix2_vine_i64 | _Slicer_Matrix0_vine_f32 | _Slicer_Matrix1_vine_f32 | _Slicer_Matrix2_vine_f32 | _Slicer_Matrix0_vine_f64 | _Slicer_Matrix1_vine_f64 | _Slicer_Matrix2_vine_f64 | _KSlicer_Matrix0_i32 | _KSlicer_Matrix1_i32 | _KSlicer_Matrix2_i32 | _KSlicer_Matrix0_i64 | _KSlicer_Matrix1_i64 | _KSlicer_Matrix2_i64 | _KSlicer_Matrix0_f32 | _KSlicer_Matrix1_f32 | _KSlicer_Matrix2_f32 | _KSlicer_Matrix0_f64 | _KSlicer_Matrix1_f64 | _KSlicer_Matrix2_f64 | _Slicer_Matrix0_i32 | _Slicer_Matrix1_i32 | _Slicer_Matrix2_i32 | _Slicer_Matrix0_i64 | _Slicer_Matrix1_i64 | _Slicer_Matrix2_i64 | _Slicer_Matrix0_f32 | _Slicer_Matrix1_f32 | _Slicer_Matrix2_f32 | _Slicer_Matrix0_f64 | _Slicer_Matrix1_f64 | _Slicer_Matrix2_f64 | _KSlicer_GudhiCohomology0_i32 | _KSlicer_GudhiCohomology0_i64 | _KSlicer_GudhiCohomology0_f32 | _KSlicer_GudhiCohomology0_f64 | _Slicer_GudhiCohomology0_i32 | _Slicer_GudhiCohomology0_i64 | _Slicer_GudhiCohomology0_f32 | _Slicer_GudhiCohomology0_f64 | tuple)

  • box (ndarray | None)

  • slicer_backend (Literal['matrix', 'clement', 'graph'])

  • minpres (Literal['mpfree'] | None)

  • degree (int | None)

Return type:

PyModule_f32 | PyModule_f64

multipers.signed_measure(filtered_complex, degree=None, degrees=[], mass_default=None, grid_strategy='exact', invariant=None, plot=False, verbose=False, n_jobs=-1, expand_collapse=False, backend=None, thread_id='', grid=None, coordinate_measure=False, num_collapses=0, clean=None, vineyard=False, grid_conversion=None, **infer_grid_kwargs)

Computes the signed measures given by the decomposition of the hilbert function or the euler characteristic, or the rank invariant.

Input

  • filtered_complex: given by a simplextree or a slicer.

  • degree:int|None / degrees:list[int] the degrees to compute. None represents the euler characteristic.

  • mass_default: Either None, or ‘auto’ or ‘inf’, or array-like of floats. Where to put the default mass to get a zero-mass measure. This corresponds to zero-out the filtered complex outside of ${ xin mathbb R^n mid xle mass_default}$

  • invariant: The invariant to use, either “hilbert”, “rank”, or “euler”.

  • plot:bool, plots the computed measures if true.

  • n_jobs:int, number of jobs. Defaults to #cpu.

  • verbose:bool, prints c++ logs.

  • expand_collapse: when the input is a simplextree, only expands the complex when computing 1-dimensional slices. Meant to reduce memory footprint at some computational expense.

  • backend:str reduces first the filtered complex using an external library backend,

    see backend in multipers.io.reduce_complex().

  • grid: If given, the computations will be done on the restriction of the filtered complex to this grid.

    It can also be used for auto-differentiation, i.e., if the grid is a list of pytorch tensors, then the output measure will be pytorch-differentiable.

  • grid_strategy: If not squeezed yet, and no grid is given, the strategy to coarsen the grid; see strategy in multipers.grids.compute_grid().

  • coordinate_measure: bool, if True, compute the signed measure as a coordinates given in grid.

  • num_collapses: int, if filtered_complex is a simplextree, does some collapses if possible.

  • clean: if True, reduces the measure. It is not necessary in general.

Output

[signed_measure_of_degree for degree in degrees] with signed_measure_of_degree of the form (dirac location, dirac weights).

Notes on computational backends

There are several backends for each of these computations. The backend for computations used can be displayed with verbose=True, use it! Also note that if backend is given, then the input will be converted to a slicer.

  • Euler: is always computed by summing the weights of the simplices

  • Hilbert: is computed by computing persistence on slices, and a Möbius inversion, unless the detected input is a minimal presentation (i.e., filtered_complex.is_minpres), which in that case, doesn’t need any computation. - If the input is a simplextree, this is done via a the standard Gudhi implementation,

    with parallel (TBB) computations of slices.

    • If the input is a slicer then - If the input is vineyard-capable, then slices are computed via vineyards updates.

      It is slower in general, but faster if single threaded. In particular, it is usually faster to use this backend if you want to compute the signed measure of multiple datasets in a parallel context.

      • Otherwise, slices are computed in parallel. It is usually faster to use this backend if not in a parallel context.

  • Rank: Same as Hilbert.

Parameters:
  • filtered_complex (SimplexTreeMulti_KFi32 | SimplexTreeMulti_Fi32 | SimplexTreeMulti_KFi64 | SimplexTreeMulti_Fi64 | SimplexTreeMulti_KFf32 | SimplexTreeMulti_Ff32 | SimplexTreeMulti_KFf64 | SimplexTreeMulti_Ff64 | _KSlicer_Matrix0_vine_i32 | _KSlicer_Matrix1_vine_i32 | _KSlicer_Matrix2_vine_i32 | _KSlicer_Matrix0_vine_i64 | _KSlicer_Matrix1_vine_i64 | _KSlicer_Matrix2_vine_i64 | _KSlicer_Matrix0_vine_f32 | _KSlicer_Matrix1_vine_f32 | _KSlicer_Matrix2_vine_f32 | _KSlicer_Matrix0_vine_f64 | _KSlicer_Matrix1_vine_f64 | _KSlicer_Matrix2_vine_f64 | _Slicer_Matrix0_vine_i32 | _Slicer_Matrix1_vine_i32 | _Slicer_Matrix2_vine_i32 | _Slicer_Matrix0_vine_i64 | _Slicer_Matrix1_vine_i64 | _Slicer_Matrix2_vine_i64 | _Slicer_Matrix0_vine_f32 | _Slicer_Matrix1_vine_f32 | _Slicer_Matrix2_vine_f32 | _Slicer_Matrix0_vine_f64 | _Slicer_Matrix1_vine_f64 | _Slicer_Matrix2_vine_f64 | _KSlicer_Matrix0_i32 | _KSlicer_Matrix1_i32 | _KSlicer_Matrix2_i32 | _KSlicer_Matrix0_i64 | _KSlicer_Matrix1_i64 | _KSlicer_Matrix2_i64 | _KSlicer_Matrix0_f32 | _KSlicer_Matrix1_f32 | _KSlicer_Matrix2_f32 | _KSlicer_Matrix0_f64 | _KSlicer_Matrix1_f64 | _KSlicer_Matrix2_f64 | _Slicer_Matrix0_i32 | _Slicer_Matrix1_i32 | _Slicer_Matrix2_i32 | _Slicer_Matrix0_i64 | _Slicer_Matrix1_i64 | _Slicer_Matrix2_i64 | _Slicer_Matrix0_f32 | _Slicer_Matrix1_f32 | _Slicer_Matrix2_f32 | _Slicer_Matrix0_f64 | _Slicer_Matrix1_f64 | _Slicer_Matrix2_f64 | _KSlicer_GudhiCohomology0_i32 | _KSlicer_GudhiCohomology0_i64 | _KSlicer_GudhiCohomology0_f32 | _KSlicer_GudhiCohomology0_f64 | _Slicer_GudhiCohomology0_i32 | _Slicer_GudhiCohomology0_i64 | _Slicer_GudhiCohomology0_f32 | _Slicer_GudhiCohomology0_f64)

  • degree (int | None)

  • degrees (Sequence[int | None])

  • grid_strategy (Literal['regular', 'regular_closest', 'regular_left', 'partition', 'quantile', 'precomputed'])

  • invariant (str | None)

  • plot (bool)

  • verbose (bool)

  • n_jobs (int)

  • expand_collapse (bool)

  • backend (str | None)

  • thread_id (str)

  • grid (Iterable | None)

  • coordinate_measure (bool)

  • num_collapses (int)

  • clean (bool | None)

  • vineyard (bool)

  • grid_conversion (Iterable | None)

Return type:

list[tuple[ndarray, ndarray]]