multipers 2.3.2b1__cp310-cp310-win_amd64.whl → 2.3.3__cp310-cp310-win_amd64.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 (38) hide show
  1. multipers/_signed_measure_meta.py +22 -8
  2. multipers/array_api/__init__.py +25 -2
  3. multipers/array_api/numpy.py +70 -0
  4. multipers/array_api/torch.py +82 -0
  5. multipers/filtrations/density.py +11 -52
  6. multipers/filtrations/filtrations.py +21 -8
  7. multipers/function_rips.cp310-win_amd64.pyd +0 -0
  8. multipers/grids.cp310-win_amd64.pyd +0 -0
  9. multipers/grids.pyx +91 -43
  10. multipers/gudhi/gudhi/Multi_critical_filtration.h +1 -1
  11. multipers/io.cp310-win_amd64.pyd +0 -0
  12. multipers/ml/mma.py +1 -1
  13. multipers/ml/signed_measures.py +106 -26
  14. multipers/mma_structures.cp310-win_amd64.pyd +0 -0
  15. multipers/mma_structures.pyx +2 -2
  16. multipers/mma_structures.pyx.tp +1 -1
  17. multipers/multiparameter_module_approximation.cp310-win_amd64.pyd +0 -0
  18. multipers/multiparameter_module_approximation.pyx +2 -1
  19. multipers/plots.py +164 -37
  20. multipers/point_measure.cp310-win_amd64.pyd +0 -0
  21. multipers/point_measure.pyx +71 -2
  22. multipers/simplex_tree_multi.cp310-win_amd64.pyd +0 -0
  23. multipers/simplex_tree_multi.pxd +2 -2
  24. multipers/simplex_tree_multi.pyx +236 -36
  25. multipers/simplex_tree_multi.pyx.tp +18 -7
  26. multipers/slicer.cp310-win_amd64.pyd +0 -0
  27. multipers/slicer.pxd +20 -20
  28. multipers/slicer.pyx +57 -53
  29. multipers/slicer.pyx.tp +8 -4
  30. multipers/tbb12.dll +0 -0
  31. multipers/tbbbind_2_5.dll +0 -0
  32. multipers/tbbmalloc.dll +0 -0
  33. multipers/tbbmalloc_proxy.dll +0 -0
  34. {multipers-2.3.2b1.dist-info → multipers-2.3.3.dist-info}/METADATA +6 -1
  35. {multipers-2.3.2b1.dist-info → multipers-2.3.3.dist-info}/RECORD +38 -38
  36. {multipers-2.3.2b1.dist-info → multipers-2.3.3.dist-info}/WHEEL +1 -1
  37. {multipers-2.3.2b1.dist-info → multipers-2.3.3.dist-info}/licenses/LICENSE +0 -0
  38. {multipers-2.3.2b1.dist-info → multipers-2.3.3.dist-info}/top_level.txt +0 -0
@@ -625,6 +625,41 @@ cdef class SimplexTreeMulti_KFi32:
625
625
  """
626
626
  return self.get_ptr().prune_above_dimension(dimension)
627
627
 
628
+ def expansion(self, int max_dim)->SimplexTreeMulti_KFi32:
629
+ """Expands the simplex tree containing only its one skeleton
630
+ until dimension max_dim.
631
+
632
+ The expanded simplicial complex until dimension :math:`d`
633
+ attached to a graph :math:`G` is the maximal simplicial complex of
634
+ dimension at most :math:`d` admitting the graph :math:`G` as
635
+ :math:`1`-skeleton.
636
+ The filtration value assigned to a simplex is the maximal filtration
637
+ value of one of its edges.
638
+
639
+ The simplex tree must contain no simplex of dimension bigger than
640
+ 1 when calling the method.
641
+
642
+ :param max_dim: The maximal dimension.
643
+ :type max_dim: int
644
+ """
645
+ with nogil:
646
+ self.get_ptr().expansion(max_dim)
647
+ # This is a fix for multipersistence. FIXME expansion in c++
648
+ self.get_ptr().make_filtration_non_decreasing()
649
+ return self
650
+
651
+ def make_filtration_non_decreasing(self)->bool:
652
+ """This function ensures that each simplex has a higher filtration
653
+ value than its faces by increasing the filtration values.
654
+
655
+ :returns: True if any filtration value was modified,
656
+ False if the filtration was already non-decreasing.
657
+ :rtype: bool
658
+ """
659
+ cdef bool out
660
+ with nogil:
661
+ out = self.get_ptr().make_filtration_non_decreasing()
662
+ return out
628
663
 
629
664
  def reset_filtration(self, filtration, min_dim = 0)->SimplexTreeMulti_KFi32:
630
665
  """This function resets the filtration value of all the simplices of dimension at least min_dim. Resets all the
