multipers 2.2.3__cp311-cp311-win_amd64.whl → 2.3.1__cp311-cp311-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 (182) hide show
  1. multipers/__init__.py +33 -31
  2. multipers/_signed_measure_meta.py +430 -430
  3. multipers/_slicer_meta.py +211 -212
  4. multipers/data/MOL2.py +458 -458
  5. multipers/data/UCR.py +18 -18
  6. multipers/data/graphs.py +466 -466
  7. multipers/data/immuno_regions.py +27 -27
  8. multipers/data/pytorch2simplextree.py +90 -90
  9. multipers/data/shape3d.py +101 -101
  10. multipers/data/synthetic.py +113 -111
  11. multipers/distances.py +198 -198
  12. multipers/filtration_conversions.pxd.tp +84 -84
  13. multipers/filtrations/__init__.py +18 -0
  14. multipers/{ml/convolutions.py → filtrations/density.py} +563 -520
  15. multipers/filtrations/filtrations.py +289 -0
  16. multipers/filtrations.pxd +224 -224
  17. multipers/function_rips.cp311-win_amd64.pyd +0 -0
  18. multipers/function_rips.pyx +105 -105
  19. multipers/grids.cp311-win_amd64.pyd +0 -0
  20. multipers/grids.pyx +350 -350
  21. multipers/gudhi/Persistence_slices_interface.h +132 -132
  22. multipers/gudhi/Simplex_tree_interface.h +239 -245
  23. multipers/gudhi/Simplex_tree_multi_interface.h +516 -561
  24. multipers/gudhi/cubical_to_boundary.h +59 -59
  25. multipers/gudhi/gudhi/Bitmap_cubical_complex.h +450 -450
  26. multipers/gudhi/gudhi/Bitmap_cubical_complex_base.h +1070 -1070
  27. multipers/gudhi/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h +579 -579
  28. multipers/gudhi/gudhi/Debug_utils.h +45 -45
  29. multipers/gudhi/gudhi/Fields/Multi_field.h +484 -484
  30. multipers/gudhi/gudhi/Fields/Multi_field_operators.h +455 -455
  31. multipers/gudhi/gudhi/Fields/Multi_field_shared.h +450 -450
  32. multipers/gudhi/gudhi/Fields/Multi_field_small.h +531 -531
  33. multipers/gudhi/gudhi/Fields/Multi_field_small_operators.h +507 -507
  34. multipers/gudhi/gudhi/Fields/Multi_field_small_shared.h +531 -531
  35. multipers/gudhi/gudhi/Fields/Z2_field.h +355 -355
  36. multipers/gudhi/gudhi/Fields/Z2_field_operators.h +376 -376
  37. multipers/gudhi/gudhi/Fields/Zp_field.h +420 -420
  38. multipers/gudhi/gudhi/Fields/Zp_field_operators.h +400 -400
  39. multipers/gudhi/gudhi/Fields/Zp_field_shared.h +418 -418
  40. multipers/gudhi/gudhi/Flag_complex_edge_collapser.h +337 -337
  41. multipers/gudhi/gudhi/Matrix.h +2107 -2107
  42. multipers/gudhi/gudhi/Multi_critical_filtration.h +1038 -1038
  43. multipers/gudhi/gudhi/Multi_persistence/Box.h +171 -171
  44. multipers/gudhi/gudhi/Multi_persistence/Line.h +282 -282
  45. multipers/gudhi/gudhi/Off_reader.h +173 -173
  46. multipers/gudhi/gudhi/One_critical_filtration.h +1433 -1431
  47. multipers/gudhi/gudhi/Persistence_matrix/Base_matrix.h +769 -769
  48. multipers/gudhi/gudhi/Persistence_matrix/Base_matrix_with_column_compression.h +686 -686
  49. multipers/gudhi/gudhi/Persistence_matrix/Boundary_matrix.h +842 -842
  50. multipers/gudhi/gudhi/Persistence_matrix/Chain_matrix.h +1350 -1350
  51. multipers/gudhi/gudhi/Persistence_matrix/Id_to_index_overlay.h +1105 -1105
  52. multipers/gudhi/gudhi/Persistence_matrix/Position_to_index_overlay.h +859 -859
  53. multipers/gudhi/gudhi/Persistence_matrix/RU_matrix.h +910 -910
  54. multipers/gudhi/gudhi/Persistence_matrix/allocators/entry_constructors.h +139 -139
  55. multipers/gudhi/gudhi/Persistence_matrix/base_pairing.h +230 -230
  56. multipers/gudhi/gudhi/Persistence_matrix/base_swap.h +211 -211
  57. multipers/gudhi/gudhi/Persistence_matrix/boundary_cell_position_to_id_mapper.h +60 -60
  58. multipers/gudhi/gudhi/Persistence_matrix/boundary_face_position_to_id_mapper.h +60 -60
  59. multipers/gudhi/gudhi/Persistence_matrix/chain_pairing.h +136 -136
  60. multipers/gudhi/gudhi/Persistence_matrix/chain_rep_cycles.h +190 -190
  61. multipers/gudhi/gudhi/Persistence_matrix/chain_vine_swap.h +616 -616
  62. multipers/gudhi/gudhi/Persistence_matrix/columns/chain_column_extra_properties.h +150 -150
  63. multipers/gudhi/gudhi/Persistence_matrix/columns/column_dimension_holder.h +106 -106
  64. multipers/gudhi/gudhi/Persistence_matrix/columns/column_utilities.h +219 -219
  65. multipers/gudhi/gudhi/Persistence_matrix/columns/entry_types.h +327 -327
  66. multipers/gudhi/gudhi/Persistence_matrix/columns/heap_column.h +1140 -1140
  67. multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_list_column.h +934 -934
  68. multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_set_column.h +934 -934
  69. multipers/gudhi/gudhi/Persistence_matrix/columns/list_column.h +980 -980
  70. multipers/gudhi/gudhi/Persistence_matrix/columns/naive_vector_column.h +1092 -1092
  71. multipers/gudhi/gudhi/Persistence_matrix/columns/row_access.h +192 -192
  72. multipers/gudhi/gudhi/Persistence_matrix/columns/set_column.h +921 -921
  73. multipers/gudhi/gudhi/Persistence_matrix/columns/small_vector_column.h +1093 -1093
  74. multipers/gudhi/gudhi/Persistence_matrix/columns/unordered_set_column.h +1012 -1012
  75. multipers/gudhi/gudhi/Persistence_matrix/columns/vector_column.h +1244 -1244
  76. multipers/gudhi/gudhi/Persistence_matrix/matrix_dimension_holders.h +186 -186
  77. multipers/gudhi/gudhi/Persistence_matrix/matrix_row_access.h +164 -164
  78. multipers/gudhi/gudhi/Persistence_matrix/ru_pairing.h +156 -156
  79. multipers/gudhi/gudhi/Persistence_matrix/ru_rep_cycles.h +376 -376
  80. multipers/gudhi/gudhi/Persistence_matrix/ru_vine_swap.h +540 -540
  81. multipers/gudhi/gudhi/Persistent_cohomology/Field_Zp.h +118 -118
  82. multipers/gudhi/gudhi/Persistent_cohomology/Multi_field.h +173 -173
  83. multipers/gudhi/gudhi/Persistent_cohomology/Persistent_cohomology_column.h +128 -128
  84. multipers/gudhi/gudhi/Persistent_cohomology.h +745 -745
  85. multipers/gudhi/gudhi/Points_off_io.h +171 -171
  86. multipers/gudhi/gudhi/Simple_object_pool.h +69 -69
  87. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_iterators.h +463 -463
  88. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h +83 -83
  89. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_siblings.h +106 -106
  90. multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_star_simplex_iterators.h +277 -277
  91. multipers/gudhi/gudhi/Simplex_tree/hooks_simplex_base.h +62 -62
  92. multipers/gudhi/gudhi/Simplex_tree/indexing_tag.h +27 -27
  93. multipers/gudhi/gudhi/Simplex_tree/serialization_utils.h +62 -62
  94. multipers/gudhi/gudhi/Simplex_tree/simplex_tree_options.h +157 -157
  95. multipers/gudhi/gudhi/Simplex_tree.h +2794 -2794
  96. multipers/gudhi/gudhi/Simplex_tree_multi.h +152 -163
  97. multipers/gudhi/gudhi/distance_functions.h +62 -62
  98. multipers/gudhi/gudhi/graph_simplicial_complex.h +104 -104
  99. multipers/gudhi/gudhi/persistence_interval.h +253 -253
  100. multipers/gudhi/gudhi/persistence_matrix_options.h +170 -170
  101. multipers/gudhi/gudhi/reader_utils.h +367 -367
  102. multipers/gudhi/mma_interface_coh.h +256 -255
  103. multipers/gudhi/mma_interface_h0.h +223 -231
  104. multipers/gudhi/mma_interface_matrix.h +291 -282
  105. multipers/gudhi/naive_merge_tree.h +536 -575
  106. multipers/gudhi/scc_io.h +310 -289
  107. multipers/gudhi/truc.h +957 -888
  108. multipers/io.cp311-win_amd64.pyd +0 -0
  109. multipers/io.pyx +714 -711
  110. multipers/ml/accuracies.py +90 -90
  111. multipers/ml/invariants_with_persistable.py +79 -79
  112. multipers/ml/kernels.py +176 -176
  113. multipers/ml/mma.py +713 -714
  114. multipers/ml/one.py +472 -472
  115. multipers/ml/point_clouds.py +352 -346
  116. multipers/ml/signed_measures.py +1589 -1589
  117. multipers/ml/sliced_wasserstein.py +461 -461
  118. multipers/ml/tools.py +113 -113
  119. multipers/mma_structures.cp311-win_amd64.pyd +0 -0
  120. multipers/mma_structures.pxd +127 -127
  121. multipers/mma_structures.pyx +4 -8
  122. multipers/mma_structures.pyx.tp +1083 -1085
  123. multipers/multi_parameter_rank_invariant/diff_helpers.h +84 -93
  124. multipers/multi_parameter_rank_invariant/euler_characteristic.h +97 -97
  125. multipers/multi_parameter_rank_invariant/function_rips.h +322 -322
  126. multipers/multi_parameter_rank_invariant/hilbert_function.h +769 -769
  127. multipers/multi_parameter_rank_invariant/persistence_slices.h +148 -148
  128. multipers/multi_parameter_rank_invariant/rank_invariant.h +369 -369
  129. multipers/multiparameter_edge_collapse.py +41 -41
  130. multipers/multiparameter_module_approximation/approximation.h +2298 -2295
  131. multipers/multiparameter_module_approximation/combinatory.h +129 -129
  132. multipers/multiparameter_module_approximation/debug.h +107 -107
  133. multipers/multiparameter_module_approximation/format_python-cpp.h +286 -286
  134. multipers/multiparameter_module_approximation/heap_column.h +238 -238
  135. multipers/multiparameter_module_approximation/images.h +79 -79
  136. multipers/multiparameter_module_approximation/list_column.h +174 -174
  137. multipers/multiparameter_module_approximation/list_column_2.h +232 -232
  138. multipers/multiparameter_module_approximation/ru_matrix.h +347 -347
  139. multipers/multiparameter_module_approximation/set_column.h +135 -135
  140. multipers/multiparameter_module_approximation/structure_higher_dim_barcode.h +36 -36
  141. multipers/multiparameter_module_approximation/unordered_set_column.h +166 -166
  142. multipers/multiparameter_module_approximation/utilities.h +403 -419
  143. multipers/multiparameter_module_approximation/vector_column.h +223 -223
  144. multipers/multiparameter_module_approximation/vector_matrix.h +331 -331
  145. multipers/multiparameter_module_approximation/vineyards.h +464 -464
  146. multipers/multiparameter_module_approximation/vineyards_trajectories.h +649 -649
  147. multipers/multiparameter_module_approximation.cp311-win_amd64.pyd +0 -0
  148. multipers/multiparameter_module_approximation.pyx +218 -217
  149. multipers/pickle.py +90 -53
  150. multipers/plots.py +342 -334
  151. multipers/point_measure.cp311-win_amd64.pyd +0 -0
  152. multipers/point_measure.pyx +322 -320
  153. multipers/simplex_tree_multi.cp311-win_amd64.pyd +0 -0
  154. multipers/simplex_tree_multi.pxd +133 -133
  155. multipers/simplex_tree_multi.pyx +115 -48
  156. multipers/simplex_tree_multi.pyx.tp +1947 -1935
  157. multipers/slicer.cp311-win_amd64.pyd +0 -0
  158. multipers/slicer.pxd +301 -120
  159. multipers/slicer.pxd.tp +218 -214
  160. multipers/slicer.pyx +1570 -507
  161. multipers/slicer.pyx.tp +931 -914
  162. multipers/tensor/tensor.h +672 -672
  163. multipers/tensor.pxd +13 -13
  164. multipers/test.pyx +44 -44
  165. multipers/tests/__init__.py +57 -57
  166. multipers/torch/diff_grids.py +217 -217
  167. multipers/torch/rips_density.py +310 -304
  168. {multipers-2.2.3.dist-info → multipers-2.3.1.dist-info}/LICENSE +21 -21
  169. {multipers-2.2.3.dist-info → multipers-2.3.1.dist-info}/METADATA +21 -11
  170. multipers-2.3.1.dist-info/RECORD +182 -0
  171. {multipers-2.2.3.dist-info → multipers-2.3.1.dist-info}/WHEEL +1 -1
  172. multipers/tests/test_diff_helper.py +0 -73
  173. multipers/tests/test_hilbert_function.py +0 -82
  174. multipers/tests/test_mma.py +0 -83
  175. multipers/tests/test_point_clouds.py +0 -49
  176. multipers/tests/test_python-cpp_conversion.py +0 -82
  177. multipers/tests/test_signed_betti.py +0 -181
  178. multipers/tests/test_signed_measure.py +0 -89
  179. multipers/tests/test_simplextreemulti.py +0 -221
  180. multipers/tests/test_slicer.py +0 -221
  181. multipers-2.2.3.dist-info/RECORD +0 -189
  182. {multipers-2.2.3.dist-info → multipers-2.3.1.dist-info}/top_level.txt +0 -0
