multipers 2.3.0__cp312-cp312-win_amd64.whl → 2.3.1__cp312-cp312-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 (37) hide show
  1. multipers/{ml/convolutions.py → filtrations/density.py} +45 -2
  2. multipers/filtrations/filtrations.py +2 -2
  3. multipers/function_rips.cp312-win_amd64.pyd +0 -0
  4. multipers/grids.cp312-win_amd64.pyd +0 -0
  5. multipers/gudhi/Simplex_tree_multi_interface.h +1 -1
  6. multipers/gudhi/gudhi/One_critical_filtration.h +2 -1
  7. multipers/gudhi/mma_interface_h0.h +1 -1
  8. multipers/gudhi/mma_interface_matrix.h +8 -1
  9. multipers/gudhi/naive_merge_tree.h +1 -1
  10. multipers/gudhi/truc.h +82 -15
  11. multipers/io.cp312-win_amd64.pyd +0 -0
  12. multipers/io.pyx +14 -11
  13. multipers/ml/point_clouds.py +2 -2
  14. multipers/ml/signed_measures.py +3 -3
  15. multipers/mma_structures.cp312-win_amd64.pyd +0 -0
  16. multipers/mma_structures.pyx +0 -4
  17. multipers/mma_structures.pyx.tp +0 -2
  18. multipers/multiparameter_module_approximation/approximation.h +4 -2
  19. multipers/multiparameter_module_approximation.cp312-win_amd64.pyd +0 -0
  20. multipers/multiparameter_module_approximation.pyx +3 -1
  21. multipers/plots.py +1 -1
  22. multipers/point_measure.cp312-win_amd64.pyd +0 -0
  23. multipers/simplex_tree_multi.cp312-win_amd64.pyd +0 -0
  24. multipers/simplex_tree_multi.pyx +97 -33
  25. multipers/simplex_tree_multi.pyx.tp +13 -5
  26. multipers/slicer.cp312-win_amd64.pyd +0 -0
  27. multipers/slicer.pxd +200 -80
  28. multipers/slicer.pxd.tp +5 -2
  29. multipers/slicer.pyx +484 -204
  30. multipers/slicer.pyx.tp +16 -9
  31. multipers/tensor/tensor.h +1 -1
  32. multipers/torch/rips_density.py +1 -1
  33. {multipers-2.3.0.dist-info → multipers-2.3.1.dist-info}/METADATA +1 -1
  34. {multipers-2.3.0.dist-info → multipers-2.3.1.dist-info}/RECORD +37 -37
  35. {multipers-2.3.0.dist-info → multipers-2.3.1.dist-info}/WHEEL +1 -1
  36. {multipers-2.3.0.dist-info → multipers-2.3.1.dist-info}/LICENSE +0 -0
  37. {multipers-2.3.0.dist-info → multipers-2.3.1.dist-info}/top_level.txt +0 -0
@@ -89,7 +89,7 @@ cdef class SimplexTreeMulti_KFi32:
89
89
 
90
90
  # cdef Simplex_tree_persistence_interface * pcohptr
91
91
  # Fake constructor that does nothing but documenting the constructor
