def test_sample_roundtrip(self): sa_dict = {"sample_name": "Ni", "sample_composition": {"Ni": 1}} sam = Sample(self.bt, sa_dict) reloaded_sam = Sample.from_yaml(sam.to_yaml()) os.remove(self.bt.filepath) os.remove(sam.filepath) self.assertEqual(reloaded_sam, sam)
def test_sample_roundtrip(self): sa_dict = {'sample_name': 'Ni', 'sample_composition': {'Ni': 1}} bt = Beamtime('Simon', '123', [], wavelength=0.1828) sam = Sample(bt, sa_dict) reloaded_sam = Sample.from_yaml(sam.to_yaml()) os.remove(bt.filepath) os.remove(sam.filepath) self.assertEqual(reloaded_sam, sam)
def test_sample_roundtrip(self): sa_dict = {"sample_name": "Ni", "sample_composition": {"Ni": 1}} bt = Beamtime("Simon", "123", [], wavelength=0.1828) sam = Sample(bt, sa_dict) reloaded_sam = Sample.from_yaml(sam.to_yaml()) os.remove(bt.filepath) os.remove(sam.filepath) self.assertEqual(reloaded_sam, sam)
def setUp(self): self.base_dir = glbl.base self.home_dir = glbl.home self.config_dir = glbl.xpdconfig os.makedirs(self.config_dir, exist_ok=True) self.PI_name = 'Billinge ' self.saf_num = 123 self.wavelength = 0.1812 self.experimenters = [('van der Banerjee', 'S0ham', 1), ('Terban ', ' Max', 2)] self.saffile = os.path.join(self.config_dir, 'saf{}.yml'.format(self.saf_num)) loadinfo = { 'saf number': self.saf_num, 'PI last name': self.PI_name, 'experimenter list': self.experimenters } with open(self.saffile, 'w') as fo: yaml.dump(loadinfo, fo) self.bt = _start_beamtime(self.saf_num, home_dir=self.home_dir) self.stbt_list = [ 'bt_bt.yml', 'ex_l-user.yml', 'sa_l-user.yml', 'sc_ct.1s.yml', 'sc_ct.5s.yml', 'sc_ct1s.yml', 'sc_ct5s.yml', 'sc_ct10s.yml', 'sc_ct30s.yml' ] self.ex = Experiment('validateDark_unittest', self.bt) self.sa = Sample('unitttestSample', self.ex)
def test_chaining(self): """All contents of Beamtime and Experiment should propagate into Sample.""" bt = Beamtime('Simon', 123, [], wavelength=0.1828, custom1='A') sa_dict = {'sample_name': 'Ni', 'sample_composition': {'Ni': 1}} sa = Sample(bt, sa_dict, custom3='C') for k, v in bt.items(): sa[k] == bt[k]
def test_load_beamtime(self): bt = Beamtime("Simon", 123, [], wavelength=0.1828, custom1="A") sa_dict = {"sample_name": "Ni", "sample_composition": {"Ni": 1}} sa = Sample(bt, sa_dict, custom3="C") bt2 = load_beamtime() self.assertEqual(bt2, bt) self.assertEqual(list(bt2.samples.values())[0], sa)
def test_chaining(self): """All contents of Beamtime and Experiment should propagate into Sample.""" bt = Beamtime("Simon", 123, [], wavelength=0.1828, custom1="A") sa_dict = {"sample_name": "Ni", "sample_composition": {"Ni": 1}} sa = Sample(bt, sa_dict, custom3="C") for k, v in bt.items(): assert sa[k] == bt[k]
def test_load_beamtime(self): bt = Beamtime('Simon', 123, [], wavelength=0.1828, custom1='A') sa_dict = {'sample_name': 'Ni', 'sample_composition': {'Ni': 1}} sa = Sample(bt, sa_dict, custom3='C') bt2 = load_beamtime() self.assertEqual(bt2, bt) self.assertEqual(bt2.samples[0], sa)
def _execute_start_beamtime(piname, safn, explist, wavelength=None, home_dir=None): PI_name = piname saf_num = safn _make_clean_env() os.chdir(home_dir) bt = Beamtime(PI_name, saf_num, experimenters=explist) # now populate the database with some lazy-user objects ex = Experiment('l-user', bt) sa = Sample('l-user', ex) sc01 = ScanPlan('ct', {'exposure': 0.1}) sc05 = ScanPlan('ct', {'exposure': 0.5}) sc1 = ScanPlan('ct', {'exposure': 1.0}) sc5 = ScanPlan('ct', {'exposure': 5.0}) sc10 = ScanPlan('ct', {'exposure': 10.0}) sc30 = ScanPlan('ct', {'exposure': 30.0}) return bt