@@ -51,15 +51,14 @@ cimport cython
51
51
  from gudhi.simplex_tree import SimplexTree ## Small hack for typing
52
52
  from typing import Iterable,Literal,Optional
53
53
  from tqdm import tqdm
54
- import multipers.grids as mpg
55
-
54
+ from multipers.grids import Lstrategies, compute_grid
56
55
  from multipers.point_measure import signed_betti, rank_decomposition_by_rectangles, sparsify
57
56
 
58
57
  from warnings import warn
59
58
 
60
59
  SAFE_CONVERSION=False #Slower but at least it works everywhere
61
60
 
62
- _available_strategies =mpg.Lstrategies
61
+ _available_strategies =Lstrategies
63
62
 
64
63
 
65
64
 
@@ -90,7 +89,7 @@ cdef class SimplexTreeMulti_KFi32:
90
89
 
91
90
  # cdef Simplex_tree_persistence_interface * pcohptr
92
91
  # Fake constructor that does nothing but documenting the constructor
93
- def __init__(self, other = None, num_parameters:int=2,default_values=[], safe_conversion=False):
92
+ def __init__(self, other = None, num_parameters:int=-1,default_values=[], safe_conversion=False):
94
93
  """SimplexTreeMulti constructor.
95
94
 
96
95
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.
@@ -115,7 +114,7 @@ cdef class SimplexTreeMulti_KFi32:
115
114
  def is_kcritical(self)->bool:
116
115
  return True
117
116
  # The real cython constructor
118
- def __cinit__(self, other = None, int num_parameters=2,
117
+ def __cinit__(self, other = None, int num_parameters=-1,
119
118
  default_values=np.asarray([SimplexTreeMulti_KFi32.T_minus_inf()]), # I'm not sure why `[]` does not work. Cython bug ?
120
119
  bool safe_conversion=False,
121
120
  ): #TODO doc
@@ -128,10 +127,13 @@ cdef class SimplexTreeMulti_KFi32:
128
127
  if isinstance(other, SimplexTreeMulti_KFi32):
129
128
  other_ptr = other.thisptr
130
129
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFi32, int32_t](dereference(<Simplex_tree_multi_interface[KFi32, int32_t]*>other_ptr))) ## prevents calling destructor of other
131
- num_parameters = other.num_parameters
130
+ if num_parameters <=0:
131
+ num_parameters = other.num_parameters
132
132
  self.filtration_grid = other.filtration_grid
133
133
  elif isinstance(other, SimplexTree): # Constructs a SimplexTreeMulti from a SimplexTree
134
134
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFi32, int32_t]())
135
+ if num_parameters <= 0:
136
+ num_parameters = 1
135
137
  if safe_conversion or SAFE_CONVERSION:
136
138
  new_st_multi = _safe_simplextree_multify_KFi32(other, num_parameters = num_parameters, default_values=np.asarray(default_values))
137
139
  self.thisptr, new_st_multi.thisptr = new_st_multi.thisptr, self.thisptr
@@ -146,8 +148,10 @@ cdef class SimplexTreeMulti_KFi32:
146
148
  else:
147
149
  raise TypeError("`other` argument requires to be of type `SimplexTree`, `SimplexTreeMulti`, or `None`.")
148
150
  else:
151
+ if num_parameters <=0:
152
+ num_parameters = 2 # I don't know how dangerous this is, but this is mostly used.
149
153
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFi32, int32_t]())
150
- self.get_ptr().set_number_of_parameters(num_parameters)
154
+ self.set_num_parameter(num_parameters)
151
155
  self._is_function_simplextree = False
152
156
  self.filtration_grid=[[]*num_parameters]
153
157
 
@@ -159,6 +163,9 @@ cdef class SimplexTreeMulti_KFi32:
159
163
 
160
164
  def __repr__(self):
161
165
  return f"SimplexTreeMulti[dtype={np.dtype(self.dtype).name},num_param={self.num_parameters},kcritical={self.is_kcritical},is_squeezed={self.is_squeezed},max_dim={self.dimension}]"
166
+ def __len__(self):
167
+ return self.num_simplices
168
+
162
169
  def __getstate__(self):
163
170
  """:returns: Serialized (or flattened) SimplexTree data structure in order to pickle SimplexTree.