92
- 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):
93
93
  """SimplexTreeMulti constructor.
94
94
 
95
95
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.
@@ -114,7 +114,7 @@ cdef class SimplexTreeMulti_KFi32:
114
114
  def is_kcritical(self)->bool:
115
115
  return True
116
116
  # The real cython constructor
117
- def __cinit__(self, other = None, int num_parameters=2,
117
+ def __cinit__(self, other = None, int num_parameters=-1,
118
118
  default_values=np.asarray([SimplexTreeMulti_KFi32.T_minus_inf()]), # I'm not sure why `[]` does not work. Cython bug ?
119
119
  bool safe_conversion=False,
120
120
  ): #TODO doc
@@ -127,10 +127,13 @@ cdef class SimplexTreeMulti_KFi32:
127
127
  if isinstance(other, SimplexTreeMulti_KFi32):
128
128
  other_ptr = other.thisptr
129
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
130
- num_parameters = other.num_parameters
130
+ if num_parameters <=0:
131
+ num_parameters = other.num_parameters
131
132
  self.filtration_grid = other.filtration_grid
132
133
  elif isinstance(other, SimplexTree): # Constructs a SimplexTreeMulti from a SimplexTree
133
134
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFi32, int32_t]())
135
+ if num_parameters <= 0:
136
+ num_parameters = 1
134
137
  if safe_conversion or SAFE_CONVERSION:
135
138
  new_st_multi = _safe_simplextree_multify_KFi32(other, num_parameters = num_parameters, default_values=np.asarray(default_values))
136
139
  self.thisptr, new_st_multi.thisptr = new_st_multi.thisptr, self.thisptr
@@ -145,8 +148,10 @@ cdef class SimplexTreeMulti_KFi32:
145
148
  else:
146
149
  raise TypeError("`other` argument requires to be of type `SimplexTree`, `SimplexTreeMulti`, or `None`.")
147
150
  else:
151
+ if num_parameters <=0:
152
+ num_parameters = 2 # I don't know how dangerous this is, but this is mostly used.
148
153
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFi32, int32_t]())
149
- self.get_ptr().set_number_of_parameters(num_parameters)
154
+ self.set_num_parameter(num_parameters)
150
155
  self._is_function_simplextree = False
151
156
  self.filtration_grid=[[]*num_parameters]
152
157
 
@@ -158,6 +163,9 @@ cdef class SimplexTreeMulti_KFi32:
158
163
 
159
164
  def __repr__(self):
160
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
+
161
169
  def __getstate__(self):
162
170
  """:returns: Serialized (or flattened) SimplexTree data structure in order to pickle SimplexTree.
163
171
  :rtype: numpy.array of shape (n,)
@@ -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,)
@@ -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,)
@@ -3652,7 +3676,7 @@ cdef class SimplexTreeMulti_Fi64:
3652
3676
 
3653
3677
  # cdef Simplex_tree_persistence_interface * pcohptr
3654
3678
  # Fake constructor that does nothing but documenting the constructor
3655
- 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):
3656
3680
  """SimplexTreeMulti constructor.
3657
3681
 
3658
3682
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.
@@ -3677,7 +3701,7 @@ cdef class SimplexTreeMulti_Fi64:
3677
3701
  def is_kcritical(self)->bool:
3678
3702
  return False
3679
3703
  # The real cython constructor
3680
- def __cinit__(self, other = None, int num_parameters=2,
3704
+ def __cinit__(self, other = None, int num_parameters=-1,
3681
3705
  default_values=np.asarray([SimplexTreeMulti_Fi64.T_minus_inf()]), # I'm not sure why `[]` does not work. Cython bug ?
3682
3706
  bool safe_conversion=False,
3683
3707
  ): #TODO doc
@@ -3690,10 +3714,13 @@ cdef class SimplexTreeMulti_Fi64:
3690
3714
  if isinstance(other, SimplexTreeMulti_Fi64):
3691
3715
  other_ptr = other.thisptr
3692
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
3693
- num_parameters = other.num_parameters
3717
+ if num_parameters <=0:
3718
+ num_parameters = other.num_parameters
3694
3719
  self.filtration_grid = other.filtration_grid
3695
3720
  elif isinstance(other, SimplexTree): # Constructs a SimplexTreeMulti from a SimplexTree
3696
3721
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Fi64, int64_t]())
3722
+ if num_parameters <= 0:
3723
+ num_parameters = 1
3697
3724
  if safe_conversion or SAFE_CONVERSION:
3698
3725
  new_st_multi = _safe_simplextree_multify_Fi64(other, num_parameters = num_parameters, default_values=np.asarray(default_values))
3699
3726
  self.thisptr, new_st_multi.thisptr = new_st_multi.thisptr, self.thisptr
@@ -3708,8 +3735,10 @@ cdef class SimplexTreeMulti_Fi64:
3708
3735
  else:
3709
3736
  raise TypeError("`other` argument requires to be of type `SimplexTree`, `SimplexTreeMulti`, or `None`.")
3710
3737
  else:
3738
+ if num_parameters <=0:
3739
+ num_parameters = 2 # I don't know how dangerous this is, but this is mostly used.
3711
3740
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Fi64, int64_t]())
3712
- self.get_ptr().set_number_of_parameters(num_parameters)
3741
+ self.set_num_parameter(num_parameters)
3713
3742
  self._is_function_simplextree = False
3714
3743
  self.filtration_grid=[[]*num_parameters]
3715
3744
 
@@ -3721,6 +3750,9 @@ cdef class SimplexTreeMulti_Fi64:
3721
3750
 
3722
3751
  def __repr__(self):
3723
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
+
3724
3756
  def __getstate__(self):
3725
3757
  """:returns: Serialized (or flattened) SimplexTree data structure in order to pickle SimplexTree.
