def test_order_step_combinations(self): for num_terms in [1, 2, 3]: for step in [1, 2]: for order in range(1, 7): r_extrap = Richardson(step_ratio=2.0, step=step, num_terms=num_terms, order=order) rule = r_extrap.rule() # print((num_terms, step, order), rule.tolist()) assert_array_almost_equal(rule, self.true_vals[(num_terms, step, order)])
def test_order_step_combinations(self): for num_terms in [1, 2, 3]: for step in [1, 2]: for order in range(1, 7): r_extrap = Richardson(step_ratio=2.0, step=step, num_terms=num_terms, order=order) rule = r_extrap.rule() # print((num_terms, step, order), rule.tolist()) assert_array_almost_equal( rule, self.true_vals[(num_terms, step, order)])
def set_richardson_rule(self, step_ratio, num_terms=2): order = self._method_order step = self._richardson_step() self.richardson = Richardson(step_ratio=step_ratio, step=step, order=order, num_terms=num_terms)
def __init__(self, fun, step=None, method='above', order=4, full_output=False, **options): self.fun = fun self.method = method self.order = order self.full_output = full_output self.step = step, options self.richardson = Richardson(step_ratio=1.6, step=1, order=1, num_terms=2)
def test_richardson(self): Ei, h = self.Ei[:, np.newaxis], self.h[:, np.newaxis] En, err, _step = Richardson(step=1, order=1)(Ei, h) assert_allclose(En, 1.) self.assertTrue(np.all(err < 0.0022))
def _set_richardson_rule(self, step_ratio, num_terms=2): self.richardson = Richardson(step_ratio=step_ratio, step=1, order=1, num_terms=num_terms)
def test_richardson(self): e_i, h = self.e_i[:, np.newaxis], self.h[:, np.newaxis] e_n, err, _step = Richardson(step=1, order=1)(e_i, h) assert_allclose(e_n, 1.) assert np.all(err < 0.0022)