Exemplo n.º 1
0
def work_xScanFactory():
    '''Test out the ScanFactory.'''

    import dxtbx
    directory = os.path.join(os.path.split(dxtbx.__file__)[0], 'tests')

    template = 'image_###.dat'

    xscans = [
        ScanFactory.single(
            scan_helper_image_files.template_directory_index_to_image(
                template, directory, j + 1),
            scan_helper_image_formats.FORMAT_CBF, 1.0, 18 + 0.5 * j, 0.5, j)
        for j in range(20)
    ]

    xscans.reverse()

    try:
        print sum(xscans[1:], xscans[0])
        print 'I should not see this message'
    except RuntimeError:
        pass

    xscans.sort()

    sum(xscans[1:], xscans[0])

    a = ScanFactory.add(xscans[:10])
    b = ScanFactory.add(xscans[10:])

    a + b

    filename = scan_helper_image_files.template_directory_index_to_image(
        template, directory, 1)

    assert (len(ScanFactory.search(filename)) == 20)

    (a + b)[1:5]
    (a + b)[:10]

    cbf = os.path.join(directory, 'phi_scan_001.cbf')

    print 'OK'
Exemplo n.º 2
0
def test_xScanFactory():
    """Test out the ScanFactory."""

    import dxtbx

    directory = os.path.join(os.path.split(dxtbx.__file__)[0], "tests")

    template = "image_###.dat"

    xscans = [
        ScanFactory.single(
            scan_helper_image_files.template_directory_index_to_image(
                template, directory, j + 1),
            scan_helper_image_formats.FORMAT_CBF,
            1.0,
            18 + 0.5 * j,
            0.5,
            j,
        ) for j in range(20)
    ]

    xscans.reverse()

    with pytest.raises(RuntimeError):
        print(sum(xscans[1:], xscans[0]))

    xscans.sort()

    sum(xscans[1:], xscans[0])

    a = ScanFactory.add(xscans[:10])
    b = ScanFactory.add(xscans[10:])

    a + b

    filename = scan_helper_image_files.template_directory_index_to_image(
        template, directory, 1)

    assert len(ScanFactory.search(filename)) == 20

    (a + b)[1:5]
    (a + b)[:10]
Exemplo n.º 3
0
def test_xScanFactory(image_test_dir):
    """Test out the ScanFactory."""

    template = "image_###.dat"

    xscans = [
        ScanFactory.single_file(
            scan_helper_image_files.template_directory_index_to_image(
                template, image_test_dir, j + 1
            ),
            1.0,
            18 + 0.5 * j,
            0.5,
            j,
        )
        for j in range(20)
    ]

    xscans.reverse()

    with pytest.raises(RuntimeError):
        print(sum(xscans[1:], xscans[0]))

    xscans.sort()

    sum(xscans[1:], xscans[0])

    a = ScanFactory.add(xscans[:10])
    b = ScanFactory.add(xscans[10:])

    a + b

    filename = scan_helper_image_files.template_directory_index_to_image(
        template, image_test_dir, 1
    )

    assert len(ScanFactory.search(filename)) == 20

    (a + b)[1:5]
    (a + b)[:10]
Exemplo n.º 4
0
          template, directory, j + 1), scan_helper_image_formats.FORMAT_CBF,
      1.0, 18 + 0.5 * j, 0.5, j) for j in range(20)]

  xscans.reverse()

  try:
    print sum(xscans[1:], xscans[0])
    print 'I should not see this message'
  except RuntimeError, e:
    pass

  xscans.sort()

  sum(xscans[1:], xscans[0])

  a = ScanFactory.add(xscans[:10])
  b = ScanFactory.add(xscans[10:])

  a + b

  filename = scan_helper_image_files.template_directory_index_to_image(
      template, directory, 1)

  assert(len(ScanFactory.search(filename)) == 20)

  (a + b)[1:5]
  (a + b)[:10]

  cbf = os.path.join(directory, 'phi_scan_001.cbf')

  print 'OK'