def test_diff_cache(self): poly1 = Polynom1D() poly2 = Polynom1D() poly3 = Polynom1D() poly1.pars[1].thaw() poly2.pars[1].thaw() poly3.pars[1].thaw() sdata = DataSimulFit('d123', (self.d1, self.d2, self.d3)) smodel = SimulFitModel('diff', (poly1, poly2, poly3)) sfit = Fit(sdata, smodel, method=NelderMead(), stat=Cash()) result = sfit.fit() self.compare_results(self._fit_diff_poly_bench, result)
def test_data_1d_int_eval_model_to_fit_filter(data): model = Polynom1D() model.c0 = 0 model.c1 = MULTIPLIER data.mask = X_ARRAY <= X_THRESHOLD evaluated_data = data.eval_model_to_fit(model) numpy.testing.assert_array_equal(evaluated_data, MULTIPLIER * X_ARRAY[:X_THRESHOLD + 1])
def test_same_cache(self): poly = Polynom1D() poly.pars[1].thaw() sdata = DataSimulFit('d1d2d3', (self.d1, self.d2, self.d3)) smodel = SimulFitModel('same', (poly, poly, poly)) sfit = Fit(sdata, smodel, method=NelderMead(), stat=Cash()) result = sfit.fit() self.compare_results(self._fit_same_poly_bench, result)
def test_data_simul_fit_eval_model_to_fit(data_simul_fit): model = Polynom1D() model.c0 = 0 model.c1 = MULTIPLIER data_simul_fit.datasets[0].mask = X_ARRAY <= X_THRESHOLD data_simul_fit.datasets[1].mask = X_ARRAY <= X_THRESHOLD evaluated_data = data_simul_fit.eval_model_to_fit((model, model)) expected_data = numpy.concatenate((MULTIPLIER * X_ARRAY[:X_THRESHOLD+1], MULTIPLIER**2 * X_ARRAY[:X_THRESHOLD+1])) numpy.testing.assert_array_equal(evaluated_data, expected_data)
def test_data_eval_model_to_fit_no_filter(data): model = Polynom1D() model.c0 = 0 model.c1 = MULTIPLIER evaluated_data = data.eval_model_to_fit(model) numpy.testing.assert_array_equal(evaluated_data, MULTIPLIER * X_ARRAY)