Beispiel #1
0
def test_goniometer():
    '''A test class for the goniometer class.'''

    axis = (1, 0, 0)
    fixed = (1, 0, 0, 0, 1, 0, 0, 0, 1)

    xg = Goniometer(axis, fixed)

    assert (len(xg.get_rotation_axis()) == 3)
    assert (len(xg.get_fixed_rotation()) == 9)

    assert (compare_tuples(xg.get_rotation_axis(), axis))
    assert (compare_tuples(xg.get_fixed_rotation(), fixed))

    single = goniometer_factory.single_axis()

    assert (len(single.get_rotation_axis()) == 3)
    assert (len(single.get_fixed_rotation()) == 9)

    assert (compare_tuples(single.get_rotation_axis(), axis))
    assert (compare_tuples(single.get_fixed_rotation(), fixed))

    kappa = goniometer_factory.kappa(50.0, 0.0, 0.0, 0.0, '-y', 'omega')

    assert (len(kappa.get_rotation_axis()) == 3)
    assert (len(kappa.get_fixed_rotation()) == 9)
    assert (compare_tuples(kappa.get_rotation_axis(), axis))
    assert (compare_tuples(kappa.get_fixed_rotation(), fixed))

    kappa = goniometer_factory.kappa(50.0, 0.0, 0.0, 0.0, '-y', 'omega')

    assert (len(kappa.get_rotation_axis()) == 3)
    assert (len(kappa.get_fixed_rotation()) == 9)

    assert (compare_tuples(kappa.get_rotation_axis(), axis))
    assert (compare_tuples(kappa.get_fixed_rotation(), fixed))

    kappa = goniometer_factory.kappa(50.0, 0.0, 0.0, 0.0, '-y', 'phi')

    assert (len(kappa.get_rotation_axis()) == 3)
    assert (len(kappa.get_fixed_rotation()) == 9)

    assert (compare_tuples(kappa.get_rotation_axis(), axis))
    assert (compare_tuples(kappa.get_fixed_rotation(), fixed))

    kappa = goniometer_factory.kappa(50.0, 0.0, 30.0, 0.0, '-y', 'omega')

    assert (len(kappa.get_rotation_axis()) == 3)
    assert (len(kappa.get_fixed_rotation()) == 9)

    assert (compare_tuples(kappa.get_rotation_axis(), axis))
    assert (not compare_tuples(kappa.get_fixed_rotation(), fixed))

    import libtbx.load_env
    import os

    dxtbx_dir = libtbx.env.dist_path('dxtbx')

    image = os.path.join(dxtbx_dir, 'tests', 'phi_scan_001.cbf')
    cbf = goniometer_factory.imgCIF(image)

    kappa = goniometer_factory.kappa(50.0, -10.0, 30.0, 0.0, '-y', 'phi')

    s = easy_pickle.dumps(kappa)
    kappa2 = easy_pickle.loads(s)
    assert kappa == kappa2

    image = os.path.join(dxtbx_dir, 'tests', 'omega_scan.cbf')
    cbf = goniometer_factory.imgCIF(image)

    kappa = goniometer_factory.kappa(50.0, -10.0, 30.0, 20.0, '-y', 'omega')

    s = easy_pickle.dumps(kappa)
    kappa2 = easy_pickle.loads(s)
    assert kappa == kappa2

    print 'OK'
