Ejemplo n.º 1
0
def test_bootstrap(tmp_path, testdata):
    with TemporaryDirectoryChanger(tmp_path):
        shutil.copy2(testdata / 'nonmem' / 'pheno.mod', tmp_path)
        shutil.copy2(testdata / 'nonmem' / 'pheno.dta', tmp_path)
        model = Model('pheno.mod')
        model.dataset_path = tmp_path / 'pheno.dta'
        res = Bootstrap(model, 3).run()
        assert len(res.parameter_estimates) == 3
Ejemplo n.º 2
0
def test_fit_single(tmp_path, testdata):
    with TemporaryDirectoryChanger(tmp_path):
        shutil.copy2(testdata / 'nonmem' / 'pheno.mod', tmp_path)
        shutil.copy2(testdata / 'nonmem' / 'pheno.dta', tmp_path)
        model = Model('pheno.mod')
        model.dataset_path = tmp_path / 'pheno.dta'
        modeling.fit(model)
        rundir = tmp_path / 'modelfit_dir1'
        assert model.modelfit_results.ofv == pytest.approx(730.8947268137308)
        assert rundir.is_dir()
Ejemplo n.º 3
0
def test_fit_multiple(tmp_path, testdata):
    with TemporaryDirectoryChanger(tmp_path):
        shutil.copy2(testdata / 'nonmem' / 'pheno.mod',
                     tmp_path / 'pheno_1.mod')
        shutil.copy2(testdata / 'nonmem' / 'pheno.dta',
                     tmp_path / 'pheno_1.dta')
        model_1 = Model('pheno_1.mod')
        model_1.dataset_path = tmp_path / 'pheno_1.dta'
        model_1.update_source()
        shutil.copy2(testdata / 'nonmem' / 'pheno.mod',
                     tmp_path / 'pheno_2.mod')
        shutil.copy2(testdata / 'nonmem' / 'pheno.dta',
                     tmp_path / 'pheno_2.dta')
        model_2 = Model('pheno_2.mod')
        model_2.dataset_path = tmp_path / 'pheno_2.dta'
        model_2.update_source()
        modeling.fit([model_1, model_2])
        rundir = tmp_path / 'modelfit_dir1'
        assert model_1.modelfit_results.ofv == pytest.approx(730.8947268137308)
        assert model_2.modelfit_results.ofv == pytest.approx(730.8947268137308)
        assert rundir.is_dir()