Description
Hi @rgommers @seberg @ngoldbaum!
NEP 52 1 (tracking issue #23999) describes cleaning up NumPy's Python API - I started rewiring it, starting from the main namespace (so with a top-down approach - first to clean-up top namespace and then step down to submodules).
Below I share top NumPy namespace (so items that are available within np.*
) with entries to be removed from there. I took an aggressive approach to cut as much as possible (from 563 items here I propose to drop 221, so 40% of the main namespace) so I assume to rather relax this list after a review. UPDATE The final list removes 18% of the main namespace.
It mostly covers moving duplicates, removing multiple aliases, moving dtype
classes and aliases to np.dtypes
submodule proposed in NEP 52, and considers some unused/deprecated methods mentioned in previous issues/PRs.
This list doesn't concern removing any function per se, only restructuring the main namespace.
Please share your feedback!
[UPDATE] Latest list can be found in comments below: #24306 (comment)
[UPDATE 31.08] Here's the final list with "remove" and "stay" columns:
remove 🔴 | stay 🟢 |
---|---|
ALLOW_THREADS | matrix |
AxisError (available in np.exceptions) | ScalarType |
BUFSIZE | asfortranarray |
CLIP | abs |
ComplexWarning (available in np.exceptions) | add |
ERR_CALL | all |
ERR_DEFAULT | allclose |
ERR_IGNORE | alltrue |
ERR_LOG | amax |
ERR_PRINT | amin |
ERR_RAISE | angle |
ERR_WARN | any |
FLOATING_POINT_SUPPORT | append |
FPE_DIVIDEBYZERO | can_cast (present in Array API) |
FPE_INVALID | apply_along_axis |
FPE_OVERFLOW | apply_over_axes |
FPE_UNDERFLOW | arange |
Inf (use np.inf) | arccos |
Infinity (use np.inf) | arccosh |
MAXDIMS (use axis=None) | arcsin |
MAY_SHARE_BOUNDS | arcsinh |
MAY_SHARE_EXACT | arctan |
ModuleDeprecationWarning (available in np.exceptions) | arctan2 |
NAN (use np.nan) | arctanh |
NINF (use -np.inf) | argmax |
NZERO (use -0.0) | argmin |
NaN (use np.nan) | argpartition |
PINF (use np.inf) | argsort |
PZERO (use 0.0) | argwhere |
RAISE | around |
in1d (use np.isin(a, b).ravel()) | array |
SHIFT_DIVIDEBYZERO | array_equal |
SHIFT_INVALID | array_equiv |
SHIFT_OVERFLOW | array_repr |
SHIFT_UNDERFLOW | asanyarray |
Tester (originally deleted in 1.25) | asarray |
TooHardError (moved to np.exceptions) | atleast_1d |
UFUNC_BUFSIZE_DEFAULT | atleast_2d |
UFUNC_PYVALS_NAME | atleast_3d |
VisibleDeprecationWarning (available in np.exceptions) | average |
WRAP | bartlett |
issctype | base_repr |
add_docstring (available in np.lib) | binary_repr |
add_newdoc (available in np.lib) | bincount |
add_newdoc_ufunc (niche, no replacement) | bitwise_and |
cfloat (use np.cdouble) | bitwise_not |
mat (use np.asmatrix) | bitwise_or |
clongfloat (use np.clongdouble) | bitwise_xor |
compat (niche, no replacement) | blackman |
issubclass_ (use issubclass builtin) | block |
deprecate (use DeprecationWarning) | bool_ |
deprecate_with_doc (use DeprecationWarning) | broadcast |
disp (use printing) | broadcast_arrays |
fastCopyAndTranspose | broadcast_shapes |
float_ (use np.float64) | broadcast_to |
infty (use inf) | byte |
longcomplex (use np.clongdouble) | byte_bounds |
longfloat (use np.longdouble) | bytes_ |
lookfor | cbrt |
math (use math directly) | cdouble |
numarray (already gone) | ceil |
oldnumeric (already gone) | char |
recfromcsv (use np.genfromtxt) | character |
recfromtxt (use np.genfromtxt) | choose |
safe_eval (use ast.literal_eval) | clip |
set_numeric_ops (niche) | clongdouble |
set_string_function | column_stack |
singlecomplex (use np.csingle) | complex128 |
string_ (use np.bytes_) | complex256 |
unicode_ (use np.str_) | complex64 |
use_hugepage (internal) | complex_ |
who (niche, no replacement) | complexfloating |
w (internal) | compress |
asfarray (use np.asarray(..., dtype=...)) | concatenate |
issubsctype (use issubdtype) | conj |
maximum_sctype (niche, no replacement) | conjugate |
obj2sctype (use .dtype.type) | convolve |
sctype2char | copy |
sctypeDict | copysign |
sctypes | copyto |
corrcoef | |
trapz (use scipy.integrate.trapezoid) | correlate |
tracemalloc_domain (available in np.lib) | cos |
source | cosh |
cast (niche, no replacement) | count_nonzero |
nbytes | cov |
round_ (instead use np.round) | csingle |
find_common_type | ctypeslib |
RankWarning (moved to np.exceptions) | cumprod (rename) |
get_array_wrap | cumproduct (rename) |
seterrobj | cumsum (rename) |
geterrobj | datetime64 |
msort (deprecated, removed) | deg2rad |
DataSource (still in np.lib.npyio) | degrees |
float96 | delete |
float128 | diag |
compare_chararrays (still in np.char) | diag_indices |
chararray (still in np.char) | diag_indices_from |
recarray (still in np.rec) | diagflat |
format_parser (still in np.rec) | diagonal |
diff | |
digitize | |
divide | |
divmod | |
dot | |
dsplit | |
double | |
dstack | |
dtype | |
e | |
ediff1d | |
einsum | |
einsum_path | |
emath | |
empty | |
empty_like | |
equal | |
error_message | |
errstate | |
euler_gamma | |
exp | |
exp2 | |
expand_dims | |
expm1 | |
extract | |
eye | |
finfo | |
fabs | |
fft | |
fill_diagonal | |
fix | |
flatiter | |
flatnonzero | |
flexible | |
flip | |
fliplr | |
flipud | |
float16 | |
float32 | |
float64 | |
float_power | |
floating | |
floor | |
floor_divide | |
fmax | |
fmin | |
fmod | |
format_float_positional | |
format_float_scientific | |
frexp | |
from_dlpack | |
frombuffer | |
fromfile | |
fromfunction | |
fromiter | |
frompyfunc | |
fromregex | |
fromstring | |
full | |
full_like | |
gcd | |
generic | |
genfromtxt | |
geomspace | |
get_printoptions | |
getbufsize | |
gradient | |
greater | |
greater_equal | |
half | |
hamming | |
hanning | |
heaviside | |
hsplit | |
hstack | |
hypot | |
identity | |
imag | |
iinfo | |
indices | |
inexact | |
inf | |
info | |
insert | |
int16 | |
int32 | |
int64 | |
int8 | |
int_ | |
intc | |
integer | |
interp | |
intersect1d | |
invert | |
isclose | |
isfinite | |
isin | |
isinf | |
isnan | |
isnat | |
isneginf | |
isposinf | |
iterable | |
kaiser | |
lcm | |
ldexp | |
left_shift | |
less | |
less_equal | |
lexsort | |
lib | |
linalg | |
linspace | |
little_endian | |
load | |
loadtxt | |
log | |
log10 | |
log1p | |
log2 | |
logaddexp | |
logaddexp2 | |
logical_and | |
logical_not | |
logical_or | |
logical_xor | |
logspace | |
longdouble | |
longlong | |
ma | |
mask_indices | |
matmul | |
max | |
maximum | |
mean | |
median | |
memmap | |
meshgrid | |
mgrid | |
min | |
minimum | |
mod | |
modf | |
moveaxis | |
multiply | |
nan | |
nan_to_num | |
all nan_* functions (can be addressed another time) | |
ndarray | |
ndenumerate | |
ndim | |
ndindex | |
nditer | |
negative | |
nested_iters | |
newaxis | |
nextafter | |
nonzero | |
not_equal | |
number | |
object_ | |
ogrid | |
ones | |
ones_like | |
packbits | |
pad | |
partition | |
percentile | |
pi | |
piecewise | |
place | |
positive | |
power | |
printoptions | |
prod | |
product | |
ptp | |
put | |
result_type | |
put_along_axis | |
quantile | |
rad2deg | |
radians | |
random | |
ravel | |
ravel_multi_index | |
real | |
real_if_close | |
rec | |
reciprocal | |
record | |
remainder | |
repeat | |
reshape | |
resize | |
right_shift | |
roll | |
rollaxis | |
rot90 | |
round | |
save | |
savetxt | |
savez | |
savez_compressed | |
searchsorted | |
select | |
set_printoptions | |
setbufsize | |
setdiff1d | |
setxor1d | |
shape | |
shares_memory | |
short | |
show_config | |
show_runtime | |
sign | |
signbit | |
signedinteger | |
sin | |
sinc | |
single | |
sinh | |
size | |
sometrue | |
sort | |
sort_complex | |
spacing | |
split | |
sqrt | |
square | |
squeeze | |
stack | |
std | |
str_ | |
subtract | |
sum | |
swapaxes | |
take | |
take_along_axis | |
tan | |
tensordot | |
tanh | |
test | |
testing | |
tile | |
timedelta64 | |
trace | |
tri (tril and triu are in Array API) | |
tril | |
tril_indices | |
tril_indices_from | |
triu | |
triu_indices | |
triu_indices_from | |
trim_zeros | |
true_divide | |
trunc | |
ubyte | |
ufunc | |
uint | |
uint16 | |
uint32 | |
uint64 | |
uint8 | |
uintc | |
ulonglong | |
union1d | |
unique | |
unpackbits | |
unravel_index | |
unsignedinteger | |
ushort | |
unwrap | |
vectorize | |
version | |
void | |
vsplit | |
vstack | |
where | |
zeros | |
zeros_like | |
var | |
ascontiguousarray | |
may_share_memory | |
get_include | |
intp | |
uintp | |
i0 | |
issubdtype | |
absolute | |
histogram | |
histogram2d | |
histogram_bin_edges | |
histogramdd | |
asmatrix | |
seterrcall | |
geterr | |
geterrcall | |
rint | |
ix_ | |
outer | |
common_type | |
putmask | |
datetime_as_string | |
inner | |
vander | |
vdot | |
cross | |
typecodes | |
typename | |
transpose | |
kron | |
asarray_chkfinite | |
all poly* functions | |
roots | |
is_busday | |
busday_count | |
busday_offset | |
busdaycalendar | |
iscomplex | |
iscomplexobj | |
isfortran | |
isreal | |
isrealobj | |
isscalar | |
False_ | |
True_ | |
c_ | |
r_ | |
s_ | |
index_exp | |
mintypecode | |
min_scalar_type | |
array2string | |
array_str | |
array_split | |
require | |
datetime_data | |
bmat | |
promote_types |