multipers 1.1.3__cp311-cp311-macosx_11_0_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of multipers might be problematic. Click here for more details.
- multipers/.dylibs/libtbb.12.12.dylib +0 -0
- multipers/.dylibs/libtbbmalloc.2.12.dylib +0 -0
- multipers/__init__.py +5 -0
- multipers/_old_rank_invariant.pyx +328 -0
- multipers/_signed_measure_meta.py +193 -0
- multipers/data/MOL2.py +350 -0
- multipers/data/UCR.py +18 -0
- multipers/data/__init__.py +1 -0
- multipers/data/graphs.py +466 -0
- multipers/data/immuno_regions.py +27 -0
- multipers/data/minimal_presentation_to_st_bf.py +0 -0
- multipers/data/pytorch2simplextree.py +91 -0
- multipers/data/shape3d.py +101 -0
- multipers/data/synthetic.py +68 -0
- multipers/distances.py +172 -0
- multipers/euler_characteristic.cpython-311-darwin.so +0 -0
- multipers/euler_characteristic.pyx +137 -0
- multipers/function_rips.cpython-311-darwin.so +0 -0
- multipers/function_rips.pyx +102 -0
- multipers/hilbert_function.cpython-311-darwin.so +0 -0
- multipers/hilbert_function.pyi +46 -0
- multipers/hilbert_function.pyx +151 -0
- multipers/io.cpython-311-darwin.so +0 -0
- multipers/io.pyx +176 -0
- multipers/ml/__init__.py +0 -0
- multipers/ml/accuracies.py +61 -0
- multipers/ml/convolutions.py +510 -0
- multipers/ml/invariants_with_persistable.py +79 -0
- multipers/ml/kernels.py +128 -0
- multipers/ml/mma.py +657 -0
- multipers/ml/one.py +472 -0
- multipers/ml/point_clouds.py +191 -0
- multipers/ml/signed_betti.py +50 -0
- multipers/ml/signed_measures.py +1479 -0
- multipers/ml/sliced_wasserstein.py +313 -0
- multipers/ml/tools.py +116 -0
- multipers/mma_structures.cpython-311-darwin.so +0 -0
- multipers/mma_structures.pxd +155 -0
- multipers/mma_structures.pyx +651 -0
- multipers/multiparameter_edge_collapse.py +29 -0
- multipers/multiparameter_module_approximation.cpython-311-darwin.so +0 -0
- multipers/multiparameter_module_approximation.pyi +439 -0
- multipers/multiparameter_module_approximation.pyx +311 -0
- multipers/pickle.py +53 -0
- multipers/plots.py +292 -0
- multipers/point_measure_integration.cpython-311-darwin.so +0 -0
- multipers/point_measure_integration.pyx +59 -0
- multipers/rank_invariant.cpython-311-darwin.so +0 -0
- multipers/rank_invariant.pyx +154 -0
- multipers/simplex_tree_multi.cpython-311-darwin.so +0 -0
- multipers/simplex_tree_multi.pxd +121 -0
- multipers/simplex_tree_multi.pyi +715 -0
- multipers/simplex_tree_multi.pyx +1417 -0
- multipers/slicer.cpython-311-darwin.so +0 -0
- multipers/slicer.pxd +94 -0
- multipers/slicer.pyx +276 -0
- multipers/tensor.pxd +13 -0
- multipers/test.pyx +44 -0
- multipers-1.1.3.dist-info/LICENSE +21 -0
- multipers-1.1.3.dist-info/METADATA +22 -0
- multipers-1.1.3.dist-info/RECORD +63 -0
- multipers-1.1.3.dist-info/WHEEL +5 -0
- multipers-1.1.3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
## This code was written by Luis Scoccola
|
|
2
|
+
import numpy as np
|
|
3
|
+
from scipy.sparse import coo_array
|
|
4
|
+
from scipy.ndimage import convolve1d
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def signed_betti(hilbert_function, threshold=False, sparse=False):
|
|
8
|
+
n = len(hilbert_function.shape)
|
|
9
|
+
res = np.copy(hilbert_function)
|
|
10
|
+
# zero out the "end" of the Hilbert function
|
|
11
|
+
if threshold:
|
|
12
|
+
for dimension in range(n):
|
|
13
|
+
slicer = tuple([slice(None) if i != dimension else -1 for i in range(n)])
|
|
14
|
+
res[slicer] = 0
|
|
15
|
+
weights = np.array([0, 1, -1], dtype=int)
|
|
16
|
+
for i in range(n):
|
|
17
|
+
res = convolve1d(res, weights, axis=i, mode="constant", cval=0)
|
|
18
|
+
if sparse:
|
|
19
|
+
return coo_array(res)
|
|
20
|
+
else:
|
|
21
|
+
return res
|
|
22
|
+
|
|
23
|
+
def rank_decomposition_by_rectangles(rank_invariant, threshold=False):
|
|
24
|
+
# takes as input the rank invariant of an n-parameter persistence module
|
|
25
|
+
# M : [0, ..., s_1 - 1] x ... x [0, ..., s_n - 1] ---> Vec
|
|
26
|
+
# on a grid with dimensions of sizes s_1, ..., s_n. The input is assumed to be
|
|
27
|
+
# given as a tensor of dimensions (s_1, ..., s_n, s_1, ..., s_n), so that,
|
|
28
|
+
# at index [i_1, ..., i_n, j_1, ..., j_n] we have the rank of the structure
|
|
29
|
+
# map M(i) -> M(j), where i = (i_1, ..., i_n) and j = (j_1, ..., j_n), and
|
|
30
|
+
# i <= j, meaning that i_1 <= j_1, ..., i_n <= j_n.
|
|
31
|
+
# NOTE :
|
|
32
|
+
# - About the input, we assume that, if not( i <= j ), then at index
|
|
33
|
+
# [i_1, ..., i_n, j_1, ..., j_n] we have a zero.
|
|
34
|
+
# - Similarly, the output at index [i_1, ..., i_n, j_1, ..., j_n] only
|
|
35
|
+
# makes sense when i <= j. For indices where not( i <= j ) the output
|
|
36
|
+
# may take arbitrary values and they should be ignored.
|
|
37
|
+
n = len(rank_invariant.shape) // 2
|
|
38
|
+
if threshold:
|
|
39
|
+
rank_invariant = rank_invariant.copy()
|
|
40
|
+
# print(rank_invariant)
|
|
41
|
+
# zero out the "end"
|
|
42
|
+
for dimension in range(n):
|
|
43
|
+
slicer = tuple(
|
|
44
|
+
[slice(None) for _ in range(n)]
|
|
45
|
+
+ [slice(None) if i != dimension else -1 for i in range(n)]
|
|
46
|
+
)
|
|
47
|
+
rank_invariant[slicer] = 0
|
|
48
|
+
# print(rank_invariant)
|
|
49
|
+
to_flip = tuple(range(n, 2 * n))
|
|
50
|
+
return np.flip(signed_betti(np.flip(rank_invariant, to_flip)), to_flip)
|