deprecated
¶
Module to help with deprecating objects and classes
|
Insert FutureWarning for object creation |
|
Proxy for module that may not yet have been imported |
Deprecation warning that will be shown by default |
FutureWarningMixin
¶
-
class
nibabel.deprecated.
FutureWarningMixin
(*args, **kwargs)¶ Bases:
object
Insert FutureWarning for object creation
Examples
>>> class C(object): pass >>> class D(FutureWarningMixin, C): ... warn_message = "Please, don't use this class"
Record the warning
>>> with warnings.catch_warnings(record=True) as warns: ... d = D() ... warns[0].message.args[0] "Please, don't use this class"
-
__init__
(*args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
warn_message
= 'This class will be removed in future versions'¶
-
ModuleProxy
¶
-
class
nibabel.deprecated.
ModuleProxy
(module_name)¶ Bases:
object
Proxy for module that may not yet have been imported
- Parameters
- module_namestr
Full module name e.g.
nibabel.minc
Examples
- ::
arr = np.arange(24).reshape((2, 3, 4)) nifti1 = ModuleProxy(‘nibabel.nifti1’) nifti1_image = nifti1.Nifti1Image(arr, np.eye(4))
So, the
nifti1
object is a proxy that will import the required module when you do attribute access and return the attributes of the imported module.-
__init__
(module_name)¶ Initialize self. See help(type(self)) for accurate signature.
VisibleDeprecationWarning
¶
-
class
nibabel.deprecated.
VisibleDeprecationWarning
¶ Bases:
UserWarning
Deprecation warning that will be shown by default
Python >= 2.7 does not show standard DeprecationWarnings by default:
http://docs.python.org/dev/whatsnew/2.7.html#the-future-for-python-2-x
Use this class for cases where we do want to show deprecations by default.
-
__init__
(*args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-