def test_zmean(self): """Testing mobility when z_mean is passed.""" with pytest.warns(exceptions.PhysicsWarning, match="strong coupling effects"): methodVal = mobility( self.T, self.n_e, self.particles, z_mean=self.z_mean, V=np.nan * u.m / u.s, method="classical", ) testTrue = np.isclose(self.True_zmean, methodVal.si.value, rtol=1e-1, atol=0.0) errStr = f"Mobility should be {self.True_zmean} and " f"not {methodVal}." assert testTrue, errStr
def test_known1(self): """ Test for known value. """ with pytest.warns(exceptions.PhysicsWarning, match="strong coupling effects"): methodVal = mobility( 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"Mobility 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 = mobility( 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"Mobility value test gives {methodVal} and " f"should not be equal to {fail1}." ) assert testTrue, errStr
def test_symmetry(self): with pytest.warns(CouplingWarning): result = mobility(self.T, self.n_e, self.particles) resultRev = mobility(self.T, self.n_e, self.particles[::-1]) assert result == resultRev