_internal.py 947 B

12345678910111213141516171819202122232425
  1. from numpy._core import _internal
  2. # Build a new array from the information in a pickle.
  3. # Note that the name numpy.core._internal._reconstruct is embedded in
  4. # pickles of ndarrays made with NumPy before release 1.0
  5. # so don't remove the name here, or you'll
  6. # break backward compatibility.
  7. def _reconstruct(subtype, shape, dtype):
  8. from numpy import ndarray
  9. return ndarray.__new__(subtype, shape, dtype)
  10. # Pybind11 (in versions <= 2.11.1) imports _dtype_from_pep3118 from the
  11. # _internal submodule, therefore it must be importable without a warning.
  12. _dtype_from_pep3118 = _internal._dtype_from_pep3118
  13. def __getattr__(attr_name):
  14. from numpy._core import _internal
  15. from ._utils import _raise_warning
  16. ret = getattr(_internal, attr_name, None)
  17. if ret is None:
  18. raise AttributeError(
  19. f"module 'numpy.core._internal' has no attribute {attr_name}")
  20. _raise_warning(attr_name, "_internal")
  21. return ret