3726
3758
  :rtype: numpy.array of shape (n,)
@@ -5023,7 +5055,7 @@ cdef class SimplexTreeMulti_KFf32:
5023
5055
 
5024
5056
  # cdef Simplex_tree_persistence_interface * pcohptr
5025
5057
  # Fake constructor that does nothing but documenting the constructor
5026
- 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):
5027
5059
  """SimplexTreeMulti constructor.
5028
5060
 
5029
5061
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.
@@ -5048,7 +5080,7 @@ cdef class SimplexTreeMulti_KFf32:
5048
5080
  def is_kcritical(self)->bool:
5049
5081
  return True
5050
5082
  # The real cython constructor
5051
- def __cinit__(self, other = None, int num_parameters=2,
5083
+ def __cinit__(self, other = None, int num_parameters=-1,
5052
5084
  default_values=np.asarray([SimplexTreeMulti_KFf32.T_minus_inf()]), # I'm not sure why `[]` does not work. Cython bug ?
5053
5085
  bool safe_conversion=False,
5054
5086
  ): #TODO doc
@@ -5061,10 +5093,13 @@ cdef class SimplexTreeMulti_KFf32:
5061
5093
  if isinstance(other, SimplexTreeMulti_KFf32):
5062
5094
  other_ptr = other.thisptr
5063
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
5064
- num_parameters = other.num_parameters
5096
+ if num_parameters <=0:
5097
+ num_parameters = other.num_parameters
5065
5098
  self.filtration_grid = other.filtration_grid
5066
5099
  elif isinstance(other, SimplexTree): # Constructs a SimplexTreeMulti from a SimplexTree
5067
5100
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFf32, float]())
5101
+ if num_parameters <= 0:
5102
+ num_parameters = 1
5068
5103
  if safe_conversion or SAFE_CONVERSION:
5069
5104
  new_st_multi = _safe_simplextree_multify_KFf32(other, num_parameters = num_parameters, default_values=np.asarray(default_values))
5070
5105
  self.thisptr, new_st_multi.thisptr = new_st_multi.thisptr, self.thisptr
@@ -5079,8 +5114,10 @@ cdef class SimplexTreeMulti_KFf32:
5079
5114
  else:
5080
5115
  raise TypeError("`other` argument requires to be of type `SimplexTree`, `SimplexTreeMulti`, or `None`.")
5081
5116
  else:
5117
+ if num_parameters <=0:
5118
+ num_parameters = 2 # I don't know how dangerous this is, but this is mostly used.
5082
5119
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFf32, float]())
5083
- self.get_ptr().set_number_of_parameters(num_parameters)
5120
+ self.set_num_parameter(num_parameters)
5084
5121
  self._is_function_simplextree = False
5085
5122
  self.filtration_grid=[[]*num_parameters]
5086
5123
 
@@ -5092,6 +5129,9 @@ cdef class SimplexTreeMulti_KFf32:
5092
5129
 
5093
5130
  def __repr__(self):
5094
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
+
5095
5135
  def __getstate__(self):
5096
5136
  """:returns: Serialized (or flattened) SimplexTree data structure in order to pickle SimplexTree.
5097
5137
  :rtype: numpy.array of shape (n,)
@@ -6119,7 +6159,7 @@ cdef class SimplexTreeMulti_Ff32:
6119
6159
 
6120
6160
  # cdef Simplex_tree_persistence_interface * pcohptr
6121
6161
  # Fake constructor that does nothing but documenting the constructor
