Exemplo n.º 1
0
def work_helper_image_files():
  '''Test the static methods in scan_helper_image_files.'''

  helper = scan_helper_image_files()

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

  template = 'image_###.dat'

  assert(len(scan_helper_image_files.template_directory_to_indices(
      template, directory)) == 20)

  assert(scan_helper_image_files.template_directory_index_to_image(
      template, directory, 1) == os.path.join(directory, 'image_001.dat'))

  assert(scan_helper_image_files.template_index_to_image(
      template, 1) == 'image_001.dat')

  assert(scan_helper_image_files.image_to_template_directory(
      os.path.join(directory, 'image_001.dat')) == (template, directory))

  assert(scan_helper_image_files.image_to_index('image_001.dat') == 1)

  assert(scan_helper_image_files.image_to_template(
      'image_001.dat') == 'image_###.dat')

  assert(scan_helper_image_files.image_to_index("image_6.8kev_1_001.cbf") == 1)

  return
Exemplo n.º 2
0
def test_helper_image_files():
    """Test the static methods in scan_helper_image_files."""

    helper = scan_helper_image_files()

    import dxtbx

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

    template = "image_###.dat"

    assert (len(
        scan_helper_image_files.template_directory_to_indices(
            template, directory)) == 20)

    assert scan_helper_image_files.template_directory_index_to_image(
        template, directory, 1) == os.path.join(directory, "image_001.dat")

    assert (scan_helper_image_files.template_index_to_image(
        template, 1) == "image_001.dat")

    assert scan_helper_image_files.image_to_template_directory(
        os.path.join(directory, "image_001.dat")) == (template, directory)

    assert scan_helper_image_files.image_to_index("image_001.dat") == 1

    assert scan_helper_image_files.image_to_template(
        "image_001.dat") == "image_###.dat"

    assert scan_helper_image_files.image_to_index(
        "image_6.8kev_1_001.cbf") == 1
Exemplo n.º 3
0
def work_helper_image_files():
  '''Test the static methods in scan_helper_image_files.'''

  helper = scan_helper_image_files()

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

  template = 'image_###.dat'

  assert(len(scan_helper_image_files.template_directory_to_indices(
      template, directory)) == 20)

  assert(scan_helper_image_files.template_directory_index_to_image(
      template, directory, 1) == os.path.join(directory, 'image_001.dat'))

  assert(scan_helper_image_files.template_index_to_image(
      template, 1) == 'image_001.dat')

  assert(scan_helper_image_files.image_to_template_directory(
      os.path.join(directory, 'image_001.dat')) == (template, directory))

  assert(scan_helper_image_files.image_to_index('image_001.dat') == 1)

  assert(scan_helper_image_files.image_to_template(
      'image_001.dat') == 'image_###.dat')

  assert(scan_helper_image_files.image_to_index("image_6.8kev_1_001.cbf") == 1)

  return
Exemplo n.º 4
0
def test_helper_image_files(image_test_dir):
    """Test the static methods in scan_helper_image_files."""
    assert scan_helper_image_files()

    template = "image_###.dat"

    assert (
        len(
            scan_helper_image_files.template_directory_to_indices(
                template, image_test_dir
            )
        )
        == 20
    )

    assert scan_helper_image_files.template_directory_index_to_image(
        template, image_test_dir, 1
    ) == os.path.join(image_test_dir, "image_001.dat")

    assert (
        scan_helper_image_files.template_index_to_image(template, 1) == "image_001.dat"
    )

    assert scan_helper_image_files.image_to_template_directory(
        os.path.join(image_test_dir, "image_001.dat")
    ) == (template, image_test_dir)

    assert scan_helper_image_files.image_to_index("image_001.dat") == 1

    assert scan_helper_image_files.image_to_template("image_001.dat") == "image_###.dat"

    assert scan_helper_image_files.image_to_index("image_6.8kev_1_001.cbf") == 1
Exemplo n.º 5
0
  def search(filename):
    '''Get a list of files which appear to match the template and
    directory implied by the input filename. This could well be used
    to get a list of image headers to read and hence construct scans
    from.'''

    template, directory = \
              scan_helper_image_files.image_to_template_directory(filename)

    indices = scan_helper_image_files.template_directory_to_indices(
        template, directory)

    return [scan_helper_image_files.template_directory_index_to_image(
        template, directory, index) for index in indices]