numeric.pyi 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  1. from collections.abc import Callable, Sequence
  2. from typing import (
  3. Any,
  4. Final,
  5. TypeAlias,
  6. overload,
  7. TypeVar,
  8. Literal as L,
  9. SupportsAbs,
  10. SupportsIndex,
  11. NoReturn,
  12. TypeGuard,
  13. )
  14. from typing_extensions import Unpack
  15. import numpy as np
  16. from numpy import (
  17. # re-exports
  18. bitwise_not,
  19. False_,
  20. True_,
  21. broadcast,
  22. dtype,
  23. flatiter,
  24. from_dlpack,
  25. inf,
  26. little_endian,
  27. matmul,
  28. vecdot,
  29. nan,
  30. ndarray,
  31. nditer,
  32. newaxis,
  33. ufunc,
  34. # other
  35. generic,
  36. unsignedinteger,
  37. signedinteger,
  38. floating,
  39. complexfloating,
  40. int_,
  41. intp,
  42. float64,
  43. timedelta64,
  44. object_,
  45. _AnyShapeType,
  46. _OrderKACF,
  47. _OrderCF,
  48. )
  49. from .fromnumeric import (
  50. all as all,
  51. any as any,
  52. argpartition as argpartition,
  53. matrix_transpose as matrix_transpose,
  54. mean as mean,
  55. )
  56. from .multiarray import (
  57. # re-exports
  58. arange,
  59. array,
  60. asarray,
  61. asanyarray,
  62. ascontiguousarray,
  63. asfortranarray,
  64. can_cast,
  65. concatenate,
  66. copyto,
  67. dot,
  68. empty,
  69. empty_like,
  70. frombuffer,
  71. fromfile,
  72. fromiter,
  73. fromstring,
  74. inner,
  75. lexsort,
  76. may_share_memory,
  77. min_scalar_type,
  78. nested_iters,
  79. putmask,
  80. promote_types,
  81. result_type,
  82. shares_memory,
  83. vdot,
  84. where,
  85. zeros,
  86. # other
  87. _Array,
  88. _ConstructorEmpty,
  89. _KwargsEmpty,
  90. )
  91. from numpy._typing import (
  92. ArrayLike,
  93. NDArray,
  94. DTypeLike,
  95. _SupportsDType,
  96. _ShapeLike,
  97. _DTypeLike,
  98. _ArrayLike,
  99. _SupportsArrayFunc,
  100. _ScalarLike_co,
  101. _ArrayLikeBool_co,
  102. _ArrayLikeUInt_co,
  103. _ArrayLikeInt_co,
  104. _ArrayLikeFloat_co,
  105. _ArrayLikeComplex_co,
  106. _ArrayLikeTD64_co,
  107. _ArrayLikeObject_co,
  108. _ArrayLikeUnknown,
  109. _NestedSequence,
  110. )
  111. __all__ = [
  112. "newaxis",
  113. "ndarray",
  114. "flatiter",
  115. "nditer",
  116. "nested_iters",
  117. "ufunc",
  118. "arange",
  119. "array",
  120. "asarray",
  121. "asanyarray",
  122. "ascontiguousarray",
  123. "asfortranarray",
  124. "zeros",
  125. "count_nonzero",
  126. "empty",
  127. "broadcast",
  128. "dtype",
  129. "fromstring",
  130. "fromfile",
  131. "frombuffer",
  132. "from_dlpack",
  133. "where",
  134. "argwhere",
  135. "copyto",
  136. "concatenate",
  137. "lexsort",
  138. "astype",
  139. "can_cast",
  140. "promote_types",
  141. "min_scalar_type",
  142. "result_type",
  143. "isfortran",
  144. "empty_like",
  145. "zeros_like",
  146. "ones_like",
  147. "correlate",
  148. "convolve",
  149. "inner",
  150. "dot",
  151. "outer",
  152. "vdot",
  153. "roll",
  154. "rollaxis",
  155. "moveaxis",
  156. "cross",
  157. "tensordot",
  158. "little_endian",
  159. "fromiter",
  160. "array_equal",
  161. "array_equiv",
  162. "indices",
  163. "fromfunction",
  164. "isclose",
  165. "isscalar",
  166. "binary_repr",
  167. "base_repr",
  168. "ones",
  169. "identity",
  170. "allclose",
  171. "putmask",
  172. "flatnonzero",
  173. "inf",
  174. "nan",
  175. "False_",
  176. "True_",
  177. "bitwise_not",
  178. "full",
  179. "full_like",
  180. "matmul",
  181. "vecdot",
  182. "shares_memory",
  183. "may_share_memory",
  184. ]
  185. _T = TypeVar("_T")
  186. _SCT = TypeVar("_SCT", bound=generic)
  187. _DType = TypeVar("_DType", bound=np.dtype[Any])
  188. _ArrayType = TypeVar("_ArrayType", bound=np.ndarray[Any, Any])
  189. _ShapeType = TypeVar("_ShapeType", bound=tuple[int, ...])
  190. _CorrelateMode: TypeAlias = L["valid", "same", "full"]
  191. @overload
  192. def zeros_like(
  193. a: _ArrayType,
  194. dtype: None = ...,
  195. order: _OrderKACF = ...,
  196. subok: L[True] = ...,
  197. shape: None = ...,
  198. *,
  199. device: None | L["cpu"] = ...,
  200. ) -> _ArrayType: ...
  201. @overload
  202. def zeros_like(
  203. a: _ArrayLike[_SCT],
  204. dtype: None = ...,
  205. order: _OrderKACF = ...,
  206. subok: bool = ...,
  207. shape: None | _ShapeLike = ...,
  208. *,
  209. device: None | L["cpu"] = ...,
  210. ) -> NDArray[_SCT]: ...
  211. @overload
  212. def zeros_like(
  213. a: object,
  214. dtype: None = ...,
  215. order: _OrderKACF = ...,
  216. subok: bool = ...,
  217. shape: None | _ShapeLike= ...,
  218. *,
  219. device: None | L["cpu"] = ...,
  220. ) -> NDArray[Any]: ...
  221. @overload
  222. def zeros_like(
  223. a: Any,
  224. dtype: _DTypeLike[_SCT],
  225. order: _OrderKACF = ...,
  226. subok: bool = ...,
  227. shape: None | _ShapeLike= ...,
  228. *,
  229. device: None | L["cpu"] = ...,
  230. ) -> NDArray[_SCT]: ...
  231. @overload
  232. def zeros_like(
  233. a: Any,
  234. dtype: DTypeLike,
  235. order: _OrderKACF = ...,
  236. subok: bool = ...,
  237. shape: None | _ShapeLike= ...,
  238. *,
  239. device: None | L["cpu"] = ...,
  240. ) -> NDArray[Any]: ...
  241. ones: Final[_ConstructorEmpty]
  242. @overload
  243. def ones_like(
  244. a: _ArrayType,
  245. dtype: None = ...,
  246. order: _OrderKACF = ...,
  247. subok: L[True] = ...,
  248. shape: None = ...,
  249. *,
  250. device: None | L["cpu"] = ...,
  251. ) -> _ArrayType: ...
  252. @overload
  253. def ones_like(
  254. a: _ArrayLike[_SCT],
  255. dtype: None = ...,
  256. order: _OrderKACF = ...,
  257. subok: bool = ...,
  258. shape: None | _ShapeLike = ...,
  259. *,
  260. device: None | L["cpu"] = ...,
  261. ) -> NDArray[_SCT]: ...
  262. @overload
  263. def ones_like(
  264. a: object,
  265. dtype: None = ...,
  266. order: _OrderKACF = ...,
  267. subok: bool = ...,
  268. shape: None | _ShapeLike= ...,
  269. *,
  270. device: None | L["cpu"] = ...,
  271. ) -> NDArray[Any]: ...
  272. @overload
  273. def ones_like(
  274. a: Any,
  275. dtype: _DTypeLike[_SCT],
  276. order: _OrderKACF = ...,
  277. subok: bool = ...,
  278. shape: None | _ShapeLike= ...,
  279. *,
  280. device: None | L["cpu"] = ...,
  281. ) -> NDArray[_SCT]: ...
  282. @overload
  283. def ones_like(
  284. a: Any,
  285. dtype: DTypeLike,
  286. order: _OrderKACF = ...,
  287. subok: bool = ...,
  288. shape: None | _ShapeLike= ...,
  289. *,
  290. device: None | L["cpu"] = ...,
  291. ) -> NDArray[Any]: ...
  292. # TODO: Add overloads for bool, int, float, complex, str, bytes, and memoryview
  293. # 1-D shape
  294. @overload
  295. def full(
  296. shape: SupportsIndex,
  297. fill_value: _SCT,
  298. dtype: None = ...,
  299. order: _OrderCF = ...,
  300. **kwargs: Unpack[_KwargsEmpty],
  301. ) -> _Array[tuple[int], _SCT]: ...
  302. @overload
  303. def full(
  304. shape: SupportsIndex,
  305. fill_value: Any,
  306. dtype: _DType | _SupportsDType[_DType],
  307. order: _OrderCF = ...,
  308. **kwargs: Unpack[_KwargsEmpty],
  309. ) -> np.ndarray[tuple[int], _DType]: ...
  310. @overload
  311. def full(
  312. shape: SupportsIndex,
  313. fill_value: Any,
  314. dtype: type[_SCT],
  315. order: _OrderCF = ...,
  316. **kwargs: Unpack[_KwargsEmpty],
  317. ) -> _Array[tuple[int], _SCT]: ...
  318. @overload
  319. def full(
  320. shape: SupportsIndex,
  321. fill_value: Any,
  322. dtype: None | DTypeLike = ...,
  323. order: _OrderCF = ...,
  324. **kwargs: Unpack[_KwargsEmpty],
  325. ) -> _Array[tuple[int], Any]: ...
  326. # known shape
  327. @overload
  328. def full(
  329. shape: _AnyShapeType,
  330. fill_value: _SCT,
  331. dtype: None = ...,
  332. order: _OrderCF = ...,
  333. **kwargs: Unpack[_KwargsEmpty],
  334. ) -> _Array[_AnyShapeType, _SCT]: ...
  335. @overload
  336. def full(
  337. shape: _AnyShapeType,
  338. fill_value: Any,
  339. dtype: _DType | _SupportsDType[_DType],
  340. order: _OrderCF = ...,
  341. **kwargs: Unpack[_KwargsEmpty],
  342. ) -> np.ndarray[_AnyShapeType, _DType]: ...
  343. @overload
  344. def full(
  345. shape: _AnyShapeType,
  346. fill_value: Any,
  347. dtype: type[_SCT],
  348. order: _OrderCF = ...,
  349. **kwargs: Unpack[_KwargsEmpty],
  350. ) -> _Array[_AnyShapeType, _SCT]: ...
  351. @overload
  352. def full(
  353. shape: _AnyShapeType,
  354. fill_value: Any,
  355. dtype: None | DTypeLike = ...,
  356. order: _OrderCF = ...,
  357. **kwargs: Unpack[_KwargsEmpty],
  358. ) -> _Array[_AnyShapeType, Any]: ...
  359. # unknown shape
  360. @overload
  361. def full(
  362. shape: _ShapeLike,
  363. fill_value: _SCT,
  364. dtype: None = ...,
  365. order: _OrderCF = ...,
  366. **kwargs: Unpack[_KwargsEmpty],
  367. ) -> NDArray[_SCT]: ...
  368. @overload
  369. def full(
  370. shape: _ShapeLike,
  371. fill_value: Any,
  372. dtype: _DType | _SupportsDType[_DType],
  373. order: _OrderCF = ...,
  374. **kwargs: Unpack[_KwargsEmpty],
  375. ) -> np.ndarray[Any, _DType]: ...
  376. @overload
  377. def full(
  378. shape: _ShapeLike,
  379. fill_value: Any,
  380. dtype: type[_SCT],
  381. order: _OrderCF = ...,
  382. **kwargs: Unpack[_KwargsEmpty],
  383. ) -> NDArray[_SCT]: ...
  384. @overload
  385. def full(
  386. shape: _ShapeLike,
  387. fill_value: Any,
  388. dtype: None | DTypeLike = ...,
  389. order: _OrderCF = ...,
  390. **kwargs: Unpack[_KwargsEmpty],
  391. ) -> NDArray[Any]: ...
  392. @overload
  393. def full_like(
  394. a: _ArrayType,
  395. fill_value: Any,
  396. dtype: None = ...,
  397. order: _OrderKACF = ...,
  398. subok: L[True] = ...,
  399. shape: None = ...,
  400. *,
  401. device: None | L["cpu"] = ...,
  402. ) -> _ArrayType: ...
  403. @overload
  404. def full_like(
  405. a: _ArrayLike[_SCT],
  406. fill_value: Any,
  407. dtype: None = ...,
  408. order: _OrderKACF = ...,
  409. subok: bool = ...,
  410. shape: None | _ShapeLike = ...,
  411. *,
  412. device: None | L["cpu"] = ...,
  413. ) -> NDArray[_SCT]: ...
  414. @overload
  415. def full_like(
  416. a: object,
  417. fill_value: Any,
  418. dtype: None = ...,
  419. order: _OrderKACF = ...,
  420. subok: bool = ...,
  421. shape: None | _ShapeLike= ...,
  422. *,
  423. device: None | L["cpu"] = ...,
  424. ) -> NDArray[Any]: ...
  425. @overload
  426. def full_like(
  427. a: Any,
  428. fill_value: Any,
  429. dtype: _DTypeLike[_SCT],
  430. order: _OrderKACF = ...,
  431. subok: bool = ...,
  432. shape: None | _ShapeLike= ...,
  433. *,
  434. device: None | L["cpu"] = ...,
  435. ) -> NDArray[_SCT]: ...
  436. @overload
  437. def full_like(
  438. a: Any,
  439. fill_value: Any,
  440. dtype: DTypeLike,
  441. order: _OrderKACF = ...,
  442. subok: bool = ...,
  443. shape: None | _ShapeLike= ...,
  444. *,
  445. device: None | L["cpu"] = ...,
  446. ) -> NDArray[Any]: ...
  447. #
  448. @overload
  449. def count_nonzero(a: ArrayLike, axis: None = None, *, keepdims: L[False] = False) -> int: ...
  450. @overload
  451. def count_nonzero(a: _ScalarLike_co, axis: _ShapeLike | None = None, *, keepdims: L[True]) -> np.intp: ...
  452. @overload
  453. def count_nonzero(
  454. a: NDArray[Any] | _NestedSequence[ArrayLike], axis: _ShapeLike | None = None, *, keepdims: L[True]
  455. ) -> NDArray[np.intp]: ...
  456. @overload
  457. def count_nonzero(a: ArrayLike, axis: _ShapeLike | None = None, *, keepdims: bool = False) -> Any: ...
  458. #
  459. def isfortran(a: NDArray[Any] | generic) -> bool: ...
  460. def argwhere(a: ArrayLike) -> NDArray[intp]: ...
  461. def flatnonzero(a: ArrayLike) -> NDArray[intp]: ...
  462. @overload
  463. def correlate(
  464. a: _ArrayLikeUnknown,
  465. v: _ArrayLikeUnknown,
  466. mode: _CorrelateMode = ...,
  467. ) -> NDArray[Any]: ...
  468. @overload
  469. def correlate(
  470. a: _ArrayLikeBool_co,
  471. v: _ArrayLikeBool_co,
  472. mode: _CorrelateMode = ...,
  473. ) -> NDArray[np.bool]: ...
  474. @overload
  475. def correlate(
  476. a: _ArrayLikeUInt_co,
  477. v: _ArrayLikeUInt_co,
  478. mode: _CorrelateMode = ...,
  479. ) -> NDArray[unsignedinteger[Any]]: ...
  480. @overload
  481. def correlate(
  482. a: _ArrayLikeInt_co,
  483. v: _ArrayLikeInt_co,
  484. mode: _CorrelateMode = ...,
  485. ) -> NDArray[signedinteger[Any]]: ...
  486. @overload
  487. def correlate(
  488. a: _ArrayLikeFloat_co,
  489. v: _ArrayLikeFloat_co,
  490. mode: _CorrelateMode = ...,
  491. ) -> NDArray[floating[Any]]: ...
  492. @overload
  493. def correlate(
  494. a: _ArrayLikeComplex_co,
  495. v: _ArrayLikeComplex_co,
  496. mode: _CorrelateMode = ...,
  497. ) -> NDArray[complexfloating[Any, Any]]: ...
  498. @overload
  499. def correlate(
  500. a: _ArrayLikeTD64_co,
  501. v: _ArrayLikeTD64_co,
  502. mode: _CorrelateMode = ...,
  503. ) -> NDArray[timedelta64]: ...
  504. @overload
  505. def correlate(
  506. a: _ArrayLikeObject_co,
  507. v: _ArrayLikeObject_co,
  508. mode: _CorrelateMode = ...,
  509. ) -> NDArray[object_]: ...
  510. @overload
  511. def convolve(
  512. a: _ArrayLikeUnknown,
  513. v: _ArrayLikeUnknown,
  514. mode: _CorrelateMode = ...,
  515. ) -> NDArray[Any]: ...
  516. @overload
  517. def convolve(
  518. a: _ArrayLikeBool_co,
  519. v: _ArrayLikeBool_co,
  520. mode: _CorrelateMode = ...,
  521. ) -> NDArray[np.bool]: ...
  522. @overload
  523. def convolve(
  524. a: _ArrayLikeUInt_co,
  525. v: _ArrayLikeUInt_co,
  526. mode: _CorrelateMode = ...,
  527. ) -> NDArray[unsignedinteger[Any]]: ...
  528. @overload
  529. def convolve(
  530. a: _ArrayLikeInt_co,
  531. v: _ArrayLikeInt_co,
  532. mode: _CorrelateMode = ...,
  533. ) -> NDArray[signedinteger[Any]]: ...
  534. @overload
  535. def convolve(
  536. a: _ArrayLikeFloat_co,
  537. v: _ArrayLikeFloat_co,
  538. mode: _CorrelateMode = ...,
  539. ) -> NDArray[floating[Any]]: ...
  540. @overload
  541. def convolve(
  542. a: _ArrayLikeComplex_co,
  543. v: _ArrayLikeComplex_co,
  544. mode: _CorrelateMode = ...,
  545. ) -> NDArray[complexfloating[Any, Any]]: ...
  546. @overload
  547. def convolve(
  548. a: _ArrayLikeTD64_co,
  549. v: _ArrayLikeTD64_co,
  550. mode: _CorrelateMode = ...,
  551. ) -> NDArray[timedelta64]: ...
  552. @overload
  553. def convolve(
  554. a: _ArrayLikeObject_co,
  555. v: _ArrayLikeObject_co,
  556. mode: _CorrelateMode = ...,
  557. ) -> NDArray[object_]: ...
  558. @overload
  559. def outer(
  560. a: _ArrayLikeUnknown,
  561. b: _ArrayLikeUnknown,
  562. out: None = ...,
  563. ) -> NDArray[Any]: ...
  564. @overload
  565. def outer(
  566. a: _ArrayLikeBool_co,
  567. b: _ArrayLikeBool_co,
  568. out: None = ...,
  569. ) -> NDArray[np.bool]: ...
  570. @overload
  571. def outer(
  572. a: _ArrayLikeUInt_co,
  573. b: _ArrayLikeUInt_co,
  574. out: None = ...,
  575. ) -> NDArray[unsignedinteger[Any]]: ...
  576. @overload
  577. def outer(
  578. a: _ArrayLikeInt_co,
  579. b: _ArrayLikeInt_co,
  580. out: None = ...,
  581. ) -> NDArray[signedinteger[Any]]: ...
  582. @overload
  583. def outer(
  584. a: _ArrayLikeFloat_co,
  585. b: _ArrayLikeFloat_co,
  586. out: None = ...,
  587. ) -> NDArray[floating[Any]]: ...
  588. @overload
  589. def outer(
  590. a: _ArrayLikeComplex_co,
  591. b: _ArrayLikeComplex_co,
  592. out: None = ...,
  593. ) -> NDArray[complexfloating[Any, Any]]: ...
  594. @overload
  595. def outer(
  596. a: _ArrayLikeTD64_co,
  597. b: _ArrayLikeTD64_co,
  598. out: None = ...,
  599. ) -> NDArray[timedelta64]: ...
  600. @overload
  601. def outer(
  602. a: _ArrayLikeObject_co,
  603. b: _ArrayLikeObject_co,
  604. out: None = ...,
  605. ) -> NDArray[object_]: ...
  606. @overload
  607. def outer(
  608. a: _ArrayLikeComplex_co | _ArrayLikeTD64_co | _ArrayLikeObject_co,
  609. b: _ArrayLikeComplex_co | _ArrayLikeTD64_co | _ArrayLikeObject_co,
  610. out: _ArrayType,
  611. ) -> _ArrayType: ...
  612. @overload
  613. def tensordot(
  614. a: _ArrayLikeUnknown,
  615. b: _ArrayLikeUnknown,
  616. axes: int | tuple[_ShapeLike, _ShapeLike] = ...,
  617. ) -> NDArray[Any]: ...
  618. @overload
  619. def tensordot(
  620. a: _ArrayLikeBool_co,
  621. b: _ArrayLikeBool_co,
  622. axes: int | tuple[_ShapeLike, _ShapeLike] = ...,
  623. ) -> NDArray[np.bool]: ...
  624. @overload
  625. def tensordot(
  626. a: _ArrayLikeUInt_co,
  627. b: _ArrayLikeUInt_co,
  628. axes: int | tuple[_ShapeLike, _ShapeLike] = ...,
  629. ) -> NDArray[unsignedinteger[Any]]: ...
  630. @overload
  631. def tensordot(
  632. a: _ArrayLikeInt_co,
  633. b: _ArrayLikeInt_co,
  634. axes: int | tuple[_ShapeLike, _ShapeLike] = ...,
  635. ) -> NDArray[signedinteger[Any]]: ...
  636. @overload
  637. def tensordot(
  638. a: _ArrayLikeFloat_co,
  639. b: _ArrayLikeFloat_co,
  640. axes: int | tuple[_ShapeLike, _ShapeLike] = ...,
  641. ) -> NDArray[floating[Any]]: ...
  642. @overload
  643. def tensordot(
  644. a: _ArrayLikeComplex_co,
  645. b: _ArrayLikeComplex_co,
  646. axes: int | tuple[_ShapeLike, _ShapeLike] = ...,
  647. ) -> NDArray[complexfloating[Any, Any]]: ...
  648. @overload
  649. def tensordot(
  650. a: _ArrayLikeTD64_co,
  651. b: _ArrayLikeTD64_co,
  652. axes: int | tuple[_ShapeLike, _ShapeLike] = ...,
  653. ) -> NDArray[timedelta64]: ...
  654. @overload
  655. def tensordot(
  656. a: _ArrayLikeObject_co,
  657. b: _ArrayLikeObject_co,
  658. axes: int | tuple[_ShapeLike, _ShapeLike] = ...,
  659. ) -> NDArray[object_]: ...
  660. @overload
  661. def roll(
  662. a: _ArrayLike[_SCT],
  663. shift: _ShapeLike,
  664. axis: None | _ShapeLike = ...,
  665. ) -> NDArray[_SCT]: ...
  666. @overload
  667. def roll(
  668. a: ArrayLike,
  669. shift: _ShapeLike,
  670. axis: None | _ShapeLike = ...,
  671. ) -> NDArray[Any]: ...
  672. def rollaxis(
  673. a: NDArray[_SCT],
  674. axis: int,
  675. start: int = ...,
  676. ) -> NDArray[_SCT]: ...
  677. def moveaxis(
  678. a: NDArray[_SCT],
  679. source: _ShapeLike,
  680. destination: _ShapeLike,
  681. ) -> NDArray[_SCT]: ...
  682. @overload
  683. def cross(
  684. a: _ArrayLikeUnknown,
  685. b: _ArrayLikeUnknown,
  686. axisa: int = ...,
  687. axisb: int = ...,
  688. axisc: int = ...,
  689. axis: None | int = ...,
  690. ) -> NDArray[Any]: ...
  691. @overload
  692. def cross(
  693. a: _ArrayLikeBool_co,
  694. b: _ArrayLikeBool_co,
  695. axisa: int = ...,
  696. axisb: int = ...,
  697. axisc: int = ...,
  698. axis: None | int = ...,
  699. ) -> NoReturn: ...
  700. @overload
  701. def cross(
  702. a: _ArrayLikeUInt_co,
  703. b: _ArrayLikeUInt_co,
  704. axisa: int = ...,
  705. axisb: int = ...,
  706. axisc: int = ...,
  707. axis: None | int = ...,
  708. ) -> NDArray[unsignedinteger[Any]]: ...
  709. @overload
  710. def cross(
  711. a: _ArrayLikeInt_co,
  712. b: _ArrayLikeInt_co,
  713. axisa: int = ...,
  714. axisb: int = ...,
  715. axisc: int = ...,
  716. axis: None | int = ...,
  717. ) -> NDArray[signedinteger[Any]]: ...
  718. @overload
  719. def cross(
  720. a: _ArrayLikeFloat_co,
  721. b: _ArrayLikeFloat_co,
  722. axisa: int = ...,
  723. axisb: int = ...,
  724. axisc: int = ...,
  725. axis: None | int = ...,
  726. ) -> NDArray[floating[Any]]: ...
  727. @overload
  728. def cross(
  729. a: _ArrayLikeComplex_co,
  730. b: _ArrayLikeComplex_co,
  731. axisa: int = ...,
  732. axisb: int = ...,
  733. axisc: int = ...,
  734. axis: None | int = ...,
  735. ) -> NDArray[complexfloating[Any, Any]]: ...
  736. @overload
  737. def cross(
  738. a: _ArrayLikeObject_co,
  739. b: _ArrayLikeObject_co,
  740. axisa: int = ...,
  741. axisb: int = ...,
  742. axisc: int = ...,
  743. axis: None | int = ...,
  744. ) -> NDArray[object_]: ...
  745. @overload
  746. def indices(
  747. dimensions: Sequence[int],
  748. dtype: type[int] = ...,
  749. sparse: L[False] = ...,
  750. ) -> NDArray[int_]: ...
  751. @overload
  752. def indices(
  753. dimensions: Sequence[int],
  754. dtype: type[int] = ...,
  755. sparse: L[True] = ...,
  756. ) -> tuple[NDArray[int_], ...]: ...
  757. @overload
  758. def indices(
  759. dimensions: Sequence[int],
  760. dtype: _DTypeLike[_SCT],
  761. sparse: L[False] = ...,
  762. ) -> NDArray[_SCT]: ...
  763. @overload
  764. def indices(
  765. dimensions: Sequence[int],
  766. dtype: _DTypeLike[_SCT],
  767. sparse: L[True],
  768. ) -> tuple[NDArray[_SCT], ...]: ...
  769. @overload
  770. def indices(
  771. dimensions: Sequence[int],
  772. dtype: DTypeLike,
  773. sparse: L[False] = ...,
  774. ) -> NDArray[Any]: ...
  775. @overload
  776. def indices(
  777. dimensions: Sequence[int],
  778. dtype: DTypeLike,
  779. sparse: L[True],
  780. ) -> tuple[NDArray[Any], ...]: ...
  781. def fromfunction(
  782. function: Callable[..., _T],
  783. shape: Sequence[int],
  784. *,
  785. dtype: DTypeLike = ...,
  786. like: _SupportsArrayFunc = ...,
  787. **kwargs: Any,
  788. ) -> _T: ...
  789. def isscalar(element: object) -> TypeGuard[
  790. generic | bool | int | float | complex | str | bytes | memoryview
  791. ]: ...
  792. def binary_repr(num: SupportsIndex, width: None | int = ...) -> str: ...
  793. def base_repr(
  794. number: SupportsAbs[float],
  795. base: float = ...,
  796. padding: SupportsIndex = ...,
  797. ) -> str: ...
  798. @overload
  799. def identity(
  800. n: int,
  801. dtype: None = ...,
  802. *,
  803. like: _SupportsArrayFunc = ...,
  804. ) -> NDArray[float64]: ...
  805. @overload
  806. def identity(
  807. n: int,
  808. dtype: _DTypeLike[_SCT],
  809. *,
  810. like: _SupportsArrayFunc = ...,
  811. ) -> NDArray[_SCT]: ...
  812. @overload
  813. def identity(
  814. n: int,
  815. dtype: DTypeLike,
  816. *,
  817. like: _SupportsArrayFunc = ...,
  818. ) -> NDArray[Any]: ...
  819. def allclose(
  820. a: ArrayLike,
  821. b: ArrayLike,
  822. rtol: ArrayLike = ...,
  823. atol: ArrayLike = ...,
  824. equal_nan: bool = ...,
  825. ) -> bool: ...
  826. @overload
  827. def isclose(
  828. a: _ScalarLike_co,
  829. b: _ScalarLike_co,
  830. rtol: ArrayLike = ...,
  831. atol: ArrayLike = ...,
  832. equal_nan: bool = ...,
  833. ) -> np.bool: ...
  834. @overload
  835. def isclose(
  836. a: ArrayLike,
  837. b: ArrayLike,
  838. rtol: ArrayLike = ...,
  839. atol: ArrayLike = ...,
  840. equal_nan: bool = ...,
  841. ) -> NDArray[np.bool]: ...
  842. def array_equal(a1: ArrayLike, a2: ArrayLike, equal_nan: bool = ...) -> bool: ...
  843. def array_equiv(a1: ArrayLike, a2: ArrayLike) -> bool: ...
  844. @overload
  845. def astype(
  846. x: ndarray[_ShapeType, dtype[Any]],
  847. dtype: _DTypeLike[_SCT],
  848. /,
  849. *,
  850. copy: bool = ...,
  851. device: None | L["cpu"] = ...,
  852. ) -> ndarray[_ShapeType, dtype[_SCT]]: ...
  853. @overload
  854. def astype(
  855. x: ndarray[_ShapeType, dtype[Any]],
  856. dtype: DTypeLike,
  857. /,
  858. *,
  859. copy: bool = ...,
  860. device: None | L["cpu"] = ...,
  861. ) -> ndarray[_ShapeType, dtype[Any]]: ...