6122
- 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):
6123
6163
  """SimplexTreeMulti constructor.
6124
6164
 
6125
6165
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.
@@ -6144,7 +6184,7 @@ cdef class SimplexTreeMulti_Ff32:
6144
6184
  def is_kcritical(self)->bool:
6145
6185
  return False
6146
6186
  # The real cython constructor
6147
- def __cinit__(self, other = None, int num_parameters=2,
6187
+ def __cinit__(self, other = None, int num_parameters=-1,
6148
6188
  default_values=np.asarray([SimplexTreeMulti_Ff32.T_minus_inf()]), # I'm not sure why `[]` does not work. Cython bug ?
6149
6189
  bool safe_conversion=False,
6150
6190
  ): #TODO doc
@@ -6157,10 +6197,13 @@ cdef class SimplexTreeMulti_Ff32:
6157
6197
  if isinstance(other, SimplexTreeMulti_Ff32):
6158
6198
  other_ptr = other.thisptr
6159
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
6160
- num_parameters = other.num_parameters
6200
+ if num_parameters <=0:
6201
+ num_parameters = other.num_parameters
6161
6202
  self.filtration_grid = other.filtration_grid
6162
6203
  elif isinstance(other, SimplexTree): # Constructs a SimplexTreeMulti from a SimplexTree
6163
6204
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Ff32, float]())
6205
+ if num_parameters <= 0:
6206
+ num_parameters = 1
6164
6207
  if safe_conversion or SAFE_CONVERSION:
6165
6208
  new_st_multi = _safe_simplextree_multify_Ff32(other, num_parameters = num_parameters, default_values=np.asarray(default_values))
6166
6209
  self.thisptr, new_st_multi.thisptr = new_st_multi.thisptr, self.thisptr
@@ -6175,8 +6218,10 @@ cdef class SimplexTreeMulti_Ff32:
6175
6218
  else:
6176
6219
  raise TypeError("`other` argument requires to be of type `SimplexTree`, `SimplexTreeMulti`, or `None`.")
6177
6220
  else:
6221
+ if num_parameters <=0:
6222
+ num_parameters = 2 # I don't know how dangerous this is, but this is mostly used.
6178
6223
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Ff32, float]())
6179
- self.get_ptr().set_number_of_parameters(num_parameters)
6224
+ self.set_num_parameter(num_parameters)
6180
6225
  self._is_function_simplextree = False
6181
6226
  self.filtration_grid=[[]*num_parameters]
6182
6227
 
@@ -6188,6 +6233,9 @@ cdef class SimplexTreeMulti_Ff32:
6188
6233
 
6189
6234
  def __repr__(self):
6190
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
+
6191
6239
  def __getstate__(self):
6192
6240
  """:returns: Serialized (or flattened) SimplexTree data structure in order to pickle SimplexTree.
6193
6241
  :rtype: numpy.array of shape (n,)
@@ -7490,7 +7538,7 @@ cdef class SimplexTreeMulti_KFf64:
7490
7538
 
7491
7539
  # cdef Simplex_tree_persistence_interface * pcohptr
7492
7540
  # Fake constructor that does nothing but documenting the constructor
7493
- 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):
7494
7542
  """SimplexTreeMulti constructor.
7495
7543
 
7496
7544
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.
@@ -7515,7 +7563,7 @@ cdef class SimplexTreeMulti_KFf64:
7515
7563
  def is_kcritical(self)->bool:
7516
7564
  return True
7517
7565
  # The real cython constructor
7518
- def __cinit__(self, other = None, int num_parameters=2,
7566
+ def __cinit__(self, other = None, int num_parameters=-1,
7519
7567
  default_values=np.asarray([SimplexTreeMulti_KFf64.T_minus_inf()]), # I'm not sure why `[]` does not work. Cython bug ?
7520
7568
  bool safe_conversion=False,
7521
7569
  ): #TODO doc
@@ -7528,10 +7576,13 @@ cdef class SimplexTreeMulti_KFf64:
7528
7576
  if isinstance(other, SimplexTreeMulti_KFf64):
7529
7577
  other_ptr = other.thisptr
7530
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
7531
- num_parameters = other.num_parameters
7579
+ if num_parameters <=0:
7580
+ num_parameters = other.num_parameters
7532
7581
  self.filtration_grid = other.filtration_grid
7533
7582
  elif isinstance(other, SimplexTree): # Constructs a SimplexTreeMulti from a SimplexTree
7534
7583
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFf64, double]())
7584
+ if num_parameters <= 0:
7585
+ num_parameters = 1
7535
7586
  if safe_conversion or SAFE_CONVERSION:
7536
7587
  new_st_multi = _safe_simplextree_multify_KFf64(other, num_parameters = num_parameters, default_values=np.asarray(default_values))
7537
7588
  self.thisptr, new_st_multi.thisptr = new_st_multi.thisptr, self.thisptr
@@ -7546,8 +7597,10 @@ cdef class SimplexTreeMulti_KFf64:
7546
7597
  else:
7547
7598
  raise TypeError("`other` argument requires to be of type `SimplexTree`, `SimplexTreeMulti`, or `None`.")
7548
7599
  else:
7600
+ if num_parameters <=0:
7601
+ num_parameters = 2 # I don't know how dangerous this is, but this is mostly used.
7549
7602
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[KFf64, double]())
7550
- self.get_ptr().set_number_of_parameters(num_parameters)
7603
+ self.set_num_parameter(num_parameters)
7551
7604
  self._is_function_simplextree = False
7552
7605
  self.filtration_grid=[[]*num_parameters]
7553
7606
 
@@ -7559,6 +7612,9 @@ cdef class SimplexTreeMulti_KFf64:
7559
7612
 
7560
7613
  def __repr__(self):
7561
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
+
7562
7618
  def __getstate__(self):
7563
7619
  """:returns: Serialized (or flattened) SimplexTree data structure in order to pickle SimplexTree.
