8000 API: Expand star imports [skip ci] · numpy/numpy@8e60daa · GitHub
[go: up one dir, main page]

Skip to content

Commit 8e60daa

Browse files
committed
API: Expand star imports [skip ci]
1 parent 775b5dd commit 8e60daa

File tree

4 files changed

+82
-19
lines changed

4 files changed

+82
-19
lines changed

numpy/__init__.py

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,90 @@
120120
__all__ = ['exceptions']
121121

122122
from . import core
123-
from .core import *
123+
from .core import (
124+
_no_nep50_warning, memmap,
125+
iinfo, finfo, # getlimits submodule exports
126+
False_, ScalarType, True_, abs, absolute, add, all, allclose, alltrue,
127+
amax, amin, any, arange, arccos, arccosh, arcsin, arcsinh, arctan,
128+
arctan2, arctanh, argmax, argmin, argpartition, argsort, argwhere,
129+
around, array, array2string, array_equal, array_equiv, array_repr,
130+
array_str, asanyarray, asarray, ascontiguousarray, asfortranarray,
131+
atleast_1d, atleast_2d, atleast_3d, base_repr, binary_repr,
132+
bitwise_and, bitwise_not, bitwise_or, bitwise_xor, block, bool_,
133+
broadcast, busday_count, busday_offset, busdaycalendar, byte, bytes_,
134+
can_cast, cbrt, cdouble, ceil, cfloat, char, character, chararray,
135+
choose, clip, clongdouble, clongfloat, compare_chararrays, complex_,
136+
complexfloating, compress, concatenate, conj, conjugate, convolve,
137+
copysign, copyto, correlate, cos, cosh, count_nonzero, cross, csingle,
138+
cumprod, cumproduct, cumsum, datetime64, datetime_as_string,
139+
datetime_data, deg2rad, degrees, diagonal, divide, divmod, dot,
140+
double, dtype, e, einsum, einsum_path, empty, empty_like, equal,
141+
errstate, euler_gamma, exp, exp2, expm1, fabs, find_common_type,
142+
flatiter, flatnonzero, flexible, float128, float16, float32, float64,
143+
float_, float_power, floating, floor, floor_divide, fmax, fmin, fmod,
144+
format_float_positional, format_float_scientific, format_parser,
145+
frexp, from_dlpack, frombuffer, fromfile, fromfunction, fromiter,
146+
frompyfunc, fromstring, full, full_like, gcd, generic, geomspace,
147+
get_printoptions, getbufsize, geterr, geterrcall, greater,
148+
greater_equal, half, heaviside, hstack, hypot, identity, iinfo,
149+
indices, inexact, inf, infty, inner, int16, int32, int64, int8, int_,
150+
intc, integer, intp, invert, is_busday, isclose, isfinite, isfortran,
151+
isinf, isnan, isnat, isscalar, issctype, issubdtype, lcm, ldexp,
152+
left_shift, less, less_equal, lexsort, linspace, little_endian, log,
153+
log10, log1p, log2, logaddexp, logaddexp2, logical_and, logical_not,
154+
logical_or, logical_xor, logspace, longcomplex, longdouble,
155+
longfloat, longlong, matmul, max, maximum, maximum_sctype,
156+
may_share_memory, mean, min, min_scalar_type, minimum, mod,
157+
modf, moveaxis, multiply, nan, nbytes, ndarray, ndim, nditer,
158+
negative, nested_iters, newaxis, nextafter, nonzero, not_equal,
159+
number, obj2sctype, object_, ones, ones_like, outer, partition,
160+
pi, positive, power, printoptions, prod, product, promote_types,
161+
ptp, put, putmask, rad2deg, radians, ravel, rec, recarray, reciprocal,
162+
record, remainder, repeat, require, reshape, resize, result_type,
163+
right_shift, rint, roll, rollaxis, round, round_, sctype2char,
164+
sctypeDict, sctypes, searchsorted, set_printoptions,
165+
set_string_function, setbufsize, seterr, seterrcall, shape,
166+
shares_memory, short, sign, signbit, signedinteger, sin, single,
167+
singlecomplex, sinh, size, sometrue, sort, spacing, sqrt, square,
168+
squeeze, stack, std, str_, string_, subtract, sum, swapaxes, take,
169+
tan, tanh, tensordot, test, timedelta64, trace, transpose,
170+
true_divide, trunc, typecodes, ubyte, ufunc, uint, uint16, uint32,
171+
uint64, uint8, uintc, uintp, ulonglong, unicode_, unsignedinteger,
172+
ushort, var, vdot, void, vstack, warnings, where, zeros, zeros_like
173+
)
174+
124175
from . import exceptions
125176
from . import dtypes
126177
from . import lib
127178
# NOTE: to be revisited following future namespace cleanup.
128179
# See gh-14454 and gh-15672 for discussion.
129-
from .lib import *
180+
from .lib import (
181+
DataSource, angle, append, apply_along_axis, apply_over_axes,
182+
array_split, asarray_chkfinite, asfarray, average, bartlett,
183+
bincount, blackman, broadcast_arrays, broadcast_shapes,
184+
broadcast_to, byte_bounds, c_, column_stack, common_type,
185+
copy, corrcoef, cov, delete, diag, diag_indices,
186+
diag_indices_from, diagflat, diff, digitize, dsplit, dstack,
187+
ediff1d, emath, expand_dims, extract, eye, fill_diagonal, fix,
188+
flip, fliplr, flipud, fromregex, get_array_wrap, genfromtxt,
189+
get_include, gradient, hamming, hanning, histogram, histogram2d,
190+
histogram_bin_edges, histogramdd, hsplit, i0, imag, in1d,
191+
index_exp, info, insert, interp, intersect1d, iscomplex,
192+
iscomplexobj, isin, isneginf, isreal, isrealobj, issubclass_,
193+
issubsctype, iterable, ix_, kaiser, kron, load, loadtxt, mask_indices,
194+
median, meshgrid, mgrid, mintypecode, msort, nan_to_num,
195+
nanargmax, nanargmin, nancumprod, nancumsum, nanmax, nanmean,
196+
nanmedian, nanmin, nanpercentile, nanprod, nanquantile, nanstd,
197+
nansum, nanvar, ndenumerate, ndindex, ogrid, packbits, pad,
198+
percentile, piecewise, place, poly, poly1d, polyadd, polyder,
199+
polydiv, polyfit, polyint, polymul, polynomial, polysub, polyval,
200+
put_along_axis, quantile, r_, ravel_multi_index, real, real_if_close,
201+
roots, rot90, row_stack, s_, save, savetxt, savez, savez_compressed,
202+
select, setdiff1d, setxor1d, show_runtime, sinc, sort_complex, split,
203+
take_along_axis, test, tile, tracemalloc_domain, trapz, tri, tril,
204+
tril_indices, tril_indices_from, typename, union1d, unique, unpackbits,
205+
unravel_index, unwrap, vander, vectorize, vsplit
206+
)
130207

