codekingpro/portable-devtools
115k
1from typing import Any, Literal, TypeAlias, TypeVar, overload
2
3import numpy as np
4import numpy.typing as npt
5from numpy import ( # noqa: F401
6 False_,
7 ScalarType,
8 True_,
9 __array_namespace_info__,
10 __version__,
11 abs,
12 absolute,
13 acos,
14 acosh,
15 add,
16 all,
17 allclose,
18 amax,
19 amin,
20 angle,
21 any,
22 append,
23 apply_along_axis,
24 apply_over_axes,
25 arange,
26 arccos,
27 arccosh,
28 arcsin,
29 arcsinh,
30 arctan,
31 arctan2,
32 arctanh,
33 argmax,
34 argmin,
35 argpartition,
36 argsort,
37 argwhere,
38 around,
39 array,
40 array2string,
41 array_equal,
42 array_equiv,
43 array_repr,
44 array_split,
45 array_str,
46 asanyarray,
47 asarray,
48 asarray_chkfinite,
49 ascontiguousarray,
50 asfortranarray,
51 asin,
52 asinh,
53 asmatrix,
54 astype,
55 atan,
56 atan2,
57 atanh,
58 atleast_1d,
59 atleast_2d,
60 atleast_3d,
61 average,
62 bartlett,
63 base_repr,
64 binary_repr,
65 bincount,
66 bitwise_and,
67 bitwise_count,
68 bitwise_invert,
69 bitwise_left_shift,
70 bitwise_not,
71 bitwise_or,
72 bitwise_right_shift,
73 bitwise_xor,
74 blackman,
75 block,
76 bmat,
77 bool,
78 bool_,
79 broadcast,
80 broadcast_arrays,
81 broadcast_shapes,
82 broadcast_to,
83 busday_count,
84 busday_offset,
85 busdaycalendar,
86 byte,
87 bytes_,
88 c_,
89 can_cast,
90 cbrt,
91 cdouble,
92 ceil,
93 char,
94 character,
95 choose,
96 clip,
97 clongdouble,
98 column_stack,
99 common_type,
100 complex64,
101 complex128,
102 complex192,
103 complex256,
104 complexfloating,
105 compress,
106 concat,
107 concatenate,
108 conj,
109 conjugate,
110 convolve,
111 copy,
112 copysign,
113 copyto,
114 core,
115 corrcoef,
116 correlate,
117 cos,
118 cosh,
119 count_nonzero,
120 cov,
121 cross,
122 csingle,
123 ctypeslib,
124 cumprod,
125 cumsum,
126 cumulative_prod,
127 cumulative_sum,
128 datetime64,
129 datetime_as_string,
130 datetime_data,
131 deg2rad,
132 degrees,
133 delete,
134 diag,
135 diag_indices,
136 diag_indices_from,
137 diagflat,
138 diagonal,
139 diff,
140 digitize,
141 divide,
142 divmod,
143 dot,
144 double,
145 dsplit,
146 dstack,
147 dtype,
148 dtypes,
149 e,
150 ediff1d,
151 einsum,
152 einsum_path,
153 emath,
154 empty_like,
155 equal,
156 errstate,
157 euler_gamma,
158 exceptions,
159 exp,
160 exp2,
161 expand_dims,
162 expm1,
163 extract,
164 f2py,
165 fabs,
166 fft,
167 fill_diagonal,
168 finfo,
169 fix,
170 flatiter,
171 flatnonzero,
172 flexible,
173 flip,
174 fliplr,
175 flipud,
176 float16,
177 float32,
178 float64,
179 float96,
180 float128,
181 float_power,
182 floating,
183 floor,
184 floor_divide,
185 fmax,
186 fmin,
187 fmod,
188 format_float_positional,
189 format_float_scientific,
190 frexp,
191 from_dlpack,
192 frombuffer,
193 fromfile,
194 fromfunction,
195 fromiter,
196 frompyfunc,
197 fromregex,
198 fromstring,
199 full,
200 full_like,
201 gcd,
202 generic,
203 genfromtxt,
204 geomspace,
205 get_include,
206 get_printoptions,
207 getbufsize,
208 geterr,
209 geterrcall,
210 gradient,
211 greater,
212 greater_equal,
213 half,
214 hamming,
215 hanning,
216 heaviside,
217 histogram,
218 histogram2d,
219 histogram_bin_edges,
220 histogramdd,
221 hsplit,
222 hstack,
223 hypot,
224 i0,
225 iinfo,
226 imag,
227 index_exp,
228 indices,
229 inexact,
230 inf,
231 info,
232 inner,
233 insert,
234 int8,
235 int16,
236 int32,
237 int64,
238 int_,
239 intc,
240 integer,
241 interp,
242 intersect1d,
243 intp,
244 invert,
245 is_busday,
246 isclose,
247 iscomplex,
248 iscomplexobj,
249 isdtype,
250 isfinite,
251 isfortran,
252 isin,
253 isinf,
254 isnan,
255 isnat,
256 isneginf,
257 isposinf,
258 isreal,
259 isrealobj,
260 isscalar,
261 issubdtype,
262 iterable,
263 ix_,
264 kaiser,
265 kron,
266 lcm,
267 ldexp,
268 left_shift,
269 less,
270 less_equal,
271 lexsort,
272 lib,
273 linalg,
274 linspace,
275 little_endian,
276 load,
277 loadtxt,
278 log,
279 log1p,
280 log2,
281 log10,
282 logaddexp,
283 logaddexp2,
284 logical_and,
285 logical_not,
286 logical_or,
287 logical_xor,
288 logspace,
289 long,
290 longdouble,
291 longlong,
292 ma,
293 mask_indices,
294 matmul,
295 matrix,
296 matrix_transpose,
297 matvec,
298 max,
299 maximum,
300 may_share_memory,
301 mean,
302 median,
303 memmap,
304 meshgrid,
305 mgrid,
306 min,
307 min_scalar_type,
308 minimum,
309 mintypecode,
310 mod,
311 modf,
312 moveaxis,
313 multiply,
314 nan,
315 nan_to_num,
316 nanargmax,
317 nanargmin,
318 nancumprod,
319 nancumsum,
320 nanmax,
321 nanmean,
322 nanmedian,
323 nanmin,
324 nanpercentile,
325 nanprod,
326 nanquantile,
327 nanstd,
328 nansum,
329 nanvar,
330 ndarray,
331 ndenumerate,
332 ndim,
333 ndindex,
334 nditer,
335 negative,
336 nested_iters,
337 newaxis,
338 nextafter,
339 nonzero,
340 not_equal,
341 number,
342 object_,
343 ogrid,
344 ones_like,
345 outer,
346 packbits,
347 pad,
348 partition,
349 percentile,
350 permute_dims,
351 pi,
352 piecewise,
353 place,
354 poly,
355 poly1d,
356 polyadd,
357 polyder,
358 polydiv,
359 polyfit,
360 polyint,
361 polymul,
362 polynomial,
363 polysub,
364 polyval,
365 positive,
366 pow,
367 power,
368 printoptions,
369 prod,
370 promote_types,
371 ptp,
372 put,
373 put_along_axis,
374 putmask,
375 quantile,
376 r_,
377 rad2deg,
378 radians,
379 random,
380 ravel,
381 ravel_multi_index,
382 real,
383 real_if_close,
384 rec,
385 recarray,
386 reciprocal,
387 record,
388 remainder,
389 repeat,
390 require,
391 reshape,
392 resize,
393 result_type,
394 right_shift,
395 rint,
396 roll,
397 rollaxis,
398 roots,
399 rot90,
400 round,
401 row_stack,
402 s_,
403 save,
404 savetxt,
405 savez,
406 savez_compressed,
407 sctypeDict,
408 searchsorted,
409 select,
410 set_printoptions,
411 setbufsize,
412 setdiff1d,
413 seterr,
414 seterrcall,
415 setxor1d,
416 shape,
417 shares_memory,
418 short,
419 show_config,
420 show_runtime,
421 sign,
422 signbit,
423 signedinteger,
424 sin,
425 sinc,
426 single,
427 sinh,
428 size,
429 sort,
430 sort_complex,
431 spacing,
432 split,
433 sqrt,
434 square,
435 squeeze,
436 stack,
437 std,
438 str_,
439 strings,
440 subtract,
441 sum,
442 swapaxes,
443 take,
444 take_along_axis,
445 tan,
446 tanh,
447 tensordot,
448 test,
449 testing,
450 tile,
451 timedelta64,
452 trace,
453 transpose,
454 trapezoid,
455 tri,
456 tril,
457 tril_indices,
458 tril_indices_from,
459 trim_zeros,
460 triu,
461 triu_indices,
462 triu_indices_from,
463 true_divide,
464 trunc,
465 typecodes,
466 typename,
467 typing,
468 ubyte,
469 ufunc,
470 uint,
471 uint8,
472 uint16,
473 uint32,
474 uint64,
475 uintc,
476 uintp,
477 ulong,
478 ulonglong,
479 union1d,
480 unique,
481 unique_all,
482 unique_counts,
483 unique_inverse,
484 unique_values,
485 unpackbits,
486 unravel_index,
487 unsignedinteger,
488 unstack,
489 unwrap,
490 ushort,
491 vander,
492 var,
493 vdot,
494 vecdot,
495 vecmat,
496 vectorize,
497 void,
498 vsplit,
499 vstack,
500 where,
501 zeros_like,
502)
503from numpy._typing import _ArrayLike, _DTypeLike
504
505__all__ = ["rand", "randn", "repmat"]
506__all__ += np.__all__
507
508###
509
510_ScalarT = TypeVar("_ScalarT", bound=np.generic)
511_Matrix: TypeAlias = np.matrix[tuple[int, int], np.dtype[_ScalarT]]
512_Order: TypeAlias = Literal["C", "F"]
513
514###
515
516#
517@overload
518def empty(shape: int | tuple[int, int], dtype: None = None, order: _Order = "C") -> _Matrix[np.float64]: ...
519@overload
520def empty(shape: int | tuple[int, int], dtype: _DTypeLike[_ScalarT], order: _Order = "C") -> _Matrix[_ScalarT]: ...
521@overload
522def empty(shape: int | tuple[int, int], dtype: npt.DTypeLike, order: _Order = "C") -> _Matrix[Any]: ...
523
524#
525@overload
526def ones(shape: int | tuple[int, int], dtype: None = None, order: _Order = "C") -> _Matrix[np.float64]: ...
527@overload
528def ones(shape: int | tuple[int, int], dtype: _DTypeLike[_ScalarT], order: _Order = "C") -> _Matrix[_ScalarT]: ...
529@overload
530def ones(shape: int | tuple[int, int], dtype: npt.DTypeLike, order: _Order = "C") -> _Matrix[Any]: ...
531
532#
533@overload
534def zeros(shape: int | tuple[int, int], dtype: None = None, order: _Order = "C") -> _Matrix[np.float64]: ...
535@overload
536def zeros(shape: int | tuple[int, int], dtype: _DTypeLike[_ScalarT], order: _Order = "C") -> _Matrix[_ScalarT]: ...
537@overload
538def zeros(shape: int | tuple[int, int], dtype: npt.DTypeLike, order: _Order = "C") -> _Matrix[Any]: ...
539
540#
541@overload
542def identity(n: int, dtype: None = None) -> _Matrix[np.float64]: ...
543@overload
544def identity(n: int, dtype: _DTypeLike[_ScalarT]) -> _Matrix[_ScalarT]: ...
545@overload
546def identity(n: int, dtype: npt.DTypeLike | None = None) -> _Matrix[Any]: ...
547
548#
549@overload
550def eye(
551 n: int,
552 M: int | None = None,
553 k: int = 0,
554 dtype: type[np.float64] | None = ...,
555 order: _Order = "C",
556) -> _Matrix[np.float64]: ...
557@overload
558def eye(n: int, M: int | None, k: int, dtype: _DTypeLike[_ScalarT], order: _Order = "C") -> _Matrix[_ScalarT]: ...
559@overload
560def eye(n: int, M: int | None = None, k: int = 0, *, dtype: _DTypeLike[_ScalarT], order: _Order = "C") -> _Matrix[_ScalarT]: ...
561@overload
562def eye(n: int, M: int | None = None, k: int = 0, dtype: npt.DTypeLike | None = ..., order: _Order = "C") -> _Matrix[Any]: ...
563
564#
565@overload
566def rand(arg: int | tuple[()] | tuple[int] | tuple[int, int], /) -> _Matrix[np.float64]: ...
567@overload
568def rand(arg: int, /, *args: int) -> _Matrix[np.float64]: ...
569
570#
571@overload
572def randn(arg: int | tuple[()] | tuple[int] | tuple[int, int], /) -> _Matrix[np.float64]: ...
573@overload
574def randn(arg: int, /, *args: int) -> _Matrix[np.float64]: ...
575
576#
577@overload
578def repmat(a: _Matrix[_ScalarT], m: int, n: int) -> _Matrix[_ScalarT]: ...
579@overload
580def repmat(a: _ArrayLike[_ScalarT], m: int, n: int) -> npt.NDArray[_ScalarT]: ...
581@overload
582def repmat(a: npt.ArrayLike, m: int, n: int) -> npt.NDArray[Any]: ...
583 