def test_beam_with_scan_points(): b1 = Beam((1, 0, 0), 2, 0.1, 0.1) s0_static = matrix.col(b1.get_s0()) b1.set_s0_at_scan_points([s0_static] * 5) d = b1.to_dict() b2 = BeamFactory.from_dict(d) for s0comp in d["s0_at_scan_points"]: assert matrix.col(s0comp) == s0_static for s0comp in b2.get_s0_at_scan_points(): assert matrix.col(s0comp) == s0_static assert b1 == b2
def test_beam_with_scan_points(): from dxtbx.model import Beam, BeamFactory b1 = Beam((1, 0, 0), 2, 0.1, 0.1) from scitbx import matrix s0_static = matrix.col(b1.get_s0()) b1.set_s0_at_scan_points([s0_static] * 5) d = b1.to_dict() b2 = BeamFactory.from_dict(d) for s0comp in d['s0_at_scan_points']: assert matrix.col(s0comp) == s0_static for s0comp in b2.get_s0_at_scan_points(): assert matrix.col(s0comp) == s0_static assert b1 == b2
def test_beam(): # Construct the object b1 = Beam( direction=(1, 2, 3), wavelength=1.1, divergence=0.01, sigma_divergence=0.01, polarization_normal=(4, 5, 6), polarization_fraction=0.9, flux=1.0, transmission=1.0, ) # Create a dictionary and get the beam back d = b1.to_dict() b2 = Beam.from_dict(d) assert b2 == b1
def __call__(self): from dxtbx.model import Beam # Construct the object b1 = Beam(direction=(1, 2, 3), wavelength=1.1, divergence=0.01, sigma_divergence=0.01, polarization_normal=(4, 5, 6), polarization_fraction=0.9) # Create a dictionary and get the beam back d = b1.to_dict() b2 = Beam.from_dict(d) assert (b2 == b1) print 'OK'
def __call__(self): from dxtbx.model import Beam # Construct the object b1 = Beam( direction=(1, 2, 3), wavelength=1.1, divergence=0.01, sigma_divergence=0.01, polarization_normal=(4, 5, 6), polarization_fraction=0.9) # Create a dictionary and get the beam back d = b1.to_dict() b2 = Beam.from_dict(d) assert(b2 == b1) print 'OK'
def test_beam(): b1 = Beam((1, 0, 0), 2, 0.1, 0.1) d = b1.to_dict() b2 = BeamFactory.from_dict(d) assert d["direction"] == (1, 0, 0) assert d["wavelength"] == 2 assert d["divergence"] == pytest.approx(0.1) assert d["sigma_divergence"] == pytest.approx(0.1) assert b1 == b2 assert "s0_at_scan_points" not in d # Test with a template and partial dictionary d2 = {"direction": (0, 1, 0), "divergence": 0.2} b3 = BeamFactory.from_dict(d2, d) assert b3.get_sample_to_source_direction() == (0, 1, 0) assert b3.get_wavelength() == 2 assert b3.get_divergence() == pytest.approx(0.2) assert b3.get_sigma_divergence() == pytest.approx(0.1) assert b2 != b3
def tst_beam(self): from dxtbx.model import Beam, BeamFactory b1 = Beam((1, 0, 0), 2, 0.1, 0.1) d = b1.to_dict() b2 = BeamFactory.from_dict(d) assert (d['direction'] == (1, 0, 0)) assert (d['wavelength'] == 2) assert (abs(d['divergence'] - 0.1) <= 1e-7) assert (abs(d['sigma_divergence'] - 0.1) <= 1e-7) assert (b1 == b2) # Test with a template and partial dictionary d2 = {'direction': (0, 1, 0), 'divergence': 0.2} b3 = BeamFactory.from_dict(d2, d) assert (b3.get_direction() == (0, 1, 0)) assert (b3.get_wavelength() == 2) assert (abs(b3.get_divergence() - 0.2) <= 1e-7) assert (abs(b3.get_sigma_divergence() - 0.1) <= 1e-7) assert (b2 != b3) print 'OK'
def test_beam(): from dxtbx.model import Beam, BeamFactory b1 = Beam((1, 0, 0), 2, 0.1, 0.1) d = b1.to_dict() b2 = BeamFactory.from_dict(d) assert d['direction'] == (1, 0, 0) assert d['wavelength'] == 2 assert d['divergence'] == pytest.approx(0.1) assert d['sigma_divergence'] == pytest.approx(0.1) assert b1 == b2 assert 's0_at_scan_points' not in d # Test with a template and partial dictionary d2 = {'direction': (0, 1, 0), 'divergence': 0.2} b3 = BeamFactory.from_dict(d2, d) assert b3.get_direction() == (0, 1, 0) assert b3.get_wavelength() == 2 assert b3.get_divergence() == pytest.approx(0.2) assert b3.get_sigma_divergence() == pytest.approx(0.1) assert b2 != b3
def test_beam_self_serialization(): beam = Beam() assert beam == BeamFactory.from_dict(beam.to_dict())