__init__.py 723 B

1234567891011121314151617181920212223242526272829
  1. """
  2. This is a module for defining private helpers which do not depend on the
  3. rest of NumPy.
  4. Everything in here must be self-contained so that it can be
  5. imported anywhere else without creating circular imports.
  6. If a utility requires the import of NumPy, it probably belongs
  7. in ``numpy.core``.
  8. """
  9. from ._convertions import asunicode, asbytes
  10. def set_module(module):
  11. """Private decorator for overriding __module__ on a function or class.
  12. Example usage::
  13. @set_module('numpy')
  14. def example():
  15. pass
  16. assert example.__module__ == 'numpy'
  17. """
  18. def decorator(func):
  19. if module is not None:
  20. func.__module__ = module
  21. return func
  22. return decorator