Skip to content

Commit a277f62

Browse files
authored
Merge pull request #24537 from mtsokol/lib-typecheck-namespace
API: Update `lib.type_check` namespace [skip ci]
2 parents ef0fd39 + 4e1f7cf commit a277f62

11 files changed

+22
-36
lines changed

numpy/__init__.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -185,23 +185,20 @@
185185
from .lib import (
186186
DataSource, apply_along_axis, apply_over_axes,
187187
array_split, broadcast_arrays, broadcast_shapes,
188-
broadcast_to, byte_bounds, c_, column_stack, common_type,
189-
diag, diag_indices,
188+
broadcast_to, byte_bounds, c_, column_stack, diag, diag_indices,
190189
diag_indices_from, diagflat, dsplit, dstack,
191190
ediff1d, emath, expand_dims, eye, fill_diagonal, fix,
192191
fliplr, flipud, fromregex, get_array_wrap, genfromtxt,
193-
get_include, histogram2d,
194-
hsplit, imag, in1d, index_exp, info, intersect1d, iscomplex,
195-
iscomplexobj, isin, isneginf, isreal, isrealobj,
196-
ix_, kron, load, loadtxt, mask_indices,
197-
mgrid, mintypecode, nan_to_num, ndenumerate, ndindex, ogrid,
192+
get_include, histogram2d, hsplit, in1d, index_exp, info, intersect1d,
193+
isin, isneginf, ix_, kron, load, loadtxt, mask_indices,
194+
mgrid, ndenumerate, ndindex, ogrid,
198195
packbits, pad, poly, poly1d, polyadd, polyder,
199196
polydiv, polyfit, polyint, polymul, polysub, polyval,
200-
put_along_axis, r_, ravel_multi_index, real, real_if_close,
197+
put_along_axis, r_, ravel_multi_index,
201198
roots, row_stack, s_, save, savetxt, savez, savez_compressed,
202199
setdiff1d, setxor1d, show_runtime, split,
203200
take_along_axis, tile, tri, tril,
204-
tril_indices, tril_indices_from, typename, union1d, unique, unpackbits,
201+
tril_indices, tril_indices_from, union1d, unique, unpackbits,
205202
unravel_index, vander, vsplit, triu, triu_indices, triu_indices_from,
206203
isposinf
207204
)
@@ -220,6 +217,10 @@
220217
corrcoef, median, sinc, hamming, hanning, bartlett, blackman,
221218
kaiser, trapz, i0, meshgrid, delete, insert, append, interp, quantile
222219
)
220+
from .lib._type_check_impl import (
221+
iscomplexobj, isrealobj, imag, iscomplex, isreal, nan_to_num, real,
222+
real_if_close, typename, mintypecode, common_type
223+
)
223224
from . import matrixlib as _mat
224225
from .matrixlib import (
225226
asmatrix, bmat, matrix
@@ -283,6 +284,7 @@
283284
set(_mat.__all__) | set(lib._histograms_impl.__all__) |
284285
set(lib._nanfunctions_impl.__all__) |
285286
set(lib._function_base_impl.__all__) |
287+
set(lib._type_check_impl.__all__) |
286288
{"show_config", "__version__"}
287289
)
288290

numpy/__init__.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ from numpy.lib.twodim_base import (
561561
triu_indices_from as triu_indices_from,
562562
)
563563

