Skip to content

Commit 54c38f8

Browse files
committed
DEP: Transition minc module to deprecated, announce 3.0 removal
1 parent 2663b68 commit 54c38f8

File tree

5 files changed

+29
-19
lines changed

5 files changed

+29
-19
lines changed

nibabel/minc.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import warnings
44

5-
warnings.warn("We will remove this module from nibabel soon; "
5+
warnings.warn("We will remove this module from nibabel 3.0; "
66
"Please use the 'minc1' module instead",
7-
FutureWarning,
7+
DeprecationWarning,
88
stacklevel=2)
99

1010
from .minc1 import * # noqa

nibabel/minc1.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from .fileslice import canonical_slicers
1919

2020
from .keywordonly import kw_only_meth
21-
from .deprecated import FutureWarningMixin
21+
from .deprecated import deprecate_with_version
2222

2323
_dt_dict = {
2424
('b', 'unsigned'): np.uint8,
@@ -331,13 +331,13 @@ def from_file_map(klass, file_map, mmap=True, keep_file_open=None):
331331

332332

333333
# Backwards compatibility
334-
class MincFile(FutureWarningMixin, Minc1File):
335-
""" Deprecated alternative name for Minc1File
336-
"""
337-
warn_message = 'MincFile is deprecated; please use Minc1File instead'
334+
@deprecate_with_version('MincFile is deprecated; please use Minc1File instead',
335+
since='2.0.0', until='3.0.0', warn_class=FutureWarning)
336+
class MincFile(Minc1File):
337+
pass
338338

339339

340-
class MincImage(FutureWarningMixin, Minc1Image):
341-
""" Deprecated alternative name for Minc1Image
342-
"""
343-
warn_message = 'MincImage is deprecated; please use Minc1Image instead'
340+
@deprecate_with_version('MincImage is deprecated; please use Minc1Image instead',
341+
since='2.0.0', until='3.0.0', warn_class=FutureWarning)
342+
class MincImage(Minc1Image):
343+
pass

nibabel/testing/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from os.path import dirname, abspath, join as pjoin
1717

1818
import numpy as np
19-
from numpy.testing import assert_array_equal
19+
from numpy.testing import assert_array_equal, assert_warns
2020
from numpy.testing import dec
2121
skipif = dec.skipif
2222
slow = dec.slow

nibabel/tests/test_minc.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from ..info import cmp_pkg_version
2+
from ..testing import assert_raises
3+
4+
5+
def test_minc_removed():
6+
if cmp_pkg_version('3.0.0dev') < 1:
7+
with assert_raises(ImportError):
8+
import nibabel.minc

nibabel/tests/test_minc1.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
from .. import minc1
2525
from ..minc1 import Minc1File, Minc1Image, MincHeader
2626

27-
from nose.tools import (assert_true, assert_equal, assert_false, assert_raises)
28-
from numpy.testing import assert_array_equal
2927
from ..tmpdirs import InTemporaryDirectory
30-
from ..testing import data_path
28+
from ..testing import (assert_true, assert_equal, assert_false, assert_raises, assert_warns,
29+
assert_array_equal, data_path, clear_and_catch_warnings)
3130

3231
from . import test_spatialimages as tsi
3332
from .test_fileslice import slicer_samples
@@ -106,7 +105,8 @@ def test_old_namespace():
106105
# Check warnings raised
107106
arr = np.arange(24).reshape((2, 3, 4))
108107
aff = np.diag([2, 3, 4, 1])
109-
with warnings.catch_warnings(record=True) as warns:
108+
with clear_and_catch_warnings() as warns:
109+
warnings.simplefilter('always', DeprecationWarning)
110110
# Top level import.
111111
# This import does not trigger an import of the minc.py module, because
112112
# it's the proxy object.
@@ -122,7 +122,9 @@ def test_old_namespace():
122122
# depending on whether the minc.py module is already imported in this
123123
# test run.
124124
if not previous_import:
125-
assert_equal(warns.pop(0).category, FutureWarning)
125+
assert_equal(warns.pop(0).category, DeprecationWarning)
126+
127+
with clear_and_catch_warnings() as warns:
126128
from .. import Minc1Image, MincImage
127129
assert_equal(warns, [])
128130
# The import from old module is the same as that from new
@@ -132,17 +134,17 @@ def test_old_namespace():
132134
assert_equal(warns, [])
133135
# Create object using old name
134136
mimg = MincImage(arr, aff)
135-
assert_array_equal(mimg.get_data(), arr)
136137
# Call to create object created warning
137138
assert_equal(warns.pop(0).category, FutureWarning)
139+
assert_array_equal(mimg.get_data(), arr)
138140
# Another old name
139141
from ..minc1 import MincFile, Minc1File
140142
assert_false(MincFile is Minc1File)
141143
assert_equal(warns, [])
142144
mf = MincFile(netcdf_file(EG_FNAME))
143-
assert_equal(mf.get_data_shape(), (10, 20, 20))
144145
# Call to create object created warning
145146
assert_equal(warns.pop(0).category, FutureWarning)
147+
assert_equal(mf.get_data_shape(), (10, 20, 20))
146148

147149

148150
class _TestMincFile(object):

0 commit comments

Comments
 (0)