@@ -881,10 +916,12 @@ cdef class SimplexTreeMulti_KFi32:
881
916
  self,
882
917
  filtration_grid:np.ndarray|list|None=None,
883
918
  bool coordinate_values=True,
884
- force=False,
885
- strategy:_available_strategies = "exact",
919
+ bool force=False,
920
+ str strategy:_available_strategies = "exact",
921
+ resolution:Optional[int|list[int]] = None,
922
+ bool coordinates = False,
886
923
  grid_strategy=None,
887
- inplace=False,
924
+ bool inplace=False,
888
925
  **filtration_grid_kwargs
889
926
  )->SimplexTreeMulti_KFi32 | SimplexTreeMulti_KFi32:
890
927
  """
@@ -910,7 +947,7 @@ cdef class SimplexTreeMulti_KFi32:
910
947
 
911
948
  #TODO : multi-critical
912
949
  if filtration_grid is None:
913
- filtration_grid = self.get_filtration_grid(grid_strategy=strategy, **filtration_grid_kwargs)
950
+ filtration_grid = self.get_filtration_grid(grid_strategy=strategy, resolution=resolution, **filtration_grid_kwargs)
914
951
  else:
915
952
  filtration_grid = sanitize_grid(filtration_grid)
916
953
  if len(filtration_grid) != self.num_parameters:
@@ -1982,7 +2019,16 @@ cdef class SimplexTreeMulti_Fi32:
1982
2019
  out = self.get_ptr().get_edge_list()
1983
2020
  return out
1984
2021
 
1985
- def collapse_edges(self, int num=1, int max_dimension = 0, bool progress=False, bool strong=True, bool full=False, bool ignore_warning=False)->SimplexTreeMulti_Fi32:
2022
+ def collapse_edges(
2023
+ self,
2024
+ int num=1,
2025
+ int max_dimension = 0,
2026
+ bool progress=False,
2027
+ bool strong=True,
2028
+ bool full=False,
2029
+ bool ignore_warning=False,
2030
+ bool auto_clean=True,
2031
+ )->SimplexTreeMulti_Fi32:
1986
2032
  """Edge collapse for 1-critical 2-parameter clique complex (see https://arxiv.org/abs/2211.05574).
1987
2033
  It uses the code from the github repository https://github.com/aj-alonso/filtration_domination .
1988
2034
 
@@ -2032,6 +2078,8 @@ cdef class SimplexTreeMulti_Fi32:
2032
2078
  edges = _collapse_edge_list(edges, num=num, full=full, strong=strong, progress=progress)
2033
2079
  # Retrieves the collapsed simplicial complex
2034
2080
  self._reconstruct_from_edge_list(edges, swap=True, expand_dimension=max_dimension)
2081
+ if self.is_squeezed and auto_clean:
2082
+ self._clean_filtration_grid()
2035
2083
  return self
2036
2084
 
2037
2085
  @cython.inline
@@ -2309,10 +2357,12 @@ cdef class SimplexTreeMulti_Fi32:
2309
2357
  self,
2310
2358
  filtration_grid:np.ndarray|list|None=None,
2311
2359
  bool coordinate_values=True,
2312
- force=False,
2313
- strategy:_available_strategies = "exact",
2360
+ bool force=False,
2361
+ str strategy:_available_strategies = "exact",
2362
+ resolution:Optional[int|list[int]] = None,
2363
+ bool coordinates = False,
2314
2364
  grid_strategy=None,
2315
- inplace=False,
2365
+ bool inplace=False,
2316
2366
  **filtration_grid_kwargs
2317
2367
  )->SimplexTreeMulti_Fi32 | SimplexTreeMulti_Fi32:
2318
2368
  """
@@ -2338,7 +2388,7 @@ cdef class SimplexTreeMulti_Fi32:
2338
2388
 
2339
2389
  #TODO : multi-critical
2340
2390
  if filtration_grid is None:
2341
- filtration_grid = self.get_filtration_grid(grid_strategy=strategy, **filtration_grid_kwargs)
2391
+ filtration_grid = self.get_filtration_grid(grid_strategy=strategy, resolution=resolution, **filtration_grid_kwargs)
2342
2392
  else:
2343
2393
  filtration_grid = sanitize_grid(filtration_grid)
2344
2394
  if len(filtration_grid) != self.num_parameters:
@@ -3202,6 +3252,41 @@ cdef class SimplexTreeMulti_KFi64:
3202
3252
  """
3203
3253
  return self.get_ptr().prune_above_dimension(dimension)
3204
3254
 
