_utils.py 923 B

123456789101112131415161718192021
  1. import warnings
  2. def _raise_warning(attr: str, submodule: str | None = None) -> None:
  3. new_module = "numpy._core"
  4. old_module = "numpy.core"
  5. if submodule is not None:
  6. new_module = f"{new_module}.{submodule}"
  7. old_module = f"{old_module}.{submodule}"
  8. warnings.warn(
  9. f"{old_module} is deprecated and has been renamed to {new_module}. "
  10. "The numpy._core namespace contains private NumPy internals and its "
  11. "use is discouraged, as NumPy internals can change without warning in "
  12. "any release. In practice, most real-world usage of numpy.core is to "
  13. "access functionality in the public NumPy API. If that is the case, "
  14. "use the public NumPy API. If not, you are using NumPy internals. "
  15. "If you would still like to access an internal attribute, "
  16. f"use {new_module}.{attr}.",
  17. DeprecationWarning,
  18. stacklevel=3
  19. )