diff options
| author | Sebastian Berg <sebastianb@nvidia.com> | 2022-11-25 13:34:11 +0100 |
|---|---|---|
| committer | Sebastian Berg <sebastianb@nvidia.com> | 2022-11-25 14:02:33 +0100 |
| commit | c807a774b86409bd905b96388fbbc7011d797d5a (patch) | |
| tree | fd89d76746b51ad38e8020c8fd6c8f12b9a431b4 /numpy/_utils | |
| parent | 7c361420b4f81713f593ebbb5c924121c1f2d19d (diff) | |
| download | numpy-c807a774b86409bd905b96388fbbc7011d797d5a.tar.gz | |
MAINT: make `_utils` a full module
Diffstat (limited to 'numpy/_utils')
| -rw-r--r-- | numpy/_utils/__init__.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/numpy/_utils/__init__.py b/numpy/_utils/__init__.py new file mode 100644 index 000000000..f27556ee2 --- /dev/null +++ b/numpy/_utils/__init__.py @@ -0,0 +1,27 @@ +""" +This is a module for defining helpers which do not depend on the +rest of NumPy. + +Everything in here must be self-contained so that it can be +imported anywhere else without creating circular imports. +If a utility requires the import of NumPy, it probably belongs +in ``numpy.core``. +""" + + +def set_module(module): + """Private decorator for overriding __module__ on a function or class. + + Example usage:: + + @set_module('numpy') + def example(): + pass + + assert example.__module__ == 'numpy' + """ + def decorator(func): + if module is not None: + func.__module__ = module + return func + return decorator |