3255
+ def expansion(self, int max_dim)->SimplexTreeMulti_KFi64:
3256
+ """Expands the simplex tree containing only its one skeleton
3257
+ until dimension max_dim.
3258
+
3259
+ The expanded simplicial complex until dimension :math:`d`
3260
+ attached to a graph :math:`G` is the maximal simplicial complex of
3261
+ dimension at most :math:`d` admitting the graph :math:`G` as
3262
+ :math:`1`-skeleton.
3263
+ The filtration value assigned to a simplex is the maximal filtration
3264
+ value of one of its edges.
3265
+
3266
+ The simplex tree must contain no simplex of dimension bigger than
3267
+ 1 when calling the method.
3268
+
3269
+ :param max_dim: The maximal dimension.
3270
+ :type max_dim: int
3271
+ """
3272
+ with nogil:
3273
+ self.get_ptr().expansion(max_dim)
3274
+ # This is a fix for multipersistence. FIXME expansion in c++
3275
+ self.get_ptr().make_filtration_non_decreasing()
3276
+ return self
3277
+
3278
+ def make_filtration_non_decreasing(self)->bool:
3279
+ """This function ensures that each simplex has a higher filtration
3280
+ value than its faces by increasing the filtration values.
3281
+
3282
+ :returns: True if any filtration value was modified,
3283
+ False if the filtration was already non-decreasing.
3284
+ :rtype: bool
3285
+ """
3286
+ cdef bool out
3287
+ with nogil:
3288
+ out = self.get_ptr().make_filtration_non_decreasing()
3289
+ return out
3205
3290
 
3206
3291
  def reset_filtration(self, filtration, min_dim = 0)->SimplexTreeMulti_KFi64:
3207
3292
  """This function resets the filtration value of all the simplices of dimension at least min_dim. Resets all the
@@ -3458,10 +3543,12 @@ cdef class SimplexTreeMulti_KFi64:
3458
3543
  self,
3459
3544
  filtration_grid:np.ndarray|list|None=None,
3460
3545
  bool coordinate_values=True,
3461
- force=False,
3462
- strategy:_available_strategies = "exact",
3546
+ bool force=False,
3547
+ str strategy:_available_strategies = "exact",
3548
+ resolution:Optional[int|list[int]] = None,
3549
+ bool coordinates = False,
3463
3550
  grid_strategy=None,
3464
- inplace=False,
3551
+ bool inplace=False,
3465
3552
  **filtration_grid_kwargs
3466
3553
  )->SimplexTreeMulti_KFi32 | SimplexTreeMulti_KFi64:
3467
3554
  """
@@ -3487,7 +3574,7 @@ cdef class SimplexTreeMulti_KFi64:
3487
3574
 
3488
3575
  #TODO : multi-critical
3489
3576
  if filtration_grid is None:
3490
- filtration_grid = self.get_filtration_grid(grid_strategy=strategy, **filtration_grid_kwargs)
3577
+ filtration_grid = self.get_filtration_grid(grid_strategy=strategy, resolution=resolution, **filtration_grid_kwargs)
3491
3578
  else:
3492
3579
  filtration_grid = sanitize_grid(filtration_grid)
3493
3580
  if len(filtration_grid) != self.num_parameters:
@@ -4559,7 +4646,16 @@ cdef class SimplexTreeMulti_Fi64:
4559
4646
  out = self.get_ptr().get_edge_list()
4560
4647
  return out
4561
4648
 
4562
- def collapse_edges(self, int num=1, int max_dimension = 0, bool progress=False, bool strong=True, bool full=False, bool ignore_warning=False)->SimplexTreeMulti_Fi64:
4649
+ def collapse_edges(
4650
+ self,
4651
+ int num=1,
4652
+ int max_dimension = 0,
4653
+ bool progress=False,
4654
+ bool strong=True,
4655
+ bool full=False,
4656
+ bool ignore_warning=False,
4657
+ bool auto_clean=True,
4658
+ )->SimplexTreeMulti_Fi64:
4563
4659
  """Edge collapse for 1-critical 2-parameter clique complex (see https://arxiv.org/abs/2211.05574).
4564
4660
  It uses the code from the github repository https://github.com/aj-alonso/filtration_domination .
4565
4661
 
@@ -4609,6 +4705,8 @@ cdef class SimplexTreeMulti_Fi64:
4609
4705
  edges = _collapse_edge_list(edges, num=num, full=full, strong=strong, progress=progress)
4610
4706
  # Retrieves the collapsed simplicial complex
4611
4707
  self._reconstruct_from_edge_list(edges, swap=True, expand_dimension=max_dimension)
4708
+ if self.is_squeezed and auto_clean:
4709
+ self._clean_filtration_grid()
4612
4710
  return self
4613
4711
 
4614
4712
  @cython.inline
@@ -4886,10 +4984,12 @@ cdef class SimplexTreeMulti_Fi64:
4886
4984
  self,
4887
4985
  filtration_grid:np.ndarray|list|None=None,
4888
4986
  bool coordinate_values=True,
4889
- force=False,
4890
- strategy:_available_strategies = "exact",
4987
+ bool force=False,
4988
+ str strategy:_available_strategies = "exact",
4989
+ resolution:Optional[int|list[int]] = None,
4990
+ bool coordinates = False,
4891
4991
  grid_strategy=None,
4892
- inplace=False,
4992
+ bool inplace=False,
4893
4993
  **filtration_grid_kwargs
4894
4994
  )->SimplexTreeMulti_Fi32 | SimplexTreeMulti_Fi64:
4895
4995
  """
@@ -4915,7 +5015,7 @@ cdef class SimplexTreeMulti_Fi64:
4915
5015
 
4916
5016
  #TODO : multi-critical
4917
5017
  if filtration_grid is None:
4918
- filtration_grid = self.get_filtration_grid(grid_strategy=strategy, **filtration_grid_kwargs)
5018
+ filtration_grid = self.get_filtration_grid(grid_strategy=strategy, resolution=resolution, **filtration_grid_kwargs)
4919
5019
  else:
4920
5020
  filtration_grid = sanitize_grid(filtration_grid)
4921
5021
  if len(filtration_grid) != self.num_parameters:
@@ -5779,6 +5879,41 @@ cdef class SimplexTreeMulti_KFf32:
5779
5879
  """
5780
5880
  return self.get_ptr().prune_above_dimension(dimension)
5781
5881
 
5882
+ def expansion(self, int max_dim)->SimplexTreeMulti_KFf32:
5883
+ """Expands the simplex tree containing only its one skeleton
5884
+ until dimension max_dim.
5885
+
5886
+ The expanded simplicial complex until dimension :math:`d`
5887
+ attached to a graph :math:`G` is the maximal simplicial complex of
5888
+ dimension at most :math:`d` admitting the graph :math:`G` as
5889
+ :math:`1`-skeleton.
5890
+ The filtration value assigned to a simplex is the maximal filtration
5891
+ value of one of its edges.
5892
+
5893
+ The simplex tree must contain no simplex of dimension bigger than
5894
+ 1 when calling the method.
5895
+
5896
+ :param max_dim: The maximal dimension.
5897
+ :type max_dim: int
5898
+ """
5899
+ with nogil:
5900
+ self.get_ptr().expansion(max_dim)
5901
+ # This is a fix for multipersistence. FIXME expansion in c++
5902
+ self.get_ptr().make_filtration_non_decreasing()
5903
+ return self
5904
+
5905
+ def make_filtration_non_decreasing(self)->bool:
5906
+ """This function ensures that each simplex has a higher filtration
5907
+ value than its faces by increasing the filtration values.
5908
+
5909
+ :returns: True if any filtration value was modified,
5910
+ False if the filtration was already non-decreasing.
5911
+ :rtype: bool
5912
+ """
5913
+ cdef bool out
5914
+ with nogil:
5915
+ out = self.get_ptr().make_filtration_non_decreasing()
5916
+ return out
5782
5917
 
5783
5918
  def reset_filtration(self, filtration, min_dim = 0)->SimplexTreeMulti_KFf32:
5784
5919
  """This function resets the filtration value of all the simplices of dimension at least min_dim. Resets all the
@@ -6035,10 +6170,12 @@ cdef class SimplexTreeMulti_KFf32:
6035
6170
  self,
6036
6171
  filtration_grid:np.ndarray|list|None=None,
6037
6172
  bool coordinate_values=True,
6038
- force=False,
6039
- strategy:_available_strategies = "exact",
6173
+ bool force=False,
6174
+ str strategy:_available_strategies = "exact",
6175
+ resolution:Optional[int|list[int]] = None,
6176
+ bool coordinates = False,
6040
6177
  grid_strategy=None,
6041
- inplace=False,
6178
+ bool inplace=False,
6042
6179
  **filtration_grid_kwargs
6043
6180
  )->SimplexTreeMulti_KFi32 | SimplexTreeMulti_KFf32:
6044
6181
  """
@@ -6064,7 +6201,7 @@ cdef class SimplexTreeMulti_KFf32:
6064
6201
 
6065
6202
  #TODO : multi-critical
6066
6203
  if filtration_grid is None:
6067
- filtration_grid = self.get_filtration_grid(grid_strategy=strategy, **filtration_grid_kwargs)
6204
+ filtration_grid = self.get_filtration_grid(grid_strategy=strategy, resolution=resolution, **filtration_grid_kwargs)
6068
6205
  else:
6069
6206
  filtration_grid = sanitize_grid(filtration_grid)
6070
6207
  if len(filtration_grid) != self.num_parameters:
@@ -7136,7 +7273,16 @@ cdef class SimplexTreeMulti_Ff32:
7136
7273
  out = self.get_ptr().get_edge_list()
7137
7274
  return out
7138
7275
 
7139
- def collapse_edges(self, int num=1, int max_dimension = 0, bool progress=False, bool strong=True, bool full=False, bool ignore_warning=False)->SimplexTreeMulti_Ff32:
7276
+ def collapse_edges(
7277
+ self,
7278
+ int num=1,
7279
+ int max_dimension = 0,
7280
+ bool progress=False,
7281
+ bool strong=True,
7282
+ bool full=False,
7283
+ bool ignore_warning=False,
7284
+ bool auto_clean=True,
7285
+ )->SimplexTreeMulti_Ff32:
7140
7286
  """Edge collapse for 1-critical 2-parameter clique complex (see https://arxiv.org/abs/2211.05574).
7141
7287
  It uses the code from the github repository https://github.com/aj-alonso/filtration_domination .
7142
7288
 
@@ -7186,6 +7332,8 @@ cdef class SimplexTreeMulti_Ff32:
7186
7332
  edges = _collapse_edge_list(edges, num=num, full=full, strong=strong, progress=progress)
7187
7333
  # Retrieves the collapsed simplicial complex
7188
7334
  self._reconstruct_from_edge_list(edges, swap=True, expand_dimension=max_dimension)
7335
+ if self.is_squeezed and auto_clean:
7336
+ self._clean_filtration_grid()
7189
7337
  return self
7190
7338
 
7191
7339
  @cython.inline
@@ -7463,10 +7611,12 @@ cdef class SimplexTreeMulti_Ff32:
7463
7611
  self,
7464
7612
  filtration_grid:np.ndarray|list|None=None,
7465
7613
  bool coordinate_values=True,
7466
- force=False,
7467
- strategy:_available_strategies = "exact",
7614
+ bool force=False,
7615
+ str strategy:_available_strategies = "exact",
7616
+ resolution:Optional[int|list[int]] = None,
7617
+ bool coordinates = False,
7468
7618
  grid_strategy=None,
7469
- inplace=False,
7619
+ bool inplace=False,
7470
7620
  **filtration_grid_kwargs
7471
7621
  )->SimplexTreeMulti_Fi32 | SimplexTreeMulti_Ff32:
7472
7622
  """
@@ -7492,7 +7642,7 @@ cdef class SimplexTreeMulti_Ff32:
7492
7642
 
7493
7643
  #TODO : multi-critical
7494
7644
  if filtration_grid is None:
7495
- filtration_grid = self.get_filtration_grid(grid_strategy=strategy, **filtration_grid_kwargs)
7645
+ filtration_grid = self.get_filtration_grid(grid_strategy=strategy, resolution=resolution, **filtration_grid_kwargs)
7496
7646
  else:
7497
7647
  filtration_grid = sanitize_grid(filtration_grid)
7498
7648
  if len(filtration_grid) != self.num_parameters:
@@ -8356,6 +8506,41 @@ cdef class SimplexTreeMulti_KFf64:
8356
8506
  """
8357
8507
  return self.get_ptr().prune_above_dimension(dimension)
8358
8508
 
8509
+ def expansion(self, int max_dim)->SimplexTreeMulti_KFf64:
8510
+ """Expands the simplex tree containing only its one skeleton
8511
+ until dimension max_dim.
8512
+
8513
+ The expanded simplicial complex until dimension :math:`d`
8514
+ attached to a graph :math:`G` is the maximal simplicial complex of
8515
+ dimension at most :math:`d` admitting the graph :math:`G` as
8516
+ :math:`1`-skeleton.
8517
+ The filtration value assigned to a simplex is the maximal filtration
8518
+ value of one of its edges.
8519
+
8520
+ The simplex tree must contain no simplex of dimension bigger than
8521
+ 1 when calling the method.
8522
+
8523
+ :param max_dim: The maximal dimension.
8524
+ :type max_dim: int
8525
+ """
8526
+ with nogil:
8527
+ self.get_ptr().expansion(max_dim)
8528
+ # This is a fix for multipersistence. FIXME expansion in c++
8529
+ self.get_ptr().make_filtration_non_decreasing()
8530
+ return self
8531
+
8532
+ def make_filtration_non_decreasing(self)->bool:
8533
+ """This function ensures that each simplex has a higher filtration
8534
+ value than its faces by increasing the filtration values.
8535
+
8536
+ :returns: True if any filtration value was modified,
8537
+ False if the filtration was already non-decreasing.
8538
+ :rtype: bool
8539
+ """
8540
+ cdef bool out
8541
+ with nogil:
8542
+ out = self.get_ptr().make_filtration_non_decreasing()
8543
+ return out
8359
8544
 