7564
7620
  :rtype: numpy.array of shape (n,)
@@ -8586,7 +8642,7 @@ cdef class SimplexTreeMulti_Ff64:
8586
8642
 
8587
8643
  # cdef Simplex_tree_persistence_interface * pcohptr
8588
8644
  # Fake constructor that does nothing but documenting the constructor
8589
- 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):
8590
8646
  """SimplexTreeMulti constructor.
8591
8647
 
8592
8648
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.
@@ -8611,7 +8667,7 @@ cdef class SimplexTreeMulti_Ff64:
8611
8667
  def is_kcritical(self)->bool:
8612
8668
  return False
8613
8669
  # The real cython constructor
8614
- def __cinit__(self, other = None, int num_parameters=2,
8670
+ def __cinit__(self, other = None, int num_parameters=-1,
8615
8671
  default_values=np.asarray([SimplexTreeMulti_Ff64.T_minus_inf()]), # I'm not sure why `[]` does not work. Cython bug ?
8616
8672
  bool safe_conversion=False,
8617
8673
  ): #TODO doc
@@ -8624,10 +8680,13 @@ cdef class SimplexTreeMulti_Ff64:
8624
8680
  if isinstance(other, SimplexTreeMulti_Ff64):
8625
8681
  other_ptr = other.thisptr
8626
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
8627
- num_parameters = other.num_parameters
8683
+ if num_parameters <=0:
8684
+ num_parameters = other.num_parameters
8628
8685
  self.filtration_grid = other.filtration_grid
8629
8686
  elif isinstance(other, SimplexTree): # Constructs a SimplexTreeMulti from a SimplexTree
8630
8687
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Ff64, double]())
8688
+ if num_parameters <= 0:
8689
+ num_parameters = 1
8631
8690
  if safe_conversion or SAFE_CONVERSION:
8632
8691
  new_st_multi = _safe_simplextree_multify_Ff64(other, num_parameters = num_parameters, default_values=np.asarray(default_values))
8633
8692
  self.thisptr, new_st_multi.thisptr = new_st_multi.thisptr, self.thisptr
@@ -8642,8 +8701,10 @@ cdef class SimplexTreeMulti_Ff64:
8642
8701
  else:
8643
8702
  raise TypeError("`other` argument requires to be of type `SimplexTree`, `SimplexTreeMulti`, or `None`.")
8644
8703
  else:
8704
+ if num_parameters <=0:
8705
+ num_parameters = 2 # I don't know how dangerous this is, but this is mostly used.
8645
8706
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[Ff64, double]())
8646
- self.get_ptr().set_number_of_parameters(num_parameters)
8707
+ self.set_num_parameter(num_parameters)
8647
8708
  self._is_function_simplextree = False
8648
8709
  self.filtration_grid=[[]*num_parameters]
8649
8710
 
@@ -8655,6 +8716,9 @@ cdef class SimplexTreeMulti_Ff64:
8655
8716
 
8656
8717
  def __repr__(self):
8657
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
+
8658
8722
  def __getstate__(self):
8659
8723
  """:returns: Serialized (or flattened) SimplexTree data structure in order to pickle SimplexTree.
8660
8724
  :rtype: numpy.array of shape (n,)
@@ -9968,7 +10032,7 @@ def is_simplextree_multi(input)->bool:
9968
10032
 
9969
10033
 
9970
10034
 
