summaryrefslogtreecommitdiff
path: root/src/python/gudhi/representations/vector_methods.py
diff options
context:
space:
mode:
authorVincent Rouvreau <vincent.rouvreau@inria.fr>2021-11-04 17:24:15 +0100
committerVincent Rouvreau <vincent.rouvreau@inria.fr>2021-11-04 17:24:15 +0100
commita2761c01ceb26a057b94be1d45433335704c1581 (patch)
tree3b7b39661a9feff5d5eb4e54cfacd036adc83b4e /src/python/gudhi/representations/vector_methods.py
parent4a0bc0fe1d6424da9bf979cfc322067a62f41cc9 (diff)
code review: try-except inside the if
Diffstat (limited to 'src/python/gudhi/representations/vector_methods.py')
-rw-r--r--src/python/gudhi/representations/vector_methods.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/python/gudhi/representations/vector_methods.py b/src/python/gudhi/representations/vector_methods.py
index b83c2a87..e7ee57a4 100644
--- a/src/python/gudhi/representations/vector_methods.py
+++ b/src/python/gudhi/representations/vector_methods.py
@@ -44,15 +44,15 @@ class PersistenceImage(BaseEstimator, TransformerMixin):
X (list of n x 2 numpy arrays): input persistence diagrams.
y (n x 1 array): persistence diagram labels (unused).
"""
- try:
- if np.isnan(np.array(self.im_range)).any():
+ if np.isnan(np.array(self.im_range)).any():
+ try:
new_X = BirthPersistenceTransform().fit_transform(X)
pre = DiagramScaler(use=True, scalers=[([0], MinMaxScaler()), ([1], MinMaxScaler())]).fit(new_X,y)
[mx,my],[Mx,My] = [pre.scalers[0][1].data_min_[0], pre.scalers[1][1].data_min_[0]], [pre.scalers[0][1].data_max_[0], pre.scalers[1][1].data_max_[0]]
self.im_range = np.where(np.isnan(np.array(self.im_range)), np.array([mx, Mx, my, My]), np.array(self.im_range))
- except ValueError:
- # Empty persistence diagram case - https://github.com/GUDHI/gudhi-devel/issues/507
- pass
+ except ValueError:
+ # Empty persistence diagram case - https://github.com/GUDHI/gudhi-devel/issues/507
+ pass
return self
def transform(self, X):