Skip to content

Commit

Permalink
Update _sparsekde.py
Browse files Browse the repository at this point in the history
  • Loading branch information
GardevoirX committed Aug 12, 2024
1 parent 1e3d2e3 commit 939e0a4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/skmatter/utils/_sparsekde.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ def effdim(cov):
eigval = np.linalg.eigvals(cov)
eigval /= sum(eigval)
eigval *= np.log(eigval)
if (lowest_eigval := np.min(eigval)) <= -np.max(X.shape)*np.finfo(X.dtype).eps:
raise np.linalg.LinAlgError(f"Matrix is not positive definite. Lowest eigenvalue {lowest_eigval} is above numerical threshold.")
if (lowest_eigval := np.min(eigval)) <= -np.max(cov.shape)*np.finfo(cov.dtype).eps:
raise np.linalg.LinAlgError(f"Matrix is not positive definite. Lowest eigenvalue "
f"{lowest_eigval} is above numerical threshold.")
eigval[eigval <= 0.] = 0.0

return np.exp(-sum(eigval))
Expand Down

0 comments on commit 939e0a4

Please sign in to comment.