164
171
  :rtype: numpy.array of shape (n,)
@@ -796,7 +803,8 @@ cdef class SimplexTreeMulti_KFi32:
796
803
  file.write(str(i) + " ")
797
804
  file.write("; ")
798
805
  for f in F:
799
- file.write(str(f) + " ")
806
+ for fi in f:
807
+ file.write(str(fi) + " ")
800
808
  file.write("\n")
801
809
  bar.update(1)
802
810
  file.close()
@@ -850,7 +858,7 @@ cdef class SimplexTreeMulti_KFi32:
850
858
  # removes nan
851
859
  filtrations_values = [filtration[:-1] if np.isnan(filtration[-1]) else filtration for filtration in filtrations_values]
852
860
 
853
- return mpg.compute_grid(filtrations_values, resolution=resolution,strategy=grid_strategy,drop_quantiles=drop_quantiles)
861
+ return compute_grid(filtrations_values, resolution=resolution,strategy=grid_strategy,drop_quantiles=drop_quantiles)
854
862
 
855
863
 
856
864
 
@@ -1185,7 +1193,7 @@ cdef class SimplexTreeMulti_Fi32:
1185
1193
 
1186
1194
  # cdef Simplex_tree_persistence_interface * pcohptr
1187
1195
  # Fake constructor that does nothing but documenting the constructor