9971
- 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:
9972
10036
  """SimplexTreeMulti constructor.
9973
10037
 
9974
10038
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.
@@ -106,7 +106,7 @@ cdef class SimplexTreeMulti_{{FSHORT}}:
106
106
 
107
107
  # cdef Simplex_tree_persistence_interface * pcohptr
108
108
  # Fake constructor that does nothing but documenting the constructor
109
- def __init__(self, other = None, num_parameters:int=2,default_values=[], safe_conversion=False):
109
+ def __init__(self, other = None, num_parameters:int=-1,default_values=[], safe_conversion=False):
110
110
  """SimplexTreeMulti constructor.
111
111
 
112
112
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.
@@ -139,7 +139,7 @@ cdef class SimplexTreeMulti_{{FSHORT}}:
139
139
  def is_kcritical(self)->bool:
140
140
  return {{is_kcritical}}
141
141
  # The real cython constructor
142
- def __cinit__(self, other = None, int num_parameters=2,
142
+ def __cinit__(self, other = None, int num_parameters=-1,
143
143
  default_values=np.asarray([SimplexTreeMulti_{{FSHORT}}.T_minus_inf()]), # I'm not sure why `[]` does not work. Cython bug ?
144
144
  bool safe_conversion=False,
145
145
  ): #TODO doc
@@ -156,10 +156,13 @@ cdef class SimplexTreeMulti_{{FSHORT}}:
156
156
  if isinstance(other, SimplexTreeMulti_{{FSHORT}}):
157
157
  other_ptr = other.thisptr
158
158
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[{{FSHORT}}, {{CTYPE}}](dereference(<Simplex_tree_multi_interface[{{FSHORT}}, {{CTYPE}}]*>other_ptr))) ## prevents calling destructor of other
159
- num_parameters = other.num_parameters
159
+ if num_parameters <=0:
160
+ num_parameters = other.num_parameters
160
161
  self.filtration_grid = other.filtration_grid
161
162
  elif isinstance(other, SimplexTree): # Constructs a SimplexTreeMulti from a SimplexTree
162
163
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[{{FSHORT}}, {{CTYPE}}]())
164
+ if num_parameters <= 0:
165
+ num_parameters = 1
163
166
  if safe_conversion or SAFE_CONVERSION:
164
167
  new_st_multi = _safe_simplextree_multify_{{FSHORT}}(other, num_parameters = num_parameters, default_values=np.asarray(default_values))
165
168
  self.thisptr, new_st_multi.thisptr = new_st_multi.thisptr, self.thisptr
@@ -174,8 +177,10 @@ cdef class SimplexTreeMulti_{{FSHORT}}:
174
177
  else:
175
178
  raise TypeError("`other` argument requires to be of type `SimplexTree`, `SimplexTreeMulti`, or `None`.")
176
179
  else:
180
+ if num_parameters <=0:
181
+ num_parameters = 2 # I don't know how dangerous this is, but this is mostly used.
177
182
  self.thisptr = <intptr_t>(new Simplex_tree_multi_interface[{{FSHORT}}, {{CTYPE}}]())
178
- self.get_ptr().set_number_of_parameters(num_parameters)
183
+ self.set_num_parameter(num_parameters)
179
184
  self._is_function_simplextree = False
180
185
  self.filtration_grid=[[]*num_parameters]
181
186
 
@@ -187,6 +192,9 @@ cdef class SimplexTreeMulti_{{FSHORT}}:
187
192
 
188
193
  def __repr__(self):
189
194
  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}]"
195
+ def __len__(self):
196
+ return self.num_simplices
197
+
190
198
  def __getstate__(self):
191
199
  """:returns: Serialized (or flattened) SimplexTree data structure in order to pickle SimplexTree.
192
200
  :rtype: numpy.array of shape (n,)
@@ -1632,7 +1640,7 @@ def is_simplextree_multi(input)->bool:
1632
1640
 
1633
1641
 
1634
1642
 
1635
- def SimplexTreeMulti(input=None, int num_parameters=2, dtype:type = np.float64, bool kcritical = False,**kwargs) -> SimplexTreeMulti_type:
1643
+ def SimplexTreeMulti(input=None, int num_parameters=-1, dtype:type = np.float64, bool kcritical = False,**kwargs) -> SimplexTreeMulti_type:
1636
1644
  """SimplexTreeMulti constructor.
1637
1645
 
1638
1646
  :param other: If `other` is `None` (default value), an empty `SimplexTreeMulti` is created.
Binary file