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
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
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
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]