__init__.py 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. """
  2. The `numpy.core` submodule exists solely for backward compatibility
  3. purposes. The original `core` was renamed to `_core` and made private.
  4. `numpy.core` will be removed in the future.
  5. """
  6. from numpy import _core
  7. from ._utils import _raise_warning
  8. # We used to use `np.core._ufunc_reconstruct` to unpickle.
  9. # This is unnecessary, but old pickles saved before 1.20 will be using it,
  10. # and there is no reason to break loading them.
  11. def _ufunc_reconstruct(module, name):
  12. # The `fromlist` kwarg is required to ensure that `mod` points to the
  13. # inner-most module rather than the parent package when module name is
  14. # nested. This makes it possible to pickle non-toplevel ufuncs such as
  15. # scipy.special.expit for instance.
  16. mod = __import__(module, fromlist=[name])
  17. return getattr(mod, name)
  18. # force lazy-loading of submodules to ensure a warning is printed
  19. __all__ = ["arrayprint", "defchararray", "_dtype_ctypes", "_dtype",
  20. "einsumfunc", "fromnumeric", "function_base", "getlimits",
  21. "_internal", "multiarray", "_multiarray_umath", "numeric",
  22. "numerictypes", "overrides", "records", "shape_base", "umath"]
  23. def __getattr__(attr_name):
  24. attr = getattr(_core, attr_name)
  25. _raise_warning(attr_name)
  26. return attr