def test_len_udN_gt_dsN_case_1(self): ms = ModelSettings() udN = np.ones([1,2]) dsN = np.ones([1]) N = ms._check_number_of_observations(udN = udN, dsN = dsN) self.assertTrue((N == dsN).all())
def test_array_equal(self): ms = ModelSettings() udN = np.ones([1,2]) dsN = np.ones([1,2]) N = ms._check_number_of_observations(udN = udN, dsN = dsN) self.assertTrue((N == udN).all() and (N == dsN).all())
def test_key_removal(self): model = ModelSettings() model.define_model_settings(N=100, sos_function='hello world') RS = ResultsStructure() RS.add_model(model=model) self.assertEqual(RS.results['model_settings']['N'], model.N, msg=str('N = {}'.format(model.N))) self.assertFalse('sos_function' in RS.results['model_settings'].items(), msg='sos_function setting should not be saved')
def test_print_these_none(self): data = DataStructure() x = np.zeros([2]) y = np.zeros([2]) data.add_data_set(x,y) options = SimulationOptions() ms = ModelSettings() ms.define_model_settings() ms._check_dependent_model_settings(data, options) ms._check_dependent_model_settings_wrt_nsos(nsos = 1) print_these = ms.display_model_settings(print_these = None) self.assertEqual(print_these, ['sos_function', 'model_function', 'sigma2', 'N', 'N0', 'S20', 'nsos', 'nbatch'], msg = 'Default print keys')
def test_print_these_not_none(self): data = DataStructure() x = np.zeros([2]) y = np.zeros([2]) data.add_data_set(x,y) options = SimulationOptions() ms = ModelSettings() ms.define_model_settings() ms._check_dependent_model_settings(data, options) ms._check_dependent_model_settings_wrt_nsos(nsos = 1) print_these = ms.display_model_settings(print_these = ['model_function']) self.assertEqual(print_these, ['model_function'], msg = 'Specified print keys') # -------------------------------------------
""" Created on Thu May 31 11:52:58 2018 @author: prmiles """ from pymcmcstat.settings.SimulationOptions import SimulationOptions from pymcmcstat.settings.ModelSettings import ModelSettings import unittest def setup_options(**kwargs): SO = SimulationOptions() SO.define_simulation_options(**kwargs) return SO MS = ModelSettings() MS.define_model_settings() # -------------------------- class DisplaySimulationOptions(unittest.TestCase): def test_print_these_none(self): SO = setup_options() print_these = SO.display_simulation_options(print_these = None) self.assertEqual(print_these, ['nsimu', 'adaptint', 'ntry', 'method', 'printint', 'lastadapt', 'drscale', 'qcov'], msg = 'Default print keys') def test_print_these_not_none(self): SO = setup_options() print_these = SO.display_simulation_options(print_these = ['nsimu']) self.assertEqual(print_these, ['nsimu'], msg = 'Specified print keys')
def test_len_udN_dsN_gt_1(self): ms = ModelSettings() udN = np.ones([1,3]) dsN = np.zeros([1,3]) with self.assertRaises(SystemExit, msg = 'Dimensions match, but values differ.'): ms._check_number_of_observations(udN = udN, dsN = dsN)
def test_len_udN_gt_dsN_case_2(self): ms = ModelSettings() udN = np.ones([1,3]) dsN = np.ones([1,2]) with self.assertRaises(SystemExit, msg = 'Mismatching dimensions'): ms._check_number_of_observations(udN = udN, dsN = dsN)
def test_does_initialization_yield_description(self): ms = ModelSettings() self.assertTrue(hasattr(ms,'description'))
def setup_model_settings(**kwargs): # create settings MS = ModelSettings() MS.define_model_settings(**kwargs) return MS
def test_tuple_N_returns_error(self): ms = ModelSettings() with self.assertRaises(SystemExit, msg = 'Tuple input not accepted'): ms.define_model_settings(N = (1,2))
""" Created on Wed Apr 11 13:17:23 2018 Description: This file contains a series of utilities designed to test the features in the 'ModelSettings.py" package of the pymcmcstat module. @author: prmiles """ from pymcmcstat.settings.DataStructure import DataStructure from pymcmcstat.settings.SimulationOptions import SimulationOptions from pymcmcstat.settings.ModelSettings import ModelSettings import unittest import numpy as np MS = ModelSettings() def setup_model_settings(**kwargs): # create settings MS = ModelSettings() MS.define_model_settings(**kwargs) return MS def setup_simulation_options(**kwargs): # create options options = SimulationOptions() options.define_simulation_options(**kwargs) return options # -------------------------- # initialization