131208
from . import linalg
132209
from . import fft
@@ -135,7 +212,9 @@
135212
from . import ctypeslib
136213
from . import ma
137214
from . import matrixlib as _mat
138-
from .matrixlib import *
215+
from .matrixlib import (
216+
asmatrix, bmat, defmatrix, mat, matrix, test
217+
)
139218

140219
# We build warning messages for former attributes
141220
_msg = (
@@ -177,7 +256,6 @@
177256
# import with `from numpy import *`.
178257
__future_scalars__ = {"bool", "long", "ulong", "str", "bytes", "object"}
179258

180-
from .core import abs
181259
# now that numpy core module is imported, can initialize limits
182260
core.getlimits._register_known_types()
183261

@@ -194,7 +272,6 @@
194272
# These are exported by np.core, but are replaced by the builtins below
195273
# remove them to ensure that we don't end up with `np.long == np.int_`,
196274
# which would be a breaking change.
197-
del long, unicode
198275
__all__.remove('long')
199276
__all__.remove('unicode')
200277

@@ -205,7 +282,6 @@
205282
# The list below will grow until the `from .lib import *` fixme above is
206283
# taken care of
207284
__all__.remove('Arrayterator')
208-
del Arrayterator
209285

210286
# Filter out Cython harmless warnings
211287
warnings.filterwarnings("ignore", message="numpy.dtype size changed")

numpy/__init__.pyi

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,6 @@ from numpy.core.einsumfunc import (
305305
)
306306

307307
from numpy.core.multiarray import (
308-
ALLOW_THREADS as ALLOW_THREADS,
309-
BUFSIZE as BUFSIZE,
310-
CLIP as CLIP,
311-
MAXDIMS as MAXDIMS,
312-
MAY_SHARE_BOUNDS as MAY_SHARE_BOUNDS,
313-
MAY_SHARE_EXACT as MAY_SHARE_EXACT,
314-
RAISE as RAISE,
315-
WRAP as WRAP,
316308
tracemalloc_domain as tracemalloc_domain,
317309
array as array,
318310
empty_like as empty_like,
@@ -3161,7 +3153,6 @@ FPE_UNDERFLOW: L[4]
31613153
FPE_INVALID: L[8]
31623154

31633155
FLOATING_POINT_SUPPORT: L[1]
3164-
UFUNC_BUFSIZE_DEFAULT = BUFSIZE
31653156

31663157
little_endian: Final[bool]
31673158
True_: Final[bool_]
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import numpy as np
22

33
np.Inf = np.Inf # E: Cannot assign to final
4-
np.ALLOW_THREADS = np.ALLOW_THREADS # E: Cannot assign to final
54
np.little_endian = np.little_endian # E: Cannot assign to final
65
np.UFUNC_PYVALS_NAME = "bob" # E: Incompatible types
76
np.CLIP = 2 # E: Incompatible types

numpy/typing/tests/data/reveal/constants.pyi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ reveal_type(np.infty) # E: float
1515
reveal_type(np.nan) # E: float
1616
reveal_type(np.pi) # E: float
1717

18-
reveal_type(np.ALLOW_THREADS) # E: int
19-
reveal_type(np.BUFSIZE) # E: Literal[8192]
2018
reveal_type(np.CLIP) # E: Literal[0]
2119
reveal_type(np.FLOATING_POINT_SUPPORT) # E: Literal[1]
2220
reveal_type(np.FPE_DIVIDEBYZERO) # E: Literal[1]
@@ -27,7 +25,6 @@ reveal_type(np.MAXDIMS) # E: Literal[32]
2725
reveal_type(np.MAY_SHARE_BOUNDS) # E: Literal[0]
2826
reveal_type(np.MAY_SHARE_EXACT) # E: Literal[-1]
2927
reveal_type(np.RAISE) # E: Literal[2]
30-
reveal_type(np.UFUNC_BUFSIZE_DEFAULT) # E: Literal[8192]
3128
reveal_type(np.WRAP) # E: Literal[1]
3229
reveal_type(np.tracemalloc_domain) # E: Literal[389047]
3330

0 commit comments

Comments
 (0)
0