Ejemplo n.º 1
0
def test_expand_path(h5_stack_dir):
    expansions = [Path(p) for p in DatasetInfo.expand_path(os.path.join(h5_stack_dir, "*"))]
    expected_file_paths = [
        Path(h5_stack_dir) / "2d_apoptotic_binary_0.h5",
        Path(h5_stack_dir) / "2d_apoptotic_binary_1.h5",
        Path(h5_stack_dir) / "2d_apoptotic_binary_2.h5",
    ]
    assert expansions == expected_file_paths

    expected_dataset_paths = [Path(fp) / "volume/data" for fp in expected_file_paths]
    expansions = [Path(p) for p in DatasetInfo.expand_path(os.path.join(h5_stack_dir, "*.h5", "vol*"))]
    assert expansions == expected_dataset_paths

    expansions = [Path(p) for p in DatasetInfo.expand_path(os.path.join(h5_stack_dir, "2d_apoptotic_binary_1.h5"))]
    assert expansions == expected_file_paths[1:2]

    relative_paths = ["2d_apoptotic_binary_0.h5", "2d_apoptotic_binary_1.h5", "2d_apoptotic_binary_2.h5"]
    relative_paths_with_colon = os.path.pathsep.join(relative_paths)
    expansions = [Path(p) for p in DatasetInfo.expand_path(relative_paths_with_colon, cwd=h5_stack_dir)]
    assert expansions == expected_file_paths
Ejemplo n.º 2
0
def test_create_nickname_for_single_file_does_not_contain_extension(
        h5_colon_path_stack):
    expanded_paths = DatasetInfo.expand_path(h5_colon_path_stack)
    nickname = DatasetInfo.create_nickname(expanded_paths[0:1])
    assert nickname == "2d_apoptotic_binary_0"
Ejemplo n.º 3
0
def test_create_nickname(h5_colon_path_stack):
    expanded_paths = DatasetInfo.expand_path(h5_colon_path_stack)
    nickname = DatasetInfo.create_nickname(expanded_paths)
    assert nickname == "2d_apoptotic_binary_"
Ejemplo n.º 4
0
def test_create_nickname_with_internal_paths(
        h5_colon_path_stack_with_inner_paths):
    expanded_paths = DatasetInfo.expand_path(
        h5_colon_path_stack_with_inner_paths)
    nickname = DatasetInfo.create_nickname(expanded_paths)
    assert nickname == "2d_apoptotic_binary_-volume-data"