pyrefly-numpy-stubs 1.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1527 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ from builtins import bool as py_bool
7
+ from collections.abc import Sequence
8
+ from types import EllipsisType
9
+ from typing import Any, Final, Literal, overload, SupportsIndex
10
+
11
+ import shape_extensions
12
+ from numpy.__config__ import (
13
+ show as show_config,
14
+ )
15
+ from numpy._array_api_info import (
16
+ __array_namespace_info__ as __array_namespace_info__,
17
+ )
18
+ from numpy._core._asarray import (
19
+ require as require,
20
+ )
21
+ from numpy._core._type_aliases import (
22
+ sctypeDict as sctypeDict,
23
+ )
24
+ from numpy._core._ufunc_config import (
25
+ errstate as errstate,
26
+ getbufsize as getbufsize,
27
+ geterr as geterr,
28
+ geterrcall as geterrcall,
29
+ setbufsize as setbufsize,
30
+ seterr as seterr,
31
+ seterrcall as seterrcall,
32
+ )
33
+ from numpy._core.arrayprint import (
34
+ array2string as array2string,
35
+ array_repr as array_repr,
36
+ array_str as array_str,
37
+ format_float_positional as format_float_positional,
38
+ format_float_scientific as format_float_scientific,
39
+ get_printoptions as get_printoptions,
40
+ printoptions as printoptions,
41
+ set_printoptions as set_printoptions,
42
+ )
43
+ from numpy._core.einsumfunc import (
44
+ einsum as einsum,
45
+ einsum_path as einsum_path,
46
+ )
47
+ from numpy._core.fromnumeric import (
48
+ all as all,
49
+ amax as amax,
50
+ amin as amin,
51
+ any as any,
52
+ argmax as argmax,
53
+ argpartition as argpartition,
54
+ argsort as argsort,
55
+ around as around,
56
+ choose as choose,
57
+ compress as compress,
58
+ cumprod as cumprod,
59
+ cumsum as cumsum,
60
+ cumulative_prod as cumulative_prod,
61
+ cumulative_sum as cumulative_sum,
62
+ diagonal as diagonal,
63
+ matrix_transpose as matrix_transpose,
64
+ ndim as ndim,
65
+ nonzero as nonzero,
66
+ partition as partition,
67
+ prod as prod,
68
+ ptp as ptp,
69
+ put as put,
70
+ ravel as ravel,
71
+ repeat as repeat,
72
+ reshape as reshape,
73
+ resize as resize,
74
+ searchsorted as searchsorted,
75
+ shape as shape,
76
+ size as size,
77
+ sort as sort,
78
+ squeeze as squeeze,
79
+ std as std,
80
+ swapaxes as swapaxes,
81
+ take as take,
82
+ trace as trace,
83
+ transpose as transpose,
84
+ var as var,
85
+ )
86
+ from numpy._core.function_base import (
87
+ geomspace as geomspace,
88
+ linspace as linspace,
89
+ logspace as logspace,
90
+ )
91
+ from numpy._core.getlimits import (
92
+ finfo as finfo,
93
+ iinfo as iinfo,
94
+ )
95
+ from numpy._core.memmap import (
96
+ memmap as memmap,
97
+ )
98
+ from numpy._core.multiarray import (
99
+ array as array,
100
+ asanyarray as asanyarray,
101
+ asarray as asarray,
102
+ ascontiguousarray as ascontiguousarray,
103
+ asfortranarray as asfortranarray,
104
+ bincount as bincount,
105
+ busday_count as busday_count,
106
+ busday_offset as busday_offset,
107
+ busdaycalendar as busdaycalendar,
108
+ can_cast as can_cast,
109
+ concatenate as concatenate,
110
+ copyto as copyto,
111
+ datetime_as_string as datetime_as_string,
112
+ datetime_data as datetime_data,
113
+ dot as dot,
114
+ empty_like as empty_like,
115
+ flatiter as flatiter,
116
+ frombuffer as frombuffer,
117
+ fromfile as fromfile,
118
+ fromiter as fromiter,
119
+ frompyfunc as frompyfunc,
120
+ fromstring as fromstring,
121
+ inner as inner,
122
+ is_busday as is_busday,
123
+ lexsort as lexsort,
124
+ may_share_memory as may_share_memory,
125
+ min_scalar_type as min_scalar_type,
126
+ nditer as nditer,
127
+ nested_iters as nested_iters,
128
+ packbits as packbits,
129
+ promote_types as promote_types,
130
+ putmask as putmask,
131
+ result_type as result_type,
132
+ shares_memory as shares_memory,
133
+ unpackbits as unpackbits,
134
+ vdot as vdot,
135
+ where as where,
136
+ )
137
+ from numpy._core.numeric import (
138
+ allclose as allclose,
139
+ argwhere as argwhere,
140
+ array_equal as array_equal,
141
+ array_equiv as array_equiv,
142
+ astype as astype,
143
+ base_repr as base_repr,
144
+ binary_repr as binary_repr,
145
+ convolve as convolve,
146
+ correlate as correlate,
147
+ count_nonzero as count_nonzero,
148
+ cross as cross,
149
+ flatnonzero as flatnonzero,
150
+ fromfunction as fromfunction,
151
+ full_like as full_like,
152
+ indices as indices,
153
+ isclose as isclose,
154
+ isfortran as isfortran,
155
+ isscalar as isscalar,
156
+ moveaxis as moveaxis,
157
+ ones_like as ones_like,
158
+ outer as outer,
159
+ roll as roll,
160
+ rollaxis as rollaxis,
161
+ tensordot as tensordot,
162
+ zeros_like as zeros_like,
163
+ )
164
+ from numpy._core.numerictypes import (
165
+ isdtype as isdtype,
166
+ issubdtype as issubdtype,
167
+ ScalarType as ScalarType,
168
+ typecodes as typecodes,
169
+ )
170
+ from numpy._core.records import (
171
+ recarray as recarray,
172
+ record as record,
173
+ )
174
+ from numpy._core.shape_base import (
175
+ atleast_1d as atleast_1d,
176
+ atleast_2d as atleast_2d,
177
+ atleast_3d as atleast_3d,
178
+ block as block,
179
+ hstack as hstack,
180
+ unstack as unstack,
181
+ vstack as vstack,
182
+ )
183
+ from numpy._pytesttester import PytestTester
184
+ from numpy._shapes import (
185
+ diag_extent,
186
+ matmul_shape,
187
+ matvec_shape,
188
+ reduce_shape,
189
+ stack_shape,
190
+ vecdot_shape,
191
+ vecmat_shape,
192
+ )
193
+ from numpy._typing import ArrayLike
194
+ from numpy._typing._extended_precision import (
195
+ complex256 as complex256,
196
+ float128 as float128,
197
+ )
198
+ from numpy.lib import (
199
+ scimath as emath,
200
+ )
201
+ from numpy.lib._arraypad_impl import (
202
+ pad as pad,
203
+ )
204
+ from numpy.lib._arraysetops_impl import (
205
+ ediff1d as ediff1d,
206
+ intersect1d as intersect1d,
207
+ isin as isin,
208
+ setdiff1d as setdiff1d,
209
+ setxor1d as setxor1d,
210
+ union1d as union1d,
211
+ unique as unique,
212
+ unique_all as unique_all,
213
+ unique_counts as unique_counts,
214
+ unique_inverse as unique_inverse,
215
+ unique_values as unique_values,
216
+ )
217
+ from numpy.lib._function_base_impl import (
218
+ angle as angle,
219
+ append as append,
220
+ asarray_chkfinite as asarray_chkfinite,
221
+ average as average,
222
+ bartlett as bartlett,
223
+ blackman as blackman,
224
+ copy as copy,
225
+ corrcoef as corrcoef,
226
+ cov as cov,
227
+ delete as delete,
228
+ diff as diff,
229
+ digitize as digitize,
230
+ extract as extract,
231
+ flip as flip,
232
+ gradient as gradient,
233
+ hamming as hamming,
234
+ hanning as hanning,
235
+ i0 as i0,
236
+ insert as insert,
237
+ interp as interp,
238
+ iterable as iterable,
239
+ kaiser as kaiser,
240
+ median as median,
241
+ meshgrid as meshgrid,
242
+ percentile as percentile,
243
+ piecewise as piecewise,
244
+ place as place,
245
+ quantile as quantile,
246
+ rot90 as rot90,
247
+ select as select,
248
+ sinc as sinc,
249
+ sort_complex as sort_complex,
250
+ trapezoid as trapezoid,
251
+ trim_zeros as trim_zeros,
252
+ unwrap as unwrap,
253
+ vectorize as vectorize,
254
+ )
255
+ from numpy.lib._histograms_impl import (
256
+ histogram as histogram,
257
+ histogram_bin_edges as histogram_bin_edges,
258
+ histogramdd as histogramdd,
259
+ )
260
+ from numpy.lib._index_tricks_impl import (
261
+ c_ as c_,
262
+ diag_indices as diag_indices,
263
+ diag_indices_from as diag_indices_from,
264
+ index_exp as index_exp,
265
+ ix_ as ix_,
266
+ mgrid as mgrid,
267
+ ndenumerate as ndenumerate,
268
+ ndindex as ndindex,
269
+ ogrid as ogrid,
270
+ r_ as r_,
271
+ ravel_multi_index as ravel_multi_index,
272
+ s_ as s_,
273
+ unravel_index as unravel_index,
274
+ )
275
+ from numpy.lib._nanfunctions_impl import (
276
+ nanargmax as nanargmax,
277
+ nanargmin as nanargmin,
278
+ nancumprod as nancumprod,
279
+ nancumsum as nancumsum,
280
+ nanmax as nanmax,
281
+ nanmean as nanmean,
282
+ nanmedian as nanmedian,
283
+ nanmin as nanmin,
284
+ nanpercentile as nanpercentile,
285
+ nanprod as nanprod,
286
+ nanquantile as nanquantile,
287
+ nanstd as nanstd,
288
+ nansum as nansum,
289
+ nanvar as nanvar,
290
+ )
291
+ from numpy.lib._npyio_impl import (
292
+ fromregex as fromregex,
293
+ genfromtxt as genfromtxt,
294
+ load as load,
295
+ loadtxt as loadtxt,
296
+ save as save,
297
+ savetxt as savetxt,
298
+ savez as savez,
299
+ savez_compressed as savez_compressed,
300
+ )
301
+ from numpy.lib._polynomial_impl import (
302
+ poly as poly,
303
+ poly1d as poly1d,
304
+ polyadd as polyadd,
305
+ polyder as polyder,
306
+ polydiv as polydiv,
307
+ polyfit as polyfit,
308
+ polyint as polyint,
309
+ polymul as polymul,
310
+ polysub as polysub,
311
+ polyval as polyval,
312
+ roots as roots,
313
+ )
314
+ from numpy.lib._shape_base_impl import (
315
+ apply_along_axis as apply_along_axis,
316
+ apply_over_axes as apply_over_axes,
317
+ array_split as array_split,
318
+ column_stack as column_stack,
319
+ dsplit as dsplit,
320
+ dstack as dstack,
321
+ hsplit as hsplit,
322
+ kron as kron,
323
+ put_along_axis as put_along_axis,
324
+ split as split,
325
+ take_along_axis as take_along_axis,
326
+ tile as tile,
327
+ vsplit as vsplit,
328
+ )
329
+ from numpy.lib._stride_tricks_impl import (
330
+ broadcast_arrays as broadcast_arrays,
331
+ broadcast_shapes as broadcast_shapes,
332
+ broadcast_to as broadcast_to,
333
+ )
334
+ from numpy.lib._twodim_base_impl import (
335
+ diagflat as diagflat,
336
+ fliplr as fliplr,
337
+ flipud as flipud,
338
+ histogram2d as histogram2d,
339
+ mask_indices as mask_indices,
340
+ tri as tri,
341
+ tril as tril,
342
+ tril_indices as tril_indices,
343
+ tril_indices_from as tril_indices_from,
344
+ triu as triu,
345
+ triu_indices as triu_indices,
346
+ triu_indices_from as triu_indices_from,
347
+ vander as vander,
348
+ )
349
+ from numpy.lib._type_check_impl import (
350
+ common_type as common_type,
351
+ imag as imag,
352
+ iscomplex as iscomplex,
353
+ iscomplexobj as iscomplexobj,
354
+ isreal as isreal,
355
+ isrealobj as isrealobj,
356
+ mintypecode as mintypecode,
357
+ nan_to_num as nan_to_num,
358
+ real as real,
359
+ real_if_close as real_if_close,
360
+ typename as typename,
361
+ )
362
+ from numpy.lib._ufunclike_impl import (
363
+ fix as fix,
364
+ isneginf as isneginf,
365
+ isposinf as isposinf,
366
+ )
367
+ from numpy.lib._utils_impl import (
368
+ get_include as get_include,
369
+ info as info,
370
+ show_runtime as show_runtime,
371
+ )
372
+ from numpy.matrixlib import (
373
+ asmatrix as asmatrix,
374
+ bmat as bmat,
375
+ matrix as matrix,
376
+ )
377
+ from shape_extensions import (
378
+ broadcast as _broadcast_shape,
379
+ Flag,
380
+ Index,
381
+ index_shape,
382
+ Int,
383
+ IntTuple,
384
+ IntTuples,
385
+ IntVar,
386
+ MapIntTuples,
387
+ )
388
+
389
+ # Preserve NumPy's canonical re-exports before local shape-aware declarations.
390
+ from . import (
391
+ char as char,
392
+ core as core,
393
+ ctypeslib as ctypeslib,
394
+ dtypes as dtypes,
395
+ exceptions as exceptions,
396
+ f2py as f2py,
397
+ fft as fft,
398
+ lib as lib,
399
+ linalg as linalg,
400
+ ma as ma,
401
+ polynomial as polynomial,
402
+ random as random,
403
+ rec as rec,
404
+ strings as strings,
405
+ testing as testing,
406
+ typing as typing,
407
+ )
408
+
409
+ type _Shape = IntTuple
410
+ type _Axis = int | tuple[int, ...] | None
411
+ type _BasicIndex = int | slice | list[int] | None | EllipsisType
412
+
413
+ class generic: ...
414
+ class bool_(generic): ...
415
+ class float32(generic): ...
416
+ class float64(generic): ...
417
+ class int32(generic): ...
418
+ class int64(generic): ...
419
+ class intp(generic): ...
420
+
421
+ type _IndexScalar = int | bool_ | int32 | int64 | intp
422
+ type _IndexSequence = Sequence[_IndexScalar] | Sequence[Sequence[_IndexScalar]]
423
+
424
+ __version__: Final[str]
425
+ e: Final[float]
426
+ euler_gamma: Final[float]
427
+ pi: Final[float]
428
+ inf: Final[float]
429
+ nan: Final[float]
430
+ little_endian: Final[py_bool]
431
+ False_: Final[bool_]
432
+ True_: Final[bool_]
433
+ newaxis: Final[None] = None
434
+ test: Final[PytestTester]
435
+
436
+ class dtype[Scalar = Any]:
437
+ @overload
438
+ def __new__[ScalarT: generic](cls, dtype: type[ScalarT]) -> dtype[ScalarT]: ...
439
+ @overload
440
+ def __new__(cls, dtype: Any = ...) -> dtype: ...
441
+ def __init__(self, dtype: Any = ...) -> None: ...
442
+
443
+ # `ndarray` declares a `dtype` attribute, which shadows the class above throughout
444
+ # its body. Annotations inside the class reach the class through this alias.
445
+ _dtype = dtype
446
+
447
+ class _Flags:
448
+ f_contiguous: py_bool
449
+
450
+ class ndarray[Shape: _Shape = _Shape, DType = Any]:
451
+ shape: Shape
452
+ dtype: DType
453
+ flags: _Flags
454
+ strides: tuple[int, ...]
455
+ @property
456
+ def __array_interface__(self) -> Any: ...
457
+ def __array__(
458
+ self, dtype: Any = None, copy: py_bool | None = None
459
+ ) -> ndarray[Shape]: ...
460
+ def __buffer__(self, flags: int, /) -> memoryview: ...
461
+ @property
462
+ def base(self) -> Any: ...
463
+ @property
464
+ def data(self) -> memoryview: ...
465
+ @property
466
+ def device(self) -> Literal["cpu"]: ...
467
+ @property
468
+ def itemsize(self) -> int: ...
469
+ @property
470
+ def nbytes(self) -> int: ...
471
+ @property
472
+ def ndim(self) -> int: ...
473
+ @property
474
+ def size(self) -> int: ...
475
+ @property
476
+ def imag(self) -> ndarray[Shape]: ...
477
+ @imag.setter
478
+ def imag(self, value: Any) -> None: ...
479
+ @property
480
+ def real(self) -> ndarray[Shape]: ...
481
+ @real.setter
482
+ def real(self, value: Any) -> None: ...
483
+ @overload
484
+ def __len__[N: IntVar](self: ndarray[[N]]) -> Int[N]: ...
485
+ @overload
486
+ def __len__[N: IntVar, M: IntVar](self: ndarray[[N, M]]) -> Int[N]: ...
487
+ @overload
488
+ def __getitem__[
489
+ N: IntVar,
490
+ M: IntVar,
491
+ I: IntVar,
492
+ RowIndexScalar: (int32, int64, intp),
493
+ ColumnIndexScalar: (int32, int64, intp),
494
+ ](
495
+ self: ndarray[[N, M], DType],
496
+ key: tuple[
497
+ ndarray[[I], _dtype[RowIndexScalar]],
498
+ ndarray[[I], _dtype[ColumnIndexScalar]],
499
+ ],
500
+ ) -> ndarray[[I], DType]: ...
501
+ @overload
502
+ def __getitem__[I: Index](
503
+ self: ndarray[Shape, DType], key: I
504
+ ) -> ndarray[index_shape(Shape, I), DType]: ...
505
+ # TODO(stroxler): Model general array-valued indices precisely enough to
506
+ # reject non-integer dtypes and incompatible advanced-index shapes.
507
+ @overload
508
+ def __getitem__(
509
+ self: ndarray[Shape, DType],
510
+ key: _BasicIndex
511
+ | _IndexScalar
512
+ | _IndexSequence
513
+ | ndarray
514
+ | tuple[_BasicIndex | _IndexScalar | _IndexSequence | ndarray, ...],
515
+ ) -> ndarray[IntTuple, DType]: ...
516
+ # Only 2-D transpose is modeled for the NumPy shape-stub MVP.
517
+ @property
518
+ def T[N: IntVar, P: IntVar](
519
+ self: ndarray[[N, P], DType],
520
+ ) -> ndarray[[P, N], DType]: ...
521
+ @overload
522
+ def __add__(self, other: int | float) -> ndarray[Shape, DType]: ...
523
+ @overload
524
+ def __add__[OtherShape: _Shape](
525
+ self, other: ndarray[OtherShape]
526
+ ) -> ndarray[_broadcast_shape(Shape, OtherShape), DType]: ...
527
+ @overload
528
+ def __radd__(self, other: int | float) -> ndarray[Shape, DType]: ...
529
+ @overload
530
+ def __radd__[OtherShape: _Shape](
531
+ self, other: ndarray[OtherShape]
532
+ ) -> ndarray[_broadcast_shape(Shape, OtherShape), DType]: ...
533
+ @overload
534
+ def __sub__(self, other: int | float) -> ndarray[Shape, DType]: ...
535
+ @overload
536
+ def __sub__[OtherShape: _Shape](
537
+ self, other: ndarray[OtherShape]
538
+ ) -> ndarray[_broadcast_shape(Shape, OtherShape), DType]: ...
539
+ @overload
540
+ def __rsub__(self, other: int | float) -> ndarray[Shape, DType]: ...
541
+ @overload
542
+ def __rsub__[OtherShape: _Shape](
543
+ self, other: ndarray[OtherShape]
544
+ ) -> ndarray[_broadcast_shape(Shape, OtherShape), DType]: ...
545
+ @overload
546
+ def __truediv__(self, other: int | float) -> ndarray[Shape, DType]: ...
547
+ @overload
548
+ def __truediv__[OtherShape: _Shape](
549
+ self, other: ndarray[OtherShape]
550
+ ) -> ndarray[_broadcast_shape(Shape, OtherShape), DType]: ...
551
+ @overload
552
+ def __rtruediv__(self, other: int | float) -> ndarray[Shape, DType]: ...
553
+ @overload
554
+ def __rtruediv__[OtherShape: _Shape](
555
+ self, other: ndarray[OtherShape]
556
+ ) -> ndarray[_broadcast_shape(Shape, OtherShape), DType]: ...
557
+ @overload
558
+ def __mul__(self, other: int | float) -> ndarray[Shape, DType]: ...
559
+ @overload
560
+ def __mul__[OtherShape: _Shape](
561
+ self, other: ndarray[OtherShape]
562
+ ) -> ndarray[_broadcast_shape(Shape, OtherShape), DType]: ...
563
+ @overload
564
+ def __rmul__(self, other: int | float) -> ndarray[Shape, DType]: ...
565
+ @overload
566
+ def __rmul__[OtherShape: _Shape](
567
+ self, other: ndarray[OtherShape]
568
+ ) -> ndarray[_broadcast_shape(Shape, OtherShape), DType]: ...
569
+ @overload
570
+ def __floordiv__(self, other: int | float) -> ndarray[Shape, DType]: ...
571
+ @overload
572
+ def __floordiv__[OtherShape: _Shape](
573
+ self, other: ndarray[OtherShape]
574
+ ) -> ndarray[_broadcast_shape(Shape, OtherShape), DType]: ...
575
+ @overload
576
+ def __rfloordiv__(self, other: int | float) -> ndarray[Shape, DType]: ...
577
+ @overload
578
+ def __rfloordiv__[OtherShape: _Shape](
579
+ self, other: ndarray[OtherShape]
580
+ ) -> ndarray[_broadcast_shape(Shape, OtherShape), DType]: ...
581
+ @overload
582
+ def __mod__(self, other: int | float) -> ndarray[Shape, DType]: ...
583
+ @overload
584
+ def __mod__[OtherShape: _Shape](
585
+ self, other: ndarray[OtherShape]
586
+ ) -> ndarray[_broadcast_shape(Shape, OtherShape), DType]: ...
587
+ @overload
588
+ def __rmod__(self, other: int | float) -> ndarray[Shape, DType]: ...
589
+ @overload
590
+ def __rmod__[OtherShape: _Shape](
591
+ self, other: ndarray[OtherShape]
592
+ ) -> ndarray[_broadcast_shape(Shape, OtherShape), DType]: ...
593
+ def __neg__(self) -> ndarray[Shape, DType]: ...
594
+ def __pos__(self) -> ndarray[Shape, DType]: ...
595
+ @overload
596
+ def __pow__(self, other: int | float) -> ndarray[Shape, DType]: ...
597
+ @overload
598
+ def __pow__[OtherShape: _Shape](
599
+ self, other: ndarray[OtherShape]
600
+ ) -> ndarray[_broadcast_shape(Shape, OtherShape), DType]: ...
601
+ @overload
602
+ def __rpow__(self, other: int | float) -> ndarray[Shape, DType]: ...
603
+ @overload
604
+ def __rpow__[OtherShape: _Shape](
605
+ self, other: ndarray[OtherShape]
606
+ ) -> ndarray[_broadcast_shape(Shape, OtherShape), DType]: ...
607
+ def __matmul__[OtherShape: _Shape](
608
+ self, other: ndarray[OtherShape]
609
+ ) -> ndarray[matmul_shape(Shape, OtherShape), DType]: ...
610
+ def mean[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
611
+ self,
612
+ axis: Axis = None,
613
+ *,
614
+ keepdims: KeepDims = False,
615
+ ) -> ndarray[reduce_shape(Shape, Axis, KeepDims), DType]: ...
616
+ def sum[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
617
+ self,
618
+ axis: Axis = None,
619
+ *,
620
+ keepdims: KeepDims = False,
621
+ ) -> ndarray[reduce_shape(Shape, Axis, KeepDims), DType]: ...
622
+ def min[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
623
+ self,
624
+ axis: Axis = None,
625
+ *,
626
+ keepdims: KeepDims = False,
627
+ ) -> ndarray[reduce_shape(Shape, Axis, KeepDims), DType]: ...
628
+ def max[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
629
+ self,
630
+ axis: Axis = None,
631
+ *,
632
+ keepdims: KeepDims = False,
633
+ ) -> ndarray[reduce_shape(Shape, Axis, KeepDims), DType]: ...
634
+ def all[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
635
+ self,
636
+ axis: Axis = None,
637
+ out: Any = None,
638
+ keepdims: KeepDims = False,
639
+ *,
640
+ where: Any = True,
641
+ ) -> ndarray[reduce_shape(Shape, Axis, KeepDims), _dtype[bool_]]: ...
642
+ def any[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
643
+ self,
644
+ axis: Axis = None,
645
+ out: Any = None,
646
+ keepdims: KeepDims = False,
647
+ *,
648
+ where: Any = True,
649
+ ) -> ndarray[reduce_shape(Shape, Axis, KeepDims), _dtype[bool_]]: ...
650
+ def argmax[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
651
+ self,
652
+ axis: Axis = None,
653
+ out: Any = None,
654
+ *,
655
+ keepdims: KeepDims = False,
656
+ ) -> ndarray[reduce_shape(Shape, Axis, KeepDims), _dtype[intp]]: ...
657
+ def argmin[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
658
+ self,
659
+ axis: Axis = None,
660
+ out: Any = None,
661
+ *,
662
+ keepdims: KeepDims = False,
663
+ ) -> ndarray[reduce_shape(Shape, Axis, KeepDims), _dtype[intp]]: ...
664
+ def prod[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
665
+ self,
666
+ axis: Axis = None,
667
+ dtype: Any = None,
668
+ out: Any = None,
669
+ *,
670
+ keepdims: KeepDims = False,
671
+ initial: Any = None,
672
+ where: Any = True,
673
+ ) -> ndarray[reduce_shape(Shape, Axis, KeepDims)]: ...
674
+ def std[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
675
+ self,
676
+ axis: Axis = None,
677
+ dtype: Any = None,
678
+ out: Any = None,
679
+ ddof: float = 0,
680
+ *,
681
+ keepdims: KeepDims = False,
682
+ where: Any = True,
683
+ mean: Any = None,
684
+ correction: Any = None,
685
+ ) -> ndarray[reduce_shape(Shape, Axis, KeepDims)]: ...
686
+ def var[Axis: Flag[_Axis], KeepDims: Flag[py_bool]](
687
+ self,
688
+ axis: Axis = None,
689
+ dtype: Any = None,
690
+ out: Any = None,
691
+ ddof: float = 0,
692
+ *,
693
+ keepdims: KeepDims = False,
694
+ where: Any = True,
695
+ mean: Any = None,
696
+ correction: Any = None,
697
+ ) -> ndarray[reduce_shape(Shape, Axis, KeepDims)]: ...
698
+ @overload
699
+ def argpartition(
700
+ self,
701
+ kth: Any,
702
+ axis: None,
703
+ kind: str = "introselect",
704
+ order: Any = None,
705
+ ) -> ndarray[[int], _dtype[intp]]: ...
706
+ @overload
707
+ def argpartition(
708
+ self,
709
+ kth: Any,
710
+ axis: int = -1,
711
+ kind: str = "introselect",
712
+ order: Any = None,
713
+ ) -> ndarray[Shape, _dtype[intp]]: ...
714
+ @overload
715
+ def argsort(
716
+ self,
717
+ axis: None,
718
+ kind: str | None = None,
719
+ order: Any = None,
720
+ *,
721
+ stable: py_bool | None = None,
722
+ descending: py_bool | None = None,
723
+ ) -> ndarray[[int], _dtype[intp]]: ...
724
+ @overload
725
+ def argsort(
726
+ self,
727
+ axis: int = -1,
728
+ kind: str | None = None,
729
+ order: Any = None,
730
+ *,
731
+ stable: py_bool | None = None,
732
+ descending: py_bool | None = None,
733
+ ) -> ndarray[Shape, _dtype[intp]]: ...
734
+ @overload
735
+ def astype[ScalarT: generic](
736
+ self,
737
+ dtype: type[ScalarT] | _dtype[ScalarT],
738
+ order: str = "K",
739
+ casting: str = "unsafe",
740
+ subok: py_bool = True,
741
+ copy: py_bool = True,
742
+ ) -> ndarray[Shape, _dtype[ScalarT]]: ...
743
+ @overload
744
+ def astype(
745
+ self,
746
+ dtype: Any,
747
+ order: str = "K",
748
+ casting: str = "unsafe",
749
+ subok: py_bool = True,
750
+ copy: py_bool = True,
751
+ ) -> ndarray[Shape]: ...
752
+ def byteswap(self, inplace: py_bool = False) -> ndarray[Shape, DType]: ...
753
+ def clip(
754
+ self, min: Any = None, max: Any = None, out: Any = None, **kwargs: Any
755
+ ) -> ndarray[Shape, DType]: ...
756
+ def conj(self) -> ndarray[Shape, DType]: ...
757
+ def conjugate(self) -> ndarray[Shape, DType]: ...
758
+ def copy(self, order: str = "C") -> ndarray[Shape, DType]: ...
759
+ @overload
760
+ def cumprod(
761
+ self, axis: None = None, dtype: Any = None, out: Any = None
762
+ ) -> ndarray[[int]]: ...
763
+ @overload
764
+ def cumprod(
765
+ self, axis: int, dtype: Any = None, out: Any = None
766
+ ) -> ndarray[Shape]: ...
767
+ @overload
768
+ def cumsum(
769
+ self, axis: None = None, dtype: Any = None, out: Any = None
770
+ ) -> ndarray[[int]]: ...
771
+ @overload
772
+ def cumsum(
773
+ self, axis: int, dtype: Any = None, out: Any = None
774
+ ) -> ndarray[Shape]: ...
775
+ def dump(self, file: Any) -> None: ...
776
+ def dumps(self) -> bytes: ...
777
+ def fill(self, value: Any, /) -> None: ...
778
+ def flatten(self, order: str = "C") -> ndarray[[int], DType]: ...
779
+ def getfield(self, dtype: Any, offset: int = 0) -> ndarray[Shape]: ...
780
+ def item(self, *args: Any) -> Any: ...
781
+ def partition(
782
+ self,
783
+ kth: Any,
784
+ axis: int = -1,
785
+ kind: str = "introselect",
786
+ order: Any = None,
787
+ ) -> None: ...
788
+ def put(self, indices: Any, values: Any, mode: str = "raise") -> None: ...
789
+ def ravel(self, order: str = "C") -> ndarray[[int], DType]: ...
790
+ # TODO(stroxler): Model receiver invalidation for shape-changing mutation.
791
+ resize: Any
792
+ def round(self, decimals: int = 0, out: Any = None) -> ndarray[Shape, DType]: ...
793
+ def setfield(self, val: Any, dtype: Any, offset: int = 0) -> None: ...
794
+ def setflags(
795
+ self,
796
+ write: py_bool | None = None,
797
+ align: py_bool | None = None,
798
+ uic: py_bool | None = None,
799
+ ) -> None: ...
800
+ def sort(
801
+ self,
802
+ axis: int = -1,
803
+ kind: str | None = None,
804
+ order: Any = None,
805
+ *,
806
+ stable: py_bool | None = None,
807
+ ) -> None: ...
808
+ def to_device(
809
+ self, device: Literal["cpu"], /, *, stream: Any = None
810
+ ) -> ndarray[Shape, DType]: ...
811
+ def tobytes(self, order: str = "C") -> bytes: ...
812
+ def tofile(self, fid: Any, sep: str = "", format: str = "%s") -> None: ...
813
+ def tolist(self) -> Any: ...
814
+
815
+ # TODO(stroxler): Replace these placeholders with shape-aware declarations.
816
+ choose: Any
817
+ compress: Any
818
+ ctypes: Any
819
+ diagonal: Any
820
+ dot: Any
821
+ flat: Any
822
+ mT: Any
823
+ nonzero: Any
824
+ repeat: Any
825
+ reshape: Any
826
+ searchsorted: Any
827
+ squeeze: Any
828
+ swapaxes: Any
829
+ take: Any
830
+ trace: Any
831
+ transpose: Any
832
+ view: Any
833
+
834
+ class ufunc:
835
+ __name__: str
836
+ nin: int
837
+ nout: int
838
+ nargs: int
839
+ ntypes: int
840
+ types: list[str]
841
+ identity: Any
842
+ signature: str | None
843
+ def __call__(self, /, *args: Any, **kwargs: Any) -> Any: ...
844
+ def accumulate(self, array: Any, /, *args: Any, **kwargs: Any) -> Any: ...
845
+ def reduce(self, array: Any, /, *args: Any, **kwargs: Any) -> Any: ...
846
+ def reduceat(
847
+ self, array: Any, indices: Any, /, *args: Any, **kwargs: Any
848
+ ) -> Any: ...
849
+ def outer(self, a: Any, b: Any, /, **kwargs: Any) -> Any: ...
850
+ def at(self, a: ndarray, indices: Any, b: Any = None, /) -> None: ...
851
+
852
+ permute_dims = transpose
853
+ # TODO(stroxler): Make this precise when `concatenate` accepts overlay ndarrays.
854
+ concat: Any = concatenate
855
+
856
+ @overload
857
+ def stack[Shapes: IntTuples, Axis: Flag[int]](
858
+ arrays: MapIntTuples[lambda S: ndarray[S], Shapes], axis: Axis = 0
859
+ ) -> ndarray[stack_shape(Shapes, Axis), Any]: ...
860
+ @overload
861
+ def stack(
862
+ arrays: Sequence[ArrayLike],
863
+ axis: SupportsIndex = 0,
864
+ out: None = None,
865
+ *,
866
+ dtype: Any = None,
867
+ casting: str = "same_kind",
868
+ ) -> ndarray: ...
869
+ @overload
870
+ def stack[Out: ndarray](
871
+ arrays: Sequence[ArrayLike],
872
+ axis: SupportsIndex,
873
+ out: Out,
874
+ *,
875
+ dtype: Any = None,
876
+ casting: str = "same_kind",
877
+ ) -> Out: ...
878
+ @overload
879
+ def stack[Out: ndarray](
880
+ arrays: Sequence[ArrayLike],
881
+ axis: SupportsIndex = 0,
882
+ *,
883
+ out: Out,
884
+ dtype: Any = None,
885
+ casting: str = "same_kind",
886
+ ) -> Out: ...
887
+
888
+ # The output shape depends on the external object's DLPack representation.
889
+ def from_dlpack(
890
+ x: Any,
891
+ /,
892
+ *,
893
+ device: Literal["cpu"] | None = None,
894
+ copy: py_bool | None = None,
895
+ ) -> ndarray: ...
896
+
897
+ class _UnaryUFunc(ufunc):
898
+ @overload
899
+ def __call__[Shape: _Shape](
900
+ self, x: ndarray[Shape], /, out: Any = None, **kwargs: Any
901
+ ) -> ndarray[Shape]: ...
902
+ @overload
903
+ def __call__(self, x: Any, /, out: Any = None, **kwargs: Any) -> Any: ...
904
+
905
+ class _BinaryUFunc(ufunc):
906
+ @overload
907
+ def __call__[Shape1: _Shape, Shape2: _Shape](
908
+ self,
909
+ x1: ndarray[Shape1],
910
+ x2: ndarray[Shape2],
911
+ /,
912
+ out: Any = None,
913
+ **kwargs: Any,
914
+ ) -> ndarray[_broadcast_shape(Shape1, Shape2)]: ...
915
+ @overload
916
+ def __call__[Shape: _Shape](
917
+ self, x1: ndarray[Shape], x2: Any, /, out: Any = None, **kwargs: Any
918
+ ) -> ndarray[Shape]: ...
919
+ @overload
920
+ def __call__[Shape: _Shape](
921
+ self, x1: Any, x2: ndarray[Shape], /, out: Any = None, **kwargs: Any
922
+ ) -> ndarray[Shape]: ...
923
+ @overload
924
+ def __call__(self, x1: Any, x2: Any, /, out: Any = None, **kwargs: Any) -> Any: ...
925
+
926
+ # The result dtype stays gradual because dtype promotion is not modeled, while
927
+ # `ndarray.__matmul__` carries the left operand's dtype.
928
+ class _MatmulUFunc(ufunc):
929
+ @overload
930
+ def __call__[LeftShape: _Shape, RightShape: _Shape](
931
+ self,
932
+ a: ndarray[LeftShape],
933
+ b: ndarray[RightShape],
934
+ /,
935
+ out: Any = None,
936
+ **kwargs: Any,
937
+ ) -> ndarray[matmul_shape(LeftShape, RightShape), Any]: ...
938
+ @overload
939
+ def __call__(self, a: Any, b: Any, /, out: Any = None, **kwargs: Any) -> Any: ...
940
+
941
+ class _UnaryTwoOutputUFunc(ufunc):
942
+ @overload
943
+ def __call__[Shape: _Shape](
944
+ self, x: ndarray[Shape], /, out: Any = None, *outputs: Any, **kwargs: Any
945
+ ) -> tuple[ndarray[Shape], ndarray[Shape]]: ...
946
+ @overload
947
+ def __call__(
948
+ self, x: Any, /, out: Any = None, *outputs: Any, **kwargs: Any
949
+ ) -> tuple[Any, Any]: ...
950
+
951
+ class _BinaryTwoOutputUFunc(ufunc):
952
+ @overload
953
+ def __call__[Shape1: _Shape, Shape2: _Shape](
954
+ self,
955
+ x1: ndarray[Shape1],
956
+ x2: ndarray[Shape2],
957
+ /,
958
+ out: Any = None,
959
+ *outputs: Any,
960
+ **kwargs: Any,
961
+ ) -> tuple[
962
+ ndarray[_broadcast_shape(Shape1, Shape2)],
963
+ ndarray[_broadcast_shape(Shape1, Shape2)],
964
+ ]: ...
965
+ @overload
966
+ def __call__[Shape: _Shape](
967
+ self,
968
+ x1: ndarray[Shape],
969
+ x2: Any,
970
+ /,
971
+ out: Any = None,
972
+ *outputs: Any,
973
+ **kwargs: Any,
974
+ ) -> tuple[ndarray[Shape], ndarray[Shape]]: ...
975
+ @overload
976
+ def __call__[Shape: _Shape](
977
+ self,
978
+ x1: Any,
979
+ x2: ndarray[Shape],
980
+ /,
981
+ out: Any = None,
982
+ *outputs: Any,
983
+ **kwargs: Any,
984
+ ) -> tuple[ndarray[Shape], ndarray[Shape]]: ...
985
+ @overload
986
+ def __call__(
987
+ self,
988
+ x1: Any,
989
+ x2: Any,
990
+ /,
991
+ out: Any = None,
992
+ *outputs: Any,
993
+ **kwargs: Any,
994
+ ) -> tuple[Any, Any]: ...
995
+
996
+ class _MatvecUFunc(ufunc):
997
+ @overload
998
+ def __call__[Shape1: _Shape, Shape2: _Shape](
999
+ self,
1000
+ x1: ndarray[Shape1],
1001
+ x2: ndarray[Shape2],
1002
+ /,
1003
+ out: Any = None,
1004
+ **kwargs: Any,
1005
+ ) -> ndarray[matvec_shape(Shape1, Shape2)]: ...
1006
+ @overload
1007
+ def __call__(self, x1: Any, x2: Any, /, out: Any = None, **kwargs: Any) -> Any: ...
1008
+
1009
+ class _VecdotUFunc(ufunc):
1010
+ @overload
1011
+ def __call__[Shape1: _Shape, Shape2: _Shape](
1012
+ self,
1013
+ x1: ndarray[Shape1],
1014
+ x2: ndarray[Shape2],
1015
+ /,
1016
+ out: Any = None,
1017
+ **kwargs: Any,
1018
+ ) -> ndarray[vecdot_shape(Shape1, Shape2)]: ...
1019
+ @overload
1020
+ def __call__(self, x1: Any, x2: Any, /, out: Any = None, **kwargs: Any) -> Any: ...
1021
+
1022
+ class _VecmatUFunc(ufunc):
1023
+ @overload
1024
+ def __call__[Shape1: _Shape, Shape2: _Shape](
1025
+ self,
1026
+ x1: ndarray[Shape1],
1027
+ x2: ndarray[Shape2],
1028
+ /,
1029
+ out: Any = None,
1030
+ **kwargs: Any,
1031
+ ) -> ndarray[vecmat_shape(Shape1, Shape2)]: ...
1032
+ @overload
1033
+ def __call__(self, x1: Any, x2: Any, /, out: Any = None, **kwargs: Any) -> Any: ...
1034
+
1035
+ abs: _UnaryUFunc
1036
+ absolute: _UnaryUFunc
1037
+ acos: _UnaryUFunc
1038
+ acosh: _UnaryUFunc
1039
+ arccos: _UnaryUFunc
1040
+ arccosh: _UnaryUFunc
1041
+ arcsin: _UnaryUFunc
1042
+ arcsinh: _UnaryUFunc
1043
+ arctan: _UnaryUFunc
1044
+ arctanh: _UnaryUFunc
1045
+ asin: _UnaryUFunc
1046
+ asinh: _UnaryUFunc
1047
+ atan: _UnaryUFunc
1048
+ atanh: _UnaryUFunc
1049
+ bitwise_count: _UnaryUFunc
1050
+ bitwise_invert: _UnaryUFunc
1051
+ bitwise_not: _UnaryUFunc
1052
+ cbrt: _UnaryUFunc
1053
+ ceil: _UnaryUFunc
1054
+ conj: _UnaryUFunc
1055
+ conjugate: _UnaryUFunc
1056
+ cos: _UnaryUFunc
1057
+ cosh: _UnaryUFunc
1058
+ deg2rad: _UnaryUFunc
1059
+ degrees: _UnaryUFunc
1060
+ exp: _UnaryUFunc
1061
+ exp2: _UnaryUFunc
1062
+ expm1: _UnaryUFunc
1063
+ fabs: _UnaryUFunc
1064
+ floor: _UnaryUFunc
1065
+ invert: _UnaryUFunc
1066
+ isfinite: _UnaryUFunc
1067
+ isinf: _UnaryUFunc
1068
+ isnan: _UnaryUFunc
1069
+ isnat: _UnaryUFunc
1070
+ log: _UnaryUFunc
1071
+ log10: _UnaryUFunc
1072
+ log1p: _UnaryUFunc
1073
+ log2: _UnaryUFunc
1074
+ logical_not: _UnaryUFunc
1075
+ negative: _UnaryUFunc
1076
+ positive: _UnaryUFunc
1077
+ rad2deg: _UnaryUFunc
1078
+ radians: _UnaryUFunc
1079
+ reciprocal: _UnaryUFunc
1080
+ rint: _UnaryUFunc
1081
+ sign: _UnaryUFunc
1082
+ signbit: _UnaryUFunc
1083
+ sin: _UnaryUFunc
1084
+ sinh: _UnaryUFunc
1085
+ spacing: _UnaryUFunc
1086
+ sqrt: _UnaryUFunc
1087
+ square: _UnaryUFunc
1088
+ tan: _UnaryUFunc
1089
+ tanh: _UnaryUFunc
1090
+ trunc: _UnaryUFunc
1091
+
1092
+ add: _BinaryUFunc
1093
+ arctan2: _BinaryUFunc
1094
+ atan2: _BinaryUFunc
1095
+ bitwise_and: _BinaryUFunc
1096
+ bitwise_left_shift: _BinaryUFunc
1097
+ bitwise_or: _BinaryUFunc
1098
+ bitwise_right_shift: _BinaryUFunc
1099
+ bitwise_xor: _BinaryUFunc
1100
+ copysign: _BinaryUFunc
1101
+ divide: _BinaryUFunc
1102
+ equal: _BinaryUFunc
1103
+ float_power: _BinaryUFunc
1104
+ floor_divide: _BinaryUFunc
1105
+ fmax: _BinaryUFunc
1106
+ fmin: _BinaryUFunc
1107
+ fmod: _BinaryUFunc
1108
+ gcd: _BinaryUFunc
1109
+ greater: _BinaryUFunc
1110
+ greater_equal: _BinaryUFunc
1111
+ heaviside: _BinaryUFunc
1112
+ hypot: _BinaryUFunc
1113
+ lcm: _BinaryUFunc
1114
+ ldexp: _BinaryUFunc
1115
+ left_shift: _BinaryUFunc
1116
+ less: _BinaryUFunc
1117
+ less_equal: _BinaryUFunc
1118
+ logaddexp: _BinaryUFunc
1119
+ logaddexp2: _BinaryUFunc
1120
+ logical_and: _BinaryUFunc
1121
+ logical_or: _BinaryUFunc
1122
+ logical_xor: _BinaryUFunc
1123
+ matmul: _MatmulUFunc
1124
+ maximum: _BinaryUFunc
1125
+ minimum: _BinaryUFunc
1126
+ mod: _BinaryUFunc
1127
+ multiply: _BinaryUFunc
1128
+ nextafter: _BinaryUFunc
1129
+ not_equal: _BinaryUFunc
1130
+ pow: _BinaryUFunc
1131
+ power: _BinaryUFunc
1132
+ remainder: _BinaryUFunc
1133
+ right_shift: _BinaryUFunc
1134
+ subtract: _BinaryUFunc
1135
+ true_divide: _BinaryUFunc
1136
+
1137
+ frexp: _UnaryTwoOutputUFunc
1138
+ modf: _UnaryTwoOutputUFunc
1139
+ divmod: _BinaryTwoOutputUFunc
1140
+ matvec: _MatvecUFunc
1141
+ vecdot: _VecdotUFunc
1142
+ vecmat: _VecmatUFunc
1143
+
1144
+ def round[Shape: _Shape](x: ndarray[Shape]) -> ndarray[Shape]: ...
1145
+ def clip[Shape: _Shape](
1146
+ a: ndarray[Shape], a_min: int | float, a_max: int | float
1147
+ ) -> ndarray[Shape]: ...
1148
+ def fill_diagonal[N: IntVar, DType](
1149
+ a: ndarray[[N, N], DType],
1150
+ val: Any,
1151
+ wrap: py_bool = False,
1152
+ ) -> None: ...
1153
+ @overload
1154
+ def diag[N: IntVar, DType, K: Flag[int] = 0](
1155
+ v: ndarray[[N], DType], k: K = 0
1156
+ ) -> ndarray[[diag_extent(Int[N], K), diag_extent(Int[N], K)], DType]: ...
1157
+
1158
+ # TODO(stroxler): Model the shape arithmetic here; we can do better than `int`.
1159
+ @overload
1160
+ def diag[M: IntVar, N: IntVar, DType](
1161
+ v: ndarray[[M, N], DType], k: int = 0
1162
+ ) -> ndarray[[int], DType]: ...
1163
+
1164
+ # Trailing fallback for ranks the precise overloads do not model, so their dtype survives
1165
+ # instead of degrading to `Any`. The parameter shape is a type variable rather than
1166
+ # `IntTuple`: a gradual parameter shape would also match known-rank arguments whose dtype is
1167
+ # gradual, and that ambiguity collapses their precise result to a gradual shape.
1168
+ @overload
1169
+ def diag[S: _Shape, DType](
1170
+ v: ndarray[S, DType], k: int = 0
1171
+ ) -> ndarray[IntTuple, DType]: ...
1172
+ def arange[N: IntVar](stop: Int[N], /) -> ndarray[[N], dtype[intp]]: ...
1173
+ @overload
1174
+ def expand_dims[N: IntVar, M: IntVar, DType](
1175
+ a: ndarray[[N, M], DType],
1176
+ axis: Literal[0, -3],
1177
+ ) -> ndarray[[1, N, M], DType]: ...
1178
+ @overload
1179
+ def expand_dims[N: IntVar, M: IntVar, DType](
1180
+ a: ndarray[[N, M], DType],
1181
+ axis: Literal[1, -2],
1182
+ ) -> ndarray[[N, 1, M], DType]: ...
1183
+ @overload
1184
+ def expand_dims[N: IntVar, M: IntVar, DType](
1185
+ a: ndarray[[N, M], DType],
1186
+ axis: Literal[2, -1],
1187
+ ) -> ndarray[[N, M, 1], DType]: ...
1188
+
1189
+ # These stubs track reduction shapes but leave reduction dtype gradual.
1190
+ def sum[
1191
+ Shape: _Shape,
1192
+ DType,
1193
+ Axis: Flag[_Axis],
1194
+ KeepDims: Flag[py_bool],
1195
+ ](
1196
+ a: ndarray[Shape, DType], axis: Axis = None, *, keepdims: KeepDims = False
1197
+ ) -> ndarray[reduce_shape(Shape, Axis, KeepDims), Any]: ...
1198
+ def mean[
1199
+ Shape: _Shape,
1200
+ DType,
1201
+ Axis: Flag[_Axis],
1202
+ KeepDims: Flag[py_bool],
1203
+ ](
1204
+ a: ndarray[Shape, DType], axis: Axis = None, *, keepdims: KeepDims = False
1205
+ ) -> ndarray[reduce_shape(Shape, Axis, KeepDims), Any]: ...
1206
+ def min[
1207
+ Shape: _Shape,
1208
+ DType,
1209
+ Axis: Flag[_Axis],
1210
+ KeepDims: Flag[py_bool],
1211
+ ](
1212
+ a: ndarray[Shape, DType], axis: Axis = None, *, keepdims: KeepDims = False
1213
+ ) -> ndarray[reduce_shape(Shape, Axis, KeepDims), Any]: ...
1214
+ def max[
1215
+ Shape: _Shape,
1216
+ DType,
1217
+ Axis: Flag[_Axis],
1218
+ KeepDims: Flag[py_bool],
1219
+ ](
1220
+ a: ndarray[Shape, DType], axis: Axis = None, *, keepdims: KeepDims = False
1221
+ ) -> ndarray[reduce_shape(Shape, Axis, KeepDims), Any]: ...
1222
+ @overload
1223
+ def argmin[N: IntVar, M: IntVar](
1224
+ a: ndarray[[N, M]],
1225
+ axis: Literal[0, -2],
1226
+ *,
1227
+ keepdims: Literal[False] = False,
1228
+ ) -> ndarray[[M], dtype[intp]]: ...
1229
+ @overload
1230
+ def argmin[N: IntVar, M: IntVar](
1231
+ a: ndarray[[N, M]],
1232
+ axis: Literal[1, -1],
1233
+ *,
1234
+ keepdims: Literal[False] = False,
1235
+ ) -> ndarray[[N], dtype[intp]]: ...
1236
+
1237
+ # TODO(stroxler): Replace these finite tuple-shape constructor overloads with a
1238
+ # generic `Shape: tuple[int, ...]` overload once whole-shape parameters flow
1239
+ # through downstream array operations without degrading to unknown.
1240
+ @overload
1241
+ def zeros[N: IntVar, ScalarT: generic](
1242
+ shape: Int[N], dtype: type[ScalarT], order: str = ...
1243
+ ) -> ndarray[[N], dtype[ScalarT]]: ...
1244
+ @overload
1245
+ def zeros[N: IntVar, ScalarT: generic](
1246
+ shape: IntTuple[N], dtype: type[ScalarT], order: str = ...
1247
+ ) -> ndarray[[N], dtype[ScalarT]]: ...
1248
+ @overload
1249
+ def zeros[N: IntVar, M: IntVar, ScalarT: generic](
1250
+ shape: IntTuple[N, M], dtype: type[ScalarT], order: str = ...
1251
+ ) -> ndarray[[N, M], dtype[ScalarT]]: ...
1252
+ @overload
1253
+ def zeros[N: IntVar, ScalarT: generic](
1254
+ shape: Int[N], dtype: dtype[ScalarT], order: str = ...
1255
+ ) -> ndarray[[N], dtype[ScalarT]]: ...
1256
+ @overload
1257
+ def zeros[N: IntVar, ScalarT: generic](
1258
+ shape: IntTuple[N], dtype: dtype[ScalarT], order: str = ...
1259
+ ) -> ndarray[[N], dtype[ScalarT]]: ...
1260
+ @overload
1261
+ def zeros[N: IntVar, M: IntVar, ScalarT: generic](
1262
+ shape: IntTuple[N, M], dtype: dtype[ScalarT], order: str = ...
1263
+ ) -> ndarray[[N, M], dtype[ScalarT]]: ...
1264
+ @overload
1265
+ def zeros[N: IntVar](
1266
+ shape: Int[N], dtype: None = ..., order: str = ...
1267
+ ) -> ndarray[[N], dtype[float64]]: ...
1268
+ @overload
1269
+ def zeros[N: IntVar](
1270
+ shape: IntTuple[N], dtype: None = ..., order: str = ...
1271
+ ) -> ndarray[[N], dtype[float64]]: ...
1272
+ @overload
1273
+ def zeros[N: IntVar, M: IntVar](
1274
+ shape: IntTuple[N, M], dtype: None = ..., order: str = ...
1275
+ ) -> ndarray[[N, M], dtype[float64]]: ...
1276
+ @overload
1277
+ def zeros[N: IntVar](shape: Int[N], dtype: Any, order: str = ...) -> ndarray[[N]]: ...
1278
+ @overload
1279
+ def zeros[N: IntVar](
1280
+ shape: IntTuple[N], dtype: Any, order: str = ...
1281
+ ) -> ndarray[[N]]: ...
1282
+ @overload
1283
+ def zeros[N: IntVar, M: IntVar](
1284
+ shape: IntTuple[N, M], dtype: Any, order: str = ...
1285
+ ) -> ndarray[[N, M]]: ...
1286
+ @overload
1287
+ def ones[N: IntVar, ScalarT: generic](
1288
+ shape: Int[N], dtype: type[ScalarT], order: str = ...
1289
+ ) -> ndarray[[N], dtype[ScalarT]]: ...
1290
+ @overload
1291
+ def ones[N: IntVar, ScalarT: generic](
1292
+ shape: IntTuple[N], dtype: type[ScalarT], order: str = ...
1293
+ ) -> ndarray[[N], dtype[ScalarT]]: ...
1294
+ @overload
1295
+ def ones[N: IntVar, M: IntVar, ScalarT: generic](
1296
+ shape: IntTuple[N, M], dtype: type[ScalarT], order: str = ...
1297
+ ) -> ndarray[[N, M], dtype[ScalarT]]: ...
1298
+ @overload
1299
+ def ones[N: IntVar, ScalarT: generic](
1300
+ shape: Int[N], dtype: dtype[ScalarT], order: str = ...
1301
+ ) -> ndarray[[N], dtype[ScalarT]]: ...
1302
+ @overload
1303
+ def ones[N: IntVar, ScalarT: generic](
1304
+ shape: IntTuple[N], dtype: dtype[ScalarT], order: str = ...
1305
+ ) -> ndarray[[N], dtype[ScalarT]]: ...
1306
+ @overload
1307
+ def ones[N: IntVar, M: IntVar, ScalarT: generic](
1308
+ shape: IntTuple[N, M], dtype: dtype[ScalarT], order: str = ...
1309
+ ) -> ndarray[[N, M], dtype[ScalarT]]: ...
1310
+ @overload
1311
+ def ones[N: IntVar](
1312
+ shape: Int[N], dtype: None = ..., order: str = ...
1313
+ ) -> ndarray[[N], dtype[float64]]: ...
1314
+ @overload
1315
+ def ones[N: IntVar](
1316
+ shape: IntTuple[N], dtype: None = ..., order: str = ...
1317
+ ) -> ndarray[[N], dtype[float64]]: ...
1318
+ @overload
1319
+ def ones[N: IntVar, M: IntVar](
1320
+ shape: IntTuple[N, M], dtype: None = ..., order: str = ...
1321
+ ) -> ndarray[[N, M], dtype[float64]]: ...
1322
+ @overload
1323
+ def ones[N: IntVar](shape: Int[N], dtype: Any, order: str = ...) -> ndarray[[N]]: ...
1324
+ @overload
1325
+ def ones[N: IntVar](
1326
+ shape: IntTuple[N], dtype: Any, order: str = ...
1327
+ ) -> ndarray[[N]]: ...
1328
+ @overload
1329
+ def ones[N: IntVar, M: IntVar](
1330
+ shape: IntTuple[N, M], dtype: Any, order: str = ...
1331
+ ) -> ndarray[[N, M]]: ...
1332
+ @overload
1333
+ def full[N: IntVar, ScalarT: generic](
1334
+ shape: Int[N],
1335
+ fill_value: Any,
1336
+ dtype: type[ScalarT],
1337
+ order: str = ...,
1338
+ ) -> ndarray[[N], dtype[ScalarT]]: ...
1339
+ @overload
1340
+ def full[N: IntVar, ScalarT: generic](
1341
+ shape: IntTuple[N],
1342
+ fill_value: Any,
1343
+ dtype: type[ScalarT],
1344
+ order: str = ...,
1345
+ ) -> ndarray[[N], dtype[ScalarT]]: ...
1346
+ @overload
1347
+ def full[N: IntVar, M: IntVar, ScalarT: generic](
1348
+ shape: IntTuple[N, M],
1349
+ fill_value: Any,
1350
+ dtype: type[ScalarT],
1351
+ order: str = ...,
1352
+ ) -> ndarray[[N, M], dtype[ScalarT]]: ...
1353
+ @overload
1354
+ def full[N: IntVar, ScalarT: generic](
1355
+ shape: Int[N],
1356
+ fill_value: Any,
1357
+ dtype: dtype[ScalarT],
1358
+ order: str = ...,
1359
+ ) -> ndarray[[N], dtype[ScalarT]]: ...
1360
+ @overload
1361
+ def full[N: IntVar, ScalarT: generic](
1362
+ shape: IntTuple[N],
1363
+ fill_value: Any,
1364
+ dtype: dtype[ScalarT],
1365
+ order: str = ...,
1366
+ ) -> ndarray[[N], dtype[ScalarT]]: ...
1367
+ @overload
1368
+ def full[N: IntVar, M: IntVar, ScalarT: generic](
1369
+ shape: IntTuple[N, M],
1370
+ fill_value: Any,
1371
+ dtype: dtype[ScalarT],
1372
+ order: str = ...,
1373
+ ) -> ndarray[[N, M], dtype[ScalarT]]: ...
1374
+ @overload
1375
+ def full[N: IntVar](
1376
+ shape: Int[N], fill_value: Any, dtype: Any = ..., order: str = ...
1377
+ ) -> ndarray[[N]]: ...
1378
+ @overload
1379
+ def full[N: IntVar](
1380
+ shape: IntTuple[N], fill_value: Any, dtype: Any = ..., order: str = ...
1381
+ ) -> ndarray[[N]]: ...
1382
+ @overload
1383
+ def full[N: IntVar, M: IntVar](
1384
+ shape: IntTuple[N, M],
1385
+ fill_value: Any,
1386
+ dtype: Any = ...,
1387
+ order: str = ...,
1388
+ ) -> ndarray[[N, M]]: ...
1389
+ @overload
1390
+ def empty[N: IntVar, ScalarT: generic](
1391
+ shape: Int[N], dtype: type[ScalarT], order: str = ...
1392
+ ) -> ndarray[[N], dtype[ScalarT]]: ...
1393
+ @overload
1394
+ def empty[N: IntVar, ScalarT: generic](
1395
+ shape: IntTuple[N], dtype: type[ScalarT], order: str = ...
1396
+ ) -> ndarray[[N], dtype[ScalarT]]: ...
1397
+ @overload
1398
+ def empty[N: IntVar, M: IntVar, ScalarT: generic](
1399
+ shape: IntTuple[N, M], dtype: type[ScalarT], order: str = ...
1400
+ ) -> ndarray[[N, M], dtype[ScalarT]]: ...
1401
+ @overload
1402
+ def empty[N: IntVar, ScalarT: generic](
1403
+ shape: Int[N], dtype: dtype[ScalarT], order: str = ...
1404
+ ) -> ndarray[[N], dtype[ScalarT]]: ...
1405
+ @overload
1406
+ def empty[N: IntVar, ScalarT: generic](
1407
+ shape: IntTuple[N], dtype: dtype[ScalarT], order: str = ...
1408
+ ) -> ndarray[[N], dtype[ScalarT]]: ...
1409
+ @overload
1410
+ def empty[N: IntVar, M: IntVar, ScalarT: generic](
1411
+ shape: IntTuple[N, M], dtype: dtype[ScalarT], order: str = ...
1412
+ ) -> ndarray[[N, M], dtype[ScalarT]]: ...
1413
+ @overload
1414
+ def empty[N: IntVar](
1415
+ shape: Int[N], dtype: None = ..., order: str = ...
1416
+ ) -> ndarray[[N], dtype[float64]]: ...
1417
+ @overload
1418
+ def empty[N: IntVar](
1419
+ shape: IntTuple[N], dtype: None = ..., order: str = ...
1420
+ ) -> ndarray[[N], dtype[float64]]: ...
1421
+ @overload
1422
+ def empty[N: IntVar, M: IntVar](
1423
+ shape: IntTuple[N, M], dtype: None = ..., order: str = ...
1424
+ ) -> ndarray[[N, M], dtype[float64]]: ...
1425
+ @overload
1426
+ def empty[N: IntVar](shape: Int[N], dtype: Any, order: str = ...) -> ndarray[[N]]: ...
1427
+ @overload
1428
+ def empty[N: IntVar](
1429
+ shape: IntTuple[N], dtype: Any, order: str = ...
1430
+ ) -> ndarray[[N]]: ...
1431
+ @overload
1432
+ def empty[N: IntVar, M: IntVar](
1433
+ shape: IntTuple[N, M], dtype: Any, order: str = ...
1434
+ ) -> ndarray[[N, M]]: ...
1435
+ @overload
1436
+ def eye[N: IntVar, ScalarT: generic](
1437
+ N: Int[N], M: None = ..., k: int = ..., *, dtype: type[ScalarT], order: str = ...
1438
+ ) -> ndarray[[N, N], dtype[ScalarT]]: ...
1439
+ @overload
1440
+ def eye[N: IntVar, ScalarT: generic](
1441
+ N: Int[N], M: None, k: int, dtype: type[ScalarT], order: str = ...
1442
+ ) -> ndarray[[N, N], dtype[ScalarT]]: ...
1443
+ @overload
1444
+ def eye[N: IntVar, ScalarT: generic](
1445
+ N: Int[N],
1446
+ M: None = ...,
1447
+ k: int = ...,
1448
+ *,
1449
+ dtype: dtype[ScalarT],
1450
+ order: str = ...,
1451
+ ) -> ndarray[[N, N], dtype[ScalarT]]: ...
1452
+ @overload
1453
+ def eye[N: IntVar, ScalarT: generic](
1454
+ N: Int[N], M: None, k: int, dtype: dtype[ScalarT], order: str = ...
1455
+ ) -> ndarray[[N, N], dtype[ScalarT]]: ...
1456
+ @overload
1457
+ def eye[N: IntVar](
1458
+ N: Int[N], M: None = ..., k: int = ..., dtype: None = ..., order: str = ...
1459
+ ) -> ndarray[[N, N], dtype[float64]]: ...
1460
+ @overload
1461
+ def eye[N: IntVar](
1462
+ N: Int[N], M: None = ..., k: int = ..., dtype: Any = ..., order: str = ...
1463
+ ) -> ndarray[[N, N]]: ...
1464
+ @overload
1465
+ def identity[N: IntVar, ScalarT: generic](
1466
+ n: Int[N], dtype: type[ScalarT], *, like: Any = ...
1467
+ ) -> ndarray[[N, N], dtype[ScalarT]]: ...
1468
+ @overload
1469
+ def identity[N: IntVar, ScalarT: generic](
1470
+ n: Int[N], dtype: dtype[ScalarT], *, like: Any = ...
1471
+ ) -> ndarray[[N, N], dtype[ScalarT]]: ...
1472
+ @overload
1473
+ def identity[N: IntVar](
1474
+ n: Int[N], dtype: None = ..., *, like: Any = ...
1475
+ ) -> ndarray[[N, N], dtype[float64]]: ...
1476
+ @overload
1477
+ def identity[N: IntVar](
1478
+ n: Int[N], dtype: Any, *, like: Any = ...
1479
+ ) -> ndarray[[N, N]]: ...
1480
+
1481
+ # TODO(stroxler): Replace these placeholders with NumPy's scalar type hierarchy.
1482
+ bool: Any
1483
+ broadcast: Any
1484
+ byte: Any
1485
+ bytes_: Any
1486
+ cdouble: Any
1487
+ character: Any
1488
+ clongdouble: Any
1489
+ complex128: Any
1490
+ complex64: Any
1491
+ complexfloating: Any
1492
+ csingle: Any
1493
+ datetime64: Any
1494
+ double: Any
1495
+ flexible: Any
1496
+ float16: Any
1497
+ floating: Any
1498
+ half: Any
1499
+ inexact: Any
1500
+ int16: Any
1501
+ int8: Any
1502
+ int_: Any
1503
+ intc: Any
1504
+ integer: Any
1505
+ long: Any
1506
+ longdouble: Any
1507
+ longlong: Any
1508
+ number: Any
1509
+ object_: Any
1510
+ short: Any
1511
+ signedinteger: Any
1512
+ single: Any
1513
+ str_: Any
1514
+ timedelta64: Any
1515
+ ubyte: Any
1516
+ uint: Any
1517
+ uint16: Any
1518
+ uint32: Any
1519
+ uint64: Any
1520
+ uint8: Any
1521
+ uintc: Any
1522
+ uintp: Any
1523
+ ulong: Any
1524
+ ulonglong: Any
1525
+ unsignedinteger: Any
1526
+ ushort: Any
1527
+ void: Any