Skip to content

Commit

Permalink
Merge pull request #24537 from mtsokol/lib-typecheck-namespace
Browse files Browse the repository at this point in the history
API: Update `lib.type_check` namespace

[skip ci]
  • Loading branch information
rgommers committed Aug 28, 2023
2 parents ef0fd39 + 4e1f7cf commit a277f62
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 36 deletions.
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 @@ -53,8 +52,8 @@
from numpy.core._multiarray_umath import add_docstring, tracemalloc_domain
from numpy.core.function_base import add_newdoc


__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

0 comments on commit a277f62

Please sign in to comment.