Skip to content

Commit

Permalink
add .json and .bin file compatibility and test
Browse files Browse the repository at this point in the history
  • Loading branch information
camisowers committed Jul 7, 2022
1 parent ad6ccfc commit 342673e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ark/utils/io_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def remove_file_extensions(files):
# remove the file extension
names = [os.path.splitext(name) for name in files]
names_corrected = []
extension_types = ["tiff", "tif", "png", "jpg", "jpeg", "tar", "gz", "csv", "feather"]
extension_types = ["tiff", "tif", "png", "jpg", "jpeg", "tar", "gz", "csv", "feather",
"bin", "json"]
for name in names:
# We want everything after the "." for the extension
ext = name[-1][1:]
Expand Down
4 changes: 2 additions & 2 deletions ark/utils/io_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ def test_list_files():

def test_remove_file_extensions():
# test a mixture of file paths and extensions
files = ['fov1.tiff', 'fov2.tif', 'fov3.png', 'fov4.jpg']
files = ['fov1.tiff', 'fov2.tif', 'fov3.png', 'fov4.jpg', 'fov5.bin', 'fov6.json']
files2 = ['fov.1.tiff', 'fov.2.tiff', 'fov.3.png', 'fov.4']

assert iou.remove_file_extensions(None) is None
assert iou.remove_file_extensions([]) == []

files_sans_ext = ['fov1', 'fov2', 'fov3', 'fov4']
files_sans_ext = ['fov1', 'fov2', 'fov3', 'fov4', 'fov5', 'fov6']

new_files = iou.remove_file_extensions(files)

Expand Down

0 comments on commit 342673e

Please sign in to comment.