Skip to content

Commit b8848fa

Browse files
committed
MNT: Drop FileBasedImage.to/from_files(pec) methods, deprecated in 1.0, expired in 3.0
1 parent ac5ac10 commit b8848fa

File tree

4 files changed

+8
-61
lines changed

4 files changed

+8
-61
lines changed

nibabel/filebasedimages.py

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ class FileBasedImage(object):
159159
itself back to the files pointed to in ``file_map``. When a file holder
160160
holds active file-like objects, then these may be affected by the
161161
initial file read; in this case, the contains file-like objects need to
162-
carry the position at which a write (with ``to_files``) should place the
162+
carry the position at which a write (with ``to_file_map``) should place the
163163
data. The ``file_map`` contents should therefore be such, that this will
164-
work:
164+
work.
165165
"""
166166
header_class = FileBasedHeader
167167
_meta_sniff_len = 0
@@ -263,14 +263,6 @@ def from_filename(klass, filename):
263263
def from_file_map(klass, file_map):
264264
raise NotImplementedError
265265

266-
@classmethod
267-
@deprecate_with_version('from_files class method is deprecated.\n'
268-
'Please use the ``from_file_map`` class method '
269-
'instead.',
270-
'1.0', '3.0')
271-
def from_files(klass, file_map):
272-
return klass.from_file_map(file_map)
273-
274266
@classmethod
275267
def filespec_to_file_map(klass, filespec):
276268
""" Make `file_map` for this class from filename `filespec`
@@ -307,14 +299,6 @@ def filespec_to_file_map(klass, filespec):
307299
file_map[key] = FileHolder(filename=fname)
308300
return file_map
309301

310-
@classmethod
311-
@deprecate_with_version('filespec_to_files class method is deprecated.\n'
312-
'Please use the "filespec_to_file_map" class '
313-
'method instead.',
314-
'1.0', '3.0')
315-
def filespec_to_files(klass, filespec):
316-
return klass.filespec_to_file_map(filespec)
317-
318302
def to_filename(self, filename):
319303
""" Write image to files implied by filename string
320304
@@ -332,21 +316,9 @@ def to_filename(self, filename):
332316
self.file_map = self.filespec_to_file_map(filename)
333317
self.to_file_map()
334318

335-
@deprecate_with_version('to_filespec method is deprecated.\n'
336-
'Please use the "to_filename" method instead.',
337-
'1.0', '3.0')
338-
def to_filespec(self, filename):
339-
self.to_filename(filename)
340-
341319
def to_file_map(self, file_map=None):
342320
raise NotImplementedError
343321

344-
@deprecate_with_version('to_files method is deprecated.\n'
345-
'Please use the "to_file_map" method instead.',
346-
'1.0', '3.0')
347-
def to_files(self, file_map=None):
348-
self.to_file_map(file_map)
349-
350322
@classmethod
351323
def make_file_map(klass, mapping=None):
352324
""" Class method to make files holder for this image type

nibabel/spatialimages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
itself back to the files pointed to in ``file_map``. When a file holder
109109
holds active file-like objects, then these may be affected by the
110110
initial file read; in this case, the contains file-like objects need to
111-
carry the position at which a write (with ``to_files``) should place the
111+
carry the position at which a write (with ``to_file_map``) should place the
112112
data. The ``file_map`` contents should therefore be such, that this will
113113
work:
114114

nibabel/tests/test_removalschedule.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323

2424
ATTRIBUTE_SCHEDULE = [
2525
("5.0.0", [("nibabel.dataobj_images", "DataobjImage", "get_data")]),
26-
("4.0.0", [("nibabel.dataobj_images", "DataobjImage", "get_shape")]),
26+
("4.0.0", [("nibabel.dataobj_images", "DataobjImage", "get_shape"),
27+
("nibabel.filebasedimages", "FileBasedImage", "filespec_to_files"),
28+
("nibabel.filebasedimages", "FileBasedImage", "to_filespec"),
29+
("nibabel.filebasedimages", "FileBasedImage", "to_files"),
30+
("nibabel.filebasedimages", "FileBasedImage", "from_files")]),
2731
# Verify that the test will be quiet if the schedule outlives the modules
2832
("1.0.0", [("nibabel.nosuchmod", "anyobj", "anyattr"),
2933
("nibabel.nifti1", "nosuchobj", "anyattr"),

nibabel/tests/test_spatialimages.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -529,35 +529,6 @@ def test_slicer(self):
529529
assert (sliced_data == img.get_data()[sliceobj]).all()
530530
assert (sliced_data == img.get_fdata()[sliceobj]).all()
531531

532-
def test_api_deprecations(self):
533-
534-
class FakeImage(self.image_class):
535-
536-
files_types = (('image', '.foo'),)
537-
538-
@classmethod
539-
def to_file_map(self, file_map=None):
540-
pass
541-
542-
@classmethod
543-
def from_file_map(self, file_map=None):
544-
pass
545-
546-
arr = np.arange(24, dtype=np.int16).reshape((2, 3, 4))
547-
aff = np.eye(4)
548-
img = FakeImage(arr, aff)
549-
bio = BytesIO()
550-
file_map = FakeImage.make_file_map({'image': bio})
551-
552-
with pytest.raises(ExpiredDeprecationError):
553-
img.to_files(file_map)
554-
with pytest.raises(ExpiredDeprecationError):
555-
img.to_filespec('an_image')
556-
with pytest.raises(ExpiredDeprecationError):
557-
FakeImage.from_files(file_map)
558-
with pytest.raises(ExpiredDeprecationError):
559-
FakeImage.filespec_to_files('an_image')
560-
561532

562533
class MmapImageMixin(object):
563534
""" Mixin for testing images that may return memory maps """

0 commit comments

Comments
 (0)