def test_eval_starting_params(self): """ Test that eval_starting_params returns the correct result """ fitting_problem = FittingProblem() self.assertRaises(AttributeError, fitting_problem.eval_starting_params, function_id=0) fitting_problem.functions = [[lambda x, p1: x + p1, [3]], [lambda x, p1: x + p1 + 10, [7]]] fitting_problem.data_x = np.array([1]) eval_result = fitting_problem.eval_starting_params(0) self.assertTrue(all(eval_result == np.array([4]))) eval_result = fitting_problem.eval_starting_params(1) self.assertTrue(all(eval_result == np.array([18])))
def test_eval_starting_params(self): """ Test that eval_starting_params returns the correct result """ fitting_problem = FittingProblem() self.assertRaises(exceptions.FittingProblemError, fitting_problem.eval_starting_params, param_set=0) fitting_problem.function = lambda x, p1: x + p1 fitting_problem.starting_values = [ OrderedDict([('p1', 3)]), OrderedDict([('p1', 7)]) ] fitting_problem.data_x = np.array([1]) eval_result = fitting_problem.eval_starting_params(0) self.assertTrue(all(eval_result == np.array([4]))) eval_result = fitting_problem.eval_starting_params(1) self.assertTrue(all(eval_result == np.array([8])))