mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 06:40:24 +01:00
feat: guard added to linalg.eig and tests expect NotImplementedError.
This commit is contained in:
parent
13ace62262
commit
50d975a181
2 changed files with 9 additions and 0 deletions
|
@ -270,6 +270,8 @@ def eigh(obs, **kwargs):
|
|||
|
||||
def eig(obs, **kwargs):
|
||||
"""Computes the eigenvalues of a given matrix of Obs according to np.linalg.eig."""
|
||||
if version.parse(np.__version__) >= version.parse("1.25.0"):
|
||||
raise NotImplementedError("eig error propagation is not working with numpy>=1.25 and autograd==1.5.")
|
||||
w = derived_observable(lambda x, **kwargs: anp.real(anp.linalg.eig(x)[0]), obs)
|
||||
return w
|
||||
|
||||
|
|
|
@ -312,6 +312,13 @@ def test_matrix_functions():
|
|||
|
||||
for (i, j), entry in np.ndenumerate(diff):
|
||||
assert entry.is_zero()
|
||||
else:
|
||||
with pytest.raises(NotImplementedError):
|
||||
pe.linalg.eigh(sym)
|
||||
with pytest.raises(NotImplementedError):
|
||||
pe.linalg.eig(sym)
|
||||
with pytest.raises(NotImplementedError):
|
||||
pe.linalg.svd(sym)
|
||||
|
||||
# Check determinant
|
||||
assert pe.linalg.det(np.diag(np.diag(matrix))) == np.prod(np.diag(matrix))
|
||||
|
|
Loading…
Add table
Reference in a new issue