Skip to content

API: Update lib.type_check namespace #24537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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
Expand Down Expand Up @@ -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__"}
)

Expand Down
2 changes: 1 addition & 1 deletion numpy/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions numpy/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 *
Expand All @@ -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__
Expand Down
14 changes: 0 additions & 14 deletions numpy/lib/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion numpy/lib/polynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion numpy/lib/scimath.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = [
Expand Down
8 changes: 4 additions & 4 deletions numpy/lib/tests/test_type_check.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
4 changes: 2 additions & 2 deletions numpy/testing/_private/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion numpy/tests/test_public_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down