multipers package
Subpackages
- multipers.array_api package
- multipers.data package
- Submodules
- multipers.data.MOL2 module
- 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.filtrations package
- Submodules
- multipers.filtrations.density module
- multipers.filtrations.filtrations module
- Module contents
- multipers.ml package
- Submodules
- multipers.ml.accuracies module
- multipers.ml.invariants_with_persistable module
- multipers.ml.kernels module
- multipers.ml.mma module
FilteredComplex2MMAMMA2IMGMMA2LandscapeMMAFormatterMMAFormatter._get_module_bound()MMAFormatter._infer_axis()MMAFormatter._infer_bounds()MMAFormatter._infer_degrees()MMAFormatter._infer_grid()MMAFormatter._infer_num_parameters()MMAFormatter._maybe_from_dump()MMAFormatter._sklearn_auto_wrap_output_keysMMAFormatter.copy_transform()MMAFormatter.fit()MMAFormatter.set_fit_request()MMAFormatter.set_transform_request()MMAFormatter.transform()
SimplexTree2MMA
- multipers.ml.one module
Dgm2HistogramDgms2ImageDgms2LandscapesDgms2SWKDgms2SignedMeasureDistanceDgms2SignedMeasureDistance.OSWdistance()Dgms2SignedMeasureDistance.XDgms2SignedMeasureDistance._ds()Dgms2SignedMeasureDistance._sklearn_auto_wrap_output_keysDgms2SignedMeasureDistance.degreesDgms2SignedMeasureDistance.fit()Dgms2SignedMeasureDistance.transform()Dgms2SignedMeasureDistance.wasserstein_1()
Dgms2SignedMeasureHistogramDgms2SignedMeasureImageDgms2SlicedWassersteinDistanceMatricesDgms2SlicedWassersteinDistanceMatrices.SW_Dgms2SlicedWassersteinDistanceMatrices._get_distance()Dgms2SlicedWassersteinDistanceMatrices._sklearn_auto_wrap_output_keysDgms2SlicedWassersteinDistanceMatrices.fit()Dgms2SlicedWassersteinDistanceMatrices.num_directionsDgms2SlicedWassersteinDistanceMatrices.transform()
DiagramShuffleFilvecGetterGraph2SimplexTreePointCloud2SimplexTreeSimplexTree2DgmSimplexTree2Histogramdgm2pervec()get_filtration_values()get_simplextree()get_simplextrees()graph2filvec()simplextree2hist()
- multipers.ml.point_clouds module
PointCloud2FilteredComplexPointCloud2FilteredComplex._define_bandwidths()PointCloud2FilteredComplex._define_sts()PointCloud2FilteredComplex._get_codensities()PointCloud2FilteredComplex._get_distance_quantiles_and_threshold()PointCloud2FilteredComplex._get_sts_alpha()PointCloud2FilteredComplex._get_sts_delaunay()PointCloud2FilteredComplex._get_sts_rips()PointCloud2FilteredComplex._sklearn_auto_wrap_output_keysPointCloud2FilteredComplex.fit()PointCloud2FilteredComplex.transform()
PointCloud2SimplexTree
- multipers.ml.signed_measures module
DegreeRips2SignedMeasureFilteredComplex2SignedMeasureFilteredComplex2SignedMeasure._infer_filtration()FilteredComplex2SignedMeasure._input_checks()FilteredComplex2SignedMeasure._is_filtered_complex()FilteredComplex2SignedMeasure._params_check()FilteredComplex2SignedMeasure._sklearn_auto_wrap_output_keysFilteredComplex2SignedMeasure.fit()FilteredComplex2SignedMeasure.num_parametersFilteredComplex2SignedMeasure.transform()FilteredComplex2SignedMeasure.transform1()
SignedMeasure2ConvolutionSignedMeasure2SlicedWassersteinDistanceSignedMeasureFormatterSignedMeasureFormatter._check_axis()SignedMeasureFormatter._check_backend()SignedMeasureFormatter._check_measures()SignedMeasureFormatter._check_resolution()SignedMeasureFormatter._check_sm()SignedMeasureFormatter._check_weights()SignedMeasureFormatter._get_filtration_bounds()SignedMeasureFormatter._infer_grids()SignedMeasureFormatter._integrate_measure()SignedMeasureFormatter._plot_signed_measures()SignedMeasureFormatter._print_stats()SignedMeasureFormatter._rescale_measures()SignedMeasureFormatter._sklearn_auto_wrap_output_keysSignedMeasureFormatter.fit()SignedMeasureFormatter.num_parametersSignedMeasureFormatter.transform()SignedMeasureFormatter.unsparse_signed_measure()
SignedMeasures2SlicedWassersteinDistancesSimplexTree2RectangleDecompositionSimplexTree2SignedMeasure_st2ranktensor()batch_signed_measure_convolutions()deep_unrag()rescale_sparse_signed_measure()sm2deep()sm_convolution()tensor_möbius_inversion()
- multipers.ml.sliced_wasserstein module
SlicedWassersteinDistanceWassersteinDistance_compute_signed_measure_parts()_compute_signed_measure_projections()_pairwise()_sklearn_wrapper()_sliced_wasserstein_distance()_sliced_wasserstein_distance_on_projections()_wasserstein_distance()_wasserstein_distance_on_parts()pairwise_signed_measure_distances()
- multipers.ml.tools module
- Module contents
- multipers.tests package
- multipers.torch package
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 (_KFlatSlicer_Matrix0_vine_i32 | _KContiguousSlicer_Matrix0_vine_i32 | _KFlatSlicer_Matrix0_vine_i64 | _KContiguousSlicer_Matrix0_vine_i64 | _KFlatSlicer_Matrix0_vine_f32 | _KContiguousSlicer_Matrix0_vine_f32 | _KFlatSlicer_Matrix0_vine_f64 | _KContiguousSlicer_Matrix0_vine_f64 | _ContiguousSlicer_Matrix0_vine_i32 | _ContiguousSlicer_Matrix0_vine_i64 | _ContiguousSlicer_Matrix0_vine_f32 | _ContiguousSlicer_Matrix0_vine_f64 | _KFlatSlicer_Matrix0_i32 | _KContiguousSlicer_Matrix0_i32 | _KFlatSlicer_Matrix0_i64 | _KContiguousSlicer_Matrix0_i64 | _KFlatSlicer_Matrix0_f32 | _KContiguousSlicer_Matrix0_f32 | _KFlatSlicer_Matrix0_f64 | _KContiguousSlicer_Matrix0_f64 | _ContiguousSlicer_Matrix0_i32 | _ContiguousSlicer_Matrix0_i64 | _ContiguousSlicer_Matrix0_f32 | _ContiguousSlicer_Matrix0_f64 | _KFlatSlicer_GudhiCohomology0_i32 | _KContiguousSlicer_GudhiCohomology0_i32 | _KFlatSlicer_GudhiCohomology0_i64 | _KContiguousSlicer_GudhiCohomology0_i64 | _KFlatSlicer_GudhiCohomology0_f32 | _KContiguousSlicer_GudhiCohomology0_f32 | _KFlatSlicer_GudhiCohomology0_f64 | _KContiguousSlicer_GudhiCohomology0_f64 | _ContiguousSlicer_GudhiCohomology0_i32 | _ContiguousSlicer_GudhiCohomology0_i64 | _ContiguousSlicer_GudhiCohomology0_f32 | _ContiguousSlicer_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, grid=None, coordinate_measure=False, num_collapses=0, clean=None, vineyard=False, grid_conversion=None, ignore_infinite_filtration_values=True, **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
backendinmultipers.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
strategyinmultipers.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.
ignore_infinite_filtration_values: Backend optimization.
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_Flat_Ki32 | _SimplexTreeMulti_Contiguous_Ki32 | _SimplexTreeMulti_Flat_Ki64 | _SimplexTreeMulti_Contiguous_Ki64 | _SimplexTreeMulti_Flat_Kf32 | _SimplexTreeMulti_Contiguous_Kf32 | _SimplexTreeMulti_Flat_Kf64 | _SimplexTreeMulti_Contiguous_Kf64 | _SimplexTreeMulti_Flat_i32 | _SimplexTreeMulti_Contiguous_i32 | _SimplexTreeMulti_Flat_i64 | _SimplexTreeMulti_Contiguous_i64 | _SimplexTreeMulti_Flat_f32 | _SimplexTreeMulti_Contiguous_f32 | _SimplexTreeMulti_Flat_f64 | _SimplexTreeMulti_Contiguous_f64 | _KFlatSlicer_Matrix0_vine_i32 | _KContiguousSlicer_Matrix0_vine_i32 | _KFlatSlicer_Matrix0_vine_i64 | _KContiguousSlicer_Matrix0_vine_i64 | _KFlatSlicer_Matrix0_vine_f32 | _KContiguousSlicer_Matrix0_vine_f32 | _KFlatSlicer_Matrix0_vine_f64 | _KContiguousSlicer_Matrix0_vine_f64 | _ContiguousSlicer_Matrix0_vine_i32 | _ContiguousSlicer_Matrix0_vine_i64 | _ContiguousSlicer_Matrix0_vine_f32 | _ContiguousSlicer_Matrix0_vine_f64 | _KFlatSlicer_Matrix0_i32 | _KContiguousSlicer_Matrix0_i32 | _KFlatSlicer_Matrix0_i64 | _KContiguousSlicer_Matrix0_i64 | _KFlatSlicer_Matrix0_f32 | _KContiguousSlicer_Matrix0_f32 | _KFlatSlicer_Matrix0_f64 | _KContiguousSlicer_Matrix0_f64 | _ContiguousSlicer_Matrix0_i32 | _ContiguousSlicer_Matrix0_i64 | _ContiguousSlicer_Matrix0_f32 | _ContiguousSlicer_Matrix0_f64 | _KFlatSlicer_GudhiCohomology0_i32 | _KContiguousSlicer_GudhiCohomology0_i32 | _KFlatSlicer_GudhiCohomology0_i64 | _KContiguousSlicer_GudhiCohomology0_i64 | _KFlatSlicer_GudhiCohomology0_f32 | _KContiguousSlicer_GudhiCohomology0_f32 | _KFlatSlicer_GudhiCohomology0_f64 | _KContiguousSlicer_GudhiCohomology0_f64 | _ContiguousSlicer_GudhiCohomology0_i32 | _ContiguousSlicer_GudhiCohomology0_i64 | _ContiguousSlicer_GudhiCohomology0_f32 | _ContiguousSlicer_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)
grid (Iterable | None)
coordinate_measure (bool)
num_collapses (int)
clean (bool | None)
vineyard (bool)
grid_conversion (Iterable | None)
ignore_infinite_filtration_values (bool)
- 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, kcritical=None, column_type=None, backend=None, filtration_container=None, max_dim=None, return_type_only=False, _shift_dimension=0)
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)
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)
kcritical (bool | None)
column_type (Literal['INTRUSIVE_SET'] | None)
backend (Literal['Matrix', 'GudhiCohomology'] | None)
filtration_container (str | None)
max_dim (int | None)
return_type_only (bool)
_shift_dimension (int)
- Return type:
_KFlatSlicer_Matrix0_vine_i32 | _KContiguousSlicer_Matrix0_vine_i32 | _KFlatSlicer_Matrix0_vine_i64 | _KContiguousSlicer_Matrix0_vine_i64 | _KFlatSlicer_Matrix0_vine_f32 | _KContiguousSlicer_Matrix0_vine_f32 | _KFlatSlicer_Matrix0_vine_f64 | _KContiguousSlicer_Matrix0_vine_f64 | _ContiguousSlicer_Matrix0_vine_i32 | _ContiguousSlicer_Matrix0_vine_i64 | _ContiguousSlicer_Matrix0_vine_f32 | _ContiguousSlicer_Matrix0_vine_f64 | _KFlatSlicer_Matrix0_i32 | _KContiguousSlicer_Matrix0_i32 | _KFlatSlicer_Matrix0_i64 | _KContiguousSlicer_Matrix0_i64 | _KFlatSlicer_Matrix0_f32 | _KContiguousSlicer_Matrix0_f32 | _KFlatSlicer_Matrix0_f64 | _KContiguousSlicer_Matrix0_f64 | _ContiguousSlicer_Matrix0_i32 | _ContiguousSlicer_Matrix0_i64 | _ContiguousSlicer_Matrix0_f32 | _ContiguousSlicer_Matrix0_f64 | _KFlatSlicer_GudhiCohomology0_i32 | _KContiguousSlicer_GudhiCohomology0_i32 | _KFlatSlicer_GudhiCohomology0_i64 | _KContiguousSlicer_GudhiCohomology0_i64 | _KFlatSlicer_GudhiCohomology0_f32 | _KContiguousSlicer_GudhiCohomology0_f32 | _KFlatSlicer_GudhiCohomology0_f64 | _KContiguousSlicer_GudhiCohomology0_f64 | _ContiguousSlicer_GudhiCohomology0_i32 | _ContiguousSlicer_GudhiCohomology0_i64 | _ContiguousSlicer_GudhiCohomology0_f32 | _ContiguousSlicer_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, filtration_container)
- Parameters:
pers_backend (Literal['Matrix', 'GudhiCohomology'])
vineyard (bool)
is_kcritical (bool)
dtype (int32 | int64 | float32 | float64)
col (Literal['INTRUSIVE_SET'])
filtration_container (Literal['Degree_rips_bifiltration', 'Multi_parameter_filtration'])
- 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_Flat_Ki32 | _SimplexTreeMulti_Contiguous_Ki32 | _SimplexTreeMulti_Flat_Ki64 | _SimplexTreeMulti_Contiguous_Ki64 | _SimplexTreeMulti_Flat_Kf32 | _SimplexTreeMulti_Contiguous_Kf32 | _SimplexTreeMulti_Flat_Kf64 | _SimplexTreeMulti_Contiguous_Kf64 | _SimplexTreeMulti_Flat_i32 | _SimplexTreeMulti_Contiguous_i32 | _SimplexTreeMulti_Flat_i64 | _SimplexTreeMulti_Contiguous_i64 | _SimplexTreeMulti_Flat_f32 | _SimplexTreeMulti_Contiguous_f32 | _SimplexTreeMulti_Flat_f64 | _SimplexTreeMulti_Contiguous_f64)
module (PyModule_f64 | PyModule_f32 | PyModule_i32 | PyModule_i64)
degree (int)
nlines (int)
verbose (bool)
- multipers.distances.estimate_matching(b1, b2)
- Parameters:
b1 (PyMultiDiagrams_f64 | PyMultiDiagrams_f32)
b2 (PyMultiDiagrams_f64 | PyMultiDiagrams_f32)
- multipers.distances.sm2diff(sm1, sm2, threshold=None)
- multipers.distances.sm_distance(sm1, sm2, reg=0, reg_m=0, numItermax=10000, p=1, threshold=None)
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 77)
- 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 58)
- multipers.function_rips.get_degree_rips(st, degrees: vector[int])
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 164)
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._inf_value(array)
File: multipers/grids.pyx (starting at line 364)
- multipers.grids._project_on_1d_grid(f, grid, unique: bool, api)
File: multipers/grids.pyx (starting at line 262)
- multipers.grids._push_pts_to_line(pts, basepoint, direction=None, api=None)
File: multipers/grids.pyx (starting at line 466)
- multipers.grids._push_pts_to_lines(pts, basepoints, directions=None, api=None)
File: multipers/grids.pyx (starting at line 495)
- multipers.grids._todo_partition(x, resolution: int, unique: bool, api)
File: multipers/grids.pyx (starting at line 306)
- multipers.grids._todo_partition_(signatures, args, kwargs, defaults, _fused_sigindex={})
File: multipers/grids.pyx (starting at line 313)
- multipers.grids._todo_regular(f, r: int, api)
File: multipers/grids.pyx (starting at line 255)
- multipers.grids._todo_regular_closest(f, r, unique, api)
_todo_regular_closest_keops(f, r: int, unique: bool, api)
File: multipers/grids.pyx (starting at line 277)
- multipers.grids._todo_regular_closest_keops(f, r: int, unique: bool, api)
File: multipers/grids.pyx (starting at line 277)
- multipers.grids._todo_regular_closest_old(signatures, args, kwargs, defaults, _fused_sigindex={})
File: multipers/grids.pyx (starting at line 283)
- multipers.grids._todo_regular_left(f, r: int, unique: bool, api)
File: multipers/grids.pyx (starting at line 290)
- multipers.grids._todo_regular_left_old(signatures, args, kwargs, defaults, _fused_sigindex={})
File: multipers/grids.pyx (starting at line 299)
- multipers.grids.coarsen_points(signatures, args, kwargs, defaults, _fused_sigindex={})
File: multipers/grids.pyx (starting at line 358)
- multipers.grids.compute_bounding_box(stuff, inflate=0.)
File: multipers/grids.pyx (starting at line 328)
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 58)
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, input_inf_value=None, output_inf_value=None)
File: multipers/grids.pyx (starting at line 390)
Input
pts: of the form array[int, ndim=2]
grid of the form Iterable[array[float, ndim=1]]
- multipers.grids.evaluate_mod_in_grid(mod, grid, box=None)
File: multipers/grids.pyx (starting at line 514) Given an MMA module, pushes it into the specified grid.
Useful for e.g., make it differentiable.
mod: PyModule
grid: Iterable of 1d array, for num_parameters
torch-compatible module in the format: (num_degrees) x (num_interval of degree) x ((num_birth, num_parameter), (num_death, num_parameters))
- multipers.grids.push_to_grid(signatures, args, kwargs, defaults, _fused_sigindex={})
File: multipers/grids.pyx (starting at line 341)
Given points and a grid (list of one parameter grids), pushes the points onto the grid.
- multipers.grids.sanitize_grid(grid, numpyfy: bool = False, add_inf: bool = False)
File: multipers/grids.pyx (starting at line 27)
- multipers.grids.sm_in_grid(pts, weights, grid, mass_default=None)
File: multipers/grids.pyx (starting at line 417) 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, mass_default=None)
File: multipers/grids.pyx (starting at line 453) 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.threshold_slice(a, m, M)
File: multipers/grids.pyx (starting at line 48)
- multipers.grids.todense(grid, product_order: bool = False)
File: multipers/grids.pyx (starting at line 232)
multipers.io module
File: multipers/io.pyx (starting at line 1)
- multipers.io._check_available(soft: str)
File: multipers/io.pyx (starting at line 173)
- Parameters:
soft (str)
- multipers.io._init_external_softwares(requires=[])
File: multipers/io.pyx (starting at line 152)
- multipers.io._multi_critical_from_slicer(slicer, reduce: bool = False, algo: Literal['path', 'tree'] = 'path', degree: int | None = None, clear: bool = True, swedish=None, verbose: bool = False, kcritical: bool = False, filtration_container: str = 'contiguous', **slicer_kwargs)
File: multipers/io.pyx (starting at line 306)
- Parameters:
algo (Literal['path', 'tree'])
degree (int | None)
- multipers.io._path_init(soft: str | os.PathLike)
File: multipers/io.pyx (starting at line 90)
- Parameters:
soft (str | PathLike)
- multipers.io._rhomboid_tiling_to_slicer(slicer, point_cloud: np.ndarray, k_max: int, degree: int = -1, clear: bool = True, verbose: bool = False)
File: multipers/io.pyx (starting at line 279) TODO
- Parameters:
point_cloud (ndarray)
clear (bool)
- multipers.io.function_delaunay_presentation_to_slicer(slicer, point_cloud: np.ndarray, function_values: np.ndarray, clear: bool = True, verbose: bool = False, degree: int = -1, multi_chunk: bool = False)
File: multipers/io.pyx (starting at line 238)
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)
clear (bool)
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 364)
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 421)
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 122)
Parse an scc file into the scc python format, aka blocks.
- Parameters:
path (str | PathLike)
- 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, verbose: bool = False, backend: Literal['mpfree', 'multi_chunk', 'twopac'] = 'mpfree', shift_dimension=0)
File: multipers/io.pyx (starting at line 179)
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 verbose: bool backend: “mpfree”, “multi_chunk” or “2pac”
- Parameters:
path (str | PathLike)
dimension (int | int64)
clear (bool)
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 = 557, from_coordinates: bool = False, complete: bool = True, threshold: bool = False, verbose: bool = False, ignore_warnings: bool = False, direction: vector[double] = [], swap_box_coords: vector[int] = [], *, n_jobs: int = -1) PyModule_type
File: multipers/multiparameter_module_approximation.pyx (starting at line 105) 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 = 557
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.
- 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_Flat_Ki32 | _SimplexTreeMulti_Contiguous_Ki32 | _SimplexTreeMulti_Flat_Ki64 | _SimplexTreeMulti_Contiguous_Ki64 | _SimplexTreeMulti_Flat_Kf32 | _SimplexTreeMulti_Contiguous_Kf32 | _SimplexTreeMulti_Flat_Kf64 | _SimplexTreeMulti_Contiguous_Kf64 | _SimplexTreeMulti_Flat_i32 | _SimplexTreeMulti_Contiguous_i32 | _SimplexTreeMulti_Flat_i64 | _SimplexTreeMulti_Contiguous_i64 | _SimplexTreeMulti_Flat_f32 | _SimplexTreeMulti_Contiguous_f32 | _SimplexTreeMulti_Flat_f64 | _SimplexTreeMulti_Contiguous_f64 | _KFlatSlicer_Matrix0_vine_i32 | _KContiguousSlicer_Matrix0_vine_i32 | _KFlatSlicer_Matrix0_vine_i64 | _KContiguousSlicer_Matrix0_vine_i64 | _KFlatSlicer_Matrix0_vine_f32 | _KContiguousSlicer_Matrix0_vine_f32 | _KFlatSlicer_Matrix0_vine_f64 | _KContiguousSlicer_Matrix0_vine_f64 | _ContiguousSlicer_Matrix0_vine_i32 | _ContiguousSlicer_Matrix0_vine_i64 | _ContiguousSlicer_Matrix0_vine_f32 | _ContiguousSlicer_Matrix0_vine_f64 | _KFlatSlicer_Matrix0_i32 | _KContiguousSlicer_Matrix0_i32 | _KFlatSlicer_Matrix0_i64 | _KContiguousSlicer_Matrix0_i64 | _KFlatSlicer_Matrix0_f32 | _KContiguousSlicer_Matrix0_f32 | _KFlatSlicer_Matrix0_f64 | _KContiguousSlicer_Matrix0_f64 | _ContiguousSlicer_Matrix0_i32 | _ContiguousSlicer_Matrix0_i64 | _ContiguousSlicer_Matrix0_f32 | _ContiguousSlicer_Matrix0_f64 | _KFlatSlicer_GudhiCohomology0_i32 | _KContiguousSlicer_GudhiCohomology0_i32 | _KFlatSlicer_GudhiCohomology0_i64 | _KContiguousSlicer_GudhiCohomology0_i64 | _KFlatSlicer_GudhiCohomology0_f32 | _KContiguousSlicer_GudhiCohomology0_f32 | _KFlatSlicer_GudhiCohomology0_f64 | _KContiguousSlicer_GudhiCohomology0_f64 | _ContiguousSlicer_GudhiCohomology0_i32 | _ContiguousSlicer_GudhiCohomology0_i64 | _ContiguousSlicer_GudhiCohomology0_f32 | _ContiguousSlicer_GudhiCohomology0_f64 | tuple)
box (ndarray | None)
- Return type:
PyModule_f64 | PyModule_f32 | PyModule_i32 | PyModule_i64
- 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 = [], warnings: bool = True, unsqueeze_grid=None) PyModule_type
File: multipers/multiparameter_module_approximation.pyx (starting at line 52)
- Parameters:
slicer (_KFlatSlicer_Matrix0_vine_i32 | _KContiguousSlicer_Matrix0_vine_i32 | _KFlatSlicer_Matrix0_vine_i64 | _KContiguousSlicer_Matrix0_vine_i64 | _KFlatSlicer_Matrix0_vine_f32 | _KContiguousSlicer_Matrix0_vine_f32 | _KFlatSlicer_Matrix0_vine_f64 | _KContiguousSlicer_Matrix0_vine_f64 | _ContiguousSlicer_Matrix0_vine_i32 | _ContiguousSlicer_Matrix0_vine_i64 | _ContiguousSlicer_Matrix0_vine_f32 | _ContiguousSlicer_Matrix0_vine_f64 | _KFlatSlicer_Matrix0_i32 | _KContiguousSlicer_Matrix0_i32 | _KFlatSlicer_Matrix0_i64 | _KContiguousSlicer_Matrix0_i64 | _KFlatSlicer_Matrix0_f32 | _KContiguousSlicer_Matrix0_f32 | _KFlatSlicer_Matrix0_f64 | _KContiguousSlicer_Matrix0_f64 | _ContiguousSlicer_Matrix0_i32 | _ContiguousSlicer_Matrix0_i64 | _ContiguousSlicer_Matrix0_f32 | _ContiguousSlicer_Matrix0_f64 | _KFlatSlicer_GudhiCohomology0_i32 | _KContiguousSlicer_GudhiCohomology0_i32 | _KFlatSlicer_GudhiCohomology0_i64 | _KContiguousSlicer_GudhiCohomology0_i64 | _KFlatSlicer_GudhiCohomology0_f32 | _KContiguousSlicer_GudhiCohomology0_f32 | _KFlatSlicer_GudhiCohomology0_f64 | _KContiguousSlicer_GudhiCohomology0_f64 | _ContiguousSlicer_GudhiCohomology0_i32 | _ContiguousSlicer_GudhiCohomology0_i64 | _ContiguousSlicer_GudhiCohomology0_f32 | _ContiguousSlicer_GudhiCohomology0_f64)
box (ndarray | None)
- Return type:
PyModule_f64 | PyModule_f32 | PyModule_i32 | PyModule_i64
multipers.ops module
File: multipers/ops.pyx (starting at line 1)
- multipers.ops._aida(col_degrees, row_degrees, matrix)
File: multipers/ops.pyx (starting at line 16)
- multipers.ops.aida(s, sort: bool = True, verbose: bool = False, progress: bool = False)
File: multipers/ops.pyx (starting at line 28)
Decomposes (a minimal presentation of a) 2-parameter persistence module as a direct sum of indecomposables.
From [Decomposing Multiparameter Persistence Modules](https://doi.org/10.4230/LIPIcs.SoCG.2025.41).
- Parameters:
s : The slicer to reduce. Has to be a minimal presentation.
verbose : shows log.
progress : shows a progress bar
sort : sorts the input first in a colexical order (debug)
- multipers.ops.minimal_presentation(slicer, degree: int = -1, degrees: Iterable[int] = [], backend: Literal['mpfree', '2pac', ''] = 'mpfree', n_jobs: int = -1, force: bool = False, auto_clean: bool = True, verbose: bool = False)
File: multipers/ops.pyx (starting at line 170)
Computes a minimal presentation a (1-critical) multifiltered complex.
From [Fast minimal presentations of bi-graded persistence modules](https://doi.org/10.1137/1.9781611976472.16), whose code is available here: https://bitbucket.org/mkerber/mpfree
Backends differents than mpfree are unstable.
- Parameters:
slicer : the filtration/free implicit representation to reduce
degree : the homological degree to reduce
degrees : a list of homological degrees to reduce. Output will be a list.
backend : a callable scc-compatible backend
n_jobs : process minpres in parallel if degrees is given
force : if input is already reduced, force the re-computation of the minimal presentation.
auto_clean : if input is squeezed, some filtraton values may disappear. This is a postprocessing to remove unnecessary coordinates.
- Parameters:
degrees (Iterable[int])
backend (Literal['mpfree', '2pac', ''])
- multipers.ops.one_criticalify(slicer, reduce: bool = False, degree: int | None = None, clear: bool = True, swedish: bool | None = None, verbose: bool = False, kcritical: bool = False, algo: Literal['path', 'tree'] = 'path', filtration_container: str = 'contiguous')
File: multipers/ops.pyx (starting at line 112)
Computes a free implicit representation of a given multi-critical multifiltration of a given homological degree (i.e., for a given homological degree, a quasi-isomorphic 1-critical filtration), or free resolution of the multifiltration (i.e., quasi-isomorphic 1-critical chain complex).
From [Fast free resolutions of bifiltered chain complexes](https://doi.org/10.48550/arXiv.2512.08652), whose code is available here: https://bitbucket.org/mkerber/multi_critical
- Parameters:
slicer : multicritical filtration to represent
reduce : returns a (or multiple, see degree) minimal presentation(s) instead of the chain complex.
- degreeIf an int is given, and reduce is true, only returns the minimal presentation of this degree.
If None is given and reduce is true, returns a minimal presentation of all possible degrees. If reduce is false : has no effect.
clear : Clears the temporary files.
- swedishif True, reduce=True and degree=None skips the computation of the 1critical chain complex,
and directly (sequentially) computes the individual minimal presentations.
verbose : shows log
kcritical : do not use
algo : see ref.
- Parameters:
degree (Optional[int])
swedish (Optional[bool])
algo (Literal['path', 'tree'])
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=None, verbose=False, save=False, dpi=200, xlabel=None, ylabel=None, cmap=None, outline_width=0.2, outline_threshold=inf, interleavings=None, backend=None)
- multipers.plots.plot_point_cloud(pts, function, x, y, mma=None, degree=None, ball_alpha=0.3, point_cmap='viridis', color_bias=1, ball_color=None, point_size=20)
- multipers.plots.plot_signed_measure(signed_measure, threshold=None, ax=None, **plt_kwargs)
- multipers.plots.plot_signed_measures(signed_measures, threshold=None, size=4, alpha=None)
- multipers.plots.plot_simplicial_complex(st, pts, x, y, mma=None, degree=None)
Scatters the points, with the simplices in the filtration at coordinates (x,y). if an mma module is given, plots it in a second axis
- Parameters:
pts (ArrayLike)
x (float)
y (float)
- multipers.plots.plot_surface(grid, hf, fig=None, ax=None, cmap=None, discrete_surface=False, has_negative_values=False, contour=True, **plt_args)
- Parameters:
cmap (str | None)
discrete_surface (bool)
has_negative_values (bool)
contour (bool)
- 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.add_sms(sms)
File: multipers/point_measure.pyx (starting at line 245)
- 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 258)
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(pts, w, dtype=np.int32)
File: multipers/point_measure.pyx (starting at line 195)
- multipers.point_measure.clean_signed_measure_old(signatures, args, kwargs, defaults, _fused_sigindex={})
File: multipers/point_measure.pyx (starting at line 172)
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 203)
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) np.int64
File: multipers/point_measure.pyx (starting at line 328)
Given a rank signed measure (sm) and two points (a) and (b), estimates the rank between these two points.
- Parameters:
sm (tuple)
- Return type:
int64
- multipers.point_measure.integrate_measure(signatures, args, kwargs, defaults, _fused_sigindex={})
File: multipers/point_measure.pyx (starting at line 83)
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 140)
- multipers.point_measure.rank_decomposition_by_rectangles(rank_invariant: np.ndarray, threshold: bool = False)
File: multipers/point_measure.pyx (starting at line 51)
- Parameters:
rank_invariant (ndarray)
- multipers.point_measure.rectangle_to_hook_minimal_signed_barcode(pts, w)
File: multipers/point_measure.pyx (starting at line 349)
- multipers.point_measure.signed_betti(hilbert_function: np.ndarray, threshold: bool = False)
File: multipers/point_measure.pyx (starting at line 38)
- Parameters:
hilbert_function (ndarray)
- multipers.point_measure.sparsify(x)
File: multipers/point_measure.pyx (starting at line 151)
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 211)
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 240)
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 = -1, dtype: type = np.float64, kcritical: bool = False, ftype='Contiguous', **kwargs) SimplexTreeMulti_type
File: multipers/simplex_tree_multi.pyx (starting at line 22516) 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_Flat_Ki32 | _SimplexTreeMulti_Contiguous_Ki32 | _SimplexTreeMulti_Flat_Ki64 | _SimplexTreeMulti_Contiguous_Ki64 | _SimplexTreeMulti_Flat_Kf32 | _SimplexTreeMulti_Contiguous_Kf32 | _SimplexTreeMulti_Flat_Kf64 | _SimplexTreeMulti_Contiguous_Kf64 | _SimplexTreeMulti_Flat_i32 | _SimplexTreeMulti_Contiguous_i32 | _SimplexTreeMulti_Flat_i64 | _SimplexTreeMulti_Contiguous_i64 | _SimplexTreeMulti_Flat_f32 | _SimplexTreeMulti_Contiguous_f32 | _SimplexTreeMulti_Flat_f64 | _SimplexTreeMulti_Contiguous_f64
- multipers.Slicer(st=None, vineyard=None, reduce=False, reduce_backend=None, dtype=None, kcritical=None, column_type=None, backend=None, filtration_container=None, max_dim=None, return_type_only=False, _shift_dimension=0)
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)
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)
kcritical (bool | None)
column_type (Literal['INTRUSIVE_SET'] | None)
backend (Literal['Matrix', 'GudhiCohomology'] | None)
filtration_container (str | None)
max_dim (int | None)
return_type_only (bool)
_shift_dimension (int)
- Return type:
_KFlatSlicer_Matrix0_vine_i32 | _KContiguousSlicer_Matrix0_vine_i32 | _KFlatSlicer_Matrix0_vine_i64 | _KContiguousSlicer_Matrix0_vine_i64 | _KFlatSlicer_Matrix0_vine_f32 | _KContiguousSlicer_Matrix0_vine_f32 | _KFlatSlicer_Matrix0_vine_f64 | _KContiguousSlicer_Matrix0_vine_f64 | _ContiguousSlicer_Matrix0_vine_i32 | _ContiguousSlicer_Matrix0_vine_i64 | _ContiguousSlicer_Matrix0_vine_f32 | _ContiguousSlicer_Matrix0_vine_f64 | _KFlatSlicer_Matrix0_i32 | _KContiguousSlicer_Matrix0_i32 | _KFlatSlicer_Matrix0_i64 | _KContiguousSlicer_Matrix0_i64 | _KFlatSlicer_Matrix0_f32 | _KContiguousSlicer_Matrix0_f32 | _KFlatSlicer_Matrix0_f64 | _KContiguousSlicer_Matrix0_f64 | _ContiguousSlicer_Matrix0_i32 | _ContiguousSlicer_Matrix0_i64 | _ContiguousSlicer_Matrix0_f32 | _ContiguousSlicer_Matrix0_f64 | _KFlatSlicer_GudhiCohomology0_i32 | _KContiguousSlicer_GudhiCohomology0_i32 | _KFlatSlicer_GudhiCohomology0_i64 | _KContiguousSlicer_GudhiCohomology0_i64 | _KFlatSlicer_GudhiCohomology0_f32 | _KContiguousSlicer_GudhiCohomology0_f32 | _KFlatSlicer_GudhiCohomology0_f64 | _KContiguousSlicer_GudhiCohomology0_f64 | _ContiguousSlicer_GudhiCohomology0_i32 | _ContiguousSlicer_GudhiCohomology0_i64 | _ContiguousSlicer_GudhiCohomology0_f32 | _ContiguousSlicer_GudhiCohomology0_f64
- multipers.module_approximation(input: SimplexTreeMulti_type | Slicer_type | tuple, box: np.ndarray | None = None, max_error: float = -1, nlines: int = 557, from_coordinates: bool = False, complete: bool = True, threshold: bool = False, verbose: bool = False, ignore_warnings: bool = False, direction: vector[double] = [], swap_box_coords: vector[int] = [], *, n_jobs: int = -1) PyModule_type
File: multipers/multiparameter_module_approximation.pyx (starting at line 105) 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 = 557
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.
- 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_Flat_Ki32 | _SimplexTreeMulti_Contiguous_Ki32 | _SimplexTreeMulti_Flat_Ki64 | _SimplexTreeMulti_Contiguous_Ki64 | _SimplexTreeMulti_Flat_Kf32 | _SimplexTreeMulti_Contiguous_Kf32 | _SimplexTreeMulti_Flat_Kf64 | _SimplexTreeMulti_Contiguous_Kf64 | _SimplexTreeMulti_Flat_i32 | _SimplexTreeMulti_Contiguous_i32 | _SimplexTreeMulti_Flat_i64 | _SimplexTreeMulti_Contiguous_i64 | _SimplexTreeMulti_Flat_f32 | _SimplexTreeMulti_Contiguous_f32 | _SimplexTreeMulti_Flat_f64 | _SimplexTreeMulti_Contiguous_f64 | _KFlatSlicer_Matrix0_vine_i32 | _KContiguousSlicer_Matrix0_vine_i32 | _KFlatSlicer_Matrix0_vine_i64 | _KContiguousSlicer_Matrix0_vine_i64 | _KFlatSlicer_Matrix0_vine_f32 | _KContiguousSlicer_Matrix0_vine_f32 | _KFlatSlicer_Matrix0_vine_f64 | _KContiguousSlicer_Matrix0_vine_f64 | _ContiguousSlicer_Matrix0_vine_i32 | _ContiguousSlicer_Matrix0_vine_i64 | _ContiguousSlicer_Matrix0_vine_f32 | _ContiguousSlicer_Matrix0_vine_f64 | _KFlatSlicer_Matrix0_i32 | _KContiguousSlicer_Matrix0_i32 | _KFlatSlicer_Matrix0_i64 | _KContiguousSlicer_Matrix0_i64 | _KFlatSlicer_Matrix0_f32 | _KContiguousSlicer_Matrix0_f32 | _KFlatSlicer_Matrix0_f64 | _KContiguousSlicer_Matrix0_f64 | _ContiguousSlicer_Matrix0_i32 | _ContiguousSlicer_Matrix0_i64 | _ContiguousSlicer_Matrix0_f32 | _ContiguousSlicer_Matrix0_f64 | _KFlatSlicer_GudhiCohomology0_i32 | _KContiguousSlicer_GudhiCohomology0_i32 | _KFlatSlicer_GudhiCohomology0_i64 | _KContiguousSlicer_GudhiCohomology0_i64 | _KFlatSlicer_GudhiCohomology0_f32 | _KContiguousSlicer_GudhiCohomology0_f32 | _KFlatSlicer_GudhiCohomology0_f64 | _KContiguousSlicer_GudhiCohomology0_f64 | _ContiguousSlicer_GudhiCohomology0_i32 | _ContiguousSlicer_GudhiCohomology0_i64 | _ContiguousSlicer_GudhiCohomology0_f32 | _ContiguousSlicer_GudhiCohomology0_f64 | tuple)
box (ndarray | None)
- Return type:
PyModule_f64 | PyModule_f32 | PyModule_i32 | PyModule_i64
- 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, grid=None, coordinate_measure=False, num_collapses=0, clean=None, vineyard=False, grid_conversion=None, ignore_infinite_filtration_values=True, **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
backendinmultipers.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
strategyinmultipers.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.
ignore_infinite_filtration_values: Backend optimization.
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_Flat_Ki32 | _SimplexTreeMulti_Contiguous_Ki32 | _SimplexTreeMulti_Flat_Ki64 | _SimplexTreeMulti_Contiguous_Ki64 | _SimplexTreeMulti_Flat_Kf32 | _SimplexTreeMulti_Contiguous_Kf32 | _SimplexTreeMulti_Flat_Kf64 | _SimplexTreeMulti_Contiguous_Kf64 | _SimplexTreeMulti_Flat_i32 | _SimplexTreeMulti_Contiguous_i32 | _SimplexTreeMulti_Flat_i64 | _SimplexTreeMulti_Contiguous_i64 | _SimplexTreeMulti_Flat_f32 | _SimplexTreeMulti_Contiguous_f32 | _SimplexTreeMulti_Flat_f64 | _SimplexTreeMulti_Contiguous_f64 | _KFlatSlicer_Matrix0_vine_i32 | _KContiguousSlicer_Matrix0_vine_i32 | _KFlatSlicer_Matrix0_vine_i64 | _KContiguousSlicer_Matrix0_vine_i64 | _KFlatSlicer_Matrix0_vine_f32 | _KContiguousSlicer_Matrix0_vine_f32 | _KFlatSlicer_Matrix0_vine_f64 | _KContiguousSlicer_Matrix0_vine_f64 | _ContiguousSlicer_Matrix0_vine_i32 | _ContiguousSlicer_Matrix0_vine_i64 | _ContiguousSlicer_Matrix0_vine_f32 | _ContiguousSlicer_Matrix0_vine_f64 | _KFlatSlicer_Matrix0_i32 | _KContiguousSlicer_Matrix0_i32 | _KFlatSlicer_Matrix0_i64 | _KContiguousSlicer_Matrix0_i64 | _KFlatSlicer_Matrix0_f32 | _KContiguousSlicer_Matrix0_f32 | _KFlatSlicer_Matrix0_f64 | _KContiguousSlicer_Matrix0_f64 | _ContiguousSlicer_Matrix0_i32 | _ContiguousSlicer_Matrix0_i64 | _ContiguousSlicer_Matrix0_f32 | _ContiguousSlicer_Matrix0_f64 | _KFlatSlicer_GudhiCohomology0_i32 | _KContiguousSlicer_GudhiCohomology0_i32 | _KFlatSlicer_GudhiCohomology0_i64 | _KContiguousSlicer_GudhiCohomology0_i64 | _KFlatSlicer_GudhiCohomology0_f32 | _KContiguousSlicer_GudhiCohomology0_f32 | _KFlatSlicer_GudhiCohomology0_f64 | _KContiguousSlicer_GudhiCohomology0_f64 | _ContiguousSlicer_GudhiCohomology0_i32 | _ContiguousSlicer_GudhiCohomology0_i64 | _ContiguousSlicer_GudhiCohomology0_f32 | _ContiguousSlicer_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)
grid (Iterable | None)
coordinate_measure (bool)
num_collapses (int)
clean (bool | None)
vineyard (bool)
grid_conversion (Iterable | None)
ignore_infinite_filtration_values (bool)
- Return type:
list[tuple[ndarray, ndarray]]