8360
8545
  def reset_filtration(self, filtration, min_dim = 0)->SimplexTreeMulti_KFf64:
8361
8546
  """This function resets the filtration value of all the simplices of dimension at least min_dim. Resets all the
@@ -8612,10 +8797,12 @@ cdef class SimplexTreeMulti_KFf64:
8612
8797
  self,
8613
8798
  filtration_grid:np.ndarray|list|None=None,
8614
8799
  bool coordinate_values=True,
8615
- force=False,
8616
- strategy:_available_strategies = "exact",
8800
+ bool force=False,
8801
+ str strategy:_available_strategies = "exact",
8802
+ resolution:Optional[int|list[int]] = None,
8803
+ bool coordinates = False,
8617
8804
  grid_strategy=None,
8618
- inplace=False,
8805
+ bool inplace=False,
8619
8806
  **filtration_grid_kwargs
8620
8807
  )->SimplexTreeMulti_KFi32 | SimplexTreeMulti_KFf64:
8621
8808
  """
@@ -8641,7 +8828,7 @@ cdef class SimplexTreeMulti_KFf64:
8641
8828
 
8642
8829
  #TODO : multi-critical
8643
8830
  if filtration_grid is None:
8644
- filtration_grid = self.get_filtration_grid(grid_strategy=strategy, **filtration_grid_kwargs)
8831
+ filtration_grid = self.get_filtration_grid(grid_strategy=strategy, resolution=resolution, **filtration_grid_kwargs)
8645
8832
  else:
8646
8833
  filtration_grid = sanitize_grid(filtration_grid)
8647
8834
  if len(filtration_grid) != self.num_parameters:
@@ -9713,7 +9900,16 @@ cdef class SimplexTreeMulti_Ff64:
9713
9900
  out = self.get_ptr().get_edge_list()
9714
9901
  return out
9715
9902
 
9716
- def collapse_edges(self, int num=1, int max_dimension = 0, bool progress=False, bool strong=True, bool full=False, bool ignore_warning=False)->SimplexTreeMulti_Ff64:
9903
+ def collapse_edges(
9904
+ self,
9905
+ int num=1,
9906
+ int max_dimension = 0,
9907
+ bool progress=False,
9908
+ bool strong=True,
9909
+ bool full=False,
9910
+ bool ignore_warning=False,
9911
+ bool auto_clean=True,
9912
+ )->SimplexTreeMulti_Ff64:
9717
9913
  """Edge collapse for 1-critical 2-parameter clique complex (see https://arxiv.org/abs/2211.05574).
9718
9914
  It uses the code from the github repository https://github.com/aj-alonso/filtration_domination .
9719
9915
 
@@ -9763,6 +9959,8 @@ cdef class SimplexTreeMulti_Ff64:
9763
9959
  edges = _collapse_edge_list(edges, num=num, full=full, strong=strong, progress=progress)
9764
9960
  # Retrieves the collapsed simplicial complex
9765
9961
  self._reconstruct_from_edge_list(edges, swap=True, expand_dimension=max_dimension)
9962
+ if self.is_squeezed and auto_clean:
9963
+ self._clean_filtration_grid()
9766
9964
  return self
9767
9965
 
9768
9966
  @cython.inline
@@ -10040,10 +10238,12 @@ cdef class SimplexTreeMulti_Ff64:
10040
10238
  self,
10041
10239
  filtration_grid:np.ndarray|list|None=None,
10042
10240
  bool coordinate_values=True,
10043
- force=False,
10044
- strategy:_available_strategies = "exact",
10241
+ bool force=False,
10242
+ str strategy:_available_strategies = "exact",
10243
+ resolution:Optional[int|list[int]] = None,
10244
+ bool coordinates = False,
10045
10245
  grid_strategy=None,
10046
- inplace=False,
10246
+ bool inplace=False,
10047
10247
  **filtration_grid_kwargs
10048
10248
  )->SimplexTreeMulti_Fi32 | SimplexTreeMulti_Ff64:
10049
10249
  """
@@ -10069,7 +10269,7 @@ cdef class SimplexTreeMulti_Ff64:
10069
10269
 
10070
10270
  #TODO : multi-critical
10071
10271
  if filtration_grid is None:
10072
- filtration_grid = self.get_filtration_grid(grid_strategy=strategy, **filtration_grid_kwargs)
10272
+ filtration_grid = self.get_filtration_grid(grid_strategy=strategy, resolution=resolution, **filtration_grid_kwargs)
10073
10273
  else:
10074
10274
  filtration_grid = sanitize_grid(filtration_grid)
10075
10275
  if len(filtration_grid) != self.num_parameters:
