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