Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 39bc1b1

Browse files
authored
Merge pull request #24567 from mtsokol/lib-pad-setops-ufunc-utils-namespace
API: Update `arraypad`,`arraysetops`, `ufunclike` and `utils` namespaces in `np.lib`
2 parents ff5dce9 + 08e086c commit 39bc1b1

26 files changed

+97
-157
lines changed

benchmarks/benchmarks/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44

55
def show_cpu_features():
6-
from numpy.lib.utils import _opt_info
6+
from numpy.lib._utils_impl import _opt_info
77
info = _opt_info()
88
info = "NumPy CPU features: " + (info if info else 'nothing enabled')
99
# ASV wrapping stdout & stderr, so we assume having a tty here

doc/source/reference/routines.set.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ Set routines
33

44
.. currentmodule:: numpy
55

6-
.. autosummary::
7-
:toctree: generated/
8-
9-
lib.arraysetops
10-
116
Making proper sets
127
------------------
138
.. autosummary::

numpy/__init__.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,18 @@
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, diag_indices,
188+
broadcast_to, c_, column_stack, diag_indices,
189189
diag_indices_from, dsplit, dstack,
190-
ediff1d, emath, expand_dims, fill_diagonal, fix,
190+
emath, expand_dims, fill_diagonal,
191191
fromregex, get_array_wrap, genfromtxt,
192-
get_include, hsplit, in1d, index_exp, info, intersect1d,
193-
isin, isneginf, ix_, kron, load, loadtxt,
192+
hsplit, index_exp, ix_, kron, load, loadtxt,
194193
mgrid, ndenumerate, ndindex, ogrid,
195-
packbits, pad, poly, poly1d, polyadd, polyder,
194+
packbits, poly, poly1d, polyadd, polyder,
196195
polydiv, polyfit, polyint, polymul, polysub, polyval,
197196
put_along_axis, r_, ravel_multi_index,
198-
roots, row_stack, s_, save, savetxt, savez, savez_compressed,
199-
setdiff1d, setxor1d, show_runtime, split,
200-
take_along_axis, tile, union1d, unique, unpackbits,
201-
unravel_index, vsplit, isposinf
197+
roots, row_stack, s_, save, savetxt, savez,
198+
savez_compressed, split, take_along_axis, tile,
199+
unpackbits, unravel_index, vsplit
202200
)
203201
from .lib._histograms_impl import (
204202
histogram, histogram_bin_edges, histogramdd
@@ -224,6 +222,14 @@
224222
iscomplexobj, isrealobj, imag, iscomplex, isreal, nan_to_num, real,
225223
real_if_close, typename, mintypecode, common_type
226224
)
225+
from .lib._arraysetops_impl import (
226+
ediff1d, in1d, intersect1d, isin, setdiff1d, setxor1d, union1d, unique
227+
)
228+
from .lib._ufunclike_impl import fix, isneginf, isposinf
229+
from .lib._arraypad_impl import pad
230+
from .lib._utils_impl import (
231+
byte_bounds, show_runtime, get_include, info
232+
)
227233
from . import matrixlib as _mat
228234
from .matrixlib import (
229235
asmatrix, bmat, matrix
@@ -289,6 +295,10 @@
289295
set(lib._function_base_impl.__all__) |
290296
set(lib._twodim_base_impl.__all__) |
291297
set(lib._type_check_impl.__all__) |
298+
set(lib._arraysetops_impl.__all__) |
299+
set(lib._ufunclike_impl.__all__) |
300+
set(lib._arraypad_impl.__all__) |
301+
set(lib._utils_impl.__all__) |
292302
{"show_config", "__version__"}
293303
)
294304

numpy/__init__.pyi

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,11 @@ from numpy.lib import (
397397
emath as emath,
398398
)
399399