@@ -869,7 +869,6 @@ cdef class SimplexTreeMulti_{{FSHORT}}:
869
869
  """
870
870
  return self.get_ptr().prune_above_dimension(dimension)
871
871
 
872
- {{if not is_kcritical}}
873
872
  def expansion(self, int max_dim)->SimplexTreeMulti_{{FSHORT}}:
874
873
  """Expands the simplex tree containing only its one skeleton
875
874
  until dimension max_dim.
@@ -905,7 +904,6 @@ cdef class SimplexTreeMulti_{{FSHORT}}:
905
904
  with nogil:
906
905
  out = self.get_ptr().make_filtration_non_decreasing()
907
906
  return out
908
- {{endif}}
909
907
 
910
908
  def reset_filtration(self, filtration, min_dim = 0)->SimplexTreeMulti_{{FSHORT}}:
911
909
  """This function resets the filtration value of all the simplices of dimension at least min_dim. Resets all the
@@ -972,7 +970,16 @@ cdef class SimplexTreeMulti_{{FSHORT}}:
972
970
  out = self.get_ptr().get_edge_list()
973
971
  return out
974
972
 
975
- def collapse_edges(self, int num=1, int max_dimension = 0, bool progress=False, bool strong=True, bool full=False, bool ignore_warning=False)->SimplexTreeMulti_{{FSHORT}}:
973
+ def collapse_edges(
974
+ self,
975
+ int num=1,
976
+ int max_dimension = 0,
977
+ bool progress=False,
978
+ bool strong=True,
979
+ bool full=False,
980
+ bool ignore_warning=False,
981
+ bool auto_clean=True,
982
+ )->SimplexTreeMulti_{{FSHORT}}:
976
983
  """Edge collapse for 1-critical 2-parameter clique complex (see https://arxiv.org/abs/2211.05574).
977
984
  It uses the code from the github repository https://github.com/aj-alonso/filtration_domination .
978
985
 
@@ -1022,6 +1029,8 @@ cdef class SimplexTreeMulti_{{FSHORT}}:
1022
1029
  edges = _collapse_edge_list(edges, num=num, full=full, strong=strong, progress=progress)
1023
1030
  # Retrieves the collapsed simplicial complex
1024
1031
  self._reconstruct_from_edge_list(edges, swap=True, expand_dimension=max_dimension)
1032
+ if self.is_squeezed and auto_clean:
1033
+ self._clean_filtration_grid()
1025
1034
  return self
1026
1035
 
1027
1036
  @cython.inline
@@ -1317,10 +1326,12 @@ cdef class SimplexTreeMulti_{{FSHORT}}:
1317
1326
  self,
1318
1327
  filtration_grid:np.ndarray|list|None=None,
1319
1328
  bool coordinate_values=True,
1320
- force=False,
1321
- strategy:_available_strategies = "exact",
1329
+ bool force=False,
1330
+ str strategy:_available_strategies = "exact",
1331
+ resolution:Optional[int|list[int]] = None,
1332
+ bool coordinates = False,
1322
1333
  grid_strategy=None,
1323
- inplace=False,
1334
+ bool inplace=False,
1324
1335
  **filtration_grid_kwargs
1325
1336
  )->SimplexTreeMulti_{{FSHORT[:-3] + "i32"}} | SimplexTreeMulti_{{FSHORT}}:
1326
1337
  """
@@ -1346,7 +1357,7 @@ cdef class SimplexTreeMulti_{{FSHORT}}:
1346
1357
 
1347
1358
  #TODO : multi-critical
1348
1359
  if filtration_grid is None:
1349
- filtration_grid = self.get_filtration_grid(grid_strategy=strategy, **filtration_grid_kwargs)
1360
+ filtration_grid = self.get_filtration_grid(grid_strategy=strategy, resolution=resolution, **filtration_grid_kwargs)
1350
1361
  else:
1351
1362
  filtration_grid = sanitize_grid(filtration_grid)
1352
1363
  if len(filtration_grid) != self.num_parameters:
Binary file
multipers/slicer.pxd CHANGED
@@ -2013,51 +2013,51 @@ cdef extern from "multiparameter_module_approximation/approximation.h" namespace
2013
2013
 
2014
2014
  import multipers.slicer as mps
2015
2015
  from cython.operator cimport dereference
2016
- cdef inline Module[double] _multiparameter_module_approximation_f64(object slicer, One_critical_filtration[double] direction, double max_error, Box[double] box, bool threshold, bool complete, bool verbose):
2016
+ cdef inline Module[float] _multiparameter_module_approximation_f32(object slicer, One_critical_filtration[float] direction, float max_error, Box[float] box, bool threshold, bool complete, bool verbose):
2017
2017
  import multipers.slicer as mps
2018
2018
  cdef intptr_t slicer_ptr = <intptr_t>(slicer.get_ptr())
2019
- cdef Module[double] mod
2019
+ cdef Module[float] mod
2020
2020
  if False:
2021
2021
  pass
2022
- elif isinstance(slicer, mps._KSlicer_Matrix0_vine_f64):
2022
+ elif isinstance(slicer, mps._KSlicer_Matrix0_vine_f32):
2023
2023
  with nogil:
2024
- mod = multiparameter_module_approximation(dereference(<C_KSlicer_Matrix0_vine_f64*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
2024
+ mod = multiparameter_module_approximation(dereference(<C_KSlicer_Matrix0_vine_f32*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
2025
2025
  return mod
2026
- elif isinstance(slicer, mps._KSlicer_Matrix1_vine_f64):
2026
+ elif isinstance(slicer, mps._KSlicer_Matrix1_vine_f32):
2027
2027
  with nogil:
2028
- mod = multiparameter_module_approximation(dereference(<C_KSlicer_Matrix1_vine_f64*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
2028
+ mod = multiparameter_module_approximation(dereference(<C_KSlicer_Matrix1_vine_f32*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
2029
2029
  return mod
2030
- elif isinstance(slicer, mps._Slicer_Matrix0_vine_f64):
2030
+ elif isinstance(slicer, mps._Slicer_Matrix0_vine_f32):
2031
2031
  with nogil:
2032
- mod = multiparameter_module_approximation(dereference(<C_Slicer_Matrix0_vine_f64*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
2032
+ mod = multiparameter_module_approximation(dereference(<C_Slicer_Matrix0_vine_f32*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
2033
2033
  return mod
2034
- elif isinstance(slicer, mps._Slicer_Matrix1_vine_f64):
2034
+ elif isinstance(slicer, mps._Slicer_Matrix1_vine_f32):
2035
2035
  with nogil:
2036
- mod = multiparameter_module_approximation(dereference(<C_Slicer_Matrix1_vine_f64*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
2036
+ mod = multiparameter_module_approximation(dereference(<C_Slicer_Matrix1_vine_f32*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
2037
2037
  return mod
2038
2038
  else:
2039
2039
  raise ValueError(f"Unsupported slicer type {type(slicer)}")
2040
- cdef inline Module[float] _multiparameter_module_approximation_f32(object slicer, One_critical_filtration[float] direction, float max_error, Box[float] box, bool threshold, bool complete, bool verbose):
2040
+ cdef inline Module[double] _multiparameter_module_approximation_f64(object slicer, One_critical_filtration[double] direction, double max_error, Box[double] box, bool threshold, bool complete, bool verbose):
2041
2041
  import multipers.slicer as mps
2042
2042
  cdef intptr_t slicer_ptr = <intptr_t>(slicer.get_ptr())
2043
- cdef Module[float] mod
2043
+ cdef Module[double] mod
2044
2044
  if False:
2045
2045
  pass
2046
- elif isinstance(slicer, mps._KSlicer_Matrix0_vine_f32):
2046
+ elif isinstance(slicer, mps._KSlicer_Matrix0_vine_f64):
2047
2047
  with nogil:
2048
- mod = multiparameter_module_approximation(dereference(<C_KSlicer_Matrix0_vine_f32*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
2048
+ mod = multiparameter_module_approximation(dereference(<C_KSlicer_Matrix0_vine_f64*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
2049
2049
  return mod
2050
- elif isinstance(slicer, mps._KSlicer_Matrix1_vine_f32):
2050
+ elif isinstance(slicer, mps._KSlicer_Matrix1_vine_f64):
2051
2051
  with nogil:
2052
- mod = multiparameter_module_approximation(dereference(<C_KSlicer_Matrix1_vine_f32*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
2052
+ mod = multiparameter_module_approximation(dereference(<C_KSlicer_Matrix1_vine_f64*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
2053
2053
  return mod
2054
- elif isinstance(slicer, mps._Slicer_Matrix0_vine_f32):
2054
+ elif isinstance(slicer, mps._Slicer_Matrix0_vine_f64):
2055
2055
  with nogil:
2056
- mod = multiparameter_module_approximation(dereference(<C_Slicer_Matrix0_vine_f32*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
2056
+ mod = multiparameter_module_approximation(dereference(<C_Slicer_Matrix0_vine_f64*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
2057
2057
  return mod
2058
- elif isinstance(slicer, mps._Slicer_Matrix1_vine_f32):
2058
+ elif isinstance(slicer, mps._Slicer_Matrix1_vine_f64):
2059
2059
  with nogil:
2060
- mod = multiparameter_module_approximation(dereference(<C_Slicer_Matrix1_vine_f32*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
2060
+ mod = multiparameter_module_approximation(dereference(<C_Slicer_Matrix1_vine_f64*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
2061
2061
  return mod
2062
2062
  else:
2063
2063
  raise ValueError(f"Unsupported slicer type {type(slicer)}")