1188
- def __init__(self, other = None, num_parameters:int=2,default_values=[], safe_conversion=False):
1196
+ def __init__(self, other = None, num_parameters:int=-1,default_values=[], safe_conversion=False):
1189
1197
  """SimplexTreeMulti constructor.
1190
1198
 
1191
1199
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.
@@ -1210,7 +1218,7 @@ cdef class SimplexTreeMulti_Fi32:
1210
1218
  def is_kcritical(self)->bool:
1211
1219
  return False
1212
1220
  # The real cython constructor
1213
- def __cinit__(self, other = None, int num_parameters=2,
1221
+ def __cinit__(self, other = None, int num_parameters=-1,
1214
1222
  default_values=np.asarray([SimplexTreeMulti_Fi32.T_minus_inf()]), # I'm not sure why `[]` does not work. Cython bug ?
1215
1223
  bool safe_conversion=False,
1216
1224
  ): #TODO doc
@@ -1223,10 +1231,13 @@ cdef class SimplexTreeMulti_Fi32:
1223
1231
  if isinstance(other, SimplexTreeMulti_Fi32):
1224
1232
  other_ptr = other.thisptr
1225
1233
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Fi32, int32_t](dereference(<Simplex_tree_multi_interface[Fi32, int32_t]*>other_ptr))) ## prevents calling destructor of other
1226
- num_parameters = other.num_parameters
1234
+ if num_parameters <=0:
1235
+ num_parameters = other.num_parameters
1227
1236
  self.filtration_grid = other.filtration_grid
1228
1237
  elif isinstance(other, SimplexTree): # Constructs a SimplexTreeMulti from a SimplexTree
1229
1238
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Fi32, int32_t]())
1239
+ if num_parameters <= 0:
1240
+ num_parameters = 1
1230
1241
  if safe_conversion or SAFE_CONVERSION:
1231
1242
  new_st_multi = _safe_simplextree_multify_Fi32(other, num_parameters = num_parameters, default_values=np.asarray(default_values))
1232
1243
  self.thisptr, new_st_multi.thisptr = new_st_multi.thisptr, self.thisptr
@@ -1241,8 +1252,10 @@ cdef class SimplexTreeMulti_Fi32:
1241
1252
  else:
1242
1253
  raise TypeError("`other` argument requires to be of type `SimplexTree`, `SimplexTreeMulti`, or `None`.")
1243
1254
  else:
1255
+ if num_parameters <=0:
1256
+ num_parameters = 2 # I don't know how dangerous this is, but this is mostly used.
1244
1257
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Fi32, int32_t]())
1245
- self.get_ptr().set_number_of_parameters(num_parameters)
1258
+ self.set_num_parameter(num_parameters)
1246
1259
  self._is_function_simplextree = False
1247
1260
  self.filtration_grid=[[]*num_parameters]
1248
1261
 
@@ -1254,6 +1267,9 @@ cdef class SimplexTreeMulti_Fi32:
1254
1267
 
1255
1268
  def __repr__(self):
1256
1269
  return f"SimplexTreeMulti[dtype={np.dtype(self.dtype).name},num_param={self.num_parameters},kcritical={self.is_kcritical},is_squeezed={self.is_squeezed},max_dim={self.dimension}]"
1270
+ def __len__(self):
1271
+ return self.num_simplices
1272
+
1257
1273
  def __getstate__(self):
1258
1274
  """:returns: Serialized (or flattened) SimplexTree data structure in order to pickle SimplexTree.
1259
1275
  :rtype: numpy.array of shape (n,)
@@ -2223,7 +2239,7 @@ cdef class SimplexTreeMulti_Fi32:
2223
2239
  # removes nan
2224
2240
  filtrations_values = [filtration[:-1] if np.isnan(filtration[-1]) else filtration for filtration in filtrations_values]
2225
2241
 
2226
- return mpg.compute_grid(filtrations_values, resolution=resolution,strategy=grid_strategy,drop_quantiles=drop_quantiles)
2242
+ return compute_grid(filtrations_values, resolution=resolution,strategy=grid_strategy,drop_quantiles=drop_quantiles)
2227
2243
 
2228
2244
 
2229
2245
 
@@ -2556,7 +2572,7 @@ cdef class SimplexTreeMulti_KFi64:
2556
2572
 
2557
2573
  # cdef Simplex_tree_persistence_interface * pcohptr
2558
2574
  # Fake constructor that does nothing but documenting the constructor
2559
- def __init__(self, other = None, num_parameters:int=2,default_values=[], safe_conversion=False):
2575
+ def __init__(self, other = None, num_parameters:int=-1,default_values=[], safe_conversion=False):
2560
2576
  """SimplexTreeMulti constructor.
2561
2577
 
2562
2578
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.
@@ -2581,7 +2597,7 @@ cdef class SimplexTreeMulti_KFi64:
2581
2597
  def is_kcritical(self)->bool:
2582
2598
  return True
2583
2599
  # The real cython constructor
2584
- def __cinit__(self, other = None, int num_parameters=2,
2600
+ def __cinit__(self, other = None, int num_parameters=-1,
2585
2601
  default_values=np.asarray([SimplexTreeMulti_KFi64.T_minus_inf()]), # I'm not sure why `[]` does not work. Cython bug ?
2586
2602
  bool safe_conversion=False,
2587
2603
  ): #TODO doc
@@ -2594,10 +2610,13 @@ cdef class SimplexTreeMulti_KFi64:
2594
2610
  if isinstance(other, SimplexTreeMulti_KFi64):
2595
2611
  other_ptr = other.thisptr
2596
2612
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFi64, int64_t](dereference(<Simplex_tree_multi_interface[KFi64, int64_t]*>other_ptr))) ## prevents calling destructor of other
2597
- num_parameters = other.num_parameters
2613
+ if num_parameters <=0:
2614
+ num_parameters = other.num_parameters
2598
2615
  self.filtration_grid = other.filtration_grid
2599
2616
  elif isinstance(other, SimplexTree): # Constructs a SimplexTreeMulti from a SimplexTree
2600
2617
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFi64, int64_t]())
2618
+ if num_parameters <= 0:
2619
+ num_parameters = 1
2601
2620
  if safe_conversion or SAFE_CONVERSION:
2602
2621
  new_st_multi = _safe_simplextree_multify_KFi64(other, num_parameters = num_parameters, default_values=np.asarray(default_values))
2603
2622
  self.thisptr, new_st_multi.thisptr = new_st_multi.thisptr, self.thisptr
@@ -2612,8 +2631,10 @@ cdef class SimplexTreeMulti_KFi64:
2612
2631
  else:
2613
2632
  raise TypeError("`other` argument requires to be of type `SimplexTree`, `SimplexTreeMulti`, or `None`.")
2614
2633
  else:
2634
+ if num_parameters <=0:
2635
+ num_parameters = 2 # I don't know how dangerous this is, but this is mostly used.
2615
2636
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFi64, int64_t]())
2616
- self.get_ptr().set_number_of_parameters(num_parameters)
2637
+ self.set_num_parameter(num_parameters)
2617
2638
  self._is_function_simplextree = False
2618
2639
  self.filtration_grid=[[]*num_parameters]
2619
2640
 
@@ -2625,6 +2646,9 @@ cdef class SimplexTreeMulti_KFi64:
2625
2646
 
2626
2647
  def __repr__(self):
2627
2648
  return f"SimplexTreeMulti[dtype={np.dtype(self.dtype).name},num_param={self.num_parameters},kcritical={self.is_kcritical},is_squeezed={self.is_squeezed},max_dim={self.dimension}]"
2649
+ def __len__(self):
2650
+ return self.num_simplices
2651
+
2628
2652
  def __getstate__(self):
2629
2653
  """:returns: Serialized (or flattened) SimplexTree data structure in order to pickle SimplexTree.
