8000 Completed typing rewrite · numpy/numpy@0c9b293 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0c9b293

Browse files
committed
Completed typing rewrite
1 parent 07ff08c commit 0c9b293

29 files changed

+321
-307
lines changed

numpy/__init__.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,17 @@
128128
array_str, asanyarray, asarray, ascontiguousarray, asfortranarray,
129129
atleast_1d, atleast_2d, atleast_3d, base_repr, binary_repr,
130130
bitwise_and, bitwise_count, bitwise_not, bitwise_or, bitwise_xor,
131-
block, bool, bool_, broadcast, busday_count, busday_offset, busdaycalendar,
132-
byte, bytes_, can_cast, cbrt, cdouble, ceil, character, choose, clip,
133-
clongdouble, complex128, complex64, complexfloating, compress,
134-
concatenate, conj, conjugate, convolve, copysign, copyto, correlate,
135-
cos, cosh, count_nonzero, cross, csingle, cumprod, cumproduct, cumsum,
136-
datetime64, datetime_as_string, datetime_data, deg2rad, degrees,
137-
diagonal, divide, divmod, dot, double, dtype, e, einsum, einsum_path,
138-
empty, empty_like, equal, errstate, euler_gamma, exp, exp2, expm1,
139-
fabs, finfo, flatiter, flatnonzero, flexible, float16, float32,
140-
float64, float_power, floating, floor, floor_divide, fmax, fmin, fmod,
131+
block, bool, bool_, broadcast, busday_count, busday_offset,
132+
busdaycalendar, byte, bytes_, can_cast, cbrt, cdouble, ceil,
133+
character, choose, clip, clongdouble, complex128, complex64,
134+
complexfloating, compress, concatenate, conj, conjugate, convolve,
135+
copysign, copyto, correlate, cos, cosh, count_nonzero, cross, csingle,
136+
cumprod, cumproduct, cumsum, datetime64, datetime_as_string,
137+
datetime_data, deg2rad, degrees, diagonal, divide, divmod, dot,
138+
double, dtype, e, einsum, einsum_path, empty, empty_like, equal,
139+
errstate, euler_gamma, exp, exp2, expm1, fabs, finfo, flatiter,
140+
flatnonzero, flexible, float16, float32, float64, float_power,
141+
floating, floor, floor_divide, fmax, fmin, fmod,
141142
format_float_positional, format_float_scientific, frexp, from_dlpack,
142143
frombuffer, fromfile, fromfunction, fromiter, frompyfunc, fromstring,
143144
full, full_like, gcd, generic, geomspace, get_printoptions,

numpy/_core/_add_newdocs_scalars.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,22 @@ def add_newdoc_for_scalar_type(obj, fixed_aliases, doc):
9393
add_newdoc('numpy._core.numerictypes', obj, docstring)
9494

9595

96-
add_newdoc_for_scalar_type('bool_', [],
96+
_bool_docstring = (
9797
"""
9898
Boolean type (True or False), stored as a byte.
9999
100100
.. warning::
101101
102-
The :class:`bool_` type is not a subclass of the :class:`int_` type
103-
(the :class:`bool_` is not even a number type). This is different
102+
The :class:`bool` type is not a subclass of the :class:`int_` type
103+
(the :class:`bool` is not even a number type). This is different
104104
than Python's default implementation of :class:`bool` as a
105105
sub-class of :class:`int`.
106-
""")
106+
"""
107+
)
108+
109+
add_newdoc_for_scalar_type('bool', [], _bool_docstring)
110+
111+
add_newdoc_for_scalar_type('bool_', [], _bool_docstring)
107112

108113
add_newdoc_for_scalar_type('byte', [],
109114
"""

numpy/_core/_methods.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def _mean(a, axis=None, dtype=None, out=None, keepdims=False, *, where=True):
111111

112112
# Cast bool, unsigned int, and int to float64 by default
113113
if dtype is None:
114-
if issubclass(arr.dtype.type, (nt.integer, nt.bool_)):
114+
if issubclass(arr.dtype.type, (nt.integer, nt.bool)):
115115
dtype = mu.dtype('f8')
116116
elif issubclass(arr.dtype.type, nt.float16):
117117
dtype = mu.dtype('f4')
@@ -145,7 +145,7 @@ def _var(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False, *,
145145
stacklevel=2)
146146

147147
# Cast bool, unsigned int, and int to float64 by default
148-
if dtype is None and issubclass(arr.dtype.type, (nt.integer, nt.bool_)):
148+
if dtype is None and issubclass(arr.dtype.type, (nt.integer, nt.bool)):
149149
dtype = mu.dtype('f8')
150150

151151
if mean is not None:

numpy/_core/arrayprint.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
set_legacy_print_mode)
4040
from .fromnumeric import any
4141
from .numeric import concatenate, asarray, errstate
42-
from .numerictypes import (longlong, intc, int_, float64, complex128, bool_,
42+
from .numerictypes import (longlong, intc, int_, float64, complex128,
4343
flexible)
4444
from .overrides import array_function_dispatch, set_module
4545
import operator
@@ -474,7 +474,7 @@ def _get_format_function(data, **options):
474474
formatdict = _get_formatdict(data, **options)
475475
if dtypeobj is None:
476476
return formatdict["numpystr"]()
477-
elif issubclass(dtypeobj, _nt.bool_):
477+
elif issubclass(dtypeobj, _nt.bool):
478478
return formatdict['bool']()
479479
elif issubclass(dtypeobj, _nt.integer):
480480
if issubclass(dtypeobj, _nt.timedelta64):
@@ -1460,7 +1460,7 @@ def _void_scalar_to_string(x, is_repr=True):
14601460
return f"{cls_fqn}({val_repr}, dtype={void_dtype!s})"
14611461

14621462

1463-
_typelessdata = [int_, float64, complex128, bool_]
1463+
_typelessdata = [int_, float64, complex128, _nt.bool]
14641464

14651465

14661466
def dtype_is_implied(dtype):
@@ -1490,7 +1490,7 @@ def dtype_is_implied(dtype):
14901490
array([1, 2, 3], dtype=int8)
14911491
"""
14921492
dtype = np.dtype(dtype)
1493-
if _format_options['legacy'] <= 113 and dtype.type == bool_:
1493+
if _format_options['legacy'] <= 113 and dtype.type == np.bool:
14941494
return False
14951495

14961496
# not just void types can be structured, and names are not part of the repr

0 commit comments

Comments
 (0)
0