def test_run_Continuous_231(self): """ Test suite for standard Continuous 2.3.1. models. This test contains basic models, with very minimal modifications. It also assumes the standard 1 SD BMR. Note that in the polynomial case, the degree_poly value is overridden from the default. """ session = BMD_session(BMDS_version='2.31', bmrs=self.bmr_c) run_suite = ( { 'type': 'Linear', 'fn': '2-continuous-tc-LinearCV-1SD.out' }, { 'type': 'Polynomial', 'fn': '2-continuous-tc-Poly4CV-1SD.out', 'override': { 'degree_poly': 4, 'restrict_polynomial': 1 }, 'override_text': ['Degree of Polynomial = 4'] }, { 'type': 'Power', 'fn': '2-continuous-tc-PowerCV-1SD.out' }, { 'type': 'Hill', 'fn': '2-continuous-tc-HillCV-1SD.out' }, { 'type': 'Exponential-M2', 'fn': '2-continuous-tc-M2M2ExpCV-1SD.out' }, { 'type': 'Exponential-M3', 'fn': '2-continuous-tc-M3M3ExpCV-1SD.out' }, { 'type': 'Exponential-M4', 'fn': '2-continuous-tc-M4M4ExpCV-1SD.out' }, { 'type': 'Exponential-M5', 'fn': '2-continuous-tc-M5M5ExpCV-1SD.out' }, ) for run in run_suite: logging.debug('Testing ' + run['fn']) m_run = self.v.models['C'][run['type']]() if 'override' in run: m_run.update_model(run['override'], run['override_text'], self.bmr_c) m = BMD_model_run(model_name=run['type'], BMD_session=session, option_override={}, option_override_text=[""]) m.run_model(self.v, m_run, self.dataset_continuous) output_text = m.output_text.splitlines()[10:] fn = os.path.join(BMDS_TEST_PATH, run['fn']) gold_standard = self.import_bmds_output_file(fn) # with open(os.path.join(BMDS_TEST_PATH, 'test_output.txt'), 'w') as f: # f.write('\n'.join(output_text)) # with open(os.path.join(BMDS_TEST_PATH, 'gold_standard.txt'), 'w') as f: # f.write('\n'.join(gold_standard)) self.assertTrue(output_text == gold_standard)
def test_run_Continuous_231(self): """ Test suite for standard Continuous 2.3.1. models. This test contains basic models, with very minimal modifications. It also assumes the standard 1 SD BMR. Note that in the polynomial case, the degree_poly value is overridden from the default. """ session = BMD_session(BMDS_version='2.31', bmrs=self.bmr_c) run_suite = ( { 'type': 'Linear', 'fn': '2-continuous-tc-LinearCV-1SD.out' }, { 'type': 'Polynomial', 'fn': '2-continuous-tc-Poly4CV-1SD.out', 'override': { 'degree_poly': 4, 'restrict_polynomial': 1 }, 'override_text': ['Degree of Polynomial = 4'] }, { 'type': 'Power', 'fn': '2-continuous-tc-PowerCV-1SD.out' }, { 'type': 'Hill', 'fn': '2-continuous-tc-HillCV-1SD.out' }, { 'type': 'Exponential-M2', 'fn': '2-continuous-tc-M2M2ExpCV-1SD.out' }, { 'type': 'Exponential-M3', 'fn': '2-continuous-tc-M3M3ExpCV-1SD.out' }, { 'type': 'Exponential-M4', 'fn': '2-continuous-tc-M4M4ExpCV-1SD.out' }, { 'type': 'Exponential-M5', 'fn': '2-continuous-tc-M5M5ExpCV-1SD.out' }, ) for run in run_suite: logging.debug('Testing ' + run['fn']) m_run = self.v.models['C'][run['type']]() if 'override' in run: m_run.update_model(run['override'], run['override_text'], self.bmr_c) m = BMD_model_run( model_name=run['type'], BMD_session=session, option_override={}, option_override_text=[""]) m.run_model(self.v, m_run, self.dataset_continuous) output_text = m.output_text.splitlines()[10:] fn = os.path.join(BMDS_TEST_PATH, run['fn']) gold_standard = self.import_bmds_output_file(fn) # with open(os.path.join(BMDS_TEST_PATH, 'test_output.txt'), 'w') as f: # f.write('\n'.join(output_text)) # with open(os.path.join(BMDS_TEST_PATH, 'gold_standard.txt'), 'w') as f: # f.write('\n'.join(gold_standard)) self.assertTrue(output_text == gold_standard)
def test_run_Dichotomous_231(self): """ Test suite for standard Dichotomous 2.3.1. models. This test contains basic models, with very minimal modifications. It also assumes the standard 10% BMR check. Note that in a few multistage cases, the degree_poly value is overridden from the default. """ session = BMD_session(BMDS_version='2.31', bmrs=self.bmr_d) run_suite = ( { 'type': 'Logistic', 'fn': '1-dichotomous-tc-Logistic-10%.out' }, { 'type': 'LogLogistic', 'fn': '1-dichotomous-tc-LogLogistic-10%.out' }, { 'type': 'Weibull', 'fn': '1-dichotomous-tc-Weibull-10%.out' }, { 'type': 'Probit', 'fn': '1-dichotomous-tc-Probit-10%.out' }, { 'type': 'LogProbit', 'fn': '1-dichotomous-tc-LogProbit-10%.out' }, { 'type': 'Gamma', 'fn': '1-dichotomous-tc-Gamma-10%.out' }, { 'type': 'Multistage', 'fn': '1-dichotomous-tc-Multi1-10%.out', 'override': { 'degree_poly': 1 }, 'override_text': ['Degree of Polynomial = 1'] }, { 'type': 'Multistage', 'fn': '1-dichotomous-tc-Multi2-10%.out', 'override': { 'degree_poly': 2 }, # todo: these lines shouldn't be required, think parent class needs to update child class 'override_text': ['Degree of Polynomial = 2'] }, { 'type': 'Multistage', 'fn': '1-dichotomous-tc-Multi3-10%.out', 'override': { 'degree_poly': 3 }, 'override_text': ['Degree of Polynomial = 3'] }, ) for run in run_suite: logging.debug('Testing ' + run['fn']) m_run = self.v.models['D'][run['type']]() if 'override' in run: m_run.update_model(run['override'], run['override_text'], self.bmr_d) m = BMD_model_run(model_name=run['type'], BMD_session=session, option_override={}, option_override_text=[""]) m.run_model(self.v, m_run, self.dataset_dichotomous) output_text = m.output_text.splitlines()[10:] fn = os.path.join(BMDS_TEST_PATH, run['fn']) gold_standard = self.import_bmds_output_file(fn) # f = file(os.path.join(BMDS_TEST_PATH, 'test_output.txt'), 'w') # f.write('\n'.join(output_text)) # f.close() # f = file(os.path.join(BMDS_TEST_PATH, 'gold_standard.txt'), 'w') # f.write('\n'.join(gold_standard)) # f.close() self.assertTrue(output_text == gold_standard)
def test_run_Dichotomous_231(self): """ Test suite for standard Dichotomous 2.3.1. models. This test contains basic models, with very minimal modifications. It also assumes the standard 10% BMR check. Note that in a few multistage cases, the degree_poly value is overridden from the default. """ session = BMD_session(BMDS_version='2.31', bmrs=self.bmr_d) run_suite = ( { 'type': 'Logistic', 'fn': '1-dichotomous-tc-Logistic-10%.out' }, { 'type': 'LogLogistic', 'fn': '1-dichotomous-tc-LogLogistic-10%.out' }, { 'type': 'Weibull', 'fn': '1-dichotomous-tc-Weibull-10%.out' }, { 'type': 'Probit', 'fn': '1-dichotomous-tc-Probit-10%.out' }, { 'type': 'LogProbit', 'fn': '1-dichotomous-tc-LogProbit-10%.out' }, { 'type': 'Gamma', 'fn': '1-dichotomous-tc-Gamma-10%.out' }, { 'type': 'Multistage', 'fn': '1-dichotomous-tc-Multi1-10%.out', 'override': {'degree_poly': 1}, 'override_text': ['Degree of Polynomial = 1'] }, { 'type': 'Multistage', 'fn': '1-dichotomous-tc-Multi2-10%.out', 'override': {'degree_poly': 2}, # todo: these lines shouldn't be required, think parent class needs to update child class 'override_text': ['Degree of Polynomial = 2'] }, { 'type': 'Multistage', 'fn': '1-dichotomous-tc-Multi3-10%.out', 'override': {'degree_poly': 3}, 'override_text': ['Degree of Polynomial = 3'] }, ) for run in run_suite: logging.debug('Testing ' + run['fn']) m_run = self.v.models['D'][run['type']]() if 'override' in run: m_run.update_model(run['override'], run['override_text'], self.bmr_d) m = BMD_model_run( model_name=run['type'], BMD_session=session, option_override={}, option_override_text=[""]) m.run_model(self.v, m_run, self.dataset_dichotomous) output_text = m.output_text.splitlines()[10:] fn = os.path.join(BMDS_TEST_PATH, run['fn']) gold_standard = self.import_bmds_output_file(fn) # f = file(os.path.join(BMDS_TEST_PATH, 'test_output.txt'), 'w') # f.write('\n'.join(output_text)) # f.close() # f = file(os.path.join(BMDS_TEST_PATH, 'gold_standard.txt'), 'w') # f.write('\n'.join(gold_standard)) # f.close() self.assertTrue(output_text == gold_standard)