matlib.pyi 9.5 KB

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