Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/aspire/image/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class Image:
# Map file extensions to their respective readers
extensions = {
".mrc": load_mrc,
".mrcs": load_mrc,
".tif": load_tiff,
".tiff": load_tiff,
}
Expand Down
26 changes: 25 additions & 1 deletion tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def test_load_bad_ext():

def test_load_mrc(dtype):
"""
Test `Image.load` round-trip.
Test `Image.load` round-trip for `mrc` extension.
"""

# `sample.mrc` is single precision
Expand All @@ -480,6 +480,30 @@ def test_load_mrc(dtype):
assert im2.dtype == dtype


def test_load_mrcs(dtype):
"""
Test `Image.load` round-trip for `mrcs` extension.
"""

# `sample.mrcs` is single precision
filepath = os.path.join(DATA_DIR, "sample.mrcs")

# Load data from file
im = Image.load(filepath, dtype=dtype)

with tempfile.TemporaryDirectory() as tmpdir_name:
# tmp filename
test_filepath = os.path.join(tmpdir_name, "test.mrcs")

im.save(test_filepath)

im2 = Image.load(test_filepath, dtype)

# Check the single precision round-trip
assert np.array_equal(im, im2)
assert im2.dtype == dtype


def test_load_tiff():
"""
Test `Image.load` with a TIFF file
Expand Down
Loading