def test_compare_evol_h5(self, ref_50iter): '''Test to compare plothist evolution pdf was generated''' with mock.patch( target='argparse.ArgumentParser.parse_args', return_value=argparse.Namespace( verbosity='debug', rcfile=self.cfg_filepath, input='pdist_ref.h5', firstdim='0', plot_output='hist_evol.pdf', hdf5_output='hist_evol.h5', plot_contour=False, title=None, plotscale='energy', enerzero='min', range=None, postprocess_function=None, seconddim=None, first_iter=1, last_iter=50, step_iter=None, west_subcommand=EvolutionPlotHist(1), ), ): entry_point() assert os.path.isfile('./hist_evol.pdf'), "The evolution pdf was not generated." diff = H5Diff('hist_evol_ref.h5', 'hist_evol.h5') diff.check() # clean up os.remove('hist_evol.pdf') os.remove('hist_evol.h5')
def test_run_w_pdist(self, ref_50iter): '''Testing if w_pdist runs as expected and the pdist.h5 file looks good.''' with mock.patch( target='argparse.ArgumentParser.parse_args', return_value=argparse.Namespace( verbosity='debug', rcfile=self.cfg_filepath, max_queue_length=None, we_h5filename=self.h5_filepath, construct_dataset=None, dsspecs=None, group_name='pcoord', first_iter=1, last_iter=None, bins='100', output='pdist.h5', ignore_out_of_range=False, compress=False, work_manager=None, n_workers=None, construct_wdataset=None, ), ): entry_point() assert os.path.isfile( './pdist.h5'), "The pdist.h5 file was not generated." diff = H5Diff('pdist_ref.h5', 'pdist.h5') diff.check() # clean up os.remove('pdist.h5')
def test_run_w_init(self, ref_cfg): '''Tests initialization of a WESTPA simulation system from a prebuilt .cfg''' # This test is named in such a way so it always runs before test_w_assign.py. It will fail otherwise. # The argument processing is just looking for an object with these attributes args = MockArgs(force=True, rcfile=self.cfg_filepath, verbosity='verbose') westpa.rc.process_args(args) westpa.cli.core.w_init.initialize( tstates=None, tstate_file=None, bstates=['initial,1.0'], bstate_file=None, sstates=None, sstate_file=None, segs_per_state=1, shotgun=False, ) # h5 files contain some internal information that includes timestamps, so I can't just compare md5 checksums # to ensure that w_init is producing the same output. # Instead, use my H5Diff class. # If the checked contents differ, an AssertionError will be raised. diff = H5Diff(self.ref_h5_filepath, self.h5_filepath) diff.check()
def test_run_w_multi_west(self, ref_multi): '''Testing if w_pdist runs as expected and the pdist.h5 file looks good.''' with mock.patch( target='argparse.ArgumentParser.parse_args', return_value=argparse.Namespace( verbosity='debug', rcfile=self.cfg_filepath, max_queue_length=None, west=self.h5_filepath, output_file='multi.h5', master='.', sims='3', aux=None, auxall=True, no_reweight=False, ), ): entry_point() assert os.path.isfile( './multi.h5'), "The multi.h5 file was not generated." diff = H5Diff('multi_aux_ref.h5', 'multi.h5') diff.check() # clean up os.remove('multi.h5')
def test_run_w_direct(self): '''Testing if w_direct runs as expected and the direct.h5 file looks good.''' ref_dir = os.path.join(os.path.dirname(__file__), '../refs') shutil.copy2(os.path.join(ref_dir, 'west_ref.h5'), './west.h5') os.system('w_direct all') assert os.path.isfile( './direct.h5'), "The direct.h5 file was not generated." diff = H5Diff(os.path.join(ref_dir, 'direct_ref.h5'), './direct.h5') diff.check() os.remove('direct.h5') os.remove('west.h5')
def check_output(self, arg_idx): with h5py.File(self.outfile) as f: assert 'trajectories' in list(f.keys()), "'trajectories' group not in output file" traj_group = f['trajectories'] # Expected trace groups - successive runs of w_trace with different traces should add # newly traced groups to output hdf5 file expected_groups = sorted([self.w.output_pattern % (n_iter, seg_id) for n_iter, seg_id in self.endpoints]) assert list(traj_group.keys()) == expected_groups, "H5 groups ({}) are not as expected ({})".format( list(traj_group.keys()), expected_groups ) diff = H5Diff(self.ref_files[arg_idx], self.outfile) diff.check()
def test_run_w_direct(self, ref_50iter): with mock.patch( target='argparse.ArgumentParser.parse_args', return_value=argparse.Namespace( verbosity='debug', rcfile=self.cfg_filepath, work_manager=None, max_queue_length=None, west_subcommand=DAll(1), we_h5filename=self.h5_filepath, construct_dataset=None, dsspecs=None, output='direct.h5', kinetics='direct.h5', first_iter=1, last_iter=None, step_iter=None, assignments='assign_ref.h5', evolution_mode=None, subsample=None, config_from_file=True, scheme='TEST', bootstrap=None, correl=None, alpha=0.05, acalpha=None, nsets=None, window_frac=1.0, display_averages=True, ), ): entry_point() diff = H5Diff('./direct_ref.h5', './direct.h5') diff.check() # clean up os.remove('direct.h5')
def test_run_w_assign(self, ref_50iter): args = MockArgs( verbosity='debug', rcfile=self.cfg_filepath, max_queue_length=None, we_h5filename=self.h5_filepath, construct_dataset=None, dsspecs=None, output='assign.h5', subsample=None, config_from_file=True, scheme='TEST', ) # This basically some logic that's wrapped up in WESTTool.main() for convenience. # It needs to be explicitly called like this because the args are captured and set in make_parser_and_process() # which we don't want to call, because we don't want to make a parser. # We just want to process the args that "would've" been captured if called from CLI. tool = w_assign.WAssign() # Prepare and instantiate work manager tool.wm_env.process_wm_args(args) tool.work_manager = tool.wm_env.make_work_manager() tool.process_all_args(args) with tool.work_manager: if tool.work_manager.is_master: tool.go() else: tool.work_manager.run() diff = H5Diff('./assign_ref.h5', './ANALYSIS/TEST/assign.h5') diff.check() # clean up shutil.rmtree('ANALYSIS')