Skip to content

Commit

Permalink
fix: inverse whitening transform for singular matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
nicrie committed Sep 14, 2024
1 parent c84c4a4 commit 3645547
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion xeofs/preprocessing/whitener.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ def _compute_whitener_transform_numpy(self, X):
power = (self.alpha - 1) / 2
svd_kwargs = {"random_state": self.random_state, "solver": "full"}

Check warning on line 127 in xeofs/preprocessing/whitener.py

View check run for this annotation

Codecov / codecov/patch

xeofs/preprocessing/whitener.py#L127

Added line #L127 was not covered by tests
T = _fractional_matrix_power(C, power, **svd_kwargs)
Tinv = np.linalg.inv(T)
try:
Tinv = np.linalg.inv(T)
except np.linalg.LinAlgError:
Tinv = np.linalg.pinv(T)

Check warning on line 132 in xeofs/preprocessing/whitener.py

View check run for this annotation

Codecov / codecov/patch

xeofs/preprocessing/whitener.py#L129-L132

Added lines #L129 - L132 were not covered by tests
return T, Tinv

def transform(self, X: DataArray) -> DataArray:
Expand Down

0 comments on commit 3645547

Please sign in to comment.