multipers 1.0__cp311-cp311-manylinux_2_34_x86_64.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.

Files changed (56) hide show
  1. multipers/__init__.py +4 -0
  2. multipers/_old_rank_invariant.pyx +328 -0
  3. multipers/_signed_measure_meta.py +72 -0
  4. multipers/data/MOL2.py +350 -0
  5. multipers/data/UCR.py +18 -0
  6. multipers/data/__init__.py +1 -0
  7. multipers/data/graphs.py +272 -0
  8. multipers/data/immuno_regions.py +27 -0
  9. multipers/data/minimal_presentation_to_st_bf.py +0 -0
  10. multipers/data/pytorch2simplextree.py +91 -0
  11. multipers/data/shape3d.py +101 -0
  12. multipers/data/synthetic.py +68 -0
  13. multipers/distances.py +100 -0
  14. multipers/euler_characteristic.cpython-311-x86_64-linux-gnu.so +0 -0
  15. multipers/euler_characteristic.pyx +132 -0
  16. multipers/function_rips.cpython-311-x86_64-linux-gnu.so +0 -0
  17. multipers/function_rips.pyx +101 -0
  18. multipers/hilbert_function.cpython-311-x86_64-linux-gnu.so +0 -0
  19. multipers/hilbert_function.pyi +46 -0
  20. multipers/hilbert_function.pyx +145 -0
  21. multipers/ml/__init__.py +0 -0
  22. multipers/ml/accuracies.py +61 -0
  23. multipers/ml/convolutions.py +384 -0
  24. multipers/ml/invariants_with_persistable.py +79 -0
  25. multipers/ml/kernels.py +128 -0
  26. multipers/ml/mma.py +422 -0
  27. multipers/ml/one.py +472 -0
  28. multipers/ml/point_clouds.py +191 -0
  29. multipers/ml/signed_betti.py +50 -0
  30. multipers/ml/signed_measures.py +1046 -0
  31. multipers/ml/sliced_wasserstein.py +313 -0
  32. multipers/ml/tools.py +99 -0
  33. multipers/multiparameter_edge_collapse.py +29 -0
  34. multipers/multiparameter_module_approximation.cpython-311-x86_64-linux-gnu.so +0 -0
  35. multipers/multiparameter_module_approximation.pxd +147 -0
  36. multipers/multiparameter_module_approximation.pyi +439 -0
  37. multipers/multiparameter_module_approximation.pyx +931 -0
  38. multipers/pickle.py +53 -0
  39. multipers/plots.py +207 -0
  40. multipers/point_measure_integration.cpython-311-x86_64-linux-gnu.so +0 -0
  41. multipers/point_measure_integration.pyx +59 -0
  42. multipers/rank_invariant.cpython-311-x86_64-linux-gnu.so +0 -0
  43. multipers/rank_invariant.pyx +154 -0
  44. multipers/simplex_tree_multi.cpython-311-x86_64-linux-gnu.so +0 -0
  45. multipers/simplex_tree_multi.pxd +121 -0
  46. multipers/simplex_tree_multi.pyi +715 -0
  47. multipers/simplex_tree_multi.pyx +1284 -0
  48. multipers/tensor.pxd +13 -0
  49. multipers/test.pyx +44 -0
  50. multipers-1.0.dist-info/LICENSE +21 -0
  51. multipers-1.0.dist-info/METADATA +9 -0
  52. multipers-1.0.dist-info/RECORD +56 -0
  53. multipers-1.0.dist-info/WHEEL +5 -0
  54. multipers-1.0.dist-info/top_level.txt +1 -0
  55. multipers.libs/libtbb-5d1cde94.so.12.10 +0 -0
  56. multipers.libs/libtbbmalloc-5e0a3d4c.so.2.10 +0 -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)