564-
from numpy.lib.type_check import (
564+
from numpy.lib._type_check_impl import (
565565
mintypecode as mintypecode,
566566
real as real,
567567
imag as imag,

numpy/lib/__init__.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
# Private submodules
2121
# load module names. See https://github.com/networkx/networkx/issues/5838
22-
from . import type_check
22+
from . import _type_check_impl
2323
from . import index_tricks
2424
from . import _nanfunctions_impl
2525
from . import _function_base_impl
@@ -36,7 +36,6 @@
3636
from . import arraypad
3737
from . import _version
3838

39-
from .type_check import *
4039
from .index_tricks import *
4140
from .shape_base import *
4241
from .stride_tricks import *
@@ -53,8 +52,8 @@
5352
from numpy.core._multiarray_umath import add_docstring, tracemalloc_domain
5453
from numpy.core.function_base import add_newdoc
5554

55+
5656
__all__ = ['emath']
57-
__all__ += type_check.__all__
5857
__all__ += index_tricks.__all__
5958
__all__ += shape_base.__all__
6059
__all__ += stride_tricks.__all__

numpy/lib/__init__.pyi

-14
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,6 @@ from numpy.lib.twodim_base import (
128128
triu_indices_from as triu_indices_from,
129129
)
130130

131-
from numpy.lib.type_check import (
132-
mintypecode as mintypecode,
133-
real as real,
134-
imag as imag,
135-
iscomplex as iscomplex,
136-
isreal as isreal,
137-
iscomplexobj as iscomplexobj,
138-
isrealobj as isrealobj,
139-
nan_to_num as nan_to_num,
140-
real_if_close as real_if_close,
141-
typename as typename,
142-
common_type as common_type,
143-
)
144-
145131
from numpy.lib.ufunclike import (
146132
fix as fix,
147133
isposinf as isposinf,
File renamed without changes.
File renamed without changes.

numpy/lib/polynomial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from numpy.exceptions import RankWarning
2020
from numpy.lib.twodim_base import diag, vander
2121
from numpy.lib._function_base_impl import trim_zeros
22-
from numpy.lib.type_check import iscomplex, real, imag, mintypecode
22+
from numpy.lib._type_check_impl import iscomplex, real, imag, mintypecode
2323
from numpy.linalg import eigvals, lstsq, inv
2424

2525

numpy/lib/scimath.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import numpy.core.numerictypes as nt
3535
from numpy.core.numeric import asarray, any
3636
from numpy.core.overrides import array_function_dispatch
37-
from numpy.lib.type_check import isreal
37+
from numpy.lib._type_check_impl import isreal
3838

3939

4040
__all__ = [

numpy/lib/tests/test_type_check.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import numpy as np
2-
from numpy.testing import (
3-
assert_, assert_equal, assert_array_equal, assert_raises
4-
)
5-
from numpy.lib.type_check import (
2+
from numpy import (
63
common_type, mintypecode, isreal, iscomplex, isposinf, isneginf,
74
nan_to_num, isrealobj, iscomplexobj, real_if_close
85
)
6+
from numpy.testing import (
7+
assert_, assert_equal, assert_array_equal, assert_raises
8+
)
99

1010

1111
def assert_all(x):

numpy/testing/_private/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def assert_equal(actual, desired, err_msg='', verbose=True):
277277
verbose)
278278
return
279279
from numpy.core import ndarray, isscalar, signbit
280-
from numpy.lib import iscomplexobj, real, imag
280+
from numpy import iscomplexobj, real, imag
281281
if isinstance(actual, ndarray) or isinstance(desired, ndarray):
282282
return assert_array_equal(actual, desired, err_msg, verbose)
283283
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):
482482
"""
483483
__tracebackhide__ = True # Hide traceback for py.test
484484
from numpy.core import ndarray
485-
from numpy.lib import iscomplexobj, real, imag
485+
from numpy import iscomplexobj, real, imag
486486

487487
# Handle complex numbers: separate into real/imag to handle
488488
# nan/inf/negative zero correctly

numpy/tests/test_public_api.py

-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ def test_NPY_NO_EXPORT():
204204
"lib.polynomial",
205205
"lib.shape_base",
206206
"lib.twodim_base",
207-
"lib.type_check",
208207
"lib.ufunclike",
209208
"lib.user_array", # note: not in np.lib, but probably should just be deleted
210209
"lib.utils",

0 commit comments

Comments
 (0)