New test for matrix inverse with matrix containing floats r integers

This commit is contained in:
Fabian Joswig 2021-10-17 12:45:30 +01:00
parent 10b228d434
commit 15333d2629
2 changed files with 13 additions and 1 deletions

View file

@ -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."""

View file

@ -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)