mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 14:50:25 +01:00
New test for matrix inverse with matrix containing floats r integers
This commit is contained in:
parent
10b228d434
commit
15333d2629
2 changed files with 13 additions and 1 deletions
|
@ -345,7 +345,7 @@ class Obs:
|
|||
return np.abs(self.value) <= self.dvalue
|
||||
|
||||
def is_zero(self):
|
||||
np.isclose(0.0, self.value) and all(np.allclose(0.0, delta) for delta in self.deltas.values())
|
||||
return np.isclose(0.0, self.value) and all(np.allclose(0.0, delta) for delta in self.deltas.values())
|
||||
|
||||
def plot_tauint(self, save=None):
|
||||
"""Plot integrated autocorrelation time for each ensemble."""
|
||||
|
|
|
@ -6,6 +6,18 @@ import pytest
|
|||
np.random.seed(0)
|
||||
|
||||
|
||||
def test_matrix_inverse():
|
||||
content = []
|
||||
for t in range(9):
|
||||
exponent = np.random.normal(3, 5)
|
||||
content.append(pe.pseudo_Obs(2 + 10 ** exponent, 10 ** (exponent - 1), 't'))
|
||||
|
||||
content.append(1.0) # Add 1.0 as a float
|
||||
matrix = np.diag(content)
|
||||
inverse_matrix = pe.linalg.mat_mat_op(np.linalg.inv, matrix)
|
||||
assert all([o.is_zero() for o in np.diag(matrix) * np.diag(inverse_matrix) - 1])
|
||||
|
||||
|
||||
def test_matrix_functions():
|
||||
dim = 3 + int(4 * np.random.rand())
|
||||
print(dim)
|
||||
|
|
Loading…
Add table
Reference in a new issue