def test_known1(self): """ Test for known value. """ with pytest.warns(exceptions.PhysicsWarning, match="strong coupling effects"): methodVal = mean_free_path(self.T, self.n_e, self.particles, z_mean=np.nan * u.dimensionless_unscaled, V=np.nan * u.m / u.s, method="classical") testTrue = np.isclose(self.True1, methodVal.si.value, rtol=1e-1, atol=0.0) errStr = (f"Mean free path should be {self.True1} and " f"not {methodVal}.") assert testTrue, errStr
def test_fail1(self): """ Tests if test_known1() would fail if we slightly adjusted the value comparison by some quantity close to numerical error. """ fail1 = self.True1 * (1 + 1e-15) with pytest.warns(exceptions.PhysicsWarning, match="strong coupling effects"): methodVal = mean_free_path(self.T, self.n_e, self.particles, z_mean=np.nan * u.dimensionless_unscaled, V=np.nan * u.m / u.s, method="classical") testTrue = not np.isclose( methodVal.si.value, fail1, rtol=1e-16, atol=0.0) errStr = (f"Mean free path value test gives {methodVal} and " f"should not be equal to {fail1}.") assert testTrue, errStr
def test_symmetry(self): result = mean_free_path(self.T, self.n_e, self.particles) resultRev = mean_free_path(self.T, self.n_e, self.particles[::-1]) assert result == resultRev