2630
2654
  :rtype: numpy.array of shape (n,)
@@ -3262,7 +3286,8 @@ cdef class SimplexTreeMulti_KFi64:
3262
3286
  file.write(str(i) + " ")
3263
3287
  file.write("; ")
3264
3288
  for f in F:
3265
- file.write(str(f) + " ")
3289
+ for fi in f:
3290
+ file.write(str(fi) + " ")
3266
3291
  file.write("\n")
3267
3292
  bar.update(1)
3268
3293
  file.close()
@@ -3316,7 +3341,7 @@ cdef class SimplexTreeMulti_KFi64:
3316
3341
  # removes nan
3317
3342
  filtrations_values = [filtration[:-1] if np.isnan(filtration[-1]) else filtration for filtration in filtrations_values]
3318
3343
 
3319
- return mpg.compute_grid(filtrations_values, resolution=resolution,strategy=grid_strategy,drop_quantiles=drop_quantiles)
3344
+ return compute_grid(filtrations_values, resolution=resolution,strategy=grid_strategy,drop_quantiles=drop_quantiles)
3320
3345
 
3321
3346
 
3322
3347
 
@@ -3651,7 +3676,7 @@ cdef class SimplexTreeMulti_Fi64:
3651
3676
 
3652
3677
  # cdef Simplex_tree_persistence_interface * pcohptr
3653
3678
  # Fake constructor that does nothing but documenting the constructor
3654
- def __init__(self, other = None, num_parameters:int=2,default_values=[], safe_conversion=False):
3679
+ def __init__(self, other = None, num_parameters:int=-1,default_values=[], safe_conversion=False):
3655
3680
  """SimplexTreeMulti constructor.
3656
3681
 
3657
3682
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.
@@ -3676,7 +3701,7 @@ cdef class SimplexTreeMulti_Fi64:
3676
3701
  def is_kcritical(self)->bool:
3677
3702
  return False
3678
3703
  # The real cython constructor
3679
- def __cinit__(self, other = None, int num_parameters=2,
3704
+ def __cinit__(self, other = None, int num_parameters=-1,
3680
3705
  default_values=np.asarray([SimplexTreeMulti_Fi64.T_minus_inf()]), # I'm not sure why `[]` does not work. Cython bug ?
3681
3706
  bool safe_conversion=False,
3682
3707
  ): #TODO doc
@@ -3689,10 +3714,13 @@ cdef class SimplexTreeMulti_Fi64:
3689
3714
  if isinstance(other, SimplexTreeMulti_Fi64):
3690
3715
  other_ptr = other.thisptr
3691
3716
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Fi64, int64_t](dereference(<Simplex_tree_multi_interface[Fi64, int64_t]*>other_ptr))) ## prevents calling destructor of other
3692
- num_parameters = other.num_parameters
3717
+ if num_parameters <=0:
3718
+ num_parameters = other.num_parameters
3693
3719
  self.filtration_grid = other.filtration_grid
3694
3720
  elif isinstance(other, SimplexTree): # Constructs a SimplexTreeMulti from a SimplexTree
3695
3721
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Fi64, int64_t]())
3722
+ if num_parameters <= 0:
3723
+ num_parameters = 1
3696
3724
  if safe_conversion or SAFE_CONVERSION:
3697
3725
  new_st_multi = _safe_simplextree_multify_Fi64(other, num_parameters = num_parameters, default_values=np.asarray(default_values))
3698
3726
  self.thisptr, new_st_multi.thisptr = new_st_multi.thisptr, self.thisptr
@@ -3707,8 +3735,10 @@ cdef class SimplexTreeMulti_Fi64:
3707
3735
  else:
3708
3736
  raise TypeError("`other` argument requires to be of type `SimplexTree`, `SimplexTreeMulti`, or `None`.")
3709
3737
  else:
3738
+ if num_parameters <=0:
3739
+ num_parameters = 2 # I don't know how dangerous this is, but this is mostly used.
3710
3740
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Fi64, int64_t]())
3711
- self.get_ptr().set_number_of_parameters(num_parameters)
3741
+ self.set_num_parameter(num_parameters)
3712
3742
  self._is_function_simplextree = False
3713
3743
  self.filtration_grid=[[]*num_parameters]
3714
3744
 
@@ -3720,6 +3750,9 @@ cdef class SimplexTreeMulti_Fi64:
3720
3750
 
3721
3751
  def __repr__(self):
3722
3752
  return f"SimplexTreeMulti[dtype={np.dtype(self.dtype).name},num_param={self.num_parameters},kcritical={self.is_kcritical},is_squeezed={self.is_squeezed},max_dim={self.dimension}]"
3753
+ def __len__(self):
3754
+ return self.num_simplices
3755
+
3723
3756
  def __getstate__(self):
3724
3757
  """:returns: Serialized (or flattened) SimplexTree data structure in order to pickle SimplexTree.
3725
3758
  :rtype: numpy.array of shape (n,)
