diff options
author | Gard Spreemann <gspr@nonempty.org> | 2021-04-30 15:08:19 +0200 |
---|---|---|
committer | Gard Spreemann <gspr@nonempty.org> | 2021-04-30 15:08:19 +0200 |
commit | 9841a3c845905c9b278ddb7828260a3d6fa5fce7 (patch) | |
tree | a238f1971c8481e5c78dddbbee4ef592732cc9c1 /src/python/gudhi | |
parent | 7d3fba5d1561b3241b914583ac420434e788e27f (diff) |
Allow specifying range for uniform predefined grid for compatibility with old class
Diffstat (limited to 'src/python/gudhi')
-rw-r--r-- | src/python/gudhi/representations/vector_methods.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/python/gudhi/representations/vector_methods.py b/src/python/gudhi/representations/vector_methods.py index 82f071d7..86afaa1c 100644 --- a/src/python/gudhi/representations/vector_methods.py +++ b/src/python/gudhi/representations/vector_methods.py @@ -359,8 +359,8 @@ class BettiCurve2(BaseEstimator, TransformerMixin): Parameters ---------- - predefined_grid: 1d array or None, default=None - Predefined filtration grid points at which to compute the Betti curves. Must be strictly ordered. Infinities are OK. If None (default), a grid will be computed that captures all changes in Betti numbers in the provided data. + predefined_grid: 1d array, triple or None, default=None + Predefined filtration grid points at which to compute the Betti curves. Must be strictly ordered. Infinities are OK. If a triple of the form (l, u, n), the grid will be uniform from l to u in n steps. If None (default), a grid will be computed that captures all changes in Betti numbers in the provided data. Attributes ---------- @@ -382,7 +382,13 @@ class BettiCurve2(BaseEstimator, TransformerMixin): """ def __init__(self, predefined_grid = None): - self.predefined_grid = predefined_grid + if isinstance(predefined_grid, tuple): + if len(predefined_grid) != 3: + raise ValueError("Expected array, None or triple.") + + self.predefined_grid = np.linspace(predefined_grid[0], predefined_grid[1], predefined_grid[2]) + else: + self.predefined_grid = predefined_grid def is_fitted(self): |