Beispiel #2
0
def test_goniometer():
    """A test class for the goniometer class."""

    axis = (1, 0, 0)
    fixed = (1, 0, 0, 0, 1, 0, 0, 0, 1)

    xg = Goniometer(axis, fixed)

    assert len(xg.get_rotation_axis()) == 3
    assert len(xg.get_fixed_rotation()) == 9

    _compare_tuples(xg.get_rotation_axis(), axis)
    _compare_tuples(xg.get_fixed_rotation(), fixed)

    single = GoniometerFactory.single_axis()

    assert len(single.get_rotation_axis()) == 3
    assert len(single.get_fixed_rotation()) == 9

    _compare_tuples(single.get_rotation_axis(), axis)
    _compare_tuples(single.get_fixed_rotation(), fixed)

    kappa = GoniometerFactory.kappa(50.0, 0.0, 0.0, 0.0, "-y", "omega")

    assert len(kappa.get_rotation_axis()) == 3
    assert len(kappa.get_fixed_rotation()) == 9
    _compare_tuples(kappa.get_rotation_axis(), axis)
    _compare_tuples(kappa.get_fixed_rotation(), fixed)

    kappa = GoniometerFactory.kappa(50.0, 0.0, 0.0, 0.0, "-y", "omega")

    assert len(kappa.get_rotation_axis()) == 3
    assert len(kappa.get_fixed_rotation()) == 9

    _compare_tuples(kappa.get_rotation_axis(), axis)
    _compare_tuples(kappa.get_fixed_rotation(), fixed)

    kappa = GoniometerFactory.kappa(50.0, 0.0, 0.0, 0.0, "-y", "phi")

    assert len(kappa.get_rotation_axis()) == 3
    assert len(kappa.get_fixed_rotation()) == 9

    _compare_tuples(kappa.get_rotation_axis(), axis)
    _compare_tuples(kappa.get_fixed_rotation(), fixed)

    kappa = GoniometerFactory.kappa(50.0, 0.0, 30.0, 0.0, "-y", "omega")

    assert len(kappa.get_rotation_axis()) == 3
    assert len(kappa.get_fixed_rotation()) == 9

    _compare_tuples(kappa.get_rotation_axis(), axis)
    with pytest.raises(AssertionError):
        _compare_tuples(kappa.get_fixed_rotation(), fixed)

    import libtbx.load_env

    dxtbx_dir = libtbx.env.dist_path("dxtbx")

    image = os.path.join(dxtbx_dir, "tests", "phi_scan_001.cbf")
    assert GoniometerFactory.imgCIF(image)

    kappa = GoniometerFactory.kappa(50.0, -10.0, 30.0, 0.0, "-y", "phi")

    s = easy_pickle.dumps(kappa)
    kappa2 = easy_pickle.loads(s)
    assert kappa == kappa2

    image = os.path.join(dxtbx_dir, "tests", "omega_scan.cbf")
    assert GoniometerFactory.imgCIF(image)

    kappa = GoniometerFactory.kappa(50.0, -10.0, 30.0, 20.0, "-y", "omega")

    s = easy_pickle.dumps(kappa)
    kappa2 = easy_pickle.loads(s)
    assert kappa == kappa2
def test_goniometer():
  '''A test class for the goniometer class.'''


  axis = (1, 0, 0)
  fixed = (1, 0, 0, 0, 1, 0, 0, 0, 1)

  xg = Goniometer(axis, fixed)

  assert(len(xg.get_rotation_axis()) == 3)
  assert(len(xg.get_fixed_rotation()) == 9)

  assert(compare_tuples(xg.get_rotation_axis(), axis))
  assert(compare_tuples(xg.get_fixed_rotation(), fixed))

  single = goniometer_factory.single_axis()

  assert(len(single.get_rotation_axis()) == 3)
  assert(len(single.get_fixed_rotation()) == 9)

  assert(compare_tuples(single.get_rotation_axis(), axis))
  assert(compare_tuples(single.get_fixed_rotation(), fixed))

  kappa = goniometer_factory.kappa(50.0, 0.0, 0.0, 0.0, '-y', 'omega')

  assert(len(kappa.get_rotation_axis()) == 3)
  assert(len(kappa.get_fixed_rotation()) == 9)
  assert(compare_tuples(kappa.get_rotation_axis(), axis))
  assert(compare_tuples(kappa.get_fixed_rotation(), fixed))

  kappa = goniometer_factory.kappa(50.0, 0.0, 0.0, 0.0, '-y', 'omega')

  assert(len(kappa.get_rotation_axis()) == 3)
  assert(len(kappa.get_fixed_rotation()) == 9)

  assert(compare_tuples(kappa.get_rotation_axis(), axis))
  assert(compare_tuples(kappa.get_fixed_rotation(), fixed))

  kappa = goniometer_factory.kappa(50.0, 0.0, 0.0, 0.0, '-y', 'phi')

  assert(len(kappa.get_rotation_axis()) == 3)
  assert(len(kappa.get_fixed_rotation()) == 9)

  assert(compare_tuples(kappa.get_rotation_axis(), axis))
  assert(compare_tuples(kappa.get_fixed_rotation(), fixed))

  kappa = goniometer_factory.kappa(50.0, 0.0, 30.0, 0.0, '-y', 'omega')

  assert(len(kappa.get_rotation_axis()) == 3)
  assert(len(kappa.get_fixed_rotation()) == 9)

  assert(compare_tuples(kappa.get_rotation_axis(), axis))
  assert(not compare_tuples(kappa.get_fixed_rotation(), fixed))

  import libtbx.load_env
  import os

  dxtbx_dir = libtbx.env.dist_path('dxtbx')

  image = os.path.join(dxtbx_dir, 'tests', 'phi_scan_001.cbf')
  cbf = goniometer_factory.imgCIF(image)

  kappa = goniometer_factory.kappa(50.0, -10.0, 30.0, 0.0, '-y', 'phi')

  s = easy_pickle.dumps(kappa)
  kappa2 = easy_pickle.loads(s)
  assert kappa == kappa2

  image = os.path.join(dxtbx_dir, 'tests', 'omega_scan.cbf')
  cbf = goniometer_factory.imgCIF(image)

  kappa = goniometer_factory.kappa(50.0, -10.0, 30.0, 20.0, '-y', 'omega')

  s = easy_pickle.dumps(kappa)
  kappa2 = easy_pickle.loads(s)
  assert kappa == kappa2

  print 'OK'