@@ -4689,7 +4722,7 @@ cdef class SimplexTreeMulti_Fi64:
4689
4722
  # removes nan
4690
4723
  filtrations_values = [filtration[:-1] if np.isnan(filtration[-1]) else filtration for filtration in filtrations_values]
4691
4724
 
4692
- return mpg.compute_grid(filtrations_values, resolution=resolution,strategy=grid_strategy,drop_quantiles=drop_quantiles)
4725
+ return compute_grid(filtrations_values, resolution=resolution,strategy=grid_strategy,drop_quantiles=drop_quantiles)
4693
4726
 
4694
4727
 
4695
4728
 
@@ -5022,7 +5055,7 @@ cdef class SimplexTreeMulti_KFf32:
5022
5055
 
5023
5056
  # cdef Simplex_tree_persistence_interface * pcohptr
5024
5057
  # Fake constructor that does nothing but documenting the constructor
5025
- def __init__(self, other = None, num_parameters:int=2,default_values=[], safe_conversion=False):
5058
+ def __init__(self, other = None, num_parameters:int=-1,default_values=[], safe_conversion=False):
5026
5059
  """SimplexTreeMulti constructor.
5027
5060
 
5028
5061
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.
@@ -5047,7 +5080,7 @@ cdef class SimplexTreeMulti_KFf32:
5047
5080
  def is_kcritical(self)->bool:
5048
5081
  return True
5049
5082
  # The real cython constructor
5050
- def __cinit__(self, other = None, int num_parameters=2,
5083
+ def __cinit__(self, other = None, int num_parameters=-1,
5051
5084
  default_values=np.asarray([SimplexTreeMulti_KFf32.T_minus_inf()]), # I'm not sure why `[]` does not work. Cython bug ?
5052
5085
  bool safe_conversion=False,
5053
5086
  ): #TODO doc
@@ -5060,10 +5093,13 @@ cdef class SimplexTreeMulti_KFf32:
5060
5093
  if isinstance(other, SimplexTreeMulti_KFf32):
5061
5094
  other_ptr = other.thisptr
5062
5095
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFf32, float](dereference(<Simplex_tree_multi_interface[KFf32, float]*>other_ptr))) ## prevents calling destructor of other
5063
- num_parameters = other.num_parameters
5096
+ if num_parameters <=0:
5097
+ num_parameters = other.num_parameters
5064
5098
  self.filtration_grid = other.filtration_grid
5065
5099
  elif isinstance(other, SimplexTree): # Constructs a SimplexTreeMulti from a SimplexTree
5066
5100
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFf32, float]())
5101
+ if num_parameters <= 0:
5102
+ num_parameters = 1
5067
5103
  if safe_conversion or SAFE_CONVERSION:
5068
5104
  new_st_multi = _safe_simplextree_multify_KFf32(other, num_parameters = num_parameters, default_values=np.asarray(default_values))
5069
5105
  self.thisptr, new_st_multi.thisptr = new_st_multi.thisptr, self.thisptr
@@ -5078,8 +5114,10 @@ cdef class SimplexTreeMulti_KFf32:
5078
5114
  else:
5079
5115
  raise TypeError("`other` argument requires to be of type `SimplexTree`, `SimplexTreeMulti`, or `None`.")
5080
5116
  else:
5117
+ if num_parameters <=0:
5118
+ num_parameters = 2 # I don't know how dangerous this is, but this is mostly used.
5081
5119
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFf32, float]())
5082
- self.get_ptr().set_number_of_parameters(num_parameters)
5120
+ self.set_num_parameter(num_parameters)
5083
5121
  self._is_function_simplextree = False
5084
5122
  self.filtration_grid=[[]*num_parameters]
5085
5123
 
@@ -5091,6 +5129,9 @@ cdef class SimplexTreeMulti_KFf32:
5091
5129
 
5092
5130
  def __repr__(self):
5093
5131
  return f"SimplexTreeMulti[dtype={np.dtype(self.dtype).name},num_param={self.num_parameters},kcritical={self.is_kcritical},is_squeezed={self.is_squeezed},max_dim={self.dimension}]"
5132
+ def __len__(self):
5133
+ return self.num_simplices
5134
+
5094
5135
  def __getstate__(self):
5095
5136
  """:returns: Serialized (or flattened) SimplexTree data structure in order to pickle SimplexTree.
5096
5137
  :rtype: numpy.array of shape (n,)
@@ -5728,7 +5769,8 @@ cdef class SimplexTreeMulti_KFf32:
5728
5769
  file.write(str(i) + " ")
5729
5770
  file.write("; ")
5730
5771
  for f in F:
5731
- file.write(str(f) + " ")
5772
+ for fi in f:
5773
+ file.write(str(fi) + " ")
5732
5774
  file.write("\n")
5733
5775
  bar.update(1)
5734
5776
  file.close()
@@ -5782,7 +5824,7 @@ cdef class SimplexTreeMulti_KFf32:
5782
5824
  # removes nan
5783
5825
  filtrations_values = [filtration[:-1] if np.isnan(filtration[-1]) else filtration for filtration in filtrations_values]
5784
5826
 
5785
- return mpg.compute_grid(filtrations_values, resolution=resolution,strategy=grid_strategy,drop_quantiles=drop_quantiles)
5827
+ return compute_grid(filtrations_values, resolution=resolution,strategy=grid_strategy,drop_quantiles=drop_quantiles)
5786
5828
 
5787
5829
 
5788
5830
 
@@ -6117,7 +6159,7 @@ cdef class SimplexTreeMulti_Ff32:
6117
6159
 
6118
6160
  # cdef Simplex_tree_persistence_interface * pcohptr
6119
6161
  # Fake constructor that does nothing but documenting the constructor
