Skip to content

Commit

Permalink
Update src/skmatter/utils/_sparsekde.py
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Goscinski <[email protected]>
  • Loading branch information
GardevoirX and agoscinski authored Aug 12, 2024
1 parent 62b1e0b commit 1e3d2e3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/skmatter/utils/_sparsekde.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def effdim(cov):
eigval = np.linalg.eigvals(cov)
eigval /= sum(eigval)
eigval *= np.log(eigval)
eigval[np.isnan(eigval)] = 0.0
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.")
eigval[eigval <= 0.] = 0.0

return np.exp(-sum(eigval))

Expand Down

0 comments on commit 1e3d2e3

Please sign in to comment.