Beispiel #4
0
def test_goniometer():
    """A test class for the goniometer class."""

    axis = (1, 0, 0)
    fixed = (1, 0, 0, 0, 1, 0, 0, 0, 1)

    xg = Goniometer(axis, fixed)

    assert len(xg.get_rotation_axis()) == 3
    assert len(xg.get_fixed_rotation()) == 9

    _compare_tuples(xg.get_rotation_axis(), axis)
    _compare_tuples(xg.get_fixed_rotation(), fixed)

    single = GoniometerFactory.single_axis()

    assert len(single.get_rotation_axis()) == 3
    assert len(single.get_fixed_rotation()) == 9

    _compare_tuples(single.get_rotation_axis(), axis)
    _compare_tuples(single.get_fixed_rotation(), fixed)

    kappa = GoniometerFactory.kappa(50.0, 0.0, 0.0, 0.0, "-y", "omega")

    assert len(kappa.get_rotation_axis()) == 3
    assert len(kappa.get_fixed_rotation()) == 9
    _compare_tuples(kappa.get_rotation_axis(), axis)
    _compare_tuples(kappa.get_fixed_rotation(), fixed)

    kappa = GoniometerFactory.kappa(50.0, 0.0, 0.0, 0.0, "-y", "omega")

    assert len(kappa.get_rotation_axis()) == 3
    assert len(kappa.get_fixed_rotation()) == 9

    _compare_tuples(kappa.get_rotation_axis(), axis)
    _compare_tuples(kappa.get_fixed_rotation(), fixed)

    kappa = GoniometerFactory.kappa(50.0, 0.0, 0.0, 0.0, "-y", "phi")

    assert len(kappa.get_rotation_axis()) == 3
    assert len(kappa.get_fixed_rotation()) == 9

    _compare_tuples(kappa.get_rotation_axis(), axis)
    _compare_tuples(kappa.get_fixed_rotation(), fixed)

    kappa = GoniometerFactory.kappa(50.0, 0.0, 30.0, 0.0, "-y", "omega")

    assert len(kappa.get_rotation_axis()) == 3
    assert len(kappa.get_fixed_rotation()) == 9

    _compare_tuples(kappa.get_rotation_axis(), axis)
    with pytest.raises(AssertionError):
        _compare_tuples(kappa.get_fixed_rotation(), fixed)

    image = Path(__file__).parent / "phi_scan_001.cbf"
    assert GoniometerFactory.imgCIF(str(image))

    kappa = GoniometerFactory.kappa(50.0, -10.0, 30.0, 0.0, "-y", "phi")

    s = easy_pickle.dumps(kappa)
    kappa2 = easy_pickle.loads(s)
    assert kappa == kappa2

    image = Path(__file__).parent / "omega_scan.cbf"
    assert GoniometerFactory.imgCIF(str(image))

    kappa = GoniometerFactory.kappa(50.0, -10.0, 30.0, 20.0, "-y", "omega")

    s = easy_pickle.dumps(kappa)
    kappa2 = easy_pickle.loads(s)
    assert kappa == kappa2