Skip to content

Commit ecee561

Browse files
committed
DOC: Deprecation warnings to stacklevel 2
1 parent d8f1be9 commit ecee561

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

nibabel/imageclasses.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
# DEPRECATED: mapping of names to classes and class functionality
3434
class ClassMapDict(dict):
3535
def __getitem__(self, *args, **kwargs):
36-
warnings.warn("class_map is deprecated.", DeprecationWarning)
36+
warnings.warn("class_map is deprecated.", DeprecationWarning,
37+
stacklevel=2)
3738
return super(ClassMapDict, self).__getitem__(*args, **kwargs)
3839

3940
class_map = ClassMapDict(
@@ -86,7 +87,8 @@ def __getitem__(self, *args, **kwargs):
8687

8788
class ExtMapRecoder(Recoder):
8889
def __getitem__(self, *args, **kwargs):
89-
warnings.warn("ext_map is deprecated.", DeprecationWarning)
90+
warnings.warn("ext_map is deprecated.", DeprecationWarning,
91+
stacklevel=2)
9092
return super(ExtMapRecoder, self).__getitem__(*args, **kwargs)
9193

9294
# mapping of extensions to default image class names

nibabel/loadsave.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def guessed_image_type(filename):
5858
image_class : class
5959
Class corresponding to guessed image type
6060
"""
61-
warnings.warn('guessed_image_type is deprecated', DeprecationWarning)
61+
warnings.warn('guessed_image_type is deprecated', DeprecationWarning,
62+
stacklevel=2)
6263
sniff = None
6364
for image_klass in all_image_classes:
6465
is_valid, sniff = image_klass.path_maybe_image(filename, sniff)
@@ -233,7 +234,8 @@ def which_analyze_type(binaryblock):
233234
* if ``sizeof_hdr`` is 348 or byteswapped 348 assume Analyze
234235
* Return None
235236
"""
236-
warnings.warn('which_analyze_type is deprecated', DeprecationWarning)
237+
warnings.warn('which_analyze_type is deprecated', DeprecationWarning,
238+
stacklevel=2)
237239
from .nifti1 import header_dtype
238240
hdr_struct = np.ndarray(shape=(), dtype=header_dtype, buffer=binaryblock)
239241
bs_hdr_struct = hdr_struct.byteswap()

0 commit comments

Comments
 (0)