Skip to content

Commit 7867a59

Browse files
committed
ENH: Check for multi-file images, to ensure well-defined behavior
1 parent 7dffd1c commit 7867a59

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

nibabel/filebasedimages.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,8 @@ def from_bytes(klass, bytestring):
573573
bstring : bytes
574574
Byte string containing the on-disk representation of an image
575575
"""
576+
if len(klass.files_types) > 1:
577+
raise NotImplementedError("from_bytes is undefined for multi-file images")
576578
bio = io.BytesIO(bytestring)
577579
file_map = klass.make_file_map({'image': bio, 'header': bio})
578580
return klass.from_file_map(file_map)
@@ -590,6 +592,8 @@ def to_bytes(self):
590592
bytes
591593
Serialized image
592594
"""
595+
if len(self.__class__.files_types) > 1:
596+
raise NotImplementedError("to_bytes() is undefined for multi-file images")
593597
bio = io.BytesIO()
594598
file_map = self.make_file_map({'image': bio, 'header': bio})
595599
self.to_file_map(file_map)

0 commit comments

Comments
 (0)