def test_set_radial_none(self): rf = r_f(6) o = SphericalOrbital(1, rf) o.set_radial() r = np.linspace(0, 6, 400) r0 = o.radial(r) assert np.allclose(r0, 0)
def test_radial_func1(self): r = np.linspace(0, 4, 300) f = np.exp(-r) o = SphericalOrbital(1, (r, f)) print(o) def i_univariate(r, f): return interp.UnivariateSpline(r, f, k=5, s=0, ext=1, check_finite=False) def i_interp1d(r, f): return interp.interp1d(r, f, kind='cubic', fill_value=(f[0], 0.), bounds_error=False) def i_spline(r, f): from functools import partial tck = interp.splrep(r, f, k=5, s=0) return partial(interp.splev, tck=tck, der=0, ext=1) # Interpolation radius R = np.linspace(0, 5, 400) assert np.allclose(o.f(r), f) f_default = o.f(R) o.set_radial(r, f, interp=i_univariate) assert np.allclose(o.f(r), f) f_univariate = o.f(R) o.set_radial(r, f, interp=i_interp1d) assert np.allclose(o.f(r), f) f_interp1d = o.f(R) o.set_radial(r, f, interp=i_spline) assert np.allclose(o.f(r), f) f_spline = o.f(R) # Checks that they are equal assert np.allclose(f_univariate, f_interp1d) assert np.allclose(f_univariate, f_spline) assert np.allclose(f_univariate, f_default)
def test_set_radial1(self): rf = r_f(6) o = SphericalOrbital(1, rf) with pytest.raises(ValueError): o.set_radial(1.)
def test_set_radial1(self): rf = r_f(6) o = SphericalOrbital(1, rf) o.set_radial(1.)