Skip to content
Snippets Groups Projects
Commit 76b52826 authored by Dennis Noll's avatar Dennis Noll
Browse files

[numpy] adds eigvalsh_ignore_nans

parent 6384b158
No related branches found
No related tags found
No related merge requests found
......@@ -133,3 +133,12 @@ def mean_excl(arr, value=0, axis=0):
def std_excl(arr, value=0, axis=0):
return np.nanstd(value_to_nan(arr, value=value), axis=axis)
def eigvalsh_ignore_nans(matrix):
ret = np.zeros(matrix.shape[:-2] + matrix.shape[-1:])
nans_in_matrix = np.any(np.isnan(matrix), axis=(-2, -1))
good = ~nans_in_matrix
eig = np.linalg.eigvalsh(matrix[good])
ret[good] = eig
return ret
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment