__init__.pyi 150 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416
  1. import builtins
  2. import os
  3. import sys
  4. import mmap
  5. import ctypes as ct
  6. import array as _array
  7. import datetime as dt
  8. import enum
  9. from abc import abstractmethod
  10. from types import TracebackType, MappingProxyType
  11. from contextlib import ContextDecorator
  12. from contextlib import contextmanager
  13. if sys.version_info >= (3, 9):
  14. from types import GenericAlias
  15. from numpy._pytesttester import PytestTester
  16. from numpy.core._internal import _ctypes
  17. from numpy._typing import (
  18. # Arrays
  19. ArrayLike,
  20. NDArray,
  21. _SupportsArray,
  22. _NestedSequence,
  23. _FiniteNestedSequence,
  24. _SupportsArray,
  25. _ArrayLikeBool_co,
  26. _ArrayLikeUInt_co,
  27. _ArrayLikeInt_co,
  28. _ArrayLikeFloat_co,
  29. _ArrayLikeComplex_co,
  30. _ArrayLikeNumber_co,
  31. _ArrayLikeTD64_co,
  32. _ArrayLikeDT64_co,
  33. _ArrayLikeObject_co,
  34. _ArrayLikeStr_co,
  35. _ArrayLikeBytes_co,
  36. _ArrayLikeUnknown,
  37. _UnknownType,
  38. # DTypes
  39. DTypeLike,
  40. _DTypeLike,
  41. _DTypeLikeVoid,
  42. _SupportsDType,
  43. _VoidDTypeLike,
  44. # Shapes
  45. _Shape,
  46. _ShapeLike,
  47. # Scalars
  48. _CharLike_co,
  49. _BoolLike_co,
  50. _IntLike_co,
  51. _FloatLike_co,
  52. _ComplexLike_co,
  53. _TD64Like_co,
  54. _NumberLike_co,
  55. _ScalarLike_co,
  56. # `number` precision
  57. NBitBase,
  58. _256Bit,
  59. _128Bit,
  60. _96Bit,
  61. _80Bit,
  62. _64Bit,
  63. _32Bit,
  64. _16Bit,
  65. _8Bit,
  66. _NBitByte,
  67. _NBitShort,
  68. _NBitIntC,
  69. _NBitIntP,
  70. _NBitInt,
  71. _NBitLongLong,
  72. _NBitHalf,
  73. _NBitSingle,
  74. _NBitDouble,
  75. _NBitLongDouble,
  76. # Character codes
  77. _BoolCodes,
  78. _UInt8Codes,
  79. _UInt16Codes,
  80. _UInt32Codes,
  81. _UInt64Codes,
  82. _Int8Codes,
  83. _Int16Codes,
  84. _Int32Codes,
  85. _Int64Codes,
  86. _Float16Codes,
  87. _Float32Codes,
  88. _Float64Codes,
  89. _Complex64Codes,
  90. _Complex128Codes,
  91. _ByteCodes,
  92. _ShortCodes,
  93. _IntCCodes,
  94. _IntPCodes,
  95. _IntCodes,
  96. _LongLongCodes,
  97. _UByteCodes,
  98. _UShortCodes,
  99. _UIntCCodes,
  100. _UIntPCodes,
  101. _UIntCodes,
  102. _ULongLongCodes,
  103. _HalfCodes,
  104. _SingleCodes,
  105. _DoubleCodes,
  106. _LongDoubleCodes,
  107. _CSingleCodes,
  108. _CDoubleCodes,
  109. _CLongDoubleCodes,
  110. _DT64Codes,
  111. _TD64Codes,
  112. _StrCodes,
  113. _BytesCodes,
  114. _VoidCodes,
  115. _ObjectCodes,
  116. # Ufuncs
  117. _UFunc_Nin1_Nout1,
  118. _UFunc_Nin2_Nout1,
  119. _UFunc_Nin1_Nout2,
  120. _UFunc_Nin2_Nout2,
  121. _GUFunc_Nin2_Nout1,
  122. )
  123. from numpy._typing._callable import (
  124. _BoolOp,
  125. _BoolBitOp,
  126. _BoolSub,
  127. _BoolTrueDiv,
  128. _BoolMod,
  129. _BoolDivMod,
  130. _TD64Div,
  131. _IntTrueDiv,
  132. _UnsignedIntOp,
  133. _UnsignedIntBitOp,
  134. _UnsignedIntMod,
  135. _UnsignedIntDivMod,
  136. _SignedIntOp,
  137. _SignedIntBitOp,
  138. _SignedIntMod,
  139. _SignedIntDivMod,
  140. _FloatOp,
  141. _FloatMod,
  142. _FloatDivMod,
  143. _ComplexOp,
  144. _NumberOp,
  145. _ComparisonOp,
  146. )
  147. # NOTE: Numpy's mypy plugin is used for removing the types unavailable
  148. # to the specific platform
  149. from numpy._typing._extended_precision import (
  150. uint128 as uint128,
  151. uint256 as uint256,
  152. int128 as int128,
  153. int256 as int256,
  154. float80 as float80,
  155. float96 as float96,
  156. float128 as float128,
  157. float256 as float256,
  158. complex160 as complex160,
  159. complex192 as complex192,
  160. complex256 as complex256,
  161. complex512 as complex512,
  162. )
  163. from collections.abc import (
  164. Callable,
  165. Container,
  166. Iterable,
  167. Iterator,
  168. Mapping,
  169. Sequence,
  170. Sized,
  171. )
  172. from typing import (
  173. Literal as L,
  174. Any,
  175. Generator,
  176. Generic,
  177. IO,
  178. NoReturn,
  179. overload,
  180. SupportsComplex,
  181. SupportsFloat,
  182. SupportsInt,
  183. TypeVar,
  184. Union,
  185. Protocol,
  186. SupportsIndex,
  187. Final,
  188. final,
  189. ClassVar,
  190. )
  191. # Ensures that the stubs are picked up
  192. from numpy import (
  193. ctypeslib as ctypeslib,
  194. fft as fft,
  195. lib as lib,
  196. linalg as linalg,
  197. ma as ma,
  198. polynomial as polynomial,
  199. random as random,
  200. testing as testing,
  201. version as version,
  202. )
  203. from numpy.core import defchararray, records
  204. char = defchararray
  205. rec = records
  206. from numpy.core.function_base import (
  207. linspace as linspace,
  208. logspace as logspace,
  209. geomspace as geomspace,
  210. )
  211. from numpy.core.fromnumeric import (
  212. take as take,
  213. reshape as reshape,
  214. choose as choose,
  215. repeat as repeat,
  216. put as put,
  217. swapaxes as swapaxes,
  218. transpose as transpose,
  219. partition as partition,
  220. argpartition as argpartition,
  221. sort as sort,
  222. argsort as argsort,
  223. argmax as argmax,
  224. argmin as argmin,
  225. searchsorted as searchsorted,
  226. resize as resize,
  227. squeeze as squeeze,
  228. diagonal as diagonal,
  229. trace as trace,
  230. ravel as ravel,
  231. nonzero as nonzero,
  232. shape as shape,
  233. compress as compress,
  234. clip as clip,
  235. sum as sum,
  236. all as all,
  237. any as any,
  238. cumsum as cumsum,
  239. ptp as ptp,
  240. amax as amax,
  241. amin as amin,
  242. prod as prod,
  243. cumprod as cumprod,
  244. ndim as ndim,
  245. size as size,
  246. around as around,
  247. mean as mean,
  248. std as std,
  249. var as var,
  250. )
  251. from numpy.core._asarray import (
  252. require as require,
  253. )
  254. from numpy.core._type_aliases import (
  255. sctypes as sctypes,
  256. sctypeDict as sctypeDict,
  257. )
  258. from numpy.core._ufunc_config import (
  259. seterr as seterr,
  260. geterr as geterr,
  261. setbufsize as setbufsize,
  262. getbufsize as getbufsize,
  263. seterrcall as seterrcall,
  264. geterrcall as geterrcall,
  265. _ErrKind,
  266. _ErrFunc,
  267. _ErrDictOptional,
  268. )
  269. from numpy.core.arrayprint import (
  270. set_printoptions as set_printoptions,
  271. get_printoptions as get_printoptions,
  272. array2string as array2string,
  273. format_float_scientific as format_float_scientific,
  274. format_float_positional as format_float_positional,
  275. array_repr as array_repr,
  276. array_str as array_str,
  277. set_string_function as set_string_function,
  278. printoptions as printoptions,
  279. )
  280. from numpy.core.einsumfunc import (
  281. einsum as einsum,
  282. einsum_path as einsum_path,
  283. )
  284. from numpy.core.multiarray import (
  285. ALLOW_THREADS as ALLOW_THREADS,
  286. BUFSIZE as BUFSIZE,
  287. CLIP as CLIP,
  288. MAXDIMS as MAXDIMS,
  289. MAY_SHARE_BOUNDS as MAY_SHARE_BOUNDS,
  290. MAY_SHARE_EXACT as MAY_SHARE_EXACT,
  291. RAISE as RAISE,
  292. WRAP as WRAP,
  293. tracemalloc_domain as tracemalloc_domain,
  294. array as array,
  295. empty_like as empty_like,
  296. empty as empty,
  297. zeros as zeros,
  298. concatenate as concatenate,
  299. inner as inner,
  300. where as where,
  301. lexsort as lexsort,
  302. can_cast as can_cast,
  303. min_scalar_type as min_scalar_type,
  304. result_type as result_type,
  305. dot as dot,
  306. vdot as vdot,
  307. bincount as bincount,
  308. copyto as copyto,
  309. putmask as putmask,
  310. packbits as packbits,
  311. unpackbits as unpackbits,
  312. shares_memory as shares_memory,
  313. may_share_memory as may_share_memory,
  314. asarray as asarray,
  315. asanyarray as asanyarray,
  316. ascontiguousarray as ascontiguousarray,
  317. asfortranarray as asfortranarray,
  318. arange as arange,
  319. busday_count as busday_count,
  320. busday_offset as busday_offset,
  321. compare_chararrays as compare_chararrays,
  322. datetime_as_string as datetime_as_string,
  323. datetime_data as datetime_data,
  324. frombuffer as frombuffer,
  325. fromfile as fromfile,
  326. fromiter as fromiter,
  327. is_busday as is_busday,
  328. promote_types as promote_types,
  329. seterrobj as seterrobj,
  330. geterrobj as geterrobj,
  331. fromstring as fromstring,
  332. frompyfunc as frompyfunc,
  333. nested_iters as nested_iters,
  334. flagsobj,
  335. )
  336. from numpy.core.numeric import (
  337. zeros_like as zeros_like,
  338. ones as ones,
  339. ones_like as ones_like,
  340. full as full,
  341. full_like as full_like,
  342. count_nonzero as count_nonzero,
  343. isfortran as isfortran,
  344. argwhere as argwhere,
  345. flatnonzero as flatnonzero,
  346. correlate as correlate,
  347. convolve as convolve,
  348. outer as outer,
  349. tensordot as tensordot,
  350. roll as roll,
  351. rollaxis as rollaxis,
  352. moveaxis as moveaxis,
  353. cross as cross,
  354. indices as indices,
  355. fromfunction as fromfunction,
  356. isscalar as isscalar,
  357. binary_repr as binary_repr,
  358. base_repr as base_repr,
  359. identity as identity,
  360. allclose as allclose,
  361. isclose as isclose,
  362. array_equal as array_equal,
  363. array_equiv as array_equiv,
  364. )
  365. from numpy.core.numerictypes import (
  366. maximum_sctype as maximum_sctype,
  367. issctype as issctype,
  368. obj2sctype as obj2sctype,
  369. issubclass_ as issubclass_,
  370. issubsctype as issubsctype,
  371. issubdtype as issubdtype,
  372. sctype2char as sctype2char,
  373. find_common_type as find_common_type,
  374. nbytes as nbytes,
  375. cast as cast,
  376. ScalarType as ScalarType,
  377. typecodes as typecodes,
  378. )
  379. from numpy.core.shape_base import (
  380. atleast_1d as atleast_1d,
  381. atleast_2d as atleast_2d,
  382. atleast_3d as atleast_3d,
  383. block as block,
  384. hstack as hstack,
  385. stack as stack,
  386. vstack as vstack,
  387. )
  388. from numpy.lib import (
  389. emath as emath,
  390. )
  391. from numpy.lib.arraypad import (
  392. pad as pad,
  393. )
  394. from numpy.lib.arraysetops import (
  395. ediff1d as ediff1d,
  396. intersect1d as intersect1d,
  397. setxor1d as setxor1d,
  398. union1d as union1d,
  399. setdiff1d as setdiff1d,
  400. unique as unique,
  401. in1d as in1d,
  402. isin as isin,
  403. )
  404. from numpy.lib.arrayterator import (
  405. Arrayterator as Arrayterator,
  406. )
  407. from numpy.lib.function_base import (
  408. select as select,
  409. piecewise as piecewise,
  410. trim_zeros as trim_zeros,
  411. copy as copy,
  412. iterable as iterable,
  413. percentile as percentile,
  414. diff as diff,
  415. gradient as gradient,
  416. angle as angle,
  417. unwrap as unwrap,
  418. sort_complex as sort_complex,
  419. disp as disp,
  420. flip as flip,
  421. rot90 as rot90,
  422. extract as extract,
  423. place as place,
  424. asarray_chkfinite as asarray_chkfinite,
  425. average as average,
  426. bincount as bincount,
  427. digitize as digitize,
  428. cov as cov,
  429. corrcoef as corrcoef,
  430. median as median,
  431. sinc as sinc,
  432. hamming as hamming,
  433. hanning as hanning,
  434. bartlett as bartlett,
  435. blackman as blackman,
  436. kaiser as kaiser,
  437. trapz as trapz,
  438. i0 as i0,
  439. add_newdoc as add_newdoc,
  440. add_docstring as add_docstring,
  441. meshgrid as meshgrid,
  442. delete as delete,
  443. insert as insert,
  444. append as append,
  445. interp as interp,
  446. add_newdoc_ufunc as add_newdoc_ufunc,
  447. quantile as quantile,
  448. )
  449. from numpy.lib.histograms import (
  450. histogram_bin_edges as histogram_bin_edges,
  451. histogram as histogram,
  452. histogramdd as histogramdd,
  453. )
  454. from numpy.lib.index_tricks import (
  455. ravel_multi_index as ravel_multi_index,
  456. unravel_index as unravel_index,
  457. mgrid as mgrid,
  458. ogrid as ogrid,
  459. r_ as r_,
  460. c_ as c_,
  461. s_ as s_,
  462. index_exp as index_exp,
  463. ix_ as ix_,
  464. fill_diagonal as fill_diagonal,
  465. diag_indices as diag_indices,
  466. diag_indices_from as diag_indices_from,
  467. )
  468. from numpy.lib.nanfunctions import (
  469. nansum as nansum,
  470. nanmax as nanmax,
  471. nanmin as nanmin,
  472. nanargmax as nanargmax,
  473. nanargmin as nanargmin,
  474. nanmean as nanmean,
  475. nanmedian as nanmedian,
  476. nanpercentile as nanpercentile,
  477. nanvar as nanvar,
  478. nanstd as nanstd,
  479. nanprod as nanprod,
  480. nancumsum as nancumsum,
  481. nancumprod as nancumprod,
  482. nanquantile as nanquantile,
  483. )
  484. from numpy.lib.npyio import (
  485. savetxt as savetxt,
  486. loadtxt as loadtxt,
  487. genfromtxt as genfromtxt,
  488. recfromtxt as recfromtxt,
  489. recfromcsv as recfromcsv,
  490. load as load,
  491. save as save,
  492. savez as savez,
  493. savez_compressed as savez_compressed,
  494. packbits as packbits,
  495. unpackbits as unpackbits,
  496. fromregex as fromregex,
  497. )
  498. from numpy.lib.polynomial import (
  499. poly as poly,
  500. roots as roots,
  501. polyint as polyint,
  502. polyder as polyder,
  503. polyadd as polyadd,
  504. polysub as polysub,
  505. polymul as polymul,
  506. polydiv as polydiv,
  507. polyval as polyval,
  508. polyfit as polyfit,
  509. )
  510. from numpy.lib.shape_base import (
  511. column_stack as column_stack,
  512. row_stack as row_stack,
  513. dstack as dstack,
  514. array_split as array_split,
  515. split as split,
  516. hsplit as hsplit,
  517. vsplit as vsplit,
  518. dsplit as dsplit,
  519. apply_over_axes as apply_over_axes,
  520. expand_dims as expand_dims,
  521. apply_along_axis as apply_along_axis,
  522. kron as kron,
  523. tile as tile,
  524. get_array_wrap as get_array_wrap,
  525. take_along_axis as take_along_axis,
  526. put_along_axis as put_along_axis,
  527. )
  528. from numpy.lib.stride_tricks import (
  529. broadcast_to as broadcast_to,
  530. broadcast_arrays as broadcast_arrays,
  531. broadcast_shapes as broadcast_shapes,
  532. )
  533. from numpy.lib.twodim_base import (
  534. diag as diag,
  535. diagflat as diagflat,
  536. eye as eye,
  537. fliplr as fliplr,
  538. flipud as flipud,
  539. tri as tri,
  540. triu as triu,
  541. tril as tril,
  542. vander as vander,
  543. histogram2d as histogram2d,
  544. mask_indices as mask_indices,
  545. tril_indices as tril_indices,
  546. tril_indices_from as tril_indices_from,
  547. triu_indices as triu_indices,
  548. triu_indices_from as triu_indices_from,
  549. )
  550. from numpy.lib.type_check import (
  551. mintypecode as mintypecode,
  552. asfarray as asfarray,
  553. real as real,
  554. imag as imag,
  555. iscomplex as iscomplex,
  556. isreal as isreal,
  557. iscomplexobj as iscomplexobj,
  558. isrealobj as isrealobj,
  559. nan_to_num as nan_to_num,
  560. real_if_close as real_if_close,
  561. typename as typename,
  562. common_type as common_type,
  563. )
  564. from numpy.lib.ufunclike import (
  565. fix as fix,
  566. isposinf as isposinf,
  567. isneginf as isneginf,
  568. )
  569. from numpy.lib.utils import (
  570. issubclass_ as issubclass_,
  571. issubsctype as issubsctype,
  572. issubdtype as issubdtype,
  573. deprecate as deprecate,
  574. deprecate_with_doc as deprecate_with_doc,
  575. get_include as get_include,
  576. info as info,
  577. source as source,
  578. who as who,
  579. lookfor as lookfor,
  580. byte_bounds as byte_bounds,
  581. safe_eval as safe_eval,
  582. show_runtime as show_runtime,
  583. )
  584. from numpy.matrixlib import (
  585. asmatrix as asmatrix,
  586. mat as mat,
  587. bmat as bmat,
  588. )
  589. _AnyStr_contra = TypeVar("_AnyStr_contra", str, bytes, contravariant=True)
  590. # Protocol for representing file-like-objects accepted
  591. # by `ndarray.tofile` and `fromfile`
  592. class _IOProtocol(Protocol):
  593. def flush(self) -> object: ...
  594. def fileno(self) -> int: ...
  595. def tell(self) -> SupportsIndex: ...
  596. def seek(self, offset: int, whence: int, /) -> object: ...
  597. # NOTE: `seek`, `write` and `flush` are technically only required
  598. # for `readwrite`/`write` modes
  599. class _MemMapIOProtocol(Protocol):
  600. def flush(self) -> object: ...
  601. def fileno(self) -> SupportsIndex: ...
  602. def tell(self) -> int: ...
  603. def seek(self, offset: int, whence: int, /) -> object: ...
  604. def write(self, s: bytes, /) -> object: ...
  605. @property
  606. def read(self) -> object: ...
  607. class _SupportsWrite(Protocol[_AnyStr_contra]):
  608. def write(self, s: _AnyStr_contra, /) -> object: ...
  609. __all__: list[str]
  610. __path__: list[str]
  611. __version__: str
  612. __git_version__: str
  613. test: PytestTester
  614. # TODO: Move placeholders to their respective module once
  615. # their annotations are properly implemented
  616. #
  617. # Placeholders for classes
  618. # Some of these are aliases; others are wrappers with an identical signature
  619. round = around
  620. round_ = around
  621. max = amax
  622. min = amin
  623. product = prod
  624. cumproduct = cumprod
  625. sometrue = any
  626. alltrue = all
  627. def show_config() -> None: ...
  628. _NdArraySubClass = TypeVar("_NdArraySubClass", bound=ndarray)
  629. _DTypeScalar_co = TypeVar("_DTypeScalar_co", covariant=True, bound=generic)
  630. _ByteOrder = L["S", "<", ">", "=", "|", "L", "B", "N", "I"]
  631. @final
  632. class dtype(Generic[_DTypeScalar_co]):
  633. names: None | tuple[builtins.str, ...]
  634. # Overload for subclass of generic
  635. @overload
  636. def __new__(
  637. cls,
  638. dtype: type[_DTypeScalar_co],
  639. align: bool = ...,
  640. copy: bool = ...,
  641. metadata: dict[builtins.str, Any] = ...,
  642. ) -> dtype[_DTypeScalar_co]: ...
  643. # Overloads for string aliases, Python types, and some assorted
  644. # other special cases. Order is sometimes important because of the
  645. # subtype relationships
  646. #
  647. # bool < int < float < complex < object
  648. #
  649. # so we have to make sure the overloads for the narrowest type is
  650. # first.
  651. # Builtin types
  652. @overload
  653. def __new__(cls, dtype: type[bool], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[bool_]: ...
  654. @overload
  655. def __new__(cls, dtype: type[int], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[int_]: ...
  656. @overload
  657. def __new__(cls, dtype: None | type[float], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[float_]: ...
  658. @overload
  659. def __new__(cls, dtype: type[complex], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[complex_]: ...
  660. @overload
  661. def __new__(cls, dtype: type[builtins.str], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[str_]: ...
  662. @overload
  663. def __new__(cls, dtype: type[bytes], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[bytes_]: ...
  664. # `unsignedinteger` string-based representations and ctypes
  665. @overload
  666. def __new__(cls, dtype: _UInt8Codes | type[ct.c_uint8], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[uint8]: ...
  667. @overload
  668. def __new__(cls, dtype: _UInt16Codes | type[ct.c_uint16], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[uint16]: ...
  669. @overload
  670. def __new__(cls, dtype: _UInt32Codes | type[ct.c_uint32], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[uint32]: ...
  671. @overload
  672. def __new__(cls, dtype: _UInt64Codes | type[ct.c_uint64], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[uint64]: ...
  673. @overload
  674. def __new__(cls, dtype: _UByteCodes | type[ct.c_ubyte], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[ubyte]: ...
  675. @overload
  676. def __new__(cls, dtype: _UShortCodes | type[ct.c_ushort], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[ushort]: ...
  677. @overload
  678. def __new__(cls, dtype: _UIntCCodes | type[ct.c_uint], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[uintc]: ...
  679. # NOTE: We're assuming here that `uint_ptr_t == size_t`,
  680. # an assumption that does not hold in rare cases (same for `ssize_t`)
  681. @overload
  682. def __new__(cls, dtype: _UIntPCodes | type[ct.c_void_p] | type[ct.c_size_t], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[uintp]: ...
  683. @overload
  684. def __new__(cls, dtype: _UIntCodes | type[ct.c_ulong], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[uint]: ...
  685. @overload
  686. def __new__(cls, dtype: _ULongLongCodes | type[ct.c_ulonglong], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[ulonglong]: ...
  687. # `signedinteger` string-based representations and ctypes
  688. @overload
  689. def __new__(cls, dtype: _Int8Codes | type[ct.c_int8], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[int8]: ...
  690. @overload
  691. def __new__(cls, dtype: _Int16Codes | type[ct.c_int16], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[int16]: ...
  692. @overload
  693. def __new__(cls, dtype: _Int32Codes | type[ct.c_int32], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[int32]: ...
  694. @overload
  695. def __new__(cls, dtype: _Int64Codes | type[ct.c_int64], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[int64]: ...
  696. @overload
  697. def __new__(cls, dtype: _ByteCodes | type[ct.c_byte], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[byte]: ...
  698. @overload
  699. def __new__(cls, dtype: _ShortCodes | type[ct.c_short], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[short]: ...
  700. @overload
  701. def __new__(cls, dtype: _IntCCodes | type[ct.c_int], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[intc]: ...
  702. @overload
  703. def __new__(cls, dtype: _IntPCodes | type[ct.c_ssize_t], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[intp]: ...
  704. @overload
  705. def __new__(cls, dtype: _IntCodes | type[ct.c_long], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[int_]: ...
  706. @overload
  707. def __new__(cls, dtype: _LongLongCodes | type[ct.c_longlong], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[longlong]: ...
  708. # `floating` string-based representations and ctypes
  709. @overload
  710. def __new__(cls, dtype: _Float16Codes, align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[float16]: ...
  711. @overload
  712. def __new__(cls, dtype: _Float32Codes, align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[float32]: ...
  713. @overload
  714. def __new__(cls, dtype: _Float64Codes, align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[float64]: ...
  715. @overload
  716. def __new__(cls, dtype: _HalfCodes, align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[half]: ...
  717. @overload
  718. def __new__(cls, dtype: _SingleCodes | type[ct.c_float], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[single]: ...
  719. @overload
  720. def __new__(cls, dtype: _DoubleCodes | type[ct.c_double], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[double]: ...
  721. @overload
  722. def __new__(cls, dtype: _LongDoubleCodes | type[ct.c_longdouble], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[longdouble]: ...
  723. # `complexfloating` string-based representations
  724. @overload
  725. def __new__(cls, dtype: _Complex64Codes, align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[complex64]: ...
  726. @overload
  727. def __new__(cls, dtype: _Complex128Codes, align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[complex128]: ...
  728. @overload
  729. def __new__(cls, dtype: _CSingleCodes, align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[csingle]: ...
  730. @overload
  731. def __new__(cls, dtype: _CDoubleCodes, align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[cdouble]: ...
  732. @overload
  733. def __new__(cls, dtype: _CLongDoubleCodes, align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[clongdouble]: ...
  734. # Miscellaneous string-based representations and ctypes
  735. @overload
  736. def __new__(cls, dtype: _BoolCodes | type[ct.c_bool], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[bool_]: ...
  737. @overload
  738. def __new__(cls, dtype: _TD64Codes, align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[timedelta64]: ...
  739. @overload
  740. def __new__(cls, dtype: _DT64Codes, align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[datetime64]: ...
  741. @overload
  742. def __new__(cls, dtype: _StrCodes, align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[str_]: ...
  743. @overload
  744. def __new__(cls, dtype: _BytesCodes | type[ct.c_char], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[bytes_]: ...
  745. @overload
  746. def __new__(cls, dtype: _VoidCodes, align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[void]: ...
  747. @overload
  748. def __new__(cls, dtype: _ObjectCodes | type[ct.py_object[Any]], align: bool = ..., copy: bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[object_]: ...
  749. # dtype of a dtype is the same dtype
  750. @overload
  751. def __new__(
  752. cls,
  753. dtype: dtype[_DTypeScalar_co],
  754. align: bool = ...,
  755. copy: bool = ...,
  756. metadata: dict[builtins.str, Any] = ...,
  757. ) -> dtype[_DTypeScalar_co]: ...
  758. @overload
  759. def __new__(
  760. cls,
  761. dtype: _SupportsDType[dtype[_DTypeScalar_co]],
  762. align: bool = ...,
  763. copy: bool = ...,
  764. metadata: dict[builtins.str, Any] = ...,
  765. ) -> dtype[_DTypeScalar_co]: ...
  766. # Handle strings that can't be expressed as literals; i.e. s1, s2, ...
  767. @overload
  768. def __new__(
  769. cls,
  770. dtype: builtins.str,
  771. align: bool = ...,
  772. copy: bool = ...,
  773. metadata: dict[builtins.str, Any] = ...,
  774. ) -> dtype[Any]: ...
  775. # Catchall overload for void-likes
  776. @overload
  777. def __new__(
  778. cls,
  779. dtype: _VoidDTypeLike,
  780. align: bool = ...,
  781. copy: bool = ...,
  782. metadata: dict[builtins.str, Any] = ...,
  783. ) -> dtype[void]: ...
  784. # Catchall overload for object-likes
  785. @overload
  786. def __new__(
  787. cls,
  788. dtype: type[object],
  789. align: bool = ...,
  790. copy: bool = ...,
  791. metadata: dict[builtins.str, Any] = ...,
  792. ) -> dtype[object_]: ...
  793. if sys.version_info >= (3, 9):
  794. def __class_getitem__(self, item: Any) -> GenericAlias: ...
  795. @overload
  796. def __getitem__(self: dtype[void], key: list[builtins.str]) -> dtype[void]: ...
  797. @overload
  798. def __getitem__(self: dtype[void], key: builtins.str | SupportsIndex) -> dtype[Any]: ...
  799. # NOTE: In the future 1-based multiplications will also yield `flexible` dtypes
  800. @overload
  801. def __mul__(self: _DType, value: L[1]) -> _DType: ...
  802. @overload
  803. def __mul__(self: _FlexDType, value: SupportsIndex) -> _FlexDType: ...
  804. @overload
  805. def __mul__(self, value: SupportsIndex) -> dtype[void]: ...
  806. # NOTE: `__rmul__` seems to be broken when used in combination with
  807. # literals as of mypy 0.902. Set the return-type to `dtype[Any]` for
  808. # now for non-flexible dtypes.
  809. @overload
  810. def __rmul__(self: _FlexDType, value: SupportsIndex) -> _FlexDType: ...
  811. @overload
  812. def __rmul__(self, value: SupportsIndex) -> dtype[Any]: ...
  813. def __gt__(self, other: DTypeLike) -> bool: ...
  814. def __ge__(self, other: DTypeLike) -> bool: ...
  815. def __lt__(self, other: DTypeLike) -> bool: ...
  816. def __le__(self, other: DTypeLike) -> bool: ...
  817. # Explicitly defined `__eq__` and `__ne__` to get around mypy's
  818. # `strict_equality` option; even though their signatures are
  819. # identical to their `object`-based counterpart
  820. def __eq__(self, other: Any) -> bool: ...
  821. def __ne__(self, other: Any) -> bool: ...
  822. @property
  823. def alignment(self) -> int: ...
  824. @property
  825. def base(self) -> dtype[Any]: ...
  826. @property
  827. def byteorder(self) -> builtins.str: ...
  828. @property
  829. def char(self) -> builtins.str: ...
  830. @property
  831. def descr(self) -> list[tuple[builtins.str, builtins.str] | tuple[builtins.str, builtins.str, _Shape]]: ...
  832. @property
  833. def fields(
  834. self,
  835. ) -> None | MappingProxyType[builtins.str, tuple[dtype[Any], int] | tuple[dtype[Any], int, Any]]: ...
  836. @property
  837. def flags(self) -> int: ...
  838. @property
  839. def hasobject(self) -> bool: ...
  840. @property
  841. def isbuiltin(self) -> int: ...
  842. @property
  843. def isnative(self) -> bool: ...
  844. @property
  845. def isalignedstruct(self) -> bool: ...
  846. @property
  847. def itemsize(self) -> int: ...
  848. @property
  849. def kind(self) -> builtins.str: ...
  850. @property
  851. def metadata(self) -> None | MappingProxyType[builtins.str, Any]: ...
  852. @property
  853. def name(self) -> builtins.str: ...
  854. @property
  855. def num(self) -> int: ...
  856. @property
  857. def shape(self) -> _Shape: ...
  858. @property
  859. def ndim(self) -> int: ...
  860. @property
  861. def subdtype(self) -> None | tuple[dtype[Any], _Shape]: ...
  862. def newbyteorder(self: _DType, __new_order: _ByteOrder = ...) -> _DType: ...
  863. @property
  864. def str(self) -> builtins.str: ...
  865. @property
  866. def type(self) -> type[_DTypeScalar_co]: ...
  867. _ArrayLikeInt = Union[
  868. int,
  869. integer,
  870. Sequence[Union[int, integer]],
  871. Sequence[Sequence[Any]], # TODO: wait for support for recursive types
  872. ndarray
  873. ]
  874. _FlatIterSelf = TypeVar("_FlatIterSelf", bound=flatiter)
  875. @final
  876. class flatiter(Generic[_NdArraySubClass]):
  877. __hash__: ClassVar[None]
  878. @property
  879. def base(self) -> _NdArraySubClass: ...
  880. @property
  881. def coords(self) -> _Shape: ...
  882. @property
  883. def index(self) -> int: ...
  884. def copy(self) -> _NdArraySubClass: ...
  885. def __iter__(self: _FlatIterSelf) -> _FlatIterSelf: ...
  886. def __next__(self: flatiter[ndarray[Any, dtype[_ScalarType]]]) -> _ScalarType: ...
  887. def __len__(self) -> int: ...
  888. @overload
  889. def __getitem__(
  890. self: flatiter[ndarray[Any, dtype[_ScalarType]]],
  891. key: int | integer | tuple[int | integer],
  892. ) -> _ScalarType: ...
  893. @overload
  894. def __getitem__(
  895. self,
  896. key: _ArrayLikeInt | slice | ellipsis | tuple[_ArrayLikeInt | slice | ellipsis],
  897. ) -> _NdArraySubClass: ...
  898. # TODO: `__setitem__` operates via `unsafe` casting rules, and can
  899. # thus accept any type accepted by the relevant underlying `np.generic`
  900. # constructor.
  901. # This means that `value` must in reality be a supertype of `npt.ArrayLike`.
  902. def __setitem__(
  903. self,
  904. key: _ArrayLikeInt | slice | ellipsis | tuple[_ArrayLikeInt | slice | ellipsis],
  905. value: Any,
  906. ) -> None: ...
  907. @overload
  908. def __array__(self: flatiter[ndarray[Any, _DType]], dtype: None = ..., /) -> ndarray[Any, _DType]: ...
  909. @overload
  910. def __array__(self, dtype: _DType, /) -> ndarray[Any, _DType]: ...
  911. _OrderKACF = L[None, "K", "A", "C", "F"]
  912. _OrderACF = L[None, "A", "C", "F"]
  913. _OrderCF = L[None, "C", "F"]
  914. _ModeKind = L["raise", "wrap", "clip"]
  915. _PartitionKind = L["introselect"]
  916. _SortKind = L["quicksort", "mergesort", "heapsort", "stable"]
  917. _SortSide = L["left", "right"]
  918. _ArraySelf = TypeVar("_ArraySelf", bound=_ArrayOrScalarCommon)
  919. class _ArrayOrScalarCommon:
  920. @property
  921. def T(self: _ArraySelf) -> _ArraySelf: ...
  922. @property
  923. def data(self) -> memoryview: ...
  924. @property
  925. def flags(self) -> flagsobj: ...
  926. @property
  927. def itemsize(self) -> int: ...
  928. @property
  929. def nbytes(self) -> int: ...
  930. def __bool__(self) -> bool: ...
  931. def __bytes__(self) -> bytes: ...
  932. def __str__(self) -> str: ...
  933. def __repr__(self) -> str: ...
  934. def __copy__(self: _ArraySelf) -> _ArraySelf: ...
  935. def __deepcopy__(self: _ArraySelf, memo: None | dict[int, Any], /) -> _ArraySelf: ...
  936. # TODO: How to deal with the non-commutative nature of `==` and `!=`?
  937. # xref numpy/numpy#17368
  938. def __eq__(self, other: Any) -> Any: ...
  939. def __ne__(self, other: Any) -> Any: ...
  940. def copy(self: _ArraySelf, order: _OrderKACF = ...) -> _ArraySelf: ...
  941. def dump(self, file: str | bytes | os.PathLike[str] | os.PathLike[bytes] | _SupportsWrite[bytes]) -> None: ...
  942. def dumps(self) -> bytes: ...
  943. def tobytes(self, order: _OrderKACF = ...) -> bytes: ...
  944. # NOTE: `tostring()` is deprecated and therefore excluded
  945. # def tostring(self, order=...): ...
  946. def tofile(
  947. self,
  948. fid: str | bytes | os.PathLike[str] | os.PathLike[bytes] | _IOProtocol,
  949. sep: str = ...,
  950. format: str = ...,
  951. ) -> None: ...
  952. # generics and 0d arrays return builtin scalars
  953. def tolist(self) -> Any: ...
  954. @property
  955. def __array_interface__(self) -> dict[str, Any]: ...
  956. @property
  957. def __array_priority__(self) -> float: ...
  958. @property
  959. def __array_struct__(self) -> Any: ... # builtins.PyCapsule
  960. def __setstate__(self, state: tuple[
  961. SupportsIndex, # version
  962. _ShapeLike, # Shape
  963. _DType_co, # DType
  964. bool, # F-continuous
  965. bytes | list[Any], # Data
  966. ], /) -> None: ...
  967. # a `bool_` is returned when `keepdims=True` and `self` is a 0d array
  968. @overload
  969. def all(
  970. self,
  971. axis: None = ...,
  972. out: None = ...,
  973. keepdims: L[False] = ...,
  974. *,
  975. where: _ArrayLikeBool_co = ...,
  976. ) -> bool_: ...
  977. @overload
  978. def all(
  979. self,
  980. axis: None | _ShapeLike = ...,
  981. out: None = ...,
  982. keepdims: bool = ...,
  983. *,
  984. where: _ArrayLikeBool_co = ...,
  985. ) -> Any: ...
  986. @overload
  987. def all(
  988. self,
  989. axis: None | _ShapeLike = ...,
  990. out: _NdArraySubClass = ...,
  991. keepdims: bool = ...,
  992. *,
  993. where: _ArrayLikeBool_co = ...,
  994. ) -> _NdArraySubClass: ...
  995. @overload
  996. def any(
  997. self,
  998. axis: None = ...,
  999. out: None = ...,
  1000. keepdims: L[False] = ...,
  1001. *,
  1002. where: _ArrayLikeBool_co = ...,
  1003. ) -> bool_: ...
  1004. @overload
  1005. def any(
  1006. self,
  1007. axis: None | _ShapeLike = ...,
  1008. out: None = ...,
  1009. keepdims: bool = ...,
  1010. *,
  1011. where: _ArrayLikeBool_co = ...,
  1012. ) -> Any: ...
  1013. @overload
  1014. def any(
  1015. self,
  1016. axis: None | _ShapeLike = ...,
  1017. out: _NdArraySubClass = ...,
  1018. keepdims: bool = ...,
  1019. *,
  1020. where: _ArrayLikeBool_co = ...,
  1021. ) -> _NdArraySubClass: ...
  1022. @overload
  1023. def argmax(
  1024. self,
  1025. axis: None = ...,
  1026. out: None = ...,
  1027. *,
  1028. keepdims: L[False] = ...,
  1029. ) -> intp: ...
  1030. @overload
  1031. def argmax(
  1032. self,
  1033. axis: SupportsIndex = ...,
  1034. out: None = ...,
  1035. *,
  1036. keepdims: bool = ...,
  1037. ) -> Any: ...
  1038. @overload
  1039. def argmax(
  1040. self,
  1041. axis: None | SupportsIndex = ...,
  1042. out: _NdArraySubClass = ...,
  1043. *,
  1044. keepdims: bool = ...,
  1045. ) -> _NdArraySubClass: ...
  1046. @overload
  1047. def argmin(
  1048. self,
  1049. axis: None = ...,
  1050. out: None = ...,
  1051. *,
  1052. keepdims: L[False] = ...,
  1053. ) -> intp: ...
  1054. @overload
  1055. def argmin(
  1056. self,
  1057. axis: SupportsIndex = ...,
  1058. out: None = ...,
  1059. *,
  1060. keepdims: bool = ...,
  1061. ) -> Any: ...
  1062. @overload
  1063. def argmin(
  1064. self,
  1065. axis: None | SupportsIndex = ...,
  1066. out: _NdArraySubClass = ...,
  1067. *,
  1068. keepdims: bool = ...,
  1069. ) -> _NdArraySubClass: ...
  1070. def argsort(
  1071. self,
  1072. axis: None | SupportsIndex = ...,
  1073. kind: None | _SortKind = ...,
  1074. order: None | str | Sequence[str] = ...,
  1075. ) -> ndarray: ...
  1076. @overload
  1077. def choose(
  1078. self,
  1079. choices: ArrayLike,
  1080. out: None = ...,
  1081. mode: _ModeKind = ...,
  1082. ) -> ndarray: ...
  1083. @overload
  1084. def choose(
  1085. self,
  1086. choices: ArrayLike,
  1087. out: _NdArraySubClass = ...,
  1088. mode: _ModeKind = ...,
  1089. ) -> _NdArraySubClass: ...
  1090. @overload
  1091. def clip(
  1092. self,
  1093. min: ArrayLike = ...,
  1094. max: None | ArrayLike = ...,
  1095. out: None = ...,
  1096. **kwargs: Any,
  1097. ) -> ndarray: ...
  1098. @overload
  1099. def clip(
  1100. self,
  1101. min: None = ...,
  1102. max: ArrayLike = ...,
  1103. out: None = ...,
  1104. **kwargs: Any,
  1105. ) -> ndarray: ...
  1106. @overload
  1107. def clip(
  1108. self,
  1109. min: ArrayLike = ...,
  1110. max: None | ArrayLike = ...,
  1111. out: _NdArraySubClass = ...,
  1112. **kwargs: Any,
  1113. ) -> _NdArraySubClass: ...
  1114. @overload
  1115. def clip(
  1116. self,
  1117. min: None = ...,
  1118. max: ArrayLike = ...,
  1119. out: _NdArraySubClass = ...,
  1120. **kwargs: Any,
  1121. ) -> _NdArraySubClass: ...
  1122. @overload
  1123. def compress(
  1124. self,
  1125. a: ArrayLike,
  1126. axis: None | SupportsIndex = ...,
  1127. out: None = ...,
  1128. ) -> ndarray: ...
  1129. @overload
  1130. def compress(
  1131. self,
  1132. a: ArrayLike,
  1133. axis: None | SupportsIndex = ...,
  1134. out: _NdArraySubClass = ...,
  1135. ) -> _NdArraySubClass: ...
  1136. def conj(self: _ArraySelf) -> _ArraySelf: ...
  1137. def conjugate(self: _ArraySelf) -> _ArraySelf: ...
  1138. @overload
  1139. def cumprod(
  1140. self,
  1141. axis: None | SupportsIndex = ...,
  1142. dtype: DTypeLike = ...,
  1143. out: None = ...,
  1144. ) -> ndarray: ...
  1145. @overload
  1146. def cumprod(
  1147. self,
  1148. axis: None | SupportsIndex = ...,
  1149. dtype: DTypeLike = ...,
  1150. out: _NdArraySubClass = ...,
  1151. ) -> _NdArraySubClass: ...
  1152. @overload
  1153. def cumsum(
  1154. self,
  1155. axis: None | SupportsIndex = ...,
  1156. dtype: DTypeLike = ...,
  1157. out: None = ...,
  1158. ) -> ndarray: ...
  1159. @overload
  1160. def cumsum(
  1161. self,
  1162. axis: None | SupportsIndex = ...,
  1163. dtype: DTypeLike = ...,
  1164. out: _NdArraySubClass = ...,
  1165. ) -> _NdArraySubClass: ...
  1166. @overload
  1167. def max(
  1168. self,
  1169. axis: None | _ShapeLike = ...,
  1170. out: None = ...,
  1171. keepdims: bool = ...,
  1172. initial: _NumberLike_co = ...,
  1173. where: _ArrayLikeBool_co = ...,
  1174. ) -> Any: ...
  1175. @overload
  1176. def max(
  1177. self,
  1178. axis: None | _ShapeLike = ...,
  1179. out: _NdArraySubClass = ...,
  1180. keepdims: bool = ...,
  1181. initial: _NumberLike_co = ...,
  1182. where: _ArrayLikeBool_co = ...,
  1183. ) -> _NdArraySubClass: ...
  1184. @overload
  1185. def mean(
  1186. self,
  1187. axis: None | _ShapeLike = ...,
  1188. dtype: DTypeLike = ...,
  1189. out: None = ...,
  1190. keepdims: bool = ...,
  1191. *,
  1192. where: _ArrayLikeBool_co = ...,
  1193. ) -> Any: ...
  1194. @overload
  1195. def mean(
  1196. self,
  1197. axis: None | _ShapeLike = ...,
  1198. dtype: DTypeLike = ...,
  1199. out: _NdArraySubClass = ...,
  1200. keepdims: bool = ...,
  1201. *,
  1202. where: _ArrayLikeBool_co = ...,
  1203. ) -> _NdArraySubClass: ...
  1204. @overload
  1205. def min(
  1206. self,
  1207. axis: None | _ShapeLike = ...,
  1208. out: None = ...,
  1209. keepdims: bool = ...,
  1210. initial: _NumberLike_co = ...,
  1211. where: _ArrayLikeBool_co = ...,
  1212. ) -> Any: ...
  1213. @overload
  1214. def min(
  1215. self,
  1216. axis: None | _ShapeLike = ...,
  1217. out: _NdArraySubClass = ...,
  1218. keepdims: bool = ...,
  1219. initial: _NumberLike_co = ...,
  1220. where: _ArrayLikeBool_co = ...,
  1221. ) -> _NdArraySubClass: ...
  1222. def newbyteorder(
  1223. self: _ArraySelf,
  1224. __new_order: _ByteOrder = ...,
  1225. ) -> _ArraySelf: ...
  1226. @overload
  1227. def prod(
  1228. self,
  1229. axis: None | _ShapeLike = ...,
  1230. dtype: DTypeLike = ...,
  1231. out: None = ...,
  1232. keepdims: bool = ...,
  1233. initial: _NumberLike_co = ...,
  1234. where: _ArrayLikeBool_co = ...,
  1235. ) -> Any: ...
  1236. @overload
  1237. def prod(
  1238. self,
  1239. axis: None | _ShapeLike = ...,
  1240. dtype: DTypeLike = ...,
  1241. out: _NdArraySubClass = ...,
  1242. keepdims: bool = ...,
  1243. initial: _NumberLike_co = ...,
  1244. where: _ArrayLikeBool_co = ...,
  1245. ) -> _NdArraySubClass: ...
  1246. @overload
  1247. def ptp(
  1248. self,
  1249. axis: None | _ShapeLike = ...,
  1250. out: None = ...,
  1251. keepdims: bool = ...,
  1252. ) -> Any: ...
  1253. @overload
  1254. def ptp(
  1255. self,
  1256. axis: None | _ShapeLike = ...,
  1257. out: _NdArraySubClass = ...,
  1258. keepdims: bool = ...,
  1259. ) -> _NdArraySubClass: ...
  1260. @overload
  1261. def round(
  1262. self: _ArraySelf,
  1263. decimals: SupportsIndex = ...,
  1264. out: None = ...,
  1265. ) -> _ArraySelf: ...
  1266. @overload
  1267. def round(
  1268. self,
  1269. decimals: SupportsIndex = ...,
  1270. out: _NdArraySubClass = ...,
  1271. ) -> _NdArraySubClass: ...
  1272. @overload
  1273. def std(
  1274. self,
  1275. axis: None | _ShapeLike = ...,
  1276. dtype: DTypeLike = ...,
  1277. out: None = ...,
  1278. ddof: float = ...,
  1279. keepdims: bool = ...,
  1280. *,
  1281. where: _ArrayLikeBool_co = ...,
  1282. ) -> Any: ...
  1283. @overload
  1284. def std(
  1285. self,
  1286. axis: None | _ShapeLike = ...,
  1287. dtype: DTypeLike = ...,
  1288. out: _NdArraySubClass = ...,
  1289. ddof: float = ...,
  1290. keepdims: bool = ...,
  1291. *,
  1292. where: _ArrayLikeBool_co = ...,
  1293. ) -> _NdArraySubClass: ...
  1294. @overload
  1295. def sum(
  1296. self,
  1297. axis: None | _ShapeLike = ...,
  1298. dtype: DTypeLike = ...,
  1299. out: None = ...,
  1300. keepdims: bool = ...,
  1301. initial: _NumberLike_co = ...,
  1302. where: _ArrayLikeBool_co = ...,
  1303. ) -> Any: ...
  1304. @overload
  1305. def sum(
  1306. self,
  1307. axis: None | _ShapeLike = ...,
  1308. dtype: DTypeLike = ...,
  1309. out: _NdArraySubClass = ...,
  1310. keepdims: bool = ...,
  1311. initial: _NumberLike_co = ...,
  1312. where: _ArrayLikeBool_co = ...,
  1313. ) -> _NdArraySubClass: ...
  1314. @overload
  1315. def var(
  1316. self,
  1317. axis: None | _ShapeLike = ...,
  1318. dtype: DTypeLike = ...,
  1319. out: None = ...,
  1320. ddof: float = ...,
  1321. keepdims: bool = ...,
  1322. *,
  1323. where: _ArrayLikeBool_co = ...,
  1324. ) -> Any: ...
  1325. @overload
  1326. def var(
  1327. self,
  1328. axis: None | _ShapeLike = ...,
  1329. dtype: DTypeLike = ...,
  1330. out: _NdArraySubClass = ...,
  1331. ddof: float = ...,
  1332. keepdims: bool = ...,
  1333. *,
  1334. where: _ArrayLikeBool_co = ...,
  1335. ) -> _NdArraySubClass: ...
  1336. _DType = TypeVar("_DType", bound=dtype[Any])
  1337. _DType_co = TypeVar("_DType_co", covariant=True, bound=dtype[Any])
  1338. _FlexDType = TypeVar("_FlexDType", bound=dtype[flexible])
  1339. # TODO: Set the `bound` to something more suitable once we
  1340. # have proper shape support
  1341. _ShapeType = TypeVar("_ShapeType", bound=Any)
  1342. _ShapeType2 = TypeVar("_ShapeType2", bound=Any)
  1343. _NumberType = TypeVar("_NumberType", bound=number[Any])
  1344. # There is currently no exhaustive way to type the buffer protocol,
  1345. # as it is implemented exclusively in the C API (python/typing#593)
  1346. _SupportsBuffer = Union[
  1347. bytes,
  1348. bytearray,
  1349. memoryview,
  1350. _array.array[Any],
  1351. mmap.mmap,
  1352. NDArray[Any],
  1353. generic,
  1354. ]
  1355. _T = TypeVar("_T")
  1356. _T_co = TypeVar("_T_co", covariant=True)
  1357. _T_contra = TypeVar("_T_contra", contravariant=True)
  1358. _2Tuple = tuple[_T, _T]
  1359. _CastingKind = L["no", "equiv", "safe", "same_kind", "unsafe"]
  1360. _ArrayUInt_co = NDArray[Union[bool_, unsignedinteger[Any]]]
  1361. _ArrayInt_co = NDArray[Union[bool_, integer[Any]]]
  1362. _ArrayFloat_co = NDArray[Union[bool_, integer[Any], floating[Any]]]
  1363. _ArrayComplex_co = NDArray[Union[bool_, integer[Any], floating[Any], complexfloating[Any, Any]]]
  1364. _ArrayNumber_co = NDArray[Union[bool_, number[Any]]]
  1365. _ArrayTD64_co = NDArray[Union[bool_, integer[Any], timedelta64]]
  1366. # Introduce an alias for `dtype` to avoid naming conflicts.
  1367. _dtype = dtype
  1368. # `builtins.PyCapsule` unfortunately lacks annotations as of the moment;
  1369. # use `Any` as a stopgap measure
  1370. _PyCapsule = Any
  1371. class _SupportsItem(Protocol[_T_co]):
  1372. def item(self, args: Any, /) -> _T_co: ...
  1373. class _SupportsReal(Protocol[_T_co]):
  1374. @property
  1375. def real(self) -> _T_co: ...
  1376. class _SupportsImag(Protocol[_T_co]):
  1377. @property
  1378. def imag(self) -> _T_co: ...
  1379. class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
  1380. __hash__: ClassVar[None]
  1381. @property
  1382. def base(self) -> None | ndarray: ...
  1383. @property
  1384. def ndim(self) -> int: ...
  1385. @property
  1386. def size(self) -> int: ...
  1387. @property
  1388. def real(
  1389. self: ndarray[_ShapeType, dtype[_SupportsReal[_ScalarType]]], # type: ignore[type-var]
  1390. ) -> ndarray[_ShapeType, _dtype[_ScalarType]]: ...
  1391. @real.setter
  1392. def real(self, value: ArrayLike) -> None: ...
  1393. @property
  1394. def imag(
  1395. self: ndarray[_ShapeType, dtype[_SupportsImag[_ScalarType]]], # type: ignore[type-var]
  1396. ) -> ndarray[_ShapeType, _dtype[_ScalarType]]: ...
  1397. @imag.setter
  1398. def imag(self, value: ArrayLike) -> None: ...
  1399. def __new__(
  1400. cls: type[_ArraySelf],
  1401. shape: _ShapeLike,
  1402. dtype: DTypeLike = ...,
  1403. buffer: None | _SupportsBuffer = ...,
  1404. offset: SupportsIndex = ...,
  1405. strides: None | _ShapeLike = ...,
  1406. order: _OrderKACF = ...,
  1407. ) -> _ArraySelf: ...
  1408. if sys.version_info >= (3, 9):
  1409. def __class_getitem__(self, item: Any) -> GenericAlias: ...
  1410. @overload
  1411. def __array__(self, dtype: None = ..., /) -> ndarray[Any, _DType_co]: ...
  1412. @overload
  1413. def __array__(self, dtype: _DType, /) -> ndarray[Any, _DType]: ...
  1414. def __array_ufunc__(
  1415. self,
  1416. ufunc: ufunc,
  1417. method: L["__call__", "reduce", "reduceat", "accumulate", "outer", "inner"],
  1418. *inputs: Any,
  1419. **kwargs: Any,
  1420. ) -> Any: ...
  1421. def __array_function__(
  1422. self,
  1423. func: Callable[..., Any],
  1424. types: Iterable[type],
  1425. args: Iterable[Any],
  1426. kwargs: Mapping[str, Any],
  1427. ) -> Any: ...
  1428. # NOTE: In practice any object is accepted by `obj`, but as `__array_finalize__`
  1429. # is a pseudo-abstract method the type has been narrowed down in order to
  1430. # grant subclasses a bit more flexiblity
  1431. def __array_finalize__(self, obj: None | NDArray[Any], /) -> None: ...
  1432. def __array_wrap__(
  1433. self,
  1434. array: ndarray[_ShapeType2, _DType],
  1435. context: None | tuple[ufunc, tuple[Any, ...], int] = ...,
  1436. /,
  1437. ) -> ndarray[_ShapeType2, _DType]: ...
  1438. def __array_prepare__(
  1439. self,
  1440. array: ndarray[_ShapeType2, _DType],
  1441. context: None | tuple[ufunc, tuple[Any, ...], int] = ...,
  1442. /,
  1443. ) -> ndarray[_ShapeType2, _DType]: ...
  1444. @overload
  1445. def __getitem__(self, key: (
  1446. NDArray[integer[Any]]
  1447. | NDArray[bool_]
  1448. | tuple[NDArray[integer[Any]] | NDArray[bool_], ...]
  1449. )) -> ndarray[Any, _DType_co]: ...
  1450. @overload
  1451. def __getitem__(self, key: SupportsIndex | tuple[SupportsIndex, ...]) -> Any: ...
  1452. @overload
  1453. def __getitem__(self, key: (
  1454. None
  1455. | slice
  1456. | ellipsis
  1457. | SupportsIndex
  1458. | _ArrayLikeInt_co
  1459. | tuple[None | slice | ellipsis | _ArrayLikeInt_co | SupportsIndex, ...]
  1460. )) -> ndarray[Any, _DType_co]: ...
  1461. @overload
  1462. def __getitem__(self: NDArray[void], key: str) -> NDArray[Any]: ...
  1463. @overload
  1464. def __getitem__(self: NDArray[void], key: list[str]) -> ndarray[_ShapeType, _dtype[void]]: ...
  1465. @property
  1466. def ctypes(self) -> _ctypes[int]: ...
  1467. @property
  1468. def shape(self) -> _Shape: ...
  1469. @shape.setter
  1470. def shape(self, value: _ShapeLike) -> None: ...
  1471. @property
  1472. def strides(self) -> _Shape: ...
  1473. @strides.setter
  1474. def strides(self, value: _ShapeLike) -> None: ...
  1475. def byteswap(self: _ArraySelf, inplace: bool = ...) -> _ArraySelf: ...
  1476. def fill(self, value: Any) -> None: ...
  1477. @property
  1478. def flat(self: _NdArraySubClass) -> flatiter[_NdArraySubClass]: ...
  1479. # Use the same output type as that of the underlying `generic`
  1480. @overload
  1481. def item(
  1482. self: ndarray[Any, _dtype[_SupportsItem[_T]]], # type: ignore[type-var]
  1483. *args: SupportsIndex,
  1484. ) -> _T: ...
  1485. @overload
  1486. def item(
  1487. self: ndarray[Any, _dtype[_SupportsItem[_T]]], # type: ignore[type-var]
  1488. args: tuple[SupportsIndex, ...],
  1489. /,
  1490. ) -> _T: ...
  1491. @overload
  1492. def itemset(self, value: Any, /) -> None: ...
  1493. @overload
  1494. def itemset(self, item: _ShapeLike, value: Any, /) -> None: ...
  1495. @overload
  1496. def resize(self, new_shape: _ShapeLike, /, *, refcheck: bool = ...) -> None: ...
  1497. @overload
  1498. def resize(self, *new_shape: SupportsIndex, refcheck: bool = ...) -> None: ...
  1499. def setflags(
  1500. self, write: bool = ..., align: bool = ..., uic: bool = ...
  1501. ) -> None: ...
  1502. def squeeze(
  1503. self,
  1504. axis: None | SupportsIndex | tuple[SupportsIndex, ...] = ...,
  1505. ) -> ndarray[Any, _DType_co]: ...
  1506. def swapaxes(
  1507. self,
  1508. axis1: SupportsIndex,
  1509. axis2: SupportsIndex,
  1510. ) -> ndarray[Any, _DType_co]: ...
  1511. @overload
  1512. def transpose(self: _ArraySelf, axes: None | _ShapeLike, /) -> _ArraySelf: ...
  1513. @overload
  1514. def transpose(self: _ArraySelf, *axes: SupportsIndex) -> _ArraySelf: ...
  1515. def argpartition(
  1516. self,
  1517. kth: _ArrayLikeInt_co,
  1518. axis: None | SupportsIndex = ...,
  1519. kind: _PartitionKind = ...,
  1520. order: None | str | Sequence[str] = ...,
  1521. ) -> ndarray[Any, _dtype[intp]]: ...
  1522. def diagonal(
  1523. self,
  1524. offset: SupportsIndex = ...,
  1525. axis1: SupportsIndex = ...,
  1526. axis2: SupportsIndex = ...,
  1527. ) -> ndarray[Any, _DType_co]: ...
  1528. # 1D + 1D returns a scalar;
  1529. # all other with at least 1 non-0D array return an ndarray.
  1530. @overload
  1531. def dot(self, b: _ScalarLike_co, out: None = ...) -> ndarray: ...
  1532. @overload
  1533. def dot(self, b: ArrayLike, out: None = ...) -> Any: ... # type: ignore[misc]
  1534. @overload
  1535. def dot(self, b: ArrayLike, out: _NdArraySubClass) -> _NdArraySubClass: ...
  1536. # `nonzero()` is deprecated for 0d arrays/generics
  1537. def nonzero(self) -> tuple[ndarray[Any, _dtype[intp]], ...]: ...
  1538. def partition(
  1539. self,
  1540. kth: _ArrayLikeInt_co,
  1541. axis: SupportsIndex = ...,
  1542. kind: _PartitionKind = ...,
  1543. order: None | str | Sequence[str] = ...,
  1544. ) -> None: ...
  1545. # `put` is technically available to `generic`,
  1546. # but is pointless as `generic`s are immutable
  1547. def put(
  1548. self,
  1549. ind: _ArrayLikeInt_co,
  1550. v: ArrayLike,
  1551. mode: _ModeKind = ...,
  1552. ) -> None: ...
  1553. @overload
  1554. def searchsorted( # type: ignore[misc]
  1555. self, # >= 1D array
  1556. v: _ScalarLike_co, # 0D array-like
  1557. side: _SortSide = ...,
  1558. sorter: None | _ArrayLikeInt_co = ...,
  1559. ) -> intp: ...
  1560. @overload
  1561. def searchsorted(
  1562. self, # >= 1D array
  1563. v: ArrayLike,
  1564. side: _SortSide = ...,
  1565. sorter: None | _ArrayLikeInt_co = ...,
  1566. ) -> ndarray[Any, _dtype[intp]]: ...
  1567. def setfield(
  1568. self,
  1569. val: ArrayLike,
  1570. dtype: DTypeLike,
  1571. offset: SupportsIndex = ...,
  1572. ) -> None: ...
  1573. def sort(
  1574. self,
  1575. axis: SupportsIndex = ...,
  1576. kind: None | _SortKind = ...,
  1577. order: None | str | Sequence[str] = ...,
  1578. ) -> None: ...
  1579. @overload
  1580. def trace(
  1581. self, # >= 2D array
  1582. offset: SupportsIndex = ...,
  1583. axis1: SupportsIndex = ...,
  1584. axis2: SupportsIndex = ...,
  1585. dtype: DTypeLike = ...,
  1586. out: None = ...,
  1587. ) -> Any: ...
  1588. @overload
  1589. def trace(
  1590. self, # >= 2D array
  1591. offset: SupportsIndex = ...,
  1592. axis1: SupportsIndex = ...,
  1593. axis2: SupportsIndex = ...,
  1594. dtype: DTypeLike = ...,
  1595. out: _NdArraySubClass = ...,
  1596. ) -> _NdArraySubClass: ...
  1597. @overload
  1598. def take( # type: ignore[misc]
  1599. self: ndarray[Any, _dtype[_ScalarType]],
  1600. indices: _IntLike_co,
  1601. axis: None | SupportsIndex = ...,
  1602. out: None = ...,
  1603. mode: _ModeKind = ...,
  1604. ) -> _ScalarType: ...
  1605. @overload
  1606. def take( # type: ignore[misc]
  1607. self,
  1608. indices: _ArrayLikeInt_co,
  1609. axis: None | SupportsIndex = ...,
  1610. out: None = ...,
  1611. mode: _ModeKind = ...,
  1612. ) -> ndarray[Any, _DType_co]: ...
  1613. @overload
  1614. def take(
  1615. self,
  1616. indices: _ArrayLikeInt_co,
  1617. axis: None | SupportsIndex = ...,
  1618. out: _NdArraySubClass = ...,
  1619. mode: _ModeKind = ...,
  1620. ) -> _NdArraySubClass: ...
  1621. def repeat(
  1622. self,
  1623. repeats: _ArrayLikeInt_co,
  1624. axis: None | SupportsIndex = ...,
  1625. ) -> ndarray[Any, _DType_co]: ...
  1626. def flatten(
  1627. self,
  1628. order: _OrderKACF = ...,
  1629. ) -> ndarray[Any, _DType_co]: ...
  1630. def ravel(
  1631. self,
  1632. order: _OrderKACF = ...,
  1633. ) -> ndarray[Any, _DType_co]: ...
  1634. @overload
  1635. def reshape(
  1636. self, shape: _ShapeLike, /, *, order: _OrderACF = ...
  1637. ) -> ndarray[Any, _DType_co]: ...
  1638. @overload
  1639. def reshape(
  1640. self, *shape: SupportsIndex, order: _OrderACF = ...
  1641. ) -> ndarray[Any, _DType_co]: ...
  1642. @overload
  1643. def astype(
  1644. self,
  1645. dtype: _DTypeLike[_ScalarType],
  1646. order: _OrderKACF = ...,
  1647. casting: _CastingKind = ...,
  1648. subok: bool = ...,
  1649. copy: bool | _CopyMode = ...,
  1650. ) -> NDArray[_ScalarType]: ...
  1651. @overload
  1652. def astype(
  1653. self,
  1654. dtype: DTypeLike,
  1655. order: _OrderKACF = ...,
  1656. casting: _CastingKind = ...,
  1657. subok: bool = ...,
  1658. copy: bool | _CopyMode = ...,
  1659. ) -> NDArray[Any]: ...
  1660. @overload
  1661. def view(self: _ArraySelf) -> _ArraySelf: ...
  1662. @overload
  1663. def view(self, type: type[_NdArraySubClass]) -> _NdArraySubClass: ...
  1664. @overload
  1665. def view(self, dtype: _DTypeLike[_ScalarType]) -> NDArray[_ScalarType]: ...
  1666. @overload
  1667. def view(self, dtype: DTypeLike) -> NDArray[Any]: ...
  1668. @overload
  1669. def view(
  1670. self,
  1671. dtype: DTypeLike,
  1672. type: type[_NdArraySubClass],
  1673. ) -> _NdArraySubClass: ...
  1674. @overload
  1675. def getfield(
  1676. self,
  1677. dtype: _DTypeLike[_ScalarType],
  1678. offset: SupportsIndex = ...
  1679. ) -> NDArray[_ScalarType]: ...
  1680. @overload
  1681. def getfield(
  1682. self,
  1683. dtype: DTypeLike,
  1684. offset: SupportsIndex = ...
  1685. ) -> NDArray[Any]: ...
  1686. # Dispatch to the underlying `generic` via protocols
  1687. def __int__(
  1688. self: ndarray[Any, _dtype[SupportsInt]], # type: ignore[type-var]
  1689. ) -> int: ...
  1690. def __float__(
  1691. self: ndarray[Any, _dtype[SupportsFloat]], # type: ignore[type-var]
  1692. ) -> float: ...
  1693. def __complex__(
  1694. self: ndarray[Any, _dtype[SupportsComplex]], # type: ignore[type-var]
  1695. ) -> complex: ...
  1696. def __index__(
  1697. self: ndarray[Any, _dtype[SupportsIndex]], # type: ignore[type-var]
  1698. ) -> int: ...
  1699. def __len__(self) -> int: ...
  1700. def __setitem__(self, key, value): ...
  1701. def __iter__(self) -> Any: ...
  1702. def __contains__(self, key) -> bool: ...
  1703. # The last overload is for catching recursive objects whose
  1704. # nesting is too deep.
  1705. # The first overload is for catching `bytes` (as they are a subtype of
  1706. # `Sequence[int]`) and `str`. As `str` is a recursive sequence of
  1707. # strings, it will pass through the final overload otherwise
  1708. @overload
  1709. def __lt__(self: _ArrayNumber_co, other: _ArrayLikeNumber_co) -> NDArray[bool_]: ...
  1710. @overload
  1711. def __lt__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> NDArray[bool_]: ...
  1712. @overload
  1713. def __lt__(self: NDArray[datetime64], other: _ArrayLikeDT64_co) -> NDArray[bool_]: ...
  1714. @overload
  1715. def __lt__(self: NDArray[object_], other: Any) -> NDArray[bool_]: ...
  1716. @overload
  1717. def __lt__(self: NDArray[Any], other: _ArrayLikeObject_co) -> NDArray[bool_]: ...
  1718. @overload
  1719. def __le__(self: _ArrayNumber_co, other: _ArrayLikeNumber_co) -> NDArray[bool_]: ...
  1720. @overload
  1721. def __le__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> NDArray[bool_]: ...
  1722. @overload
  1723. def __le__(self: NDArray[datetime64], other: _ArrayLikeDT64_co) -> NDArray[bool_]: ...
  1724. @overload
  1725. def __le__(self: NDArray[object_], other: Any) -> NDArray[bool_]: ...
  1726. @overload
  1727. def __le__(self: NDArray[Any], other: _ArrayLikeObject_co) -> NDArray[bool_]: ...
  1728. @overload
  1729. def __gt__(self: _ArrayNumber_co, other: _ArrayLikeNumber_co) -> NDArray[bool_]: ...
  1730. @overload
  1731. def __gt__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> NDArray[bool_]: ...
  1732. @overload
  1733. def __gt__(self: NDArray[datetime64], other: _ArrayLikeDT64_co) -> NDArray[bool_]: ...
  1734. @overload
  1735. def __gt__(self: NDArray[object_], other: Any) -> NDArray[bool_]: ...
  1736. @overload
  1737. def __gt__(self: NDArray[Any], other: _ArrayLikeObject_co) -> NDArray[bool_]: ...
  1738. @overload
  1739. def __ge__(self: _ArrayNumber_co, other: _ArrayLikeNumber_co) -> NDArray[bool_]: ...
  1740. @overload
  1741. def __ge__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> NDArray[bool_]: ...
  1742. @overload
  1743. def __ge__(self: NDArray[datetime64], other: _ArrayLikeDT64_co) -> NDArray[bool_]: ...
  1744. @overload
  1745. def __ge__(self: NDArray[object_], other: Any) -> NDArray[bool_]: ...
  1746. @overload
  1747. def __ge__(self: NDArray[Any], other: _ArrayLikeObject_co) -> NDArray[bool_]: ...
  1748. # Unary ops
  1749. @overload
  1750. def __abs__(self: NDArray[bool_]) -> NDArray[bool_]: ...
  1751. @overload
  1752. def __abs__(self: NDArray[complexfloating[_NBit1, _NBit1]]) -> NDArray[floating[_NBit1]]: ...
  1753. @overload
  1754. def __abs__(self: NDArray[_NumberType]) -> NDArray[_NumberType]: ...
  1755. @overload
  1756. def __abs__(self: NDArray[timedelta64]) -> NDArray[timedelta64]: ...
  1757. @overload
  1758. def __abs__(self: NDArray[object_]) -> Any: ...
  1759. @overload
  1760. def __invert__(self: NDArray[bool_]) -> NDArray[bool_]: ...
  1761. @overload
  1762. def __invert__(self: NDArray[_IntType]) -> NDArray[_IntType]: ...
  1763. @overload
  1764. def __invert__(self: NDArray[object_]) -> Any: ...
  1765. @overload
  1766. def __pos__(self: NDArray[_NumberType]) -> NDArray[_NumberType]: ...
  1767. @overload
  1768. def __pos__(self: NDArray[timedelta64]) -> NDArray[timedelta64]: ...
  1769. @overload
  1770. def __pos__(self: NDArray[object_]) -> Any: ...
  1771. @overload
  1772. def __neg__(self: NDArray[_NumberType]) -> NDArray[_NumberType]: ...
  1773. @overload
  1774. def __neg__(self: NDArray[timedelta64]) -> NDArray[timedelta64]: ...
  1775. @overload
  1776. def __neg__(self: NDArray[object_]) -> Any: ...
  1777. # Binary ops
  1778. # NOTE: `ndarray` does not implement `__imatmul__`
  1779. @overload
  1780. def __matmul__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
  1781. @overload
  1782. def __matmul__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  1783. @overload
  1784. def __matmul__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
  1785. @overload
  1786. def __matmul__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
  1787. @overload
  1788. def __matmul__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ...
  1789. @overload
  1790. def __matmul__(self: NDArray[number[Any]], other: _ArrayLikeNumber_co) -> NDArray[number[Any]]: ...
  1791. @overload
  1792. def __matmul__(self: NDArray[object_], other: Any) -> Any: ...
  1793. @overload
  1794. def __matmul__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  1795. @overload
  1796. def __rmatmul__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
  1797. @overload
  1798. def __rmatmul__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  1799. @overload
  1800. def __rmatmul__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
  1801. @overload
  1802. def __rmatmul__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
  1803. @overload
  1804. def __rmatmul__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ...
  1805. @overload
  1806. def __rmatmul__(self: NDArray[number[Any]], other: _ArrayLikeNumber_co) -> NDArray[number[Any]]: ...
  1807. @overload
  1808. def __rmatmul__(self: NDArray[object_], other: Any) -> Any: ...
  1809. @overload
  1810. def __rmatmul__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  1811. @overload
  1812. def __mod__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
  1813. @overload
  1814. def __mod__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  1815. @overload
  1816. def __mod__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
  1817. @overload
  1818. def __mod__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
  1819. @overload
  1820. def __mod__(self: _ArrayTD64_co, other: _SupportsArray[_dtype[timedelta64]] | _NestedSequence[_SupportsArray[_dtype[timedelta64]]]) -> NDArray[timedelta64]: ...
  1821. @overload
  1822. def __mod__(self: NDArray[object_], other: Any) -> Any: ...
  1823. @overload
  1824. def __mod__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  1825. @overload
  1826. def __rmod__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
  1827. @overload
  1828. def __rmod__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  1829. @overload
  1830. def __rmod__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
  1831. @overload
  1832. def __rmod__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
  1833. @overload
  1834. def __rmod__(self: _ArrayTD64_co, other: _SupportsArray[_dtype[timedelta64]] | _NestedSequence[_SupportsArray[_dtype[timedelta64]]]) -> NDArray[timedelta64]: ...
  1835. @overload
  1836. def __rmod__(self: NDArray[object_], other: Any) -> Any: ...
  1837. @overload
  1838. def __rmod__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  1839. @overload
  1840. def __divmod__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> _2Tuple[NDArray[int8]]: ... # type: ignore[misc]
  1841. @overload
  1842. def __divmod__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _2Tuple[NDArray[unsignedinteger[Any]]]: ... # type: ignore[misc]
  1843. @overload
  1844. def __divmod__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _2Tuple[NDArray[signedinteger[Any]]]: ... # type: ignore[misc]
  1845. @overload
  1846. def __divmod__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _2Tuple[NDArray[floating[Any]]]: ... # type: ignore[misc]
  1847. @overload
  1848. def __divmod__(self: _ArrayTD64_co, other: _SupportsArray[_dtype[timedelta64]] | _NestedSequence[_SupportsArray[_dtype[timedelta64]]]) -> tuple[NDArray[int64], NDArray[timedelta64]]: ...
  1849. @overload
  1850. def __rdivmod__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> _2Tuple[NDArray[int8]]: ... # type: ignore[misc]
  1851. @overload
  1852. def __rdivmod__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> _2Tuple[NDArray[unsignedinteger[Any]]]: ... # type: ignore[misc]
  1853. @overload
  1854. def __rdivmod__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> _2Tuple[NDArray[signedinteger[Any]]]: ... # type: ignore[misc]
  1855. @overload
  1856. def __rdivmod__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> _2Tuple[NDArray[floating[Any]]]: ... # type: ignore[misc]
  1857. @overload
  1858. def __rdivmod__(self: _ArrayTD64_co, other: _SupportsArray[_dtype[timedelta64]] | _NestedSequence[_SupportsArray[_dtype[timedelta64]]]) -> tuple[NDArray[int64], NDArray[timedelta64]]: ...
  1859. @overload
  1860. def __add__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
  1861. @overload
  1862. def __add__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  1863. @overload
  1864. def __add__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
  1865. @overload
  1866. def __add__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
  1867. @overload
  1868. def __add__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
  1869. @overload
  1870. def __add__(self: NDArray[number[Any]], other: _ArrayLikeNumber_co) -> NDArray[number[Any]]: ...
  1871. @overload
  1872. def __add__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ... # type: ignore[misc]
  1873. @overload
  1874. def __add__(self: _ArrayTD64_co, other: _ArrayLikeDT64_co) -> NDArray[datetime64]: ...
  1875. @overload
  1876. def __add__(self: NDArray[datetime64], other: _ArrayLikeTD64_co) -> NDArray[datetime64]: ...
  1877. @overload
  1878. def __add__(self: NDArray[object_], other: Any) -> Any: ...
  1879. @overload
  1880. def __add__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  1881. @overload
  1882. def __radd__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
  1883. @overload
  1884. def __radd__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  1885. @overload
  1886. def __radd__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
  1887. @overload
  1888. def __radd__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
  1889. @overload
  1890. def __radd__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
  1891. @overload
  1892. def __radd__(self: NDArray[number[Any]], other: _ArrayLikeNumber_co) -> NDArray[number[Any]]: ...
  1893. @overload
  1894. def __radd__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ... # type: ignore[misc]
  1895. @overload
  1896. def __radd__(self: _ArrayTD64_co, other: _ArrayLikeDT64_co) -> NDArray[datetime64]: ...
  1897. @overload
  1898. def __radd__(self: NDArray[datetime64], other: _ArrayLikeTD64_co) -> NDArray[datetime64]: ...
  1899. @overload
  1900. def __radd__(self: NDArray[object_], other: Any) -> Any: ...
  1901. @overload
  1902. def __radd__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  1903. @overload
  1904. def __sub__(self: NDArray[_UnknownType], other: _ArrayLikeUnknown) -> NDArray[Any]: ...
  1905. @overload
  1906. def __sub__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NoReturn: ...
  1907. @overload
  1908. def __sub__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  1909. @overload
  1910. def __sub__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
  1911. @overload
  1912. def __sub__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
  1913. @overload
  1914. def __sub__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
  1915. @overload
  1916. def __sub__(self: NDArray[number[Any]], other: _ArrayLikeNumber_co) -> NDArray[number[Any]]: ...
  1917. @overload
  1918. def __sub__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ... # type: ignore[misc]
  1919. @overload
  1920. def __sub__(self: NDArray[datetime64], other: _ArrayLikeTD64_co) -> NDArray[datetime64]: ...
  1921. @overload
  1922. def __sub__(self: NDArray[datetime64], other: _ArrayLikeDT64_co) -> NDArray[timedelta64]: ...
  1923. @overload
  1924. def __sub__(self: NDArray[object_], other: Any) -> Any: ...
  1925. @overload
  1926. def __sub__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  1927. @overload
  1928. def __rsub__(self: NDArray[_UnknownType], other: _ArrayLikeUnknown) -> NDArray[Any]: ...
  1929. @overload
  1930. def __rsub__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NoReturn: ...
  1931. @overload
  1932. def __rsub__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  1933. @overload
  1934. def __rsub__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
  1935. @overload
  1936. def __rsub__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
  1937. @overload
  1938. def __rsub__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
  1939. @overload
  1940. def __rsub__(self: NDArray[number[Any]], other: _ArrayLikeNumber_co) -> NDArray[number[Any]]: ...
  1941. @overload
  1942. def __rsub__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ... # type: ignore[misc]
  1943. @overload
  1944. def __rsub__(self: _ArrayTD64_co, other: _ArrayLikeDT64_co) -> NDArray[datetime64]: ... # type: ignore[misc]
  1945. @overload
  1946. def __rsub__(self: NDArray[datetime64], other: _ArrayLikeDT64_co) -> NDArray[timedelta64]: ...
  1947. @overload
  1948. def __rsub__(self: NDArray[object_], other: Any) -> Any: ...
  1949. @overload
  1950. def __rsub__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  1951. @overload
  1952. def __mul__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
  1953. @overload
  1954. def __mul__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  1955. @overload
  1956. def __mul__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
  1957. @overload
  1958. def __mul__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
  1959. @overload
  1960. def __mul__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
  1961. @overload
  1962. def __mul__(self: NDArray[number[Any]], other: _ArrayLikeNumber_co) -> NDArray[number[Any]]: ...
  1963. @overload
  1964. def __mul__(self: _ArrayTD64_co, other: _ArrayLikeFloat_co) -> NDArray[timedelta64]: ...
  1965. @overload
  1966. def __mul__(self: _ArrayFloat_co, other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ...
  1967. @overload
  1968. def __mul__(self: NDArray[object_], other: Any) -> Any: ...
  1969. @overload
  1970. def __mul__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  1971. @overload
  1972. def __rmul__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
  1973. @overload
  1974. def __rmul__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  1975. @overload
  1976. def __rmul__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
  1977. @overload
  1978. def __rmul__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
  1979. @overload
  1980. def __rmul__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
  1981. @overload
  1982. def __rmul__(self: NDArray[number[Any]], other: _ArrayLikeNumber_co) -> NDArray[number[Any]]: ...
  1983. @overload
  1984. def __rmul__(self: _ArrayTD64_co, other: _ArrayLikeFloat_co) -> NDArray[timedelta64]: ...
  1985. @overload
  1986. def __rmul__(self: _ArrayFloat_co, other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ...
  1987. @overload
  1988. def __rmul__(self: NDArray[object_], other: Any) -> Any: ...
  1989. @overload
  1990. def __rmul__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  1991. @overload
  1992. def __floordiv__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
  1993. @overload
  1994. def __floordiv__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  1995. @overload
  1996. def __floordiv__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
  1997. @overload
  1998. def __floordiv__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
  1999. @overload
  2000. def __floordiv__(self: NDArray[timedelta64], other: _SupportsArray[_dtype[timedelta64]] | _NestedSequence[_SupportsArray[_dtype[timedelta64]]]) -> NDArray[int64]: ...
  2001. @overload
  2002. def __floordiv__(self: NDArray[timedelta64], other: _ArrayLikeBool_co) -> NoReturn: ...
  2003. @overload
  2004. def __floordiv__(self: NDArray[timedelta64], other: _ArrayLikeFloat_co) -> NDArray[timedelta64]: ...
  2005. @overload
  2006. def __floordiv__(self: NDArray[object_], other: Any) -> Any: ...
  2007. @overload
  2008. def __floordiv__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  2009. @overload
  2010. def __rfloordiv__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
  2011. @overload
  2012. def __rfloordiv__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  2013. @overload
  2014. def __rfloordiv__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
  2015. @overload
  2016. def __rfloordiv__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
  2017. @overload
  2018. def __rfloordiv__(self: NDArray[timedelta64], other: _SupportsArray[_dtype[timedelta64]] | _NestedSequence[_SupportsArray[_dtype[timedelta64]]]) -> NDArray[int64]: ...
  2019. @overload
  2020. def __rfloordiv__(self: NDArray[bool_], other: _ArrayLikeTD64_co) -> NoReturn: ...
  2021. @overload
  2022. def __rfloordiv__(self: _ArrayFloat_co, other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ...
  2023. @overload
  2024. def __rfloordiv__(self: NDArray[object_], other: Any) -> Any: ...
  2025. @overload
  2026. def __rfloordiv__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  2027. @overload
  2028. def __pow__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
  2029. @overload
  2030. def __pow__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  2031. @overload
  2032. def __pow__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
  2033. @overload
  2034. def __pow__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
  2035. @overload
  2036. def __pow__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ...
  2037. @overload
  2038. def __pow__(self: NDArray[number[Any]], other: _ArrayLikeNumber_co) -> NDArray[number[Any]]: ...
  2039. @overload
  2040. def __pow__(self: NDArray[object_], other: Any) -> Any: ...
  2041. @overload
  2042. def __pow__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  2043. @overload
  2044. def __rpow__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
  2045. @overload
  2046. def __rpow__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  2047. @overload
  2048. def __rpow__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ... # type: ignore[misc]
  2049. @overload
  2050. def __rpow__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
  2051. @overload
  2052. def __rpow__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ...
  2053. @overload
  2054. def __rpow__(self: NDArray[number[Any]], other: _ArrayLikeNumber_co) -> NDArray[number[Any]]: ...
  2055. @overload
  2056. def __rpow__(self: NDArray[object_], other: Any) -> Any: ...
  2057. @overload
  2058. def __rpow__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  2059. @overload
  2060. def __truediv__(self: _ArrayInt_co, other: _ArrayInt_co) -> NDArray[float64]: ... # type: ignore[misc]
  2061. @overload
  2062. def __truediv__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
  2063. @overload
  2064. def __truediv__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
  2065. @overload
  2066. def __truediv__(self: NDArray[number[Any]], other: _ArrayLikeNumber_co) -> NDArray[number[Any]]: ...
  2067. @overload
  2068. def __truediv__(self: NDArray[timedelta64], other: _SupportsArray[_dtype[timedelta64]] | _NestedSequence[_SupportsArray[_dtype[timedelta64]]]) -> NDArray[float64]: ...
  2069. @overload
  2070. def __truediv__(self: NDArray[timedelta64], other: _ArrayLikeBool_co) -> NoReturn: ...
  2071. @overload
  2072. def __truediv__(self: NDArray[timedelta64], other: _ArrayLikeFloat_co) -> NDArray[timedelta64]: ...
  2073. @overload
  2074. def __truediv__(self: NDArray[object_], other: Any) -> Any: ...
  2075. @overload
  2076. def __truediv__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  2077. @overload
  2078. def __rtruediv__(self: _ArrayInt_co, other: _ArrayInt_co) -> NDArray[float64]: ... # type: ignore[misc]
  2079. @overload
  2080. def __rtruediv__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co) -> NDArray[floating[Any]]: ... # type: ignore[misc]
  2081. @overload
  2082. def __rtruediv__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co) -> NDArray[complexfloating[Any, Any]]: ... # type: ignore[misc]
  2083. @overload
  2084. def __rtruediv__(self: NDArray[number[Any]], other: _ArrayLikeNumber_co) -> NDArray[number[Any]]: ...
  2085. @overload
  2086. def __rtruediv__(self: NDArray[timedelta64], other: _SupportsArray[_dtype[timedelta64]] | _NestedSequence[_SupportsArray[_dtype[timedelta64]]]) -> NDArray[float64]: ...
  2087. @overload
  2088. def __rtruediv__(self: NDArray[bool_], other: _ArrayLikeTD64_co) -> NoReturn: ...
  2089. @overload
  2090. def __rtruediv__(self: _ArrayFloat_co, other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ...
  2091. @overload
  2092. def __rtruediv__(self: NDArray[object_], other: Any) -> Any: ...
  2093. @overload
  2094. def __rtruediv__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  2095. @overload
  2096. def __lshift__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
  2097. @overload
  2098. def __lshift__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  2099. @overload
  2100. def __lshift__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
  2101. @overload
  2102. def __lshift__(self: NDArray[object_], other: Any) -> Any: ...
  2103. @overload
  2104. def __lshift__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  2105. @overload
  2106. def __rlshift__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
  2107. @overload
  2108. def __rlshift__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  2109. @overload
  2110. def __rlshift__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
  2111. @overload
  2112. def __rlshift__(self: NDArray[object_], other: Any) -> Any: ...
  2113. @overload
  2114. def __rlshift__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  2115. @overload
  2116. def __rshift__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
  2117. @overload
  2118. def __rshift__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  2119. @overload
  2120. def __rshift__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
  2121. @overload
  2122. def __rshift__(self: NDArray[object_], other: Any) -> Any: ...
  2123. @overload
  2124. def __rshift__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  2125. @overload
  2126. def __rrshift__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[int8]: ... # type: ignore[misc]
  2127. @overload
  2128. def __rrshift__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  2129. @overload
  2130. def __rrshift__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
  2131. @overload
  2132. def __rrshift__(self: NDArray[object_], other: Any) -> Any: ...
  2133. @overload
  2134. def __rrshift__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  2135. @overload
  2136. def __and__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
  2137. @overload
  2138. def __and__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  2139. @overload
  2140. def __and__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
  2141. @overload
  2142. def __and__(self: NDArray[object_], other: Any) -> Any: ...
  2143. @overload
  2144. def __and__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  2145. @overload
  2146. def __rand__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
  2147. @overload
  2148. def __rand__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  2149. @overload
  2150. def __rand__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
  2151. @overload
  2152. def __rand__(self: NDArray[object_], other: Any) -> Any: ...
  2153. @overload
  2154. def __rand__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  2155. @overload
  2156. def __xor__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
  2157. @overload
  2158. def __xor__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  2159. @overload
  2160. def __xor__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
  2161. @overload
  2162. def __xor__(self: NDArray[object_], other: Any) -> Any: ...
  2163. @overload
  2164. def __xor__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  2165. @overload
  2166. def __rxor__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
  2167. @overload
  2168. def __rxor__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  2169. @overload
  2170. def __rxor__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
  2171. @overload
  2172. def __rxor__(self: NDArray[object_], other: Any) -> Any: ...
  2173. @overload
  2174. def __rxor__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  2175. @overload
  2176. def __or__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
  2177. @overload
  2178. def __or__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  2179. @overload
  2180. def __or__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
  2181. @overload
  2182. def __or__(self: NDArray[object_], other: Any) -> Any: ...
  2183. @overload
  2184. def __or__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  2185. @overload
  2186. def __ror__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ... # type: ignore[misc]
  2187. @overload
  2188. def __ror__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co) -> NDArray[unsignedinteger[Any]]: ... # type: ignore[misc]
  2189. @overload
  2190. def __ror__(self: _ArrayInt_co, other: _ArrayLikeInt_co) -> NDArray[signedinteger[Any]]: ...
  2191. @overload
  2192. def __ror__(self: NDArray[object_], other: Any) -> Any: ...
  2193. @overload
  2194. def __ror__(self: NDArray[Any], other: _ArrayLikeObject_co) -> Any: ...
  2195. # `np.generic` does not support inplace operations
  2196. # NOTE: Inplace ops generally use "same_kind" casting w.r.t. to the left
  2197. # operand. An exception to this rule are unsigned integers though, which
  2198. # also accepts a signed integer for the right operand as long it is a 0D
  2199. # object and its value is >= 0
  2200. @overload
  2201. def __iadd__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ...
  2202. @overload
  2203. def __iadd__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co | _IntLike_co) -> NDArray[unsignedinteger[_NBit1]]: ...
  2204. @overload
  2205. def __iadd__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
  2206. @overload
  2207. def __iadd__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co) -> NDArray[floating[_NBit1]]: ...
  2208. @overload
  2209. def __iadd__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
  2210. @overload
  2211. def __iadd__(self: NDArray[timedelta64], other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ...
  2212. @overload
  2213. def __iadd__(self: NDArray[datetime64], other: _ArrayLikeTD64_co) -> NDArray[datetime64]: ...
  2214. @overload
  2215. def __iadd__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
  2216. @overload
  2217. def __isub__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co | _IntLike_co) -> NDArray[unsignedinteger[_NBit1]]: ...
  2218. @overload
  2219. def __isub__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
  2220. @overload
  2221. def __isub__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co) -> NDArray[floating[_NBit1]]: ...
  2222. @overload
  2223. def __isub__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
  2224. @overload
  2225. def __isub__(self: NDArray[timedelta64], other: _ArrayLikeTD64_co) -> NDArray[timedelta64]: ...
  2226. @overload
  2227. def __isub__(self: NDArray[datetime64], other: _ArrayLikeTD64_co) -> NDArray[datetime64]: ...
  2228. @overload
  2229. def __isub__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
  2230. @overload
  2231. def __imul__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ...
  2232. @overload
  2233. def __imul__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co | _IntLike_co) -> NDArray[unsignedinteger[_NBit1]]: ...
  2234. @overload
  2235. def __imul__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
  2236. @overload
  2237. def __imul__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co) -> NDArray[floating[_NBit1]]: ...
  2238. @overload
  2239. def __imul__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
  2240. @overload
  2241. def __imul__(self: NDArray[timedelta64], other: _ArrayLikeFloat_co) -> NDArray[timedelta64]: ...
  2242. @overload
  2243. def __imul__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
  2244. @overload
  2245. def __itruediv__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co) -> NDArray[floating[_NBit1]]: ...
  2246. @overload
  2247. def __itruediv__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
  2248. @overload
  2249. def __itruediv__(self: NDArray[timedelta64], other: _ArrayLikeBool_co) -> NoReturn: ...
  2250. @overload
  2251. def __itruediv__(self: NDArray[timedelta64], other: _ArrayLikeInt_co) -> NDArray[timedelta64]: ...
  2252. @overload
  2253. def __itruediv__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
  2254. @overload
  2255. def __ifloordiv__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co | _IntLike_co) -> NDArray[unsignedinteger[_NBit1]]: ...
  2256. @overload
  2257. def __ifloordiv__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
  2258. @overload
  2259. def __ifloordiv__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co) -> NDArray[floating[_NBit1]]: ...
  2260. @overload
  2261. def __ifloordiv__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
  2262. @overload
  2263. def __ifloordiv__(self: NDArray[timedelta64], other: _ArrayLikeBool_co) -> NoReturn: ...
  2264. @overload
  2265. def __ifloordiv__(self: NDArray[timedelta64], other: _ArrayLikeInt_co) -> NDArray[timedelta64]: ...
  2266. @overload
  2267. def __ifloordiv__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
  2268. @overload
  2269. def __ipow__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co | _IntLike_co) -> NDArray[unsignedinteger[_NBit1]]: ...
  2270. @overload
  2271. def __ipow__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
  2272. @overload
  2273. def __ipow__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co) -> NDArray[floating[_NBit1]]: ...
  2274. @overload
  2275. def __ipow__(self: NDArray[complexfloating[_NBit1, _NBit1]], other: _ArrayLikeComplex_co) -> NDArray[complexfloating[_NBit1, _NBit1]]: ...
  2276. @overload
  2277. def __ipow__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
  2278. @overload
  2279. def __imod__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co | _IntLike_co) -> NDArray[unsignedinteger[_NBit1]]: ...
  2280. @overload
  2281. def __imod__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
  2282. @overload
  2283. def __imod__(self: NDArray[floating[_NBit1]], other: _ArrayLikeFloat_co) -> NDArray[floating[_NBit1]]: ...
  2284. @overload
  2285. def __imod__(self: NDArray[timedelta64], other: _SupportsArray[_dtype[timedelta64]] | _NestedSequence[_SupportsArray[_dtype[timedelta64]]]) -> NDArray[timedelta64]: ...
  2286. @overload
  2287. def __imod__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
  2288. @overload
  2289. def __ilshift__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co | _IntLike_co) -> NDArray[unsignedinteger[_NBit1]]: ...
  2290. @overload
  2291. def __ilshift__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
  2292. @overload
  2293. def __ilshift__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
  2294. @overload
  2295. def __irshift__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co | _IntLike_co) -> NDArray[unsignedinteger[_NBit1]]: ...
  2296. @overload
  2297. def __irshift__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
  2298. @overload
  2299. def __irshift__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
  2300. @overload
  2301. def __iand__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ...
  2302. @overload
  2303. def __iand__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co | _IntLike_co) -> NDArray[unsignedinteger[_NBit1]]: ...
  2304. @overload
  2305. def __iand__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
  2306. @overload
  2307. def __iand__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
  2308. @overload
  2309. def __ixor__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ...
  2310. @overload
  2311. def __ixor__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co | _IntLike_co) -> NDArray[unsignedinteger[_NBit1]]: ...
  2312. @overload
  2313. def __ixor__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
  2314. @overload
  2315. def __ixor__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
  2316. @overload
  2317. def __ior__(self: NDArray[bool_], other: _ArrayLikeBool_co) -> NDArray[bool_]: ...
  2318. @overload
  2319. def __ior__(self: NDArray[unsignedinteger[_NBit1]], other: _ArrayLikeUInt_co | _IntLike_co) -> NDArray[unsignedinteger[_NBit1]]: ...
  2320. @overload
  2321. def __ior__(self: NDArray[signedinteger[_NBit1]], other: _ArrayLikeInt_co) -> NDArray[signedinteger[_NBit1]]: ...
  2322. @overload
  2323. def __ior__(self: NDArray[object_], other: Any) -> NDArray[object_]: ...
  2324. def __dlpack__(self: NDArray[number[Any]], *, stream: None = ...) -> _PyCapsule: ...
  2325. def __dlpack_device__(self) -> tuple[int, L[0]]: ...
  2326. # Keep `dtype` at the bottom to avoid name conflicts with `np.dtype`
  2327. @property
  2328. def dtype(self) -> _DType_co: ...
  2329. # NOTE: while `np.generic` is not technically an instance of `ABCMeta`,
  2330. # the `@abstractmethod` decorator is herein used to (forcefully) deny
  2331. # the creation of `np.generic` instances.
  2332. # The `# type: ignore` comments are necessary to silence mypy errors regarding
  2333. # the missing `ABCMeta` metaclass.
  2334. # See https://github.com/numpy/numpy-stubs/pull/80 for more details.
  2335. _ScalarType = TypeVar("_ScalarType", bound=generic)
  2336. _NBit1 = TypeVar("_NBit1", bound=NBitBase)
  2337. _NBit2 = TypeVar("_NBit2", bound=NBitBase)
  2338. class generic(_ArrayOrScalarCommon):
  2339. @abstractmethod
  2340. def __init__(self, *args: Any, **kwargs: Any) -> None: ...
  2341. @overload
  2342. def __array__(self: _ScalarType, dtype: None = ..., /) -> ndarray[Any, _dtype[_ScalarType]]: ...
  2343. @overload
  2344. def __array__(self, dtype: _DType, /) -> ndarray[Any, _DType]: ...
  2345. @property
  2346. def base(self) -> None: ...
  2347. @property
  2348. def ndim(self) -> L[0]: ...
  2349. @property
  2350. def size(self) -> L[1]: ...
  2351. @property
  2352. def shape(self) -> tuple[()]: ...
  2353. @property
  2354. def strides(self) -> tuple[()]: ...
  2355. def byteswap(self: _ScalarType, inplace: L[False] = ...) -> _ScalarType: ...
  2356. @property
  2357. def flat(self: _ScalarType) -> flatiter[ndarray[Any, _dtype[_ScalarType]]]: ...
  2358. @overload
  2359. def astype(
  2360. self,
  2361. dtype: _DTypeLike[_ScalarType],
  2362. order: _OrderKACF = ...,
  2363. casting: _CastingKind = ...,
  2364. subok: bool = ...,
  2365. copy: bool | _CopyMode = ...,
  2366. ) -> _ScalarType: ...
  2367. @overload
  2368. def astype(
  2369. self,
  2370. dtype: DTypeLike,
  2371. order: _OrderKACF = ...,
  2372. casting: _CastingKind = ...,
  2373. subok: bool = ...,
  2374. copy: bool | _CopyMode = ...,
  2375. ) -> Any: ...
  2376. # NOTE: `view` will perform a 0D->scalar cast,
  2377. # thus the array `type` is irrelevant to the output type
  2378. @overload
  2379. def view(
  2380. self: _ScalarType,
  2381. type: type[ndarray[Any, Any]] = ...,
  2382. ) -> _ScalarType: ...
  2383. @overload
  2384. def view(
  2385. self,
  2386. dtype: _DTypeLike[_ScalarType],
  2387. type: type[ndarray[Any, Any]] = ...,
  2388. ) -> _ScalarType: ...
  2389. @overload
  2390. def view(
  2391. self,
  2392. dtype: DTypeLike,
  2393. type: type[ndarray[Any, Any]] = ...,
  2394. ) -> Any: ...
  2395. @overload
  2396. def getfield(
  2397. self,
  2398. dtype: _DTypeLike[_ScalarType],
  2399. offset: SupportsIndex = ...
  2400. ) -> _ScalarType: ...
  2401. @overload
  2402. def getfield(
  2403. self,
  2404. dtype: DTypeLike,
  2405. offset: SupportsIndex = ...
  2406. ) -> Any: ...
  2407. def item(
  2408. self, args: L[0] | tuple[()] | tuple[L[0]] = ..., /,
  2409. ) -> Any: ...
  2410. @overload
  2411. def take( # type: ignore[misc]
  2412. self: _ScalarType,
  2413. indices: _IntLike_co,
  2414. axis: None | SupportsIndex = ...,
  2415. out: None = ...,
  2416. mode: _ModeKind = ...,
  2417. ) -> _ScalarType: ...
  2418. @overload
  2419. def take( # type: ignore[misc]
  2420. self: _ScalarType,
  2421. indices: _ArrayLikeInt_co,
  2422. axis: None | SupportsIndex = ...,
  2423. out: None = ...,
  2424. mode: _ModeKind = ...,
  2425. ) -> ndarray[Any, _dtype[_ScalarType]]: ...
  2426. @overload
  2427. def take(
  2428. self,
  2429. indices: _ArrayLikeInt_co,
  2430. axis: None | SupportsIndex = ...,
  2431. out: _NdArraySubClass = ...,
  2432. mode: _ModeKind = ...,
  2433. ) -> _NdArraySubClass: ...
  2434. def repeat(
  2435. self: _ScalarType,
  2436. repeats: _ArrayLikeInt_co,
  2437. axis: None | SupportsIndex = ...,
  2438. ) -> ndarray[Any, _dtype[_ScalarType]]: ...
  2439. def flatten(
  2440. self: _ScalarType,
  2441. order: _OrderKACF = ...,
  2442. ) -> ndarray[Any, _dtype[_ScalarType]]: ...
  2443. def ravel(
  2444. self: _ScalarType,
  2445. order: _OrderKACF = ...,
  2446. ) -> ndarray[Any, _dtype[_ScalarType]]: ...
  2447. @overload
  2448. def reshape(
  2449. self: _ScalarType, shape: _ShapeLike, /, *, order: _OrderACF = ...
  2450. ) -> ndarray[Any, _dtype[_ScalarType]]: ...
  2451. @overload
  2452. def reshape(
  2453. self: _ScalarType, *shape: SupportsIndex, order: _OrderACF = ...
  2454. ) -> ndarray[Any, _dtype[_ScalarType]]: ...
  2455. def squeeze(
  2456. self: _ScalarType, axis: None | L[0] | tuple[()] = ...
  2457. ) -> _ScalarType: ...
  2458. def transpose(self: _ScalarType, axes: None | tuple[()] = ..., /) -> _ScalarType: ...
  2459. # Keep `dtype` at the bottom to avoid name conflicts with `np.dtype`
  2460. @property
  2461. def dtype(self: _ScalarType) -> _dtype[_ScalarType]: ...
  2462. class number(generic, Generic[_NBit1]): # type: ignore
  2463. @property
  2464. def real(self: _ArraySelf) -> _ArraySelf: ...
  2465. @property
  2466. def imag(self: _ArraySelf) -> _ArraySelf: ...
  2467. if sys.version_info >= (3, 9):
  2468. def __class_getitem__(self, item: Any) -> GenericAlias: ...
  2469. def __int__(self) -> int: ...
  2470. def __float__(self) -> float: ...
  2471. def __complex__(self) -> complex: ...
  2472. def __neg__(self: _ArraySelf) -> _ArraySelf: ...
  2473. def __pos__(self: _ArraySelf) -> _ArraySelf: ...
  2474. def __abs__(self: _ArraySelf) -> _ArraySelf: ...
  2475. # Ensure that objects annotated as `number` support arithmetic operations
  2476. __add__: _NumberOp
  2477. __radd__: _NumberOp
  2478. __sub__: _NumberOp
  2479. __rsub__: _NumberOp
  2480. __mul__: _NumberOp
  2481. __rmul__: _NumberOp
  2482. __floordiv__: _NumberOp
  2483. __rfloordiv__: _NumberOp
  2484. __pow__: _NumberOp
  2485. __rpow__: _NumberOp
  2486. __truediv__: _NumberOp
  2487. __rtruediv__: _NumberOp
  2488. __lt__: _ComparisonOp[_NumberLike_co, _ArrayLikeNumber_co]
  2489. __le__: _ComparisonOp[_NumberLike_co, _ArrayLikeNumber_co]
  2490. __gt__: _ComparisonOp[_NumberLike_co, _ArrayLikeNumber_co]
  2491. __ge__: _ComparisonOp[_NumberLike_co, _ArrayLikeNumber_co]
  2492. class bool_(generic):
  2493. def __init__(self, value: object = ..., /) -> None: ...
  2494. def item(
  2495. self, args: L[0] | tuple[()] | tuple[L[0]] = ..., /,
  2496. ) -> bool: ...
  2497. def tolist(self) -> bool: ...
  2498. @property
  2499. def real(self: _ArraySelf) -> _ArraySelf: ...
  2500. @property
  2501. def imag(self: _ArraySelf) -> _ArraySelf: ...
  2502. def __int__(self) -> int: ...
  2503. def __float__(self) -> float: ...
  2504. def __complex__(self) -> complex: ...
  2505. def __abs__(self: _ArraySelf) -> _ArraySelf: ...
  2506. __add__: _BoolOp[bool_]
  2507. __radd__: _BoolOp[bool_]
  2508. __sub__: _BoolSub
  2509. __rsub__: _BoolSub
  2510. __mul__: _BoolOp[bool_]
  2511. __rmul__: _BoolOp[bool_]
  2512. __floordiv__: _BoolOp[int8]
  2513. __rfloordiv__: _BoolOp[int8]
  2514. __pow__: _BoolOp[int8]
  2515. __rpow__: _BoolOp[int8]
  2516. __truediv__: _BoolTrueDiv
  2517. __rtruediv__: _BoolTrueDiv
  2518. def __invert__(self) -> bool_: ...
  2519. __lshift__: _BoolBitOp[int8]
  2520. __rlshift__: _BoolBitOp[int8]
  2521. __rshift__: _BoolBitOp[int8]
  2522. __rrshift__: _BoolBitOp[int8]
  2523. __and__: _BoolBitOp[bool_]
  2524. __rand__: _BoolBitOp[bool_]
  2525. __xor__: _BoolBitOp[bool_]
  2526. __rxor__: _BoolBitOp[bool_]
  2527. __or__: _BoolBitOp[bool_]
  2528. __ror__: _BoolBitOp[bool_]
  2529. __mod__: _BoolMod
  2530. __rmod__: _BoolMod
  2531. __divmod__: _BoolDivMod
  2532. __rdivmod__: _BoolDivMod
  2533. __lt__: _ComparisonOp[_NumberLike_co, _ArrayLikeNumber_co]
  2534. __le__: _ComparisonOp[_NumberLike_co, _ArrayLikeNumber_co]
  2535. __gt__: _ComparisonOp[_NumberLike_co, _ArrayLikeNumber_co]
  2536. __ge__: _ComparisonOp[_NumberLike_co, _ArrayLikeNumber_co]
  2537. class object_(generic):
  2538. def __init__(self, value: object = ..., /) -> None: ...
  2539. @property
  2540. def real(self: _ArraySelf) -> _ArraySelf: ...
  2541. @property
  2542. def imag(self: _ArraySelf) -> _ArraySelf: ...
  2543. # The 3 protocols below may or may not raise,
  2544. # depending on the underlying object
  2545. def __int__(self) -> int: ...
  2546. def __float__(self) -> float: ...
  2547. def __complex__(self) -> complex: ...
  2548. # The `datetime64` constructors requires an object with the three attributes below,
  2549. # and thus supports datetime duck typing
  2550. class _DatetimeScalar(Protocol):
  2551. @property
  2552. def day(self) -> int: ...
  2553. @property
  2554. def month(self) -> int: ...
  2555. @property
  2556. def year(self) -> int: ...
  2557. # TODO: `item`/`tolist` returns either `dt.date`, `dt.datetime` or `int`
  2558. # depending on the unit
  2559. class datetime64(generic):
  2560. @overload
  2561. def __init__(
  2562. self,
  2563. value: None | datetime64 | _CharLike_co | _DatetimeScalar = ...,
  2564. format: _CharLike_co | tuple[_CharLike_co, _IntLike_co] = ...,
  2565. /,
  2566. ) -> None: ...
  2567. @overload
  2568. def __init__(
  2569. self,
  2570. value: int,
  2571. format: _CharLike_co | tuple[_CharLike_co, _IntLike_co],
  2572. /,
  2573. ) -> None: ...
  2574. def __add__(self, other: _TD64Like_co) -> datetime64: ...
  2575. def __radd__(self, other: _TD64Like_co) -> datetime64: ...
  2576. @overload
  2577. def __sub__(self, other: datetime64) -> timedelta64: ...
  2578. @overload
  2579. def __sub__(self, other: _TD64Like_co) -> datetime64: ...
  2580. def __rsub__(self, other: datetime64) -> timedelta64: ...
  2581. __lt__: _ComparisonOp[datetime64, _ArrayLikeDT64_co]
  2582. __le__: _ComparisonOp[datetime64, _ArrayLikeDT64_co]
  2583. __gt__: _ComparisonOp[datetime64, _ArrayLikeDT64_co]
  2584. __ge__: _ComparisonOp[datetime64, _ArrayLikeDT64_co]
  2585. _IntValue = Union[SupportsInt, _CharLike_co, SupportsIndex]
  2586. _FloatValue = Union[None, _CharLike_co, SupportsFloat, SupportsIndex]
  2587. _ComplexValue = Union[
  2588. None,
  2589. _CharLike_co,
  2590. SupportsFloat,
  2591. SupportsComplex,
  2592. SupportsIndex,
  2593. complex, # `complex` is not a subtype of `SupportsComplex`
  2594. ]
  2595. class integer(number[_NBit1]): # type: ignore
  2596. @property
  2597. def numerator(self: _ScalarType) -> _ScalarType: ...
  2598. @property
  2599. def denominator(self) -> L[1]: ...
  2600. @overload
  2601. def __round__(self, ndigits: None = ...) -> int: ...
  2602. @overload
  2603. def __round__(self: _ScalarType, ndigits: SupportsIndex) -> _ScalarType: ...
  2604. # NOTE: `__index__` is technically defined in the bottom-most
  2605. # sub-classes (`int64`, `uint32`, etc)
  2606. def item(
  2607. self, args: L[0] | tuple[()] | tuple[L[0]] = ..., /,
  2608. ) -> int: ...
  2609. def tolist(self) -> int: ...
  2610. def is_integer(self) -> L[True]: ...
  2611. def bit_count(self: _ScalarType) -> int: ...
  2612. def __index__(self) -> int: ...
  2613. __truediv__: _IntTrueDiv[_NBit1]
  2614. __rtruediv__: _IntTrueDiv[_NBit1]
  2615. def __mod__(self, value: _IntLike_co) -> integer: ...
  2616. def __rmod__(self, value: _IntLike_co) -> integer: ...
  2617. def __invert__(self: _IntType) -> _IntType: ...
  2618. # Ensure that objects annotated as `integer` support bit-wise operations
  2619. def __lshift__(self, other: _IntLike_co) -> integer: ...
  2620. def __rlshift__(self, other: _IntLike_co) -> integer: ...
  2621. def __rshift__(self, other: _IntLike_co) -> integer: ...
  2622. def __rrshift__(self, other: _IntLike_co) -> integer: ...
  2623. def __and__(self, other: _IntLike_co) -> integer: ...
  2624. def __rand__(self, other: _IntLike_co) -> integer: ...
  2625. def __or__(self, other: _IntLike_co) -> integer: ...
  2626. def __ror__(self, other: _IntLike_co) -> integer: ...
  2627. def __xor__(self, other: _IntLike_co) -> integer: ...
  2628. def __rxor__(self, other: _IntLike_co) -> integer: ...
  2629. class signedinteger(integer[_NBit1]):
  2630. def __init__(self, value: _IntValue = ..., /) -> None: ...
  2631. __add__: _SignedIntOp[_NBit1]
  2632. __radd__: _SignedIntOp[_NBit1]
  2633. __sub__: _SignedIntOp[_NBit1]
  2634. __rsub__: _SignedIntOp[_NBit1]
  2635. __mul__: _SignedIntOp[_NBit1]
  2636. __rmul__: _SignedIntOp[_NBit1]
  2637. __floordiv__: _SignedIntOp[_NBit1]
  2638. __rfloordiv__: _SignedIntOp[_NBit1]
  2639. __pow__: _SignedIntOp[_NBit1]
  2640. __rpow__: _SignedIntOp[_NBit1]
  2641. __lshift__: _SignedIntBitOp[_NBit1]
  2642. __rlshift__: _SignedIntBitOp[_NBit1]
  2643. __rshift__: _SignedIntBitOp[_NBit1]
  2644. __rrshift__: _SignedIntBitOp[_NBit1]
  2645. __and__: _SignedIntBitOp[_NBit1]
  2646. __rand__: _SignedIntBitOp[_NBit1]
  2647. __xor__: _SignedIntBitOp[_NBit1]
  2648. __rxor__: _SignedIntBitOp[_NBit1]
  2649. __or__: _SignedIntBitOp[_NBit1]
  2650. __ror__: _SignedIntBitOp[_NBit1]
  2651. __mod__: _SignedIntMod[_NBit1]
  2652. __rmod__: _SignedIntMod[_NBit1]
  2653. __divmod__: _SignedIntDivMod[_NBit1]
  2654. __rdivmod__: _SignedIntDivMod[_NBit1]
  2655. int8 = signedinteger[_8Bit]
  2656. int16 = signedinteger[_16Bit]
  2657. int32 = signedinteger[_32Bit]
  2658. int64 = signedinteger[_64Bit]
  2659. byte = signedinteger[_NBitByte]
  2660. short = signedinteger[_NBitShort]
  2661. intc = signedinteger[_NBitIntC]
  2662. intp = signedinteger[_NBitIntP]
  2663. int_ = signedinteger[_NBitInt]
  2664. longlong = signedinteger[_NBitLongLong]
  2665. # TODO: `item`/`tolist` returns either `dt.timedelta` or `int`
  2666. # depending on the unit
  2667. class timedelta64(generic):
  2668. def __init__(
  2669. self,
  2670. value: None | int | _CharLike_co | dt.timedelta | timedelta64 = ...,
  2671. format: _CharLike_co | tuple[_CharLike_co, _IntLike_co] = ...,
  2672. /,
  2673. ) -> None: ...
  2674. @property
  2675. def numerator(self: _ScalarType) -> _ScalarType: ...
  2676. @property
  2677. def denominator(self) -> L[1]: ...
  2678. # NOTE: Only a limited number of units support conversion
  2679. # to builtin scalar types: `Y`, `M`, `ns`, `ps`, `fs`, `as`
  2680. def __int__(self) -> int: ...
  2681. def __float__(self) -> float: ...
  2682. def __complex__(self) -> complex: ...
  2683. def __neg__(self: _ArraySelf) -> _ArraySelf: ...
  2684. def __pos__(self: _ArraySelf) -> _ArraySelf: ...
  2685. def __abs__(self: _ArraySelf) -> _ArraySelf: ...
  2686. def __add__(self, other: _TD64Like_co) -> timedelta64: ...
  2687. def __radd__(self, other: _TD64Like_co) -> timedelta64: ...
  2688. def __sub__(self, other: _TD64Like_co) -> timedelta64: ...
  2689. def __rsub__(self, other: _TD64Like_co) -> timedelta64: ...
  2690. def __mul__(self, other: _FloatLike_co) -> timedelta64: ...
  2691. def __rmul__(self, other: _FloatLike_co) -> timedelta64: ...
  2692. __truediv__: _TD64Div[float64]
  2693. __floordiv__: _TD64Div[int64]
  2694. def __rtruediv__(self, other: timedelta64) -> float64: ...
  2695. def __rfloordiv__(self, other: timedelta64) -> int64: ...
  2696. def __mod__(self, other: timedelta64) -> timedelta64: ...
  2697. def __rmod__(self, other: timedelta64) -> timedelta64: ...
  2698. def __divmod__(self, other: timedelta64) -> tuple[int64, timedelta64]: ...
  2699. def __rdivmod__(self, other: timedelta64) -> tuple[int64, timedelta64]: ...
  2700. __lt__: _ComparisonOp[_TD64Like_co, _ArrayLikeTD64_co]
  2701. __le__: _ComparisonOp[_TD64Like_co, _ArrayLikeTD64_co]
  2702. __gt__: _ComparisonOp[_TD64Like_co, _ArrayLikeTD64_co]
  2703. __ge__: _ComparisonOp[_TD64Like_co, _ArrayLikeTD64_co]
  2704. class unsignedinteger(integer[_NBit1]):
  2705. # NOTE: `uint64 + signedinteger -> float64`
  2706. def __init__(self, value: _IntValue = ..., /) -> None: ...
  2707. __add__: _UnsignedIntOp[_NBit1]
  2708. __radd__: _UnsignedIntOp[_NBit1]
  2709. __sub__: _UnsignedIntOp[_NBit1]
  2710. __rsub__: _UnsignedIntOp[_NBit1]
  2711. __mul__: _UnsignedIntOp[_NBit1]
  2712. __rmul__: _UnsignedIntOp[_NBit1]
  2713. __floordiv__: _UnsignedIntOp[_NBit1]
  2714. __rfloordiv__: _UnsignedIntOp[_NBit1]
  2715. __pow__: _UnsignedIntOp[_NBit1]
  2716. __rpow__: _UnsignedIntOp[_NBit1]
  2717. __lshift__: _UnsignedIntBitOp[_NBit1]
  2718. __rlshift__: _UnsignedIntBitOp[_NBit1]
  2719. __rshift__: _UnsignedIntBitOp[_NBit1]
  2720. __rrshift__: _UnsignedIntBitOp[_NBit1]
  2721. __and__: _UnsignedIntBitOp[_NBit1]
  2722. __rand__: _UnsignedIntBitOp[_NBit1]
  2723. __xor__: _UnsignedIntBitOp[_NBit1]
  2724. __rxor__: _UnsignedIntBitOp[_NBit1]
  2725. __or__: _UnsignedIntBitOp[_NBit1]
  2726. __ror__: _UnsignedIntBitOp[_NBit1]
  2727. __mod__: _UnsignedIntMod[_NBit1]
  2728. __rmod__: _UnsignedIntMod[_NBit1]
  2729. __divmod__: _UnsignedIntDivMod[_NBit1]
  2730. __rdivmod__: _UnsignedIntDivMod[_NBit1]
  2731. uint8 = unsignedinteger[_8Bit]
  2732. uint16 = unsignedinteger[_16Bit]
  2733. uint32 = unsignedinteger[_32Bit]
  2734. uint64 = unsignedinteger[_64Bit]
  2735. ubyte = unsignedinteger[_NBitByte]
  2736. ushort = unsignedinteger[_NBitShort]
  2737. uintc = unsignedinteger[_NBitIntC]
  2738. uintp = unsignedinteger[_NBitIntP]
  2739. uint = unsignedinteger[_NBitInt]
  2740. ulonglong = unsignedinteger[_NBitLongLong]
  2741. class inexact(number[_NBit1]): # type: ignore
  2742. def __getnewargs__(self: inexact[_64Bit]) -> tuple[float, ...]: ...
  2743. _IntType = TypeVar("_IntType", bound=integer)
  2744. _FloatType = TypeVar('_FloatType', bound=floating)
  2745. class floating(inexact[_NBit1]):
  2746. def __init__(self, value: _FloatValue = ..., /) -> None: ...
  2747. def item(
  2748. self, args: L[0] | tuple[()] | tuple[L[0]] = ...,
  2749. /,
  2750. ) -> float: ...
  2751. def tolist(self) -> float: ...
  2752. def is_integer(self) -> bool: ...
  2753. def hex(self: float64) -> str: ...
  2754. @classmethod
  2755. def fromhex(cls: type[float64], string: str, /) -> float64: ...
  2756. def as_integer_ratio(self) -> tuple[int, int]: ...
  2757. if sys.version_info >= (3, 9):
  2758. def __ceil__(self: float64) -> int: ...
  2759. def __floor__(self: float64) -> int: ...
  2760. def __trunc__(self: float64) -> int: ...
  2761. def __getnewargs__(self: float64) -> tuple[float]: ...
  2762. def __getformat__(self: float64, typestr: L["double", "float"], /) -> str: ...
  2763. @overload
  2764. def __round__(self, ndigits: None = ...) -> int: ...
  2765. @overload
  2766. def __round__(self: _ScalarType, ndigits: SupportsIndex) -> _ScalarType: ...
  2767. __add__: _FloatOp[_NBit1]
  2768. __radd__: _FloatOp[_NBit1]
  2769. __sub__: _FloatOp[_NBit1]
  2770. __rsub__: _FloatOp[_NBit1]
  2771. __mul__: _FloatOp[_NBit1]
  2772. __rmul__: _FloatOp[_NBit1]
  2773. __truediv__: _FloatOp[_NBit1]
  2774. __rtruediv__: _FloatOp[_NBit1]
  2775. __floordiv__: _FloatOp[_NBit1]
  2776. __rfloordiv__: _FloatOp[_NBit1]
  2777. __pow__: _FloatOp[_NBit1]
  2778. __rpow__: _FloatOp[_NBit1]
  2779. __mod__: _FloatMod[_NBit1]
  2780. __rmod__: _FloatMod[_NBit1]
  2781. __divmod__: _FloatDivMod[_NBit1]
  2782. __rdivmod__: _FloatDivMod[_NBit1]
  2783. float16 = floating[_16Bit]
  2784. float32 = floating[_32Bit]
  2785. float64 = floating[_64Bit]
  2786. half = floating[_NBitHalf]
  2787. single = floating[_NBitSingle]
  2788. double = floating[_NBitDouble]
  2789. float_ = floating[_NBitDouble]
  2790. longdouble = floating[_NBitLongDouble]
  2791. longfloat = floating[_NBitLongDouble]
  2792. # The main reason for `complexfloating` having two typevars is cosmetic.
  2793. # It is used to clarify why `complex128`s precision is `_64Bit`, the latter
  2794. # describing the two 64 bit floats representing its real and imaginary component
  2795. class complexfloating(inexact[_NBit1], Generic[_NBit1, _NBit2]):
  2796. def __init__(self, value: _ComplexValue = ..., /) -> None: ...
  2797. def item(
  2798. self, args: L[0] | tuple[()] | tuple[L[0]] = ..., /,
  2799. ) -> complex: ...
  2800. def tolist(self) -> complex: ...
  2801. @property
  2802. def real(self) -> floating[_NBit1]: ... # type: ignore[override]
  2803. @property
  2804. def imag(self) -> floating[_NBit2]: ... # type: ignore[override]
  2805. def __abs__(self) -> floating[_NBit1]: ... # type: ignore[override]
  2806. def __getnewargs__(self: complex128) -> tuple[float, float]: ...
  2807. # NOTE: Deprecated
  2808. # def __round__(self, ndigits=...): ...
  2809. __add__: _ComplexOp[_NBit1]
  2810. __radd__: _ComplexOp[_NBit1]
  2811. __sub__: _ComplexOp[_NBit1]
  2812. __rsub__: _ComplexOp[_NBit1]
  2813. __mul__: _ComplexOp[_NBit1]
  2814. __rmul__: _ComplexOp[_NBit1]
  2815. __truediv__: _ComplexOp[_NBit1]
  2816. __rtruediv__: _ComplexOp[_NBit1]
  2817. __pow__: _ComplexOp[_NBit1]
  2818. __rpow__: _ComplexOp[_NBit1]
  2819. complex64 = complexfloating[_32Bit, _32Bit]
  2820. complex128 = complexfloating[_64Bit, _64Bit]
  2821. csingle = complexfloating[_NBitSingle, _NBitSingle]
  2822. singlecomplex = complexfloating[_NBitSingle, _NBitSingle]
  2823. cdouble = complexfloating[_NBitDouble, _NBitDouble]
  2824. complex_ = complexfloating[_NBitDouble, _NBitDouble]
  2825. cfloat = complexfloating[_NBitDouble, _NBitDouble]
  2826. clongdouble = complexfloating[_NBitLongDouble, _NBitLongDouble]
  2827. clongfloat = complexfloating[_NBitLongDouble, _NBitLongDouble]
  2828. longcomplex = complexfloating[_NBitLongDouble, _NBitLongDouble]
  2829. class flexible(generic): ... # type: ignore
  2830. # TODO: `item`/`tolist` returns either `bytes` or `tuple`
  2831. # depending on whether or not it's used as an opaque bytes sequence
  2832. # or a structure
  2833. class void(flexible):
  2834. @overload
  2835. def __init__(self, value: _IntLike_co | bytes, /, dtype : None = ...) -> None: ...
  2836. @overload
  2837. def __init__(self, value: Any, /, dtype: _DTypeLikeVoid) -> None: ...
  2838. @property
  2839. def real(self: _ArraySelf) -> _ArraySelf: ...
  2840. @property
  2841. def imag(self: _ArraySelf) -> _ArraySelf: ...
  2842. def setfield(
  2843. self, val: ArrayLike, dtype: DTypeLike, offset: int = ...
  2844. ) -> None: ...
  2845. @overload
  2846. def __getitem__(self, key: str | SupportsIndex) -> Any: ...
  2847. @overload
  2848. def __getitem__(self, key: list[str]) -> void: ...
  2849. def __setitem__(
  2850. self,
  2851. key: str | list[str] | SupportsIndex,
  2852. value: ArrayLike,
  2853. ) -> None: ...
  2854. class character(flexible): # type: ignore
  2855. def __int__(self) -> int: ...
  2856. def __float__(self) -> float: ...
  2857. # NOTE: Most `np.bytes_` / `np.str_` methods return their
  2858. # builtin `bytes` / `str` counterpart
  2859. class bytes_(character, bytes):
  2860. @overload
  2861. def __init__(self, value: object = ..., /) -> None: ...
  2862. @overload
  2863. def __init__(
  2864. self, value: str, /, encoding: str = ..., errors: str = ...
  2865. ) -> None: ...
  2866. def item(
  2867. self, args: L[0] | tuple[()] | tuple[L[0]] = ..., /,
  2868. ) -> bytes: ...
  2869. def tolist(self) -> bytes: ...
  2870. string_ = bytes_
  2871. class str_(character, str):
  2872. @overload
  2873. def __init__(self, value: object = ..., /) -> None: ...
  2874. @overload
  2875. def __init__(
  2876. self, value: bytes, /, encoding: str = ..., errors: str = ...
  2877. ) -> None: ...
  2878. def item(
  2879. self, args: L[0] | tuple[()] | tuple[L[0]] = ..., /,
  2880. ) -> str: ...
  2881. def tolist(self) -> str: ...
  2882. unicode_ = str_
  2883. #
  2884. # Constants
  2885. #
  2886. Inf: Final[float]
  2887. Infinity: Final[float]
  2888. NAN: Final[float]
  2889. NINF: Final[float]
  2890. NZERO: Final[float]
  2891. NaN: Final[float]
  2892. PINF: Final[float]
  2893. PZERO: Final[float]
  2894. e: Final[float]
  2895. euler_gamma: Final[float]
  2896. inf: Final[float]
  2897. infty: Final[float]
  2898. nan: Final[float]
  2899. pi: Final[float]
  2900. ERR_IGNORE: L[0]
  2901. ERR_WARN: L[1]
  2902. ERR_RAISE: L[2]
  2903. ERR_CALL: L[3]
  2904. ERR_PRINT: L[4]
  2905. ERR_LOG: L[5]
  2906. ERR_DEFAULT: L[521]
  2907. SHIFT_DIVIDEBYZERO: L[0]
  2908. SHIFT_OVERFLOW: L[3]
  2909. SHIFT_UNDERFLOW: L[6]
  2910. SHIFT_INVALID: L[9]
  2911. FPE_DIVIDEBYZERO: L[1]
  2912. FPE_OVERFLOW: L[2]
  2913. FPE_UNDERFLOW: L[4]
  2914. FPE_INVALID: L[8]
  2915. FLOATING_POINT_SUPPORT: L[1]
  2916. UFUNC_BUFSIZE_DEFAULT = BUFSIZE
  2917. little_endian: Final[bool]
  2918. True_: Final[bool_]
  2919. False_: Final[bool_]
  2920. UFUNC_PYVALS_NAME: L["UFUNC_PYVALS"]
  2921. newaxis: None
  2922. # See `numpy._typing._ufunc` for more concrete nin-/nout-specific stubs
  2923. @final
  2924. class ufunc:
  2925. @property
  2926. def __name__(self) -> str: ...
  2927. @property
  2928. def __doc__(self) -> str: ...
  2929. __call__: Callable[..., Any]
  2930. @property
  2931. def nin(self) -> int: ...
  2932. @property
  2933. def nout(self) -> int: ...
  2934. @property
  2935. def nargs(self) -> int: ...
  2936. @property
  2937. def ntypes(self) -> int: ...
  2938. @property
  2939. def types(self) -> list[str]: ...
  2940. # Broad return type because it has to encompass things like
  2941. #
  2942. # >>> np.logical_and.identity is True
  2943. # True
  2944. # >>> np.add.identity is 0
  2945. # True
  2946. # >>> np.sin.identity is None
  2947. # True
  2948. #
  2949. # and any user-defined ufuncs.
  2950. @property
  2951. def identity(self) -> Any: ...
  2952. # This is None for ufuncs and a string for gufuncs.
  2953. @property
  2954. def signature(self) -> None | str: ...
  2955. # The next four methods will always exist, but they will just
  2956. # raise a ValueError ufuncs with that don't accept two input
  2957. # arguments and return one output argument. Because of that we
  2958. # can't type them very precisely.
  2959. reduce: Any
  2960. accumulate: Any
  2961. reduceat: Any
  2962. outer: Any
  2963. # Similarly at won't be defined for ufuncs that return multiple
  2964. # outputs, so we can't type it very precisely.
  2965. at: Any
  2966. # Parameters: `__name__`, `ntypes` and `identity`
  2967. absolute: _UFunc_Nin1_Nout1[L['absolute'], L[20], None]
  2968. add: _UFunc_Nin2_Nout1[L['add'], L[22], L[0]]
  2969. arccos: _UFunc_Nin1_Nout1[L['arccos'], L[8], None]
  2970. arccosh: _UFunc_Nin1_Nout1[L['arccosh'], L[8], None]
  2971. arcsin: _UFunc_Nin1_Nout1[L['arcsin'], L[8], None]
  2972. arcsinh: _UFunc_Nin1_Nout1[L['arcsinh'], L[8], None]
  2973. arctan2: _UFunc_Nin2_Nout1[L['arctan2'], L[5], None]
  2974. arctan: _UFunc_Nin1_Nout1[L['arctan'], L[8], None]
  2975. arctanh: _UFunc_Nin1_Nout1[L['arctanh'], L[8], None]
  2976. bitwise_and: _UFunc_Nin2_Nout1[L['bitwise_and'], L[12], L[-1]]
  2977. bitwise_not: _UFunc_Nin1_Nout1[L['invert'], L[12], None]
  2978. bitwise_or: _UFunc_Nin2_Nout1[L['bitwise_or'], L[12], L[0]]
  2979. bitwise_xor: _UFunc_Nin2_Nout1[L['bitwise_xor'], L[12], L[0]]
  2980. cbrt: _UFunc_Nin1_Nout1[L['cbrt'], L[5], None]
  2981. ceil: _UFunc_Nin1_Nout1[L['ceil'], L[7], None]
  2982. conj: _UFunc_Nin1_Nout1[L['conjugate'], L[18], None]
  2983. conjugate: _UFunc_Nin1_Nout1[L['conjugate'], L[18], None]
  2984. copysign: _UFunc_Nin2_Nout1[L['copysign'], L[4], None]
  2985. cos: _UFunc_Nin1_Nout1[L['cos'], L[9], None]
  2986. cosh: _UFunc_Nin1_Nout1[L['cosh'], L[8], None]
  2987. deg2rad: _UFunc_Nin1_Nout1[L['deg2rad'], L[5], None]
  2988. degrees: _UFunc_Nin1_Nout1[L['degrees'], L[5], None]
  2989. divide: _UFunc_Nin2_Nout1[L['true_divide'], L[11], None]
  2990. divmod: _UFunc_Nin2_Nout2[L['divmod'], L[15], None]
  2991. equal: _UFunc_Nin2_Nout1[L['equal'], L[23], None]
  2992. exp2: _UFunc_Nin1_Nout1[L['exp2'], L[8], None]
  2993. exp: _UFunc_Nin1_Nout1[L['exp'], L[10], None]
  2994. expm1: _UFunc_Nin1_Nout1[L['expm1'], L[8], None]
  2995. fabs: _UFunc_Nin1_Nout1[L['fabs'], L[5], None]
  2996. float_power: _UFunc_Nin2_Nout1[L['float_power'], L[4], None]
  2997. floor: _UFunc_Nin1_Nout1[L['floor'], L[7], None]
  2998. floor_divide: _UFunc_Nin2_Nout1[L['floor_divide'], L[21], None]
  2999. fmax: _UFunc_Nin2_Nout1[L['fmax'], L[21], None]
  3000. fmin: _UFunc_Nin2_Nout1[L['fmin'], L[21], None]
  3001. fmod: _UFunc_Nin2_Nout1[L['fmod'], L[15], None]
  3002. frexp: _UFunc_Nin1_Nout2[L['frexp'], L[4], None]
  3003. gcd: _UFunc_Nin2_Nout1[L['gcd'], L[11], L[0]]
  3004. greater: _UFunc_Nin2_Nout1[L['greater'], L[23], None]
  3005. greater_equal: _UFunc_Nin2_Nout1[L['greater_equal'], L[23], None]
  3006. heaviside: _UFunc_Nin2_Nout1[L['heaviside'], L[4], None]
  3007. hypot: _UFunc_Nin2_Nout1[L['hypot'], L[5], L[0]]
  3008. invert: _UFunc_Nin1_Nout1[L['invert'], L[12], None]
  3009. isfinite: _UFunc_Nin1_Nout1[L['isfinite'], L[20], None]
  3010. isinf: _UFunc_Nin1_Nout1[L['isinf'], L[20], None]
  3011. isnan: _UFunc_Nin1_Nout1[L['isnan'], L[20], None]
  3012. isnat: _UFunc_Nin1_Nout1[L['isnat'], L[2], None]
  3013. lcm: _UFunc_Nin2_Nout1[L['lcm'], L[11], None]
  3014. ldexp: _UFunc_Nin2_Nout1[L['ldexp'], L[8], None]
  3015. left_shift: _UFunc_Nin2_Nout1[L['left_shift'], L[11], None]
  3016. less: _UFunc_Nin2_Nout1[L['less'], L[23], None]
  3017. less_equal: _UFunc_Nin2_Nout1[L['less_equal'], L[23], None]
  3018. log10: _UFunc_Nin1_Nout1[L['log10'], L[8], None]
  3019. log1p: _UFunc_Nin1_Nout1[L['log1p'], L[8], None]
  3020. log2: _UFunc_Nin1_Nout1[L['log2'], L[8], None]
  3021. log: _UFunc_Nin1_Nout1[L['log'], L[10], None]
  3022. logaddexp2: _UFunc_Nin2_Nout1[L['logaddexp2'], L[4], float]
  3023. logaddexp: _UFunc_Nin2_Nout1[L['logaddexp'], L[4], float]
  3024. logical_and: _UFunc_Nin2_Nout1[L['logical_and'], L[20], L[True]]
  3025. logical_not: _UFunc_Nin1_Nout1[L['logical_not'], L[20], None]
  3026. logical_or: _UFunc_Nin2_Nout1[L['logical_or'], L[20], L[False]]
  3027. logical_xor: _UFunc_Nin2_Nout1[L['logical_xor'], L[19], L[False]]
  3028. matmul: _GUFunc_Nin2_Nout1[L['matmul'], L[19], None]
  3029. maximum: _UFunc_Nin2_Nout1[L['maximum'], L[21], None]
  3030. minimum: _UFunc_Nin2_Nout1[L['minimum'], L[21], None]
  3031. mod: _UFunc_Nin2_Nout1[L['remainder'], L[16], None]
  3032. modf: _UFunc_Nin1_Nout2[L['modf'], L[4], None]
  3033. multiply: _UFunc_Nin2_Nout1[L['multiply'], L[23], L[1]]
  3034. negative: _UFunc_Nin1_Nout1[L['negative'], L[19], None]
  3035. nextafter: _UFunc_Nin2_Nout1[L['nextafter'], L[4], None]
  3036. not_equal: _UFunc_Nin2_Nout1[L['not_equal'], L[23], None]
  3037. positive: _UFunc_Nin1_Nout1[L['positive'], L[19], None]
  3038. power: _UFunc_Nin2_Nout1[L['power'], L[18], None]
  3039. rad2deg: _UFunc_Nin1_Nout1[L['rad2deg'], L[5], None]
  3040. radians: _UFunc_Nin1_Nout1[L['radians'], L[5], None]
  3041. reciprocal: _UFunc_Nin1_Nout1[L['reciprocal'], L[18], None]
  3042. remainder: _UFunc_Nin2_Nout1[L['remainder'], L[16], None]
  3043. right_shift: _UFunc_Nin2_Nout1[L['right_shift'], L[11], None]
  3044. rint: _UFunc_Nin1_Nout1[L['rint'], L[10], None]
  3045. sign: _UFunc_Nin1_Nout1[L['sign'], L[19], None]
  3046. signbit: _UFunc_Nin1_Nout1[L['signbit'], L[4], None]
  3047. sin: _UFunc_Nin1_Nout1[L['sin'], L[9], None]
  3048. sinh: _UFunc_Nin1_Nout1[L['sinh'], L[8], None]
  3049. spacing: _UFunc_Nin1_Nout1[L['spacing'], L[4], None]
  3050. sqrt: _UFunc_Nin1_Nout1[L['sqrt'], L[10], None]
  3051. square: _UFunc_Nin1_Nout1[L['square'], L[18], None]
  3052. subtract: _UFunc_Nin2_Nout1[L['subtract'], L[21], None]
  3053. tan: _UFunc_Nin1_Nout1[L['tan'], L[8], None]
  3054. tanh: _UFunc_Nin1_Nout1[L['tanh'], L[8], None]
  3055. true_divide: _UFunc_Nin2_Nout1[L['true_divide'], L[11], None]
  3056. trunc: _UFunc_Nin1_Nout1[L['trunc'], L[7], None]
  3057. abs = absolute
  3058. class _CopyMode(enum.Enum):
  3059. ALWAYS: L[True]
  3060. IF_NEEDED: L[False]
  3061. NEVER: L[2]
  3062. # Warnings
  3063. class ModuleDeprecationWarning(DeprecationWarning): ...
  3064. class VisibleDeprecationWarning(UserWarning): ...
  3065. class ComplexWarning(RuntimeWarning): ...
  3066. class RankWarning(UserWarning): ...
  3067. # Errors
  3068. class TooHardError(RuntimeError): ...
  3069. class AxisError(ValueError, IndexError):
  3070. axis: None | int
  3071. ndim: None | int
  3072. @overload
  3073. def __init__(self, axis: str, ndim: None = ..., msg_prefix: None = ...) -> None: ...
  3074. @overload
  3075. def __init__(self, axis: int, ndim: int, msg_prefix: None | str = ...) -> None: ...
  3076. _CallType = TypeVar("_CallType", bound=_ErrFunc | _SupportsWrite[str])
  3077. class errstate(Generic[_CallType], ContextDecorator):
  3078. call: _CallType
  3079. kwargs: _ErrDictOptional
  3080. # Expand `**kwargs` into explicit keyword-only arguments
  3081. def __init__(
  3082. self,
  3083. *,
  3084. call: _CallType = ...,
  3085. all: None | _ErrKind = ...,
  3086. divide: None | _ErrKind = ...,
  3087. over: None | _ErrKind = ...,
  3088. under: None | _ErrKind = ...,
  3089. invalid: None | _ErrKind = ...,
  3090. ) -> None: ...
  3091. def __enter__(self) -> None: ...
  3092. def __exit__(
  3093. self,
  3094. exc_type: None | type[BaseException],
  3095. exc_value: None | BaseException,
  3096. traceback: None | TracebackType,
  3097. /,
  3098. ) -> None: ...
  3099. @contextmanager
  3100. def _no_nep50_warning() -> Generator[None, None, None]: ...
  3101. def _get_promotion_state() -> str: ...
  3102. def _set_promotion_state(state: str, /) -> None: ...
  3103. class ndenumerate(Generic[_ScalarType]):
  3104. iter: flatiter[NDArray[_ScalarType]]
  3105. @overload
  3106. def __new__(
  3107. cls, arr: _FiniteNestedSequence[_SupportsArray[dtype[_ScalarType]]],
  3108. ) -> ndenumerate[_ScalarType]: ...
  3109. @overload
  3110. def __new__(cls, arr: str | _NestedSequence[str]) -> ndenumerate[str_]: ...
  3111. @overload
  3112. def __new__(cls, arr: bytes | _NestedSequence[bytes]) -> ndenumerate[bytes_]: ...
  3113. @overload
  3114. def __new__(cls, arr: bool | _NestedSequence[bool]) -> ndenumerate[bool_]: ...
  3115. @overload
  3116. def __new__(cls, arr: int | _NestedSequence[int]) -> ndenumerate[int_]: ...
  3117. @overload
  3118. def __new__(cls, arr: float | _NestedSequence[float]) -> ndenumerate[float_]: ...
  3119. @overload
  3120. def __new__(cls, arr: complex | _NestedSequence[complex]) -> ndenumerate[complex_]: ...
  3121. def __next__(self: ndenumerate[_ScalarType]) -> tuple[_Shape, _ScalarType]: ...
  3122. def __iter__(self: _T) -> _T: ...
  3123. class ndindex:
  3124. @overload
  3125. def __init__(self, shape: tuple[SupportsIndex, ...], /) -> None: ...
  3126. @overload
  3127. def __init__(self, *shape: SupportsIndex) -> None: ...
  3128. def __iter__(self: _T) -> _T: ...
  3129. def __next__(self) -> _Shape: ...
  3130. class DataSource:
  3131. def __init__(
  3132. self,
  3133. destpath: None | str | os.PathLike[str] = ...,
  3134. ) -> None: ...
  3135. def __del__(self) -> None: ...
  3136. def abspath(self, path: str) -> str: ...
  3137. def exists(self, path: str) -> bool: ...
  3138. # Whether the file-object is opened in string or bytes mode (by default)
  3139. # depends on the file-extension of `path`
  3140. def open(
  3141. self,
  3142. path: str,
  3143. mode: str = ...,
  3144. encoding: None | str = ...,
  3145. newline: None | str = ...,
  3146. ) -> IO[Any]: ...
  3147. # TODO: The type of each `__next__` and `iters` return-type depends
  3148. # on the length and dtype of `args`; we can't describe this behavior yet
  3149. # as we lack variadics (PEP 646).
  3150. @final
  3151. class broadcast:
  3152. def __new__(cls, *args: ArrayLike) -> broadcast: ...
  3153. @property
  3154. def index(self) -> int: ...
  3155. @property
  3156. def iters(self) -> tuple[flatiter[Any], ...]: ...
  3157. @property
  3158. def nd(self) -> int: ...
  3159. @property
  3160. def ndim(self) -> int: ...
  3161. @property
  3162. def numiter(self) -> int: ...
  3163. @property
  3164. def shape(self) -> _Shape: ...
  3165. @property
  3166. def size(self) -> int: ...
  3167. def __next__(self) -> tuple[Any, ...]: ...
  3168. def __iter__(self: _T) -> _T: ...
  3169. def reset(self) -> None: ...
  3170. @final
  3171. class busdaycalendar:
  3172. def __new__(
  3173. cls,
  3174. weekmask: ArrayLike = ...,
  3175. holidays: ArrayLike | dt.date | _NestedSequence[dt.date] = ...,
  3176. ) -> busdaycalendar: ...
  3177. @property
  3178. def weekmask(self) -> NDArray[bool_]: ...
  3179. @property
  3180. def holidays(self) -> NDArray[datetime64]: ...
  3181. class finfo(Generic[_FloatType]):
  3182. dtype: dtype[_FloatType]
  3183. bits: int
  3184. eps: _FloatType
  3185. epsneg: _FloatType
  3186. iexp: int
  3187. machep: int
  3188. max: _FloatType
  3189. maxexp: int
  3190. min: _FloatType
  3191. minexp: int
  3192. negep: int
  3193. nexp: int
  3194. nmant: int
  3195. precision: int
  3196. resolution: _FloatType
  3197. smallest_subnormal: _FloatType
  3198. @property
  3199. def smallest_normal(self) -> _FloatType: ...
  3200. @property
  3201. def tiny(self) -> _FloatType: ...
  3202. @overload
  3203. def __new__(
  3204. cls, dtype: inexact[_NBit1] | _DTypeLike[inexact[_NBit1]]
  3205. ) -> finfo[floating[_NBit1]]: ...
  3206. @overload
  3207. def __new__(
  3208. cls, dtype: complex | float | type[complex] | type[float]
  3209. ) -> finfo[float_]: ...
  3210. @overload
  3211. def __new__(
  3212. cls, dtype: str
  3213. ) -> finfo[floating[Any]]: ...
  3214. class iinfo(Generic[_IntType]):
  3215. dtype: dtype[_IntType]
  3216. kind: str
  3217. bits: int
  3218. key: str
  3219. @property
  3220. def min(self) -> int: ...
  3221. @property
  3222. def max(self) -> int: ...
  3223. @overload
  3224. def __new__(cls, dtype: _IntType | _DTypeLike[_IntType]) -> iinfo[_IntType]: ...
  3225. @overload
  3226. def __new__(cls, dtype: int | type[int]) -> iinfo[int_]: ...
  3227. @overload
  3228. def __new__(cls, dtype: str) -> iinfo[Any]: ...
  3229. class format_parser:
  3230. dtype: dtype[void]
  3231. def __init__(
  3232. self,
  3233. formats: DTypeLike,
  3234. names: None | str | Sequence[str],
  3235. titles: None | str | Sequence[str],
  3236. aligned: bool = ...,
  3237. byteorder: None | _ByteOrder = ...,
  3238. ) -> None: ...
  3239. class recarray(ndarray[_ShapeType, _DType_co]):
  3240. # NOTE: While not strictly mandatory, we're demanding here that arguments
  3241. # for the `format_parser`- and `dtype`-based dtype constructors are
  3242. # mutually exclusive
  3243. @overload
  3244. def __new__(
  3245. subtype,
  3246. shape: _ShapeLike,
  3247. dtype: None = ...,
  3248. buf: None | _SupportsBuffer = ...,
  3249. offset: SupportsIndex = ...,
  3250. strides: None | _ShapeLike = ...,
  3251. *,
  3252. formats: DTypeLike,
  3253. names: None | str | Sequence[str] = ...,
  3254. titles: None | str | Sequence[str] = ...,
  3255. byteorder: None | _ByteOrder = ...,
  3256. aligned: bool = ...,
  3257. order: _OrderKACF = ...,
  3258. ) -> recarray[Any, dtype[record]]: ...
  3259. @overload
  3260. def __new__(
  3261. subtype,
  3262. shape: _ShapeLike,
  3263. dtype: DTypeLike,
  3264. buf: None | _SupportsBuffer = ...,
  3265. offset: SupportsIndex = ...,
  3266. strides: None | _ShapeLike = ...,
  3267. formats: None = ...,
  3268. names: None = ...,
  3269. titles: None = ...,
  3270. byteorder: None = ...,
  3271. aligned: L[False] = ...,
  3272. order: _OrderKACF = ...,
  3273. ) -> recarray[Any, dtype[Any]]: ...
  3274. def __array_finalize__(self, obj: object) -> None: ...
  3275. def __getattribute__(self, attr: str) -> Any: ...
  3276. def __setattr__(self, attr: str, val: ArrayLike) -> None: ...
  3277. @overload
  3278. def __getitem__(self, indx: (
  3279. SupportsIndex
  3280. | _ArrayLikeInt_co
  3281. | tuple[SupportsIndex | _ArrayLikeInt_co, ...]
  3282. )) -> Any: ...
  3283. @overload
  3284. def __getitem__(self: recarray[Any, dtype[void]], indx: (
  3285. None
  3286. | slice
  3287. | ellipsis
  3288. | SupportsIndex
  3289. | _ArrayLikeInt_co
  3290. | tuple[None | slice | ellipsis | _ArrayLikeInt_co | SupportsIndex, ...]
  3291. )) -> recarray[Any, _DType_co]: ...
  3292. @overload
  3293. def __getitem__(self, indx: (
  3294. None
  3295. | slice
  3296. | ellipsis
  3297. | SupportsIndex
  3298. | _ArrayLikeInt_co
  3299. | tuple[None | slice | ellipsis | _ArrayLikeInt_co | SupportsIndex, ...]
  3300. )) -> ndarray[Any, _DType_co]: ...
  3301. @overload
  3302. def __getitem__(self, indx: str) -> NDArray[Any]: ...
  3303. @overload
  3304. def __getitem__(self, indx: list[str]) -> recarray[_ShapeType, dtype[record]]: ...
  3305. @overload
  3306. def field(self, attr: int | str, val: None = ...) -> Any: ...
  3307. @overload
  3308. def field(self, attr: int | str, val: ArrayLike) -> None: ...
  3309. class record(void):
  3310. def __getattribute__(self, attr: str) -> Any: ...
  3311. def __setattr__(self, attr: str, val: ArrayLike) -> None: ...
  3312. def pprint(self) -> str: ...
  3313. @overload
  3314. def __getitem__(self, key: str | SupportsIndex) -> Any: ...
  3315. @overload
  3316. def __getitem__(self, key: list[str]) -> record: ...
  3317. _NDIterFlagsKind = L[
  3318. "buffered",
  3319. "c_index",
  3320. "copy_if_overlap",
  3321. "common_dtype",
  3322. "delay_bufalloc",
  3323. "external_loop",
  3324. "f_index",
  3325. "grow_inner", "growinner",
  3326. "multi_index",
  3327. "ranged",
  3328. "refs_ok",
  3329. "reduce_ok",
  3330. "zerosize_ok",
  3331. ]
  3332. _NDIterOpFlagsKind = L[
  3333. "aligned",
  3334. "allocate",
  3335. "arraymask",
  3336. "copy",
  3337. "config",
  3338. "nbo",
  3339. "no_subtype",
  3340. "no_broadcast",
  3341. "overlap_assume_elementwise",
  3342. "readonly",
  3343. "readwrite",
  3344. "updateifcopy",
  3345. "virtual",
  3346. "writeonly",
  3347. "writemasked"
  3348. ]
  3349. @final
  3350. class nditer:
  3351. def __new__(
  3352. cls,
  3353. op: ArrayLike | Sequence[ArrayLike],
  3354. flags: None | Sequence[_NDIterFlagsKind] = ...,
  3355. op_flags: None | Sequence[Sequence[_NDIterOpFlagsKind]] = ...,
  3356. op_dtypes: DTypeLike | Sequence[DTypeLike] = ...,
  3357. order: _OrderKACF = ...,
  3358. casting: _CastingKind = ...,
  3359. op_axes: None | Sequence[Sequence[SupportsIndex]] = ...,
  3360. itershape: None | _ShapeLike = ...,
  3361. buffersize: SupportsIndex = ...,
  3362. ) -> nditer: ...
  3363. def __enter__(self) -> nditer: ...
  3364. def __exit__(
  3365. self,
  3366. exc_type: None | type[BaseException],
  3367. exc_value: None | BaseException,
  3368. traceback: None | TracebackType,
  3369. ) -> None: ...
  3370. def __iter__(self) -> nditer: ...
  3371. def __next__(self) -> tuple[NDArray[Any], ...]: ...
  3372. def __len__(self) -> int: ...
  3373. def __copy__(self) -> nditer: ...
  3374. @overload
  3375. def __getitem__(self, index: SupportsIndex) -> NDArray[Any]: ...
  3376. @overload
  3377. def __getitem__(self, index: slice) -> tuple[NDArray[Any], ...]: ...
  3378. def __setitem__(self, index: slice | SupportsIndex, value: ArrayLike) -> None: ...
  3379. def close(self) -> None: ...
  3380. def copy(self) -> nditer: ...
  3381. def debug_print(self) -> None: ...
  3382. def enable_external_loop(self) -> None: ...
  3383. def iternext(self) -> bool: ...
  3384. def remove_axis(self, i: SupportsIndex, /) -> None: ...
  3385. def remove_multi_index(self) -> None: ...
  3386. def reset(self) -> None: ...
  3387. @property
  3388. def dtypes(self) -> tuple[dtype[Any], ...]: ...
  3389. @property
  3390. def finished(self) -> bool: ...
  3391. @property
  3392. def has_delayed_bufalloc(self) -> bool: ...
  3393. @property
  3394. def has_index(self) -> bool: ...
  3395. @property
  3396. def has_multi_index(self) -> bool: ...
  3397. @property
  3398. def index(self) -> int: ...
  3399. @property
  3400. def iterationneedsapi(self) -> bool: ...
  3401. @property
  3402. def iterindex(self) -> int: ...
  3403. @property
  3404. def iterrange(self) -> tuple[int, ...]: ...
  3405. @property
  3406. def itersize(self) -> int: ...
  3407. @property
  3408. def itviews(self) -> tuple[NDArray[Any], ...]: ...
  3409. @property
  3410. def multi_index(self) -> tuple[int, ...]: ...
  3411. @property
  3412. def ndim(self) -> int: ...
  3413. @property
  3414. def nop(self) -> int: ...
  3415. @property
  3416. def operands(self) -> tuple[NDArray[Any], ...]: ...
  3417. @property
  3418. def shape(self) -> tuple[int, ...]: ...
  3419. @property
  3420. def value(self) -> tuple[NDArray[Any], ...]: ...
  3421. _MemMapModeKind = L[
  3422. "readonly", "r",
  3423. "copyonwrite", "c",
  3424. "readwrite", "r+",
  3425. "write", "w+",
  3426. ]
  3427. class memmap(ndarray[_ShapeType, _DType_co]):
  3428. __array_priority__: ClassVar[float]
  3429. filename: str | None
  3430. offset: int
  3431. mode: str
  3432. @overload
  3433. def __new__(
  3434. subtype,
  3435. filename: str | bytes | os.PathLike[str] | os.PathLike[bytes] | _MemMapIOProtocol,
  3436. dtype: type[uint8] = ...,
  3437. mode: _MemMapModeKind = ...,
  3438. offset: int = ...,
  3439. shape: None | int | tuple[int, ...] = ...,
  3440. order: _OrderKACF = ...,
  3441. ) -> memmap[Any, dtype[uint8]]: ...
  3442. @overload
  3443. def __new__(
  3444. subtype,
  3445. filename: str | bytes | os.PathLike[str] | os.PathLike[bytes] | _MemMapIOProtocol,
  3446. dtype: _DTypeLike[_ScalarType],
  3447. mode: _MemMapModeKind = ...,
  3448. offset: int = ...,
  3449. shape: None | int | tuple[int, ...] = ...,
  3450. order: _OrderKACF = ...,
  3451. ) -> memmap[Any, dtype[_ScalarType]]: ...
  3452. @overload
  3453. def __new__(
  3454. subtype,
  3455. filename: str | bytes | os.PathLike[str] | os.PathLike[bytes] | _MemMapIOProtocol,
  3456. dtype: DTypeLike,
  3457. mode: _MemMapModeKind = ...,
  3458. offset: int = ...,
  3459. shape: None | int | tuple[int, ...] = ...,
  3460. order: _OrderKACF = ...,
  3461. ) -> memmap[Any, dtype[Any]]: ...
  3462. def __array_finalize__(self, obj: object) -> None: ...
  3463. def __array_wrap__(
  3464. self,
  3465. array: memmap[_ShapeType, _DType_co],
  3466. context: None | tuple[ufunc, tuple[Any, ...], int] = ...,
  3467. ) -> Any: ...
  3468. def flush(self) -> None: ...
  3469. # TODO: Add a mypy plugin for managing functions whose output type is dependent
  3470. # on the literal value of some sort of signature (e.g. `einsum` and `vectorize`)
  3471. class vectorize:
  3472. pyfunc: Callable[..., Any]
  3473. cache: bool
  3474. signature: None | str
  3475. otypes: None | str
  3476. excluded: set[int | str]
  3477. __doc__: None | str
  3478. def __init__(
  3479. self,
  3480. pyfunc: Callable[..., Any],
  3481. otypes: None | str | Iterable[DTypeLike] = ...,
  3482. doc: None | str = ...,
  3483. excluded: None | Iterable[int | str] = ...,
  3484. cache: bool = ...,
  3485. signature: None | str = ...,
  3486. ) -> None: ...
  3487. def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
  3488. class poly1d:
  3489. @property
  3490. def variable(self) -> str: ...
  3491. @property
  3492. def order(self) -> int: ...
  3493. @property
  3494. def o(self) -> int: ...
  3495. @property
  3496. def roots(self) -> NDArray[Any]: ...
  3497. @property
  3498. def r(self) -> NDArray[Any]: ...
  3499. @property
  3500. def coeffs(self) -> NDArray[Any]: ...
  3501. @coeffs.setter
  3502. def coeffs(self, value: NDArray[Any]) -> None: ...
  3503. @property
  3504. def c(self) -> NDArray[Any]: ...
  3505. @c.setter
  3506. def c(self, value: NDArray[Any]) -> None: ...
  3507. @property
  3508. def coef(self) -> NDArray[Any]: ...
  3509. @coef.setter
  3510. def coef(self, value: NDArray[Any]) -> None: ...
  3511. @property
  3512. def coefficients(self) -> NDArray[Any]: ...
  3513. @coefficients.setter
  3514. def coefficients(self, value: NDArray[Any]) -> None: ...
  3515. __hash__: ClassVar[None] # type: ignore
  3516. @overload
  3517. def __array__(self, t: None = ...) -> NDArray[Any]: ...
  3518. @overload
  3519. def __array__(self, t: _DType) -> ndarray[Any, _DType]: ...
  3520. @overload
  3521. def __call__(self, val: _ScalarLike_co) -> Any: ...
  3522. @overload
  3523. def __call__(self, val: poly1d) -> poly1d: ...
  3524. @overload
  3525. def __call__(self, val: ArrayLike) -> NDArray[Any]: ...
  3526. def __init__(
  3527. self,
  3528. c_or_r: ArrayLike,
  3529. r: bool = ...,
  3530. variable: None | str = ...,
  3531. ) -> None: ...
  3532. def __len__(self) -> int: ...
  3533. def __neg__(self) -> poly1d: ...
  3534. def __pos__(self) -> poly1d: ...
  3535. def __mul__(self, other: ArrayLike) -> poly1d: ...
  3536. def __rmul__(self, other: ArrayLike) -> poly1d: ...
  3537. def __add__(self, other: ArrayLike) -> poly1d: ...
  3538. def __radd__(self, other: ArrayLike) -> poly1d: ...
  3539. def __pow__(self, val: _FloatLike_co) -> poly1d: ... # Integral floats are accepted
  3540. def __sub__(self, other: ArrayLike) -> poly1d: ...
  3541. def __rsub__(self, other: ArrayLike) -> poly1d: ...
  3542. def __div__(self, other: ArrayLike) -> poly1d: ...
  3543. def __truediv__(self, other: ArrayLike) -> poly1d: ...
  3544. def __rdiv__(self, other: ArrayLike) -> poly1d: ...
  3545. def __rtruediv__(self, other: ArrayLike) -> poly1d: ...
  3546. def __getitem__(self, val: int) -> Any: ...
  3547. def __setitem__(self, key: int, val: Any) -> None: ...
  3548. def __iter__(self) -> Iterator[Any]: ...
  3549. def deriv(self, m: SupportsInt | SupportsIndex = ...) -> poly1d: ...
  3550. def integ(
  3551. self,
  3552. m: SupportsInt | SupportsIndex = ...,
  3553. k: None | _ArrayLikeComplex_co | _ArrayLikeObject_co = ...,
  3554. ) -> poly1d: ...
  3555. class matrix(ndarray[_ShapeType, _DType_co]):
  3556. __array_priority__: ClassVar[float]
  3557. def __new__(
  3558. subtype,
  3559. data: ArrayLike,
  3560. dtype: DTypeLike = ...,
  3561. copy: bool = ...,
  3562. ) -> matrix[Any, Any]: ...
  3563. def __array_finalize__(self, obj: object) -> None: ...
  3564. @overload
  3565. def __getitem__(self, key: (
  3566. SupportsIndex
  3567. | _ArrayLikeInt_co
  3568. | tuple[SupportsIndex | _ArrayLikeInt_co, ...]
  3569. )) -> Any: ...
  3570. @overload
  3571. def __getitem__(self, key: (
  3572. None
  3573. | slice
  3574. | ellipsis
  3575. | SupportsIndex
  3576. | _ArrayLikeInt_co
  3577. | tuple[None | slice | ellipsis | _ArrayLikeInt_co | SupportsIndex, ...]
  3578. )) -> matrix[Any, _DType_co]: ...
  3579. @overload
  3580. def __getitem__(self: NDArray[void], key: str) -> matrix[Any, dtype[Any]]: ...
  3581. @overload
  3582. def __getitem__(self: NDArray[void], key: list[str]) -> matrix[_ShapeType, dtype[void]]: ...
  3583. def __mul__(self, other: ArrayLike) -> matrix[Any, Any]: ...
  3584. def __rmul__(self, other: ArrayLike) -> matrix[Any, Any]: ...
  3585. def __imul__(self, other: ArrayLike) -> matrix[_ShapeType, _DType_co]: ...
  3586. def __pow__(self, other: ArrayLike) -> matrix[Any, Any]: ...
  3587. def __ipow__(self, other: ArrayLike) -> matrix[_ShapeType, _DType_co]: ...
  3588. @overload
  3589. def sum(self, axis: None = ..., dtype: DTypeLike = ..., out: None = ...) -> Any: ...
  3590. @overload
  3591. def sum(self, axis: _ShapeLike, dtype: DTypeLike = ..., out: None = ...) -> matrix[Any, Any]: ...
  3592. @overload
  3593. def sum(self, axis: None | _ShapeLike = ..., dtype: DTypeLike = ..., out: _NdArraySubClass = ...) -> _NdArraySubClass: ...
  3594. @overload
  3595. def mean(self, axis: None = ..., dtype: DTypeLike = ..., out: None = ...) -> Any: ...
  3596. @overload
  3597. def mean(self, axis: _ShapeLike, dtype: DTypeLike = ..., out: None = ...) -> matrix[Any, Any]: ...
  3598. @overload
  3599. def mean(self, axis: None | _ShapeLike = ..., dtype: DTypeLike = ..., out: _NdArraySubClass = ...) -> _NdArraySubClass: ...
  3600. @overload
  3601. def std(self, axis: None = ..., dtype: DTypeLike = ..., out: None = ..., ddof: float = ...) -> Any: ...
  3602. @overload
  3603. def std(self, axis: _ShapeLike, dtype: DTypeLike = ..., out: None = ..., ddof: float = ...) -> matrix[Any, Any]: ...
  3604. @overload
  3605. def std(self, axis: None | _ShapeLike = ..., dtype: DTypeLike = ..., out: _NdArraySubClass = ..., ddof: float = ...) -> _NdArraySubClass: ...
  3606. @overload
  3607. def var(self, axis: None = ..., dtype: DTypeLike = ..., out: None = ..., ddof: float = ...) -> Any: ...
  3608. @overload
  3609. def var(self, axis: _ShapeLike, dtype: DTypeLike = ..., out: None = ..., ddof: float = ...) -> matrix[Any, Any]: ...
  3610. @overload
  3611. def var(self, axis: None | _ShapeLike = ..., dtype: DTypeLike = ..., out: _NdArraySubClass = ..., ddof: float = ...) -> _NdArraySubClass: ...
  3612. @overload
  3613. def prod(self, axis: None = ..., dtype: DTypeLike = ..., out: None = ...) -> Any: ...
  3614. @overload
  3615. def prod(self, axis: _ShapeLike, dtype: DTypeLike = ..., out: None = ...) -> matrix[Any, Any]: ...
  3616. @overload
  3617. def prod(self, axis: None | _ShapeLike = ..., dtype: DTypeLike = ..., out: _NdArraySubClass = ...) -> _NdArraySubClass: ...
  3618. @overload
  3619. def any(self, axis: None = ..., out: None = ...) -> bool_: ...
  3620. @overload
  3621. def any(self, axis: _ShapeLike, out: None = ...) -> matrix[Any, dtype[bool_]]: ...
  3622. @overload
  3623. def any(self, axis: None | _ShapeLike = ..., out: _NdArraySubClass = ...) -> _NdArraySubClass: ...
  3624. @overload
  3625. def all(self, axis: None = ..., out: None = ...) -> bool_: ...
  3626. @overload
  3627. def all(self, axis: _ShapeLike, out: None = ...) -> matrix[Any, dtype[bool_]]: ...
  3628. @overload
  3629. def all(self, axis: None | _ShapeLike = ..., out: _NdArraySubClass = ...) -> _NdArraySubClass: ...
  3630. @overload
  3631. def max(self: NDArray[_ScalarType], axis: None = ..., out: None = ...) -> _ScalarType: ...
  3632. @overload
  3633. def max(self, axis: _ShapeLike, out: None = ...) -> matrix[Any, _DType_co]: ...
  3634. @overload
  3635. def max(self, axis: None | _ShapeLike = ..., out: _NdArraySubClass = ...) -> _NdArraySubClass: ...
  3636. @overload
  3637. def min(self: NDArray[_ScalarType], axis: None = ..., out: None = ...) -> _ScalarType: ...
  3638. @overload
  3639. def min(self, axis: _ShapeLike, out: None = ...) -> matrix[Any, _DType_co]: ...
  3640. @overload
  3641. def min(self, axis: None | _ShapeLike = ..., out: _NdArraySubClass = ...) -> _NdArraySubClass: ...
  3642. @overload
  3643. def argmax(self: NDArray[_ScalarType], axis: None = ..., out: None = ...) -> intp: ...
  3644. @overload
  3645. def argmax(self, axis: _ShapeLike, out: None = ...) -> matrix[Any, dtype[intp]]: ...
  3646. @overload
  3647. def argmax(self, axis: None | _ShapeLike = ..., out: _NdArraySubClass = ...) -> _NdArraySubClass: ...
  3648. @overload
  3649. def argmin(self: NDArray[_ScalarType], axis: None = ..., out: None = ...) -> intp: ...
  3650. @overload
  3651. def argmin(self, axis: _ShapeLike, out: None = ...) -> matrix[Any, dtype[intp]]: ...
  3652. @overload
  3653. def argmin(self, axis: None | _ShapeLike = ..., out: _NdArraySubClass = ...) -> _NdArraySubClass: ...
  3654. @overload
  3655. def ptp(self: NDArray[_ScalarType], axis: None = ..., out: None = ...) -> _ScalarType: ...
  3656. @overload
  3657. def ptp(self, axis: _ShapeLike, out: None = ...) -> matrix[Any, _DType_co]: ...
  3658. @overload
  3659. def ptp(self, axis: None | _ShapeLike = ..., out: _NdArraySubClass = ...) -> _NdArraySubClass: ...
  3660. def squeeze(self, axis: None | _ShapeLike = ...) -> matrix[Any, _DType_co]: ...
  3661. def tolist(self: matrix[Any, dtype[_SupportsItem[_T]]]) -> list[list[_T]]: ... # type: ignore[typevar]
  3662. def ravel(self, order: _OrderKACF = ...) -> matrix[Any, _DType_co]: ...
  3663. def flatten(self, order: _OrderKACF = ...) -> matrix[Any, _DType_co]: ...
  3664. @property
  3665. def T(self) -> matrix[Any, _DType_co]: ...
  3666. @property
  3667. def I(self) -> matrix[Any, Any]: ...
  3668. @property
  3669. def A(self) -> ndarray[_ShapeType, _DType_co]: ...
  3670. @property
  3671. def A1(self) -> ndarray[Any, _DType_co]: ...
  3672. @property
  3673. def H(self) -> matrix[Any, _DType_co]: ...
  3674. def getT(self) -> matrix[Any, _DType_co]: ...
  3675. def getI(self) -> matrix[Any, Any]: ...
  3676. def getA(self) -> ndarray[_ShapeType, _DType_co]: ...
  3677. def getA1(self) -> ndarray[Any, _DType_co]: ...
  3678. def getH(self) -> matrix[Any, _DType_co]: ...
  3679. _CharType = TypeVar("_CharType", str_, bytes_)
  3680. _CharDType = TypeVar("_CharDType", dtype[str_], dtype[bytes_])
  3681. _CharArray = chararray[Any, dtype[_CharType]]
  3682. class chararray(ndarray[_ShapeType, _CharDType]):
  3683. @overload
  3684. def __new__(
  3685. subtype,
  3686. shape: _ShapeLike,
  3687. itemsize: SupportsIndex | SupportsInt = ...,
  3688. unicode: L[False] = ...,
  3689. buffer: _SupportsBuffer = ...,
  3690. offset: SupportsIndex = ...,
  3691. strides: _ShapeLike = ...,
  3692. order: _OrderKACF = ...,
  3693. ) -> chararray[Any, dtype[bytes_]]: ...
  3694. @overload
  3695. def __new__(
  3696. subtype,
  3697. shape: _ShapeLike,
  3698. itemsize: SupportsIndex | SupportsInt = ...,
  3699. unicode: L[True] = ...,
  3700. buffer: _SupportsBuffer = ...,
  3701. offset: SupportsIndex = ...,
  3702. strides: _ShapeLike = ...,
  3703. order: _OrderKACF = ...,
  3704. ) -> chararray[Any, dtype[str_]]: ...
  3705. def __array_finalize__(self, obj: object) -> None: ...
  3706. def __mul__(self, other: _ArrayLikeInt_co) -> chararray[Any, _CharDType]: ...
  3707. def __rmul__(self, other: _ArrayLikeInt_co) -> chararray[Any, _CharDType]: ...
  3708. def __mod__(self, i: Any) -> chararray[Any, _CharDType]: ...
  3709. @overload
  3710. def __eq__(
  3711. self: _CharArray[str_],
  3712. other: _ArrayLikeStr_co,
  3713. ) -> NDArray[bool_]: ...
  3714. @overload
  3715. def __eq__(
  3716. self: _CharArray[bytes_],
  3717. other: _ArrayLikeBytes_co,
  3718. ) -> NDArray[bool_]: ...
  3719. @overload
  3720. def __ne__(
  3721. self: _CharArray[str_],
  3722. other: _ArrayLikeStr_co,
  3723. ) -> NDArray[bool_]: ...
  3724. @overload
  3725. def __ne__(
  3726. self: _CharArray[bytes_],
  3727. other: _ArrayLikeBytes_co,
  3728. ) -> NDArray[bool_]: ...
  3729. @overload
  3730. def __ge__(
  3731. self: _CharArray[str_],
  3732. other: _ArrayLikeStr_co,
  3733. ) -> NDArray[bool_]: ...
  3734. @overload
  3735. def __ge__(
  3736. self: _CharArray[bytes_],
  3737. other: _ArrayLikeBytes_co,
  3738. ) -> NDArray[bool_]: ...
  3739. @overload
  3740. def __le__(
  3741. self: _CharArray[str_],
  3742. other: _ArrayLikeStr_co,
  3743. ) -> NDArray[bool_]: ...
  3744. @overload
  3745. def __le__(
  3746. self: _CharArray[bytes_],
  3747. other: _ArrayLikeBytes_co,
  3748. ) -> NDArray[bool_]: ...
  3749. @overload
  3750. def __gt__(
  3751. self: _CharArray[str_],
  3752. other: _ArrayLikeStr_co,
  3753. ) -> NDArray[bool_]: ...
  3754. @overload
  3755. def __gt__(
  3756. self: _CharArray[bytes_],
  3757. other: _ArrayLikeBytes_co,
  3758. ) -> NDArray[bool_]: ...
  3759. @overload
  3760. def __lt__(
  3761. self: _CharArray[str_],
  3762. other: _ArrayLikeStr_co,
  3763. ) -> NDArray[bool_]: ...
  3764. @overload
  3765. def __lt__(
  3766. self: _CharArray[bytes_],
  3767. other: _ArrayLikeBytes_co,
  3768. ) -> NDArray[bool_]: ...
  3769. @overload
  3770. def __add__(
  3771. self: _CharArray[str_],
  3772. other: _ArrayLikeStr_co,
  3773. ) -> _CharArray[str_]: ...
  3774. @overload
  3775. def __add__(
  3776. self: _CharArray[bytes_],
  3777. other: _ArrayLikeBytes_co,
  3778. ) -> _CharArray[bytes_]: ...
  3779. @overload
  3780. def __radd__(
  3781. self: _CharArray[str_],
  3782. other: _ArrayLikeStr_co,
  3783. ) -> _CharArray[str_]: ...
  3784. @overload
  3785. def __radd__(
  3786. self: _CharArray[bytes_],
  3787. other: _ArrayLikeBytes_co,
  3788. ) -> _CharArray[bytes_]: ...
  3789. @overload
  3790. def center(
  3791. self: _CharArray[str_],
  3792. width: _ArrayLikeInt_co,
  3793. fillchar: _ArrayLikeStr_co = ...,
  3794. ) -> _CharArray[str_]: ...
  3795. @overload
  3796. def center(
  3797. self: _CharArray[bytes_],
  3798. width: _ArrayLikeInt_co,
  3799. fillchar: _ArrayLikeBytes_co = ...,
  3800. ) -> _CharArray[bytes_]: ...
  3801. @overload
  3802. def count(
  3803. self: _CharArray[str_],
  3804. sub: _ArrayLikeStr_co,
  3805. start: _ArrayLikeInt_co = ...,
  3806. end: None | _ArrayLikeInt_co = ...,
  3807. ) -> NDArray[int_]: ...
  3808. @overload
  3809. def count(
  3810. self: _CharArray[bytes_],
  3811. sub: _ArrayLikeBytes_co,
  3812. start: _ArrayLikeInt_co = ...,
  3813. end: None | _ArrayLikeInt_co = ...,
  3814. ) -> NDArray[int_]: ...
  3815. def decode(
  3816. self: _CharArray[bytes_],
  3817. encoding: None | str = ...,
  3818. errors: None | str = ...,
  3819. ) -> _CharArray[str_]: ...
  3820. def encode(
  3821. self: _CharArray[str_],
  3822. encoding: None | str = ...,
  3823. errors: None | str = ...,
  3824. ) -> _CharArray[bytes_]: ...
  3825. @overload
  3826. def endswith(
  3827. self: _CharArray[str_],
  3828. suffix: _ArrayLikeStr_co,
  3829. start: _ArrayLikeInt_co = ...,
  3830. end: None | _ArrayLikeInt_co = ...,
  3831. ) -> NDArray[bool_]: ...
  3832. @overload
  3833. def endswith(
  3834. self: _CharArray[bytes_],
  3835. suffix: _ArrayLikeBytes_co,
  3836. start: _ArrayLikeInt_co = ...,
  3837. end: None | _ArrayLikeInt_co = ...,
  3838. ) -> NDArray[bool_]: ...
  3839. def expandtabs(
  3840. self,
  3841. tabsize: _ArrayLikeInt_co = ...,
  3842. ) -> chararray[Any, _CharDType]: ...
  3843. @overload
  3844. def find(
  3845. self: _CharArray[str_],
  3846. sub: _ArrayLikeStr_co,
  3847. start: _ArrayLikeInt_co = ...,
  3848. end: None | _ArrayLikeInt_co = ...,
  3849. ) -> NDArray[int_]: ...
  3850. @overload
  3851. def find(
  3852. self: _CharArray[bytes_],
  3853. sub: _ArrayLikeBytes_co,
  3854. start: _ArrayLikeInt_co = ...,
  3855. end: None | _ArrayLikeInt_co = ...,
  3856. ) -> NDArray[int_]: ...
  3857. @overload
  3858. def index(
  3859. self: _CharArray[str_],
  3860. sub: _ArrayLikeStr_co,
  3861. start: _ArrayLikeInt_co = ...,
  3862. end: None | _ArrayLikeInt_co = ...,
  3863. ) -> NDArray[int_]: ...
  3864. @overload
  3865. def index(
  3866. self: _CharArray[bytes_],
  3867. sub: _ArrayLikeBytes_co,
  3868. start: _ArrayLikeInt_co = ...,
  3869. end: None | _ArrayLikeInt_co = ...,
  3870. ) -> NDArray[int_]: ...
  3871. @overload
  3872. def join(
  3873. self: _CharArray[str_],
  3874. seq: _ArrayLikeStr_co,
  3875. ) -> _CharArray[str_]: ...
  3876. @overload
  3877. def join(
  3878. self: _CharArray[bytes_],
  3879. seq: _ArrayLikeBytes_co,
  3880. ) -> _CharArray[bytes_]: ...
  3881. @overload
  3882. def ljust(
  3883. self: _CharArray[str_],
  3884. width: _ArrayLikeInt_co,
  3885. fillchar: _ArrayLikeStr_co = ...,
  3886. ) -> _CharArray[str_]: ...
  3887. @overload
  3888. def ljust(
  3889. self: _CharArray[bytes_],
  3890. width: _ArrayLikeInt_co,
  3891. fillchar: _ArrayLikeBytes_co = ...,
  3892. ) -> _CharArray[bytes_]: ...
  3893. @overload
  3894. def lstrip(
  3895. self: _CharArray[str_],
  3896. chars: None | _ArrayLikeStr_co = ...,
  3897. ) -> _CharArray[str_]: ...
  3898. @overload
  3899. def lstrip(
  3900. self: _CharArray[bytes_],
  3901. chars: None | _ArrayLikeBytes_co = ...,
  3902. ) -> _CharArray[bytes_]: ...
  3903. @overload
  3904. def partition(
  3905. self: _CharArray[str_],
  3906. sep: _ArrayLikeStr_co,
  3907. ) -> _CharArray[str_]: ...
  3908. @overload
  3909. def partition(
  3910. self: _CharArray[bytes_],
  3911. sep: _ArrayLikeBytes_co,
  3912. ) -> _CharArray[bytes_]: ...
  3913. @overload
  3914. def replace(
  3915. self: _CharArray[str_],
  3916. old: _ArrayLikeStr_co,
  3917. new: _ArrayLikeStr_co,
  3918. count: None | _ArrayLikeInt_co = ...,
  3919. ) -> _CharArray[str_]: ...
  3920. @overload
  3921. def replace(
  3922. self: _CharArray[bytes_],
  3923. old: _ArrayLikeBytes_co,
  3924. new: _ArrayLikeBytes_co,
  3925. count: None | _ArrayLikeInt_co = ...,
  3926. ) -> _CharArray[bytes_]: ...
  3927. @overload
  3928. def rfind(
  3929. self: _CharArray[str_],
  3930. sub: _ArrayLikeStr_co,
  3931. start: _ArrayLikeInt_co = ...,
  3932. end: None | _ArrayLikeInt_co = ...,
  3933. ) -> NDArray[int_]: ...
  3934. @overload
  3935. def rfind(
  3936. self: _CharArray[bytes_],
  3937. sub: _ArrayLikeBytes_co,
  3938. start: _ArrayLikeInt_co = ...,
  3939. end: None | _ArrayLikeInt_co = ...,
  3940. ) -> NDArray[int_]: ...
  3941. @overload
  3942. def rindex(
  3943. self: _CharArray[str_],
  3944. sub: _ArrayLikeStr_co,
  3945. start: _ArrayLikeInt_co = ...,
  3946. end: None | _ArrayLikeInt_co = ...,
  3947. ) -> NDArray[int_]: ...
  3948. @overload
  3949. def rindex(
  3950. self: _CharArray[bytes_],
  3951. sub: _ArrayLikeBytes_co,
  3952. start: _ArrayLikeInt_co = ...,
  3953. end: None | _ArrayLikeInt_co = ...,
  3954. ) -> NDArray[int_]: ...
  3955. @overload
  3956. def rjust(
  3957. self: _CharArray[str_],
  3958. width: _ArrayLikeInt_co,
  3959. fillchar: _ArrayLikeStr_co = ...,
  3960. ) -> _CharArray[str_]: ...
  3961. @overload
  3962. def rjust(
  3963. self: _CharArray[bytes_],
  3964. width: _ArrayLikeInt_co,
  3965. fillchar: _ArrayLikeBytes_co = ...,
  3966. ) -> _CharArray[bytes_]: ...
  3967. @overload
  3968. def rpartition(
  3969. self: _CharArray[str_],
  3970. sep: _ArrayLikeStr_co,
  3971. ) -> _CharArray[str_]: ...
  3972. @overload
  3973. def rpartition(
  3974. self: _CharArray[bytes_],
  3975. sep: _ArrayLikeBytes_co,
  3976. ) -> _CharArray[bytes_]: ...
  3977. @overload
  3978. def rsplit(
  3979. self: _CharArray[str_],
  3980. sep: None | _ArrayLikeStr_co = ...,
  3981. maxsplit: None | _ArrayLikeInt_co = ...,
  3982. ) -> NDArray[object_]: ...
  3983. @overload
  3984. def rsplit(
  3985. self: _CharArray[bytes_],
  3986. sep: None | _ArrayLikeBytes_co = ...,
  3987. maxsplit: None | _ArrayLikeInt_co = ...,
  3988. ) -> NDArray[object_]: ...
  3989. @overload
  3990. def rstrip(
  3991. self: _CharArray[str_],
  3992. chars: None | _ArrayLikeStr_co = ...,
  3993. ) -> _CharArray[str_]: ...
  3994. @overload
  3995. def rstrip(
  3996. self: _CharArray[bytes_],
  3997. chars: None | _ArrayLikeBytes_co = ...,
  3998. ) -> _CharArray[bytes_]: ...
  3999. @overload
  4000. def split(
  4001. self: _CharArray[str_],
  4002. sep: None | _ArrayLikeStr_co = ...,
  4003. maxsplit: None | _ArrayLikeInt_co = ...,
  4004. ) -> NDArray[object_]: ...
  4005. @overload
  4006. def split(
  4007. self: _CharArray[bytes_],
  4008. sep: None | _ArrayLikeBytes_co = ...,
  4009. maxsplit: None | _ArrayLikeInt_co = ...,
  4010. ) -> NDArray[object_]: ...
  4011. def splitlines(self, keepends: None | _ArrayLikeBool_co = ...) -> NDArray[object_]: ...
  4012. @overload
  4013. def startswith(
  4014. self: _CharArray[str_],
  4015. prefix: _ArrayLikeStr_co,
  4016. start: _ArrayLikeInt_co = ...,
  4017. end: None | _ArrayLikeInt_co = ...,
  4018. ) -> NDArray[bool_]: ...
  4019. @overload
  4020. def startswith(
  4021. self: _CharArray[bytes_],
  4022. prefix: _ArrayLikeBytes_co,
  4023. start: _ArrayLikeInt_co = ...,
  4024. end: None | _ArrayLikeInt_co = ...,
  4025. ) -> NDArray[bool_]: ...
  4026. @overload
  4027. def strip(
  4028. self: _CharArray[str_],
  4029. chars: None | _ArrayLikeStr_co = ...,
  4030. ) -> _CharArray[str_]: ...
  4031. @overload
  4032. def strip(
  4033. self: _CharArray[bytes_],
  4034. chars: None | _ArrayLikeBytes_co = ...,
  4035. ) -> _CharArray[bytes_]: ...
  4036. @overload
  4037. def translate(
  4038. self: _CharArray[str_],
  4039. table: _ArrayLikeStr_co,
  4040. deletechars: None | _ArrayLikeStr_co = ...,
  4041. ) -> _CharArray[str_]: ...
  4042. @overload
  4043. def translate(
  4044. self: _CharArray[bytes_],
  4045. table: _ArrayLikeBytes_co,
  4046. deletechars: None | _ArrayLikeBytes_co = ...,
  4047. ) -> _CharArray[bytes_]: ...
  4048. def zfill(self, width: _ArrayLikeInt_co) -> chararray[Any, _CharDType]: ...
  4049. def capitalize(self) -> chararray[_ShapeType, _CharDType]: ...
  4050. def title(self) -> chararray[_ShapeType, _CharDType]: ...
  4051. def swapcase(self) -> chararray[_ShapeType, _CharDType]: ...
  4052. def lower(self) -> chararray[_ShapeType, _CharDType]: ...
  4053. def upper(self) -> chararray[_ShapeType, _CharDType]: ...
  4054. def isalnum(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
  4055. def isalpha(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
  4056. def isdigit(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
  4057. def islower(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
  4058. def isspace(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
  4059. def istitle(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
  4060. def isupper(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
  4061. def isnumeric(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
  4062. def isdecimal(self) -> ndarray[_ShapeType, dtype[bool_]]: ...
  4063. # NOTE: Deprecated
  4064. # class MachAr: ...
  4065. class _SupportsDLPack(Protocol[_T_contra]):
  4066. def __dlpack__(self, *, stream: None | _T_contra = ...) -> _PyCapsule: ...
  4067. def from_dlpack(obj: _SupportsDLPack[None], /) -> NDArray[Any]: ...