6120
- def __init__(self, other = None, num_parameters:int=2,default_values=[], safe_conversion=False):
6162
+ def __init__(self, other = None, num_parameters:int=-1,default_values=[], safe_conversion=False):
6121
6163
  """SimplexTreeMulti constructor.
6122
6164
 
6123
6165
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.
@@ -6142,7 +6184,7 @@ cdef class SimplexTreeMulti_Ff32:
6142
6184
  def is_kcritical(self)->bool:
6143
6185
  return False
6144
6186
  # The real cython constructor
6145
- def __cinit__(self, other = None, int num_parameters=2,
6187
+ def __cinit__(self, other = None, int num_parameters=-1,
6146
6188
  default_values=np.asarray([SimplexTreeMulti_Ff32.T_minus_inf()]), # I'm not sure why `[]` does not work. Cython bug ?
6147
6189
  bool safe_conversion=False,
6148
6190
  ): #TODO doc
@@ -6155,10 +6197,13 @@ cdef class SimplexTreeMulti_Ff32:
6155
6197
  if isinstance(other, SimplexTreeMulti_Ff32):
6156
6198
  other_ptr = other.thisptr
6157
6199
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Ff32, float](dereference(<Simplex_tree_multi_interface[Ff32, float]*>other_ptr))) ## prevents calling destructor of other
6158
- num_parameters = other.num_parameters
6200
+ if num_parameters <=0:
6201
+ num_parameters = other.num_parameters
6159
6202
  self.filtration_grid = other.filtration_grid
6160
6203
  elif isinstance(other, SimplexTree): # Constructs a SimplexTreeMulti from a SimplexTree
6161
6204
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Ff32, float]())
6205
+ if num_parameters <= 0:
6206
+ num_parameters = 1
6162
6207
  if safe_conversion or SAFE_CONVERSION:
6163
6208
  new_st_multi = _safe_simplextree_multify_Ff32(other, num_parameters = num_parameters, default_values=np.asarray(default_values))
6164
6209
  self.thisptr, new_st_multi.thisptr = new_st_multi.thisptr, self.thisptr
@@ -6173,8 +6218,10 @@ cdef class SimplexTreeMulti_Ff32:
6173
6218
  else:
6174
6219
  raise TypeError("`other` argument requires to be of type `SimplexTree`, `SimplexTreeMulti`, or `None`.")
6175
6220
  else:
6221
+ if num_parameters <=0:
6222
+ num_parameters = 2 # I don't know how dangerous this is, but this is mostly used.
6176
6223
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Ff32, float]())
6177
- self.get_ptr().set_number_of_parameters(num_parameters)
6224
+ self.set_num_parameter(num_parameters)
6178
6225
  self._is_function_simplextree = False
6179
6226
  self.filtration_grid=[[]*num_parameters]
6180
6227
 
@@ -6186,6 +6233,9 @@ cdef class SimplexTreeMulti_Ff32:
6186
6233
 
6187
6234
  def __repr__(self):
6188
6235
  return f"SimplexTreeMulti[dtype={np.dtype(self.dtype).name},num_param={self.num_parameters},kcritical={self.is_kcritical},is_squeezed={self.is_squeezed},max_dim={self.dimension}]"
6236
+ def __len__(self):
6237
+ return self.num_simplices
6238
+
6189
6239
  def __getstate__(self):
6190
6240
  """:returns: Serialized (or flattened) SimplexTree data structure in order to pickle SimplexTree.
6191
6241
  :rtype: numpy.array of shape (n,)
@@ -7155,7 +7205,7 @@ cdef class SimplexTreeMulti_Ff32:
7155
7205
  # removes nan
7156
7206
  filtrations_values = [filtration[:-1] if np.isnan(filtration[-1]) else filtration for filtration in filtrations_values]
7157
7207
 
7158
- return mpg.compute_grid(filtrations_values, resolution=resolution,strategy=grid_strategy,drop_quantiles=drop_quantiles)
7208
+ return compute_grid(filtrations_values, resolution=resolution,strategy=grid_strategy,drop_quantiles=drop_quantiles)
7159
7209
 
7160
7210
 
7161
7211
 
@@ -7488,7 +7538,7 @@ cdef class SimplexTreeMulti_KFf64:
7488
7538
 
7489
7539
  # cdef Simplex_tree_persistence_interface * pcohptr
7490
7540
  # Fake constructor that does nothing but documenting the constructor
7491
- def __init__(self, other = None, num_parameters:int=2,default_values=[], safe_conversion=False):
7541
+ def __init__(self, other = None, num_parameters:int=-1,default_values=[], safe_conversion=False):
7492
7542
  """SimplexTreeMulti constructor.
7493
7543
 
7494
7544
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.
@@ -7513,7 +7563,7 @@ cdef class SimplexTreeMulti_KFf64:
7513
7563
  def is_kcritical(self)->bool:
7514
7564
  return True
7515
7565
  # The real cython constructor
7516
- def __cinit__(self, other = None, int num_parameters=2,
7566
+ def __cinit__(self, other = None, int num_parameters=-1,
7517
7567
  default_values=np.asarray([SimplexTreeMulti_KFf64.T_minus_inf()]), # I'm not sure why `[]` does not work. Cython bug ?
7518
7568
  bool safe_conversion=False,
7519
7569
  ): #TODO doc
@@ -7526,10 +7576,13 @@ cdef class SimplexTreeMulti_KFf64:
7526
7576
  if isinstance(other, SimplexTreeMulti_KFf64):
7527
7577
  other_ptr = other.thisptr
7528
7578
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFf64, double](dereference(<Simplex_tree_multi_interface[KFf64, double]*>other_ptr))) ## prevents calling destructor of other
7529
- num_parameters = other.num_parameters
7579
+ if num_parameters <=0:
7580
+ num_parameters = other.num_parameters
7530
7581
  self.filtration_grid = other.filtration_grid
7531
7582
  elif isinstance(other, SimplexTree): # Constructs a SimplexTreeMulti from a SimplexTree
7532
7583
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFf64, double]())
7584
+ if num_parameters <= 0:
7585
+ num_parameters = 1
7533
7586
  if safe_conversion or SAFE_CONVERSION:
7534
7587
  new_st_multi = _safe_simplextree_multify_KFf64(other, num_parameters = num_parameters, default_values=np.asarray(default_values))
7535
7588
  self.thisptr, new_st_multi.thisptr = new_st_multi.thisptr, self.thisptr
@@ -7544,8 +7597,10 @@ cdef class SimplexTreeMulti_KFf64:
7544
7597
  else:
7545
7598
  raise TypeError("`other` argument requires to be of type `SimplexTree`, `SimplexTreeMulti`, or `None`.")
7546
7599
  else:
7600
+ if num_parameters <=0:
7601
+ num_parameters = 2 # I don't know how dangerous this is, but this is mostly used.
7547
7602
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFf64, double]())
7548
- self.get_ptr().set_number_of_parameters(num_parameters)
7603
+ self.set_num_parameter(num_parameters)
7549
7604
  self._is_function_simplextree = False
7550
7605
  self.filtration_grid=[[]*num_parameters]
7551
7606
 
@@ -7557,6 +7612,9 @@ cdef class SimplexTreeMulti_KFf64:
7557
7612
 
7558
7613
  def __repr__(self):
7559
7614
  return f"SimplexTreeMulti[dtype={np.dtype(self.dtype).name},num_param={self.num_parameters},kcritical={self.is_kcritical},is_squeezed={self.is_squeezed},max_dim={self.dimension}]"
7615
+ def __len__(self):
7616
+ return self.num_simplices
7617
+
7560
7618
  def __getstate__(self):
7561
7619
  """:returns: Serialized (or flattened) SimplexTree data structure in order to pickle SimplexTree.
