def dev__determine_rv_seeds(): pyposmat_app = PyposmatIterativeSampler(configuration_filename=config_fn) pyposmat_app.read_configuration_file() pyposmat_app.setup_mpi_environment() pyposmat_app.determine_rv_seeds() print('pyposmat_app.rv_seed:') print('\ttype:{}.'.format(str(type(pyposmat_app.rv_seed)))) print('pyposmat_app.rv_seeds:') print(pyposmat_app.rv_seeds.shape)
def test__determine_rv_seeds__seeds_do_not_change_when_run_again(): pyposmat_app = PyposmatIterativeSampler(configuration_filename=config_fn) pyposmat_app.read_configuration_file() pyposmat_app.setup_mpi_environment() pyposmat_app.determine_rv_seeds() # make sure the seed doesn't change when it's run again old_seed = pyposmat_app.rv_seed old_seeds = pyposmat_app.rv_seeds pyposmat_app.determine_rv_seeds() assert pyposmat_app.rv_seed == old_seed assert np.array_equal(pyposmat_app.rv_seeds, old_seeds)
def test__determine_rv_seeds__no_args__attribute_not_none(): pyposmat_app = PyposmatIterativeSampler(configuration_filename=config_fn) pyposmat_app.read_configuration_file() pyposmat_app.setup_mpi_environment() pyposmat_app.rv_seed = 1 assert type(pyposmat_app.rv_seed) is int assert type(pyposmat_app.rv_seeds) is type(None) assert pyposmat_app.rv_seed == 1 pyposmat_app.determine_rv_seeds() assert type(pyposmat_app.rv_seed) is int assert type(pyposmat_app.rv_seeds) is np.ndarray assert pyposmat_app.rv_seed == 1 assert pyposmat_app.rv_seeds.shape[0] == pyposmat_app.mpi_size assert pyposmat_app.rv_seeds.shape[1] == pyposmat_app.n_iterations
def dev__run_parametric_sampling(): o = PyposmatIterativeSampler(configuration_filename=config_fn) o.data_dir = pyposmat_data_dir o.read_configuration_file() # ensure that the configuration is actually setup as parametric assert o.configuration.sampling_type[i_iteration]['type'] == 'parametric' #this setup happens in run_all() o.setup_mpi_environment() o.initialize_data_directory() o.i_iteration = i_iteration o.log_iteration_information(i_iteration=o.i_iteration) #this setup happens in run_simulations() o.initialize_rank_directory() # ensure that the paths are absolute paths assert os.path.isabs(o.rank_directory) assert os.path.isabs(o.configuration_filename) config_filename = o.configuration_filename results_filename = os.path.join(o.rank_directory, 'pyposmat.results.{}.out') bad_parameters_filename = os.path.join(o.rank_directory, 'pyposmat.bad_parameters.{}.out') os.chdir(o.rank_directory) o.determine_rv_seeds() o.initialize_sampler(config_fn=config_filename, results_fn=results_filename, mpi_rank=o.mpi_rank, mpi_size=o.mpi_size, o_log=o.o_log) o.run_parametric_sampling(i_iteration=i_iteration)