diff --git a/numpy/__init__.py b/numpy/__init__.py index 4c43fd3fbc65..e5810931d33f 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -185,23 +185,20 @@ from .lib import ( DataSource, apply_along_axis, apply_over_axes, array_split, broadcast_arrays, broadcast_shapes, - broadcast_to, byte_bounds, c_, column_stack, common_type, - diag, diag_indices, + broadcast_to, byte_bounds, c_, column_stack, diag, diag_indices, diag_indices_from, diagflat, dsplit, dstack, ediff1d, emath, expand_dims, eye, fill_diagonal, fix, fliplr, flipud, fromregex, get_array_wrap, genfromtxt, - get_include, histogram2d, - hsplit, imag, in1d, index_exp, info, intersect1d, iscomplex, - iscomplexobj, isin, isneginf, isreal, isrealobj, - ix_, kron, load, loadtxt, mask_indices, - mgrid, mintypecode, nan_to_num, ndenumerate, ndindex, ogrid, + get_include, histogram2d, hsplit, in1d, index_exp, info, intersect1d, + isin, isneginf, ix_, kron, load, loadtxt, mask_indices, + mgrid, ndenumerate, ndindex, ogrid, packbits, pad, poly, poly1d, polyadd, polyder, polydiv, polyfit, polyint, polymul, polysub, polyval, - put_along_axis, r_, ravel_multi_index, real, real_if_close, + put_along_axis, r_, ravel_multi_index, roots, row_stack, s_, save, savetxt, savez, savez_compressed, setdiff1d, setxor1d, show_runtime, split, take_along_axis, tile, tri, tril, - tril_indices, tril_indices_from, typename, union1d, unique, unpackbits, + tril_indices, tril_indices_from, union1d, unique, unpackbits, unravel_index, vander, vsplit, triu, triu_indices, triu_indices_from, isposinf ) @@ -220,6 +217,10 @@ corrcoef, median, sinc, hamming, hanning, bartlett, blackman, kaiser, trapz, i0, meshgrid, delete, insert, append, interp, quantile ) + from .lib._type_check_impl import ( + iscomplexobj, isrealobj, imag, iscomplex, isreal, nan_to_num, real, + real_if_close, typename, mintypecode, common_type + ) from . import matrixlib as _mat from .matrixlib import ( asmatrix, bmat, matrix @@ -283,6 +284,7 @@ set(_mat.__all__) | set(lib._histograms_impl.__all__) | set(lib._nanfunctions_impl.__all__) | set(lib._function_base_impl.__all__) | + set(lib._type_check_impl.__all__) | {"show_config", "__version__"} ) diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index 8e101ffa5671..567b1503ddc1 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -561,7 +561,7 @@ from numpy.lib.twodim_base import ( triu_indices_from as triu_indices_from, ) -from numpy.lib.type_check import ( +from numpy.lib._type_check_impl import ( mintypecode as mintypecode, real as real, imag as imag, diff --git a/numpy/lib/__init__.py b/numpy/lib/__init__.py index b8845f271efb..610b696d1c46 100644 --- a/numpy/lib/__init__.py +++ b/numpy/lib/__init__.py @@ -19,7 +19,7 @@ # Private submodules # load module names. See https://github.com/networkx/networkx/issues/5838 -from . import type_check +from . import _type_check_impl from . import index_tricks from . import _nanfunctions_impl from . import _function_base_impl @@ -36,7 +36,6 @@ from . import arraypad from . import _version -from .type_check import * from .index_tricks import * from .shape_base import * from .stride_tricks import * @@ -52,8 +51,8 @@ from ._version import * from numpy.core._multiarray_umath import tracemalloc_domain + __all__ = ['emath'] -__all__ += type_check.__all__ __all__ += index_tricks.__all__ __all__ += shape_base.__all__ __all__ += stride_tricks.__all__ diff --git a/numpy/lib/__init__.pyi b/numpy/lib/__init__.pyi index 9a10a9934f7f..badcf376ed92 100644 --- a/numpy/lib/__init__.pyi +++ b/numpy/lib/__init__.pyi @@ -128,20 +128,6 @@ from numpy.lib.twodim_base import ( triu_indices_from as triu_indices_from, ) -from numpy.lib.type_check import ( - mintypecode as mintypecode, - real as real, - imag as imag, - iscomplex as iscomplex, - isreal as isreal, - iscomplexobj as iscomplexobj, - isrealobj as isrealobj, - nan_to_num as nan_to_num, - real_if_close as real_if_close, - typename as typename, - common_type as common_type, -) - from numpy.lib.ufunclike import ( fix as fix, isposinf as isposinf, diff --git a/numpy/lib/type_check.py b/numpy/lib/_type_check_impl.py similarity index 100% rename from numpy/lib/type_check.py rename to numpy/lib/_type_check_impl.py diff --git a/numpy/lib/type_check.pyi b/numpy/lib/_type_check_impl.pyi similarity index 100% rename from numpy/lib/type_check.pyi rename to numpy/lib/_type_check_impl.pyi diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py index c86f27dea9a9..732703edd5f1 100644 --- a/numpy/lib/polynomial.py +++ b/numpy/lib/polynomial.py @@ -19,7 +19,7 @@ from numpy.exceptions import RankWarning from numpy.lib.twodim_base import diag, vander from numpy.lib._function_base_impl import trim_zeros -from numpy.lib.type_check import iscomplex, real, imag, mintypecode +from numpy.lib._type_check_impl import iscomplex, real, imag, mintypecode from numpy.linalg import eigvals, lstsq, inv diff --git a/numpy/lib/scimath.py b/numpy/lib/scimath.py index b7ef0d7109c6..4a665726f448 100644 --- a/numpy/lib/scimath.py +++ b/numpy/lib/scimath.py @@ -34,7 +34,7 @@ import numpy.core.numerictypes as nt from numpy.core.numeric import asarray, any from numpy.core.overrides import array_function_dispatch -from numpy.lib.type_check import isreal +from numpy.lib._type_check_impl import isreal __all__ = [ diff --git a/numpy/lib/tests/test_type_check.py b/numpy/lib/tests/test_type_check.py index dc6946fbe642..e8e11c4257c3 100644 --- a/numpy/lib/tests/test_type_check.py +++ b/numpy/lib/tests/test_type_check.py @@ -1,11 +1,11 @@ import numpy as np -from numpy.testing import ( - assert_, assert_equal, assert_array_equal, assert_raises - ) -from numpy.lib.type_check import ( +from numpy import ( common_type, mintypecode, isreal, iscomplex, isposinf, isneginf, nan_to_num, isrealobj, iscomplexobj, real_if_close ) +from numpy.testing import ( + assert_, assert_equal, assert_array_equal, assert_raises + ) def assert_all(x): diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index 1bc57693af5d..e234a5464dcc 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -277,7 +277,7 @@ def assert_equal(actual, desired, err_msg='', verbose=True): verbose) return from numpy.core import ndarray, isscalar, signbit - from numpy.lib import iscomplexobj, real, imag + from numpy import iscomplexobj, real, imag if isinstance(actual, ndarray) or isinstance(desired, ndarray): return assert_array_equal(actual, desired, err_msg, verbose) msg = build_err_msg([actual, desired], err_msg, verbose=verbose) @@ -482,7 +482,7 @@ def assert_almost_equal(actual, desired, decimal=7, err_msg='', verbose=True): """ __tracebackhide__ = True # Hide traceback for py.test from numpy.core import ndarray - from numpy.lib import iscomplexobj, real, imag + from numpy import iscomplexobj, real, imag # Handle complex numbers: separate into real/imag to handle # nan/inf/negative zero correctly diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py index 4a1c2f0ff6ae..6dd1c73b0be1 100644 --- a/numpy/tests/test_public_api.py +++ b/numpy/tests/test_public_api.py @@ -204,7 +204,6 @@ def test_NPY_NO_EXPORT(): "lib.polynomial", "lib.shape_base", "lib.twodim_base", - "lib.type_check", "lib.ufunclike", "lib.user_array", # note: not in np.lib, but probably should just be deleted "lib.utils",