Skip to content

Commit 8d6bcb7

Browse files
committed
NF+BF - added stacklevel to DeprecationWarning; fixed recursive from_filespec; closes gh-6
1 parent 99dbbb8 commit 8d6bcb7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

nibabel/spatialimages.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,12 @@ def from_filename(klass, filename):
381381
return klass.from_file_map(file_map)
382382

383383
@classmethod
384-
def from_filespec(klass, img, filespec):
384+
def from_filespec(klass, filespec):
385385
warnings.warn('``from_filespec`` class method is deprecated\n'
386386
'Please use the ``from_filename`` class method '
387387
'instead',
388-
DeprecationWarning)
389-
klass.from_filespec(filespec)
388+
DeprecationWarning, stacklevel=2)
389+
klass.from_filename(filespec)
390390

391391
@classmethod
392392
def from_file_map(klass, file_map):
@@ -397,7 +397,7 @@ def from_files(klass, file_map):
397397
warnings.warn('``from_files`` class method is deprecated\n'
398398
'Please use the ``from_file_map`` class method '
399399
'instead',
400-
DeprecationWarning)
400+
DeprecationWarning, stacklevel=2)
401401
return klass.from_file_map(file_map)
402402

403403
@classmethod
@@ -419,7 +419,7 @@ def filespec_to_files(klass, filespec):
419419
warnings.warn('``filespec_to_files`` class method is deprecated\n'
420420
'Please use the ``filespec_to_file_map`` class method '
421421
'instead',
422-
DeprecationWarning)
422+
DeprecationWarning, stacklevel=2)
423423
return klass.filespec_to_file_map(filespec)
424424

425425
def to_filename(self, filename):
@@ -442,7 +442,7 @@ def to_filename(self, filename):
442442
def to_filespec(self, filename):
443443
warnings.warn('``to_filespec`` is deprecated, please '
444444
'use ``to_filename`` instead',
445-
DeprecationWarning)
445+
DeprecationWarning, stacklevel=2)
446446
self.to_filename(filename)
447447

448448
def to_file_map(self, file_map=None):
@@ -452,7 +452,7 @@ def to_files(self, file_map=None):
452452
warnings.warn('``to_files`` method is deprecated\n'
453453
'Please use the ``to_file_map`` method '
454454
'instead',
455-
DeprecationWarning)
455+
DeprecationWarning, stacklevel=2)
456456
self.to_file_map(file_map)
457457

458458
@classmethod
@@ -495,7 +495,7 @@ def save(klass, img, filename):
495495
warnings.warn('``save`` class method is deprecated\n'
496496
'You probably want the ``to_filename`` instance '
497497
'method, or the module-level ``save`` function',
498-
DeprecationWarning)
498+
DeprecationWarning, stacklevel=2)
499499
klass.instance_to_filename(img, filename)
500500

501501
@classmethod

0 commit comments

Comments
 (0)