400-
from numpy.lib.arraypad import (
400+
from numpy.lib._arraypad_impl import (
401401
pad as pad,
402402
)
403403

404-
from numpy.lib.arraysetops import (
404+
from numpy.lib._arraysetops_impl import (
405405
ediff1d as ediff1d,
406406
intersect1d as intersect1d,
407407
setxor1d as setxor1d,
@@ -575,17 +575,15 @@ from numpy.lib._type_check_impl import (
575575
common_type as common_type,
576576
)
577577

578-
from numpy.lib.ufunclike import (
578+
from numpy.lib._ufunclike_impl import (
579579
fix as fix,
580580
isposinf as isposinf,
581581
isneginf as isneginf,
582582
)
583583

584-
from numpy.lib.utils import (
585-
issubdtype as issubdtype,
584+
from numpy.lib._utils_impl import (
586585
get_include as get_include,
587586
info as info,
588-
source as source,
589587
byte_bounds as byte_bounds,
590588
show_runtime as show_runtime,
591589
)

numpy/_pytesttester.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _show_numpy_info():
3939
print("NumPy version %s" % np.__version__)
4040
relaxed_strides = np.ones((10, 1), order="C").flags.f_contiguous
4141
print("NumPy relaxed strides checking option:", relaxed_strides)
42-
info = np.lib.utils._opt_info()
42+
info = np.lib._utils_impl._opt_info()
4343
print("NumPy CPU features: ", (info if info else 'nothing enabled'))
4444

4545

numpy/core/tests/test_deprecations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ def test_deprecated_np_lib_math(self):
753753
class TestLibImports(_DeprecationTestCase):
754754
# Deprecated in Numpy 1.26.0, 2023-09
755755
def test_lib_functions_deprecation_call(self):
756-
from numpy.lib.utils import safe_eval
756+
from numpy.lib._utils_impl import safe_eval
757757
from numpy.lib.npyio import recfromcsv, recfromtxt
758758
from numpy.lib._function_base_impl import disp
759759
from numpy.lib.shape_base import get_array_wrap

numpy/lib/__init__.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,22 @@
2626
from . import shape_base
2727
from . import stride_tricks
2828
from . import _twodim_base_impl
29-
from . import ufunclike
29+
from . import _ufunclike_impl
3030
from . import _histograms_impl
3131
from . import polynomial
32-
from . import utils
33-
from . import arraysetops
32+
from . import _utils_impl
33+
from . import _arraysetops_impl
3434
from . import npyio
3535
from . import arrayterator
36-
from . import arraypad
36+
from . import _arraypad_impl
3737
from . import _version
3838

3939
from .index_tricks import *
4040
from .shape_base import *
4141
from .stride_tricks import *
42-
from .ufunclike import *
43-
4442
from .polynomial import *
45-
from .utils import *
46-
from .arraysetops import *
4743
from .npyio import *
4844
from .arrayterator import Arrayterator
49-
from .arraypad import *
5045
from ._version import *
5146
from numpy.core._multiarray_umath import add_docstring, tracemalloc_domain
5247
from numpy.core.function_base import add_newdoc
@@ -56,11 +51,7 @@
5651
__all__ += index_tricks.__all__
5752
__all__ += shape_base.__all__
5853
__all__ += stride_tricks.__all__
59-
__all__ += ufunclike.__all__
60-
__all__ += arraypad.__all__
6154
__all__ += polynomial.__all__
62-
__all__ += utils.__all__
63-
__all__ += arraysetops.__all__
6455
__all__ += npyio.__all__
6556

6657
from numpy._pytesttester import PytestTester
@@ -78,7 +69,15 @@ def __getattr__(attr):
7869
"`math` module (Deprecated Numpy 1.25). Replace usages of "
7970
"`numpy.lib.math` with `math`", DeprecationWarning, stacklevel=2)
8071
return math
72+
elif attr in (
73+
"histograms", "type_check", "nanfunctions", "function_base",
74+
"arraypad", "arraysetops", "ufunclike", "utils", "twodim_base"
75+
):
76+
raise AttributeError(
77+
f"`np.lib.{attr}` is now private. If you are using a public "
78+
"function, it should be available in the main numpy namespace, "
79+
"otherwise check the NumPy 2.0 migration guide."
80+
)
8181
else:
8282
raise AttributeError("module {!r} has no attribute "
8383
"{!r}".format(__name__, attr))
84-

numpy/lib/__init__.pyi

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,6 @@ from numpy.lib._version import (
2121
NumpyVersion as NumpyVersion,
2222
)
2323

24-
from numpy.lib.arraypad import (
25-
pad as pad,
26-
)
27-
28-
from numpy.lib.arraysetops import (
29-
ediff1d as ediff1d,
30-
intersect1d as intersect1d,
31-
setxor1d as setxor1d,
32-
union1d as union1d,
33-
setdiff1d as setdiff1d,
34-
unique as unique,
35-
in1d as in1d,
36-
isin as isin,
37-
)
38-
3924
from numpy.lib.arrayterator import (
4025
Arrayterator as Arrayterator,
4126
)
@@ -110,19 +95,6 @@ from numpy.lib.stride_tricks import (
11095
broadcast_shapes as broadcast_shapes,
11196
)
11297

113-
from numpy.lib.ufunclike import (
114-
fix as fix,
115-
isposinf as isposinf,
116-
isneginf as isneginf,
117-
)
118-
119-
from numpy.lib.utils import (
120-
get_include as get_include,
121-
info as info,
122-
byte_bounds as byte_bounds,
123-
show_runtime as show_runtime,
124-
)
125-
12698
from numpy.core.multiarray import (
12799
add_docstring as add_docstring,
128100
tracemalloc_domain as tracemalloc_domain,
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)