7562
7620
  :rtype: numpy.array of shape (n,)
@@ -8194,7 +8252,8 @@ cdef class SimplexTreeMulti_KFf64:
8194
8252
  file.write(str(i) + " ")
8195
8253
  file.write("; ")
8196
8254
  for f in F:
8197
- file.write(str(f) + " ")
8255
+ for fi in f:
8256
+ file.write(str(fi) + " ")
8198
8257
  file.write("\n")
8199
8258
  bar.update(1)
8200
8259
  file.close()
@@ -8248,7 +8307,7 @@ cdef class SimplexTreeMulti_KFf64:
8248
8307
  # removes nan
8249
8308
  filtrations_values = [filtration[:-1] if np.isnan(filtration[-1]) else filtration for filtration in filtrations_values]
8250
8309
 
8251
- return mpg.compute_grid(filtrations_values, resolution=resolution,strategy=grid_strategy,drop_quantiles=drop_quantiles)
8310
+ return compute_grid(filtrations_values, resolution=resolution,strategy=grid_strategy,drop_quantiles=drop_quantiles)
8252
8311
 
8253
8312
 
8254
8313
 
@@ -8583,7 +8642,7 @@ cdef class SimplexTreeMulti_Ff64:
8583
8642
 
8584
8643
  # cdef Simplex_tree_persistence_interface * pcohptr
8585
8644
  # Fake constructor that does nothing but documenting the constructor
8586
- def __init__(self, other = None, num_parameters:int=2,default_values=[], safe_conversion=False):
8645
+ def __init__(self, other = None, num_parameters:int=-1,default_values=[], safe_conversion=False):
8587
8646
  """SimplexTreeMulti constructor.
8588
8647
 
8589
8648
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.
@@ -8608,7 +8667,7 @@ cdef class SimplexTreeMulti_Ff64:
8608
8667
  def is_kcritical(self)->bool:
8609
8668
  return False
8610
8669
  # The real cython constructor
8611
- def __cinit__(self, other = None, int num_parameters=2,
8670
+ def __cinit__(self, other = None, int num_parameters=-1,
8612
8671
  default_values=np.asarray([SimplexTreeMulti_Ff64.T_minus_inf()]), # I'm not sure why `[]` does not work. Cython bug ?
8613
8672
  bool safe_conversion=False,
8614
8673
  ): #TODO doc
@@ -8621,10 +8680,13 @@ cdef class SimplexTreeMulti_Ff64:
8621
8680
  if isinstance(other, SimplexTreeMulti_Ff64):
8622
8681
  other_ptr = other.thisptr
8623
8682
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Ff64, double](dereference(<Simplex_tree_multi_interface[Ff64, double]*>other_ptr))) ## prevents calling destructor of other
8624
- num_parameters = other.num_parameters
8683
+ if num_parameters <=0:
8684
+ num_parameters = other.num_parameters
8625
8685
  self.filtration_grid = other.filtration_grid
8626
8686
  elif isinstance(other, SimplexTree): # Constructs a SimplexTreeMulti from a SimplexTree
8627
8687
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Ff64, double]())
8688
+ if num_parameters <= 0:
8689
+ num_parameters = 1
8628
8690
  if safe_conversion or SAFE_CONVERSION:
8629
8691
  new_st_multi = _safe_simplextree_multify_Ff64(other, num_parameters = num_parameters, default_values=np.asarray(default_values))
8630
8692
  self.thisptr, new_st_multi.thisptr = new_st_multi.thisptr, self.thisptr
@@ -8639,8 +8701,10 @@ cdef class SimplexTreeMulti_Ff64:
8639
8701
  else:
8640
8702
  raise TypeError("`other` argument requires to be of type `SimplexTree`, `SimplexTreeMulti`, or `None`.")
8641
8703
  else:
8704
+ if num_parameters <=0:
8705
+ num_parameters = 2 # I don't know how dangerous this is, but this is mostly used.
8642
8706
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Ff64, double]())
8643
- self.get_ptr().set_number_of_parameters(num_parameters)
8707
+ self.set_num_parameter(num_parameters)
8644
8708
  self._is_function_simplextree = False
8645
8709
  self.filtration_grid=[[]*num_parameters]
8646
8710
 
@@ -8652,6 +8716,9 @@ cdef class SimplexTreeMulti_Ff64:
8652
8716
 
8653
8717
  def __repr__(self):
8654
8718
  return f"SimplexTreeMulti[dtype={np.dtype(self.dtype).name},num_param={self.num_parameters},kcritical={self.is_kcritical},is_squeezed={self.is_squeezed},max_dim={self.dimension}]"
8719
+ def __len__(self):
8720
+ return self.num_simplices
8721
+
8655
8722
  def __getstate__(self):
8656
8723
  """:returns: Serialized (or flattened) SimplexTree data structure in order to pickle SimplexTree.
8657
8724
  :rtype: numpy.array of shape (n,)
@@ -9621,7 +9688,7 @@ cdef class SimplexTreeMulti_Ff64:
9621
9688
  # removes nan
9622
9689
  filtrations_values = [filtration[:-1] if np.isnan(filtration[-1]) else filtration for filtration in filtrations_values]
9623
9690
 
9624
- return mpg.compute_grid(filtrations_values, resolution=resolution,strategy=grid_strategy,drop_quantiles=drop_quantiles)
9691
+ return compute_grid(filtrations_values, resolution=resolution,strategy=grid_strategy,drop_quantiles=drop_quantiles)
9625
9692
 
9626
9693
 
9627
9694
 
@@ -9965,7 +10032,7 @@ def is_simplextree_multi(input)->bool:
9965
10032
 
9966
10033
 
9967
10034
 
9968
- def SimplexTreeMulti(input=None, int num_parameters=2, dtype:type = np.float64, bool kcritical = False,**kwargs) -> SimplexTreeMulti_type:
10035
+ def SimplexTreeMulti(input=None, int num_parameters=-1, dtype:type = np.float64, bool kcritical = False,**kwargs) -> SimplexTreeMulti_type:
9969
10036
  """SimplexTreeMulti constructor.
9970
10037
 
9971
10038
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.