def test_splrep_errors(self): # test that both "old" and "new" splrep raise for an n-D ``y`` array # with n > 1 x, y = self.xx, self.yy y2 = np.c_[y, y] with assert_raises(ValueError): splrep(x, y2) with assert_raises(ValueError): _impl.splrep(x, y2) # input below minimum size with assert_raises(TypeError, match="m > k must hold"): splrep(x[:3], y[:3]) with assert_raises(TypeError, match="m > k must hold"): _impl.splrep(x[:3], y[:3])
def test_splrep_errors(self): # test that both "old" and "new" splrep raise for an n-D ``y`` array # with n > 1 x, y = self.xx, self.yy y2 = np.c_[y, y] with assert_raises(ValueError): splrep(x, y2) with assert_raises(ValueError): _impl.splrep(x, y2) # input below minimum size with assert_raises(TypeError, match="m > k must hold"): splrep(x[:3], y[:3]) with assert_raises(TypeError, match="m > k must hold"): _impl.splrep(x[:3], y[:3])
def test_splrep_errors(self): # test that both "old" and "new" splrep raise for an n-D ``y`` array # with n > 1 x, y = self.xx, self.yy y2 = np.c_[y, y] msg = "failed in converting 3rd argument `y' of dfitpack.curfit to C/Fortran array" with assert_raises(Exception, message=msg): splrep(x, y2) with assert_raises(Exception, message=msg): _impl.splrep(x, y2) # input below minimum size with assert_raises(TypeError, message="m > k must hold"): splrep(x[:3], y[:3]) with assert_raises(TypeError, message="m > k must hold"): _impl.splrep(x[:3], y[:3])
def test_splrep(self): x, y = self.xx, self.yy # test that "new" splrep is equivalent to _impl.splrep tck = splrep(x, y) t, c, k = _impl.splrep(x, y) assert_allclose(tck[0], t, atol=1e-15) assert_allclose(tck[1], c, atol=1e-15) assert_equal(tck[2], k) # also cover the `full_output=True` branch tck_f, _, _, _ = splrep(x, y, full_output=True) assert_allclose(tck_f[0], t, atol=1e-15) assert_allclose(tck_f[1], c, atol=1e-15) assert_equal(tck_f[2], k) # test that the result of splrep roundtrips with splev: # evaluate the spline on the original `x` points yy = splev(x, tck) assert_allclose(y, yy, atol=1e-15) # ... and also it roundtrips if wrapped in a BSpline b = BSpline(*tck) assert_allclose(y, b(x), atol=1e-15) # test that both "old" and "new" splrep raise for an n-D ``y`` array # with n > 1 y2 = np.c_[y, y] assert_raises(Exception, splrep, x, y2) assert_raises(Exception, _impl.splrep, x, y2)
def test_splrep_errors(self): # test that both "old" and "new" splrep raise for an n-D ``y`` array # with n > 1 x, y = self.xx, self.yy y2 = np.c_[y, y] msg = "failed in converting 3rd argument `y' of dfitpack.curfit to C/Fortran array" with assert_raises(Exception, message=msg): splrep(x, y2) with assert_raises(Exception, message=msg): _impl.splrep(x, y2) # input below minimum size with assert_raises(TypeError, message="m > k must hold"): splrep(x[:3], y[:3]) with assert_raises(TypeError, message="m > k must hold"): _impl.splrep(x[:3], y[:3])
def test_splrep(self): x, y = self.xx, self.yy # test that "new" splrep is equivalent to _impl.splrep tck = splrep(x, y) t, c, k = _impl.splrep(x, y) assert_allclose(tck[0], t, atol=1e-15) assert_allclose(tck[1], c, atol=1e-15) assert_equal(tck[2], k) # also cover the `full_output=True` branch tck_f, _, _, _ = splrep(x, y, full_output=True) assert_allclose(tck_f[0], t, atol=1e-15) assert_allclose(tck_f[1], c, atol=1e-15) assert_equal(tck_f[2], k) # test that the result of splrep roundtrips with splev: # evaluate the spline on the original `x` points yy = splev(x, tck) assert_allclose(y, yy, atol=1e-15) # ... and also it roundtrips if wrapped in a BSpline b = BSpline(*tck) assert_allclose(y, b(x), atol=1e-15) # test that both "old" and "new" splrep raise for an n-D ``y`` array # with n > 1 y2 = np.c_[y, y] assert_raises(Exception, splrep, x, y2) assert_raises(Exception, _impl.splrep, x, y2)