__init__.pyi 208 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387
  1. # ruff: noqa: I001
  2. import builtins
  3. import sys
  4. import mmap
  5. import ctypes as ct
  6. import array as _array
  7. import datetime as dt
  8. from abc import abstractmethod
  9. from types import EllipsisType, ModuleType, TracebackType, MappingProxyType, GenericAlias
  10. from decimal import Decimal
  11. from fractions import Fraction
  12. from uuid import UUID
  13. import numpy as np
  14. from numpy.__config__ import show as show_config
  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. _ArrayLike,
  24. _ArrayLikeBool_co,
  25. _ArrayLikeUInt_co,
  26. _ArrayLikeInt,
  27. _ArrayLikeInt_co,
  28. _ArrayLikeFloat64_co,
  29. _ArrayLikeFloat_co,
  30. _ArrayLikeComplex128_co,
  31. _ArrayLikeComplex_co,
  32. _ArrayLikeNumber_co,
  33. _ArrayLikeObject_co,
  34. _ArrayLikeBytes_co,
  35. _ArrayLikeStr_co,
  36. _ArrayLikeString_co,
  37. _ArrayLikeTD64_co,
  38. _ArrayLikeDT64_co,
  39. # DTypes
  40. DTypeLike,
  41. _DTypeLike,
  42. _DTypeLikeVoid,
  43. _VoidDTypeLike,
  44. # Shapes
  45. _AnyShape,
  46. _Shape,
  47. _ShapeLike,
  48. # Scalars
  49. _CharLike_co,
  50. _IntLike_co,
  51. _FloatLike_co,
  52. _TD64Like_co,
  53. _NumberLike_co,
  54. _ScalarLike_co,
  55. # `number` precision
  56. NBitBase,
  57. # NOTE: Do not remove the extended precision bit-types even if seemingly unused;
  58. # they're used by the mypy plugin
  59. _128Bit,
  60. _96Bit,
  61. _64Bit,
  62. _32Bit,
  63. _16Bit,
  64. _8Bit,
  65. _NBitByte,
  66. _NBitShort,
  67. _NBitIntC,
  68. _NBitIntP,
  69. _NBitLong,
  70. _NBitLongLong,
  71. _NBitHalf,
  72. _NBitSingle,
  73. _NBitDouble,
  74. _NBitLongDouble,
  75. # Character codes
  76. _BoolCodes,
  77. _UInt8Codes,
  78. _UInt16Codes,
  79. _UInt32Codes,
  80. _UInt64Codes,
  81. _Int8Codes,
  82. _Int16Codes,
  83. _Int32Codes,
  84. _Int64Codes,
  85. _Float16Codes,
  86. _Float32Codes,
  87. _Float64Codes,
  88. _Complex64Codes,
  89. _Complex128Codes,
  90. _ByteCodes,
  91. _ShortCodes,
  92. _IntCCodes,
  93. _IntPCodes,
  94. _LongCodes,
  95. _LongLongCodes,
  96. _UByteCodes,
  97. _UShortCodes,
  98. _UIntCCodes,
  99. _UIntPCodes,
  100. _ULongCodes,
  101. _ULongLongCodes,
  102. _HalfCodes,
  103. _SingleCodes,
  104. _DoubleCodes,
  105. _LongDoubleCodes,
  106. _CSingleCodes,
  107. _CDoubleCodes,
  108. _CLongDoubleCodes,
  109. _DT64Codes,
  110. _TD64Codes,
  111. _StrCodes,
  112. _BytesCodes,
  113. _VoidCodes,
  114. _ObjectCodes,
  115. _StringCodes,
  116. _UnsignedIntegerCodes,
  117. _SignedIntegerCodes,
  118. _IntegerCodes,
  119. _FloatingCodes,
  120. _ComplexFloatingCodes,
  121. _InexactCodes,
  122. _NumberCodes,
  123. _CharacterCodes,
  124. _FlexibleCodes,
  125. _GenericCodes,
  126. # Ufuncs
  127. _UFunc_Nin1_Nout1,
  128. _UFunc_Nin2_Nout1,
  129. _UFunc_Nin1_Nout2,
  130. _UFunc_Nin2_Nout2,
  131. _GUFunc_Nin2_Nout1,
  132. )
  133. from numpy._typing._callable import (
  134. _BoolOp,
  135. _BoolBitOp,
  136. _BoolSub,
  137. _BoolTrueDiv,
  138. _BoolMod,
  139. _BoolDivMod,
  140. _IntTrueDiv,
  141. _UnsignedIntOp,
  142. _UnsignedIntBitOp,
  143. _UnsignedIntMod,
  144. _UnsignedIntDivMod,
  145. _SignedIntOp,
  146. _SignedIntBitOp,
  147. _SignedIntMod,
  148. _SignedIntDivMod,
  149. _FloatOp,
  150. _FloatMod,
  151. _FloatDivMod,
  152. _NumberOp,
  153. _ComparisonOpLT,
  154. _ComparisonOpLE,
  155. _ComparisonOpGT,
  156. _ComparisonOpGE,
  157. )
  158. # NOTE: Numpy's mypy plugin is used for removing the types unavailable to the specific platform
  159. from numpy._typing._extended_precision import (
  160. float96,
  161. float128,
  162. complex192,
  163. complex256,
  164. )
  165. from numpy._array_api_info import __array_namespace_info__
  166. from collections.abc import (
  167. Callable,
  168. Iterable,
  169. Iterator,
  170. Mapping,
  171. Sequence,
  172. )
  173. if sys.version_info >= (3, 12):
  174. from collections.abc import Buffer as _SupportsBuffer
  175. else:
  176. _SupportsBuffer: TypeAlias = (
  177. bytes
  178. | bytearray
  179. | memoryview
  180. | _array.array[Any]
  181. | mmap.mmap
  182. | NDArray[Any]
  183. | generic
  184. )
  185. from typing import (
  186. Any,
  187. ClassVar,
  188. Final,
  189. Generic,
  190. Literal as L,
  191. LiteralString,
  192. Never,
  193. NoReturn,
  194. Protocol,
  195. Self,
  196. SupportsComplex,
  197. SupportsFloat,
  198. SupportsInt,
  199. SupportsIndex,
  200. TypeAlias,
  201. TypedDict,
  202. final,
  203. overload,
  204. type_check_only,
  205. )
  206. # NOTE: `typing_extensions` and `_typeshed` are always available in `.pyi` stubs, even
  207. # if not available at runtime. This is because the `typeshed` stubs for the standard
  208. # library include `typing_extensions` stubs:
  209. # https://github.com/python/typeshed/blob/main/stdlib/typing_extensions.pyi
  210. from _typeshed import Incomplete, StrOrBytesPath, SupportsFlush, SupportsLenAndGetItem, SupportsWrite
  211. from typing_extensions import CapsuleType, TypeVar
  212. from numpy import (
  213. char,
  214. core,
  215. ctypeslib,
  216. dtypes,
  217. exceptions,
  218. f2py,
  219. fft,
  220. lib,
  221. linalg,
  222. ma,
  223. polynomial,
  224. random,
  225. rec,
  226. strings,
  227. testing,
  228. typing,
  229. )
  230. # available through `__getattr__`, but not in `__all__` or `__dir__`
  231. from numpy import (
  232. __config__ as __config__,
  233. matlib as matlib,
  234. matrixlib as matrixlib,
  235. version as version,
  236. )
  237. if sys.version_info < (3, 12):
  238. from numpy import distutils as distutils
  239. from numpy._core.records import (
  240. record,
  241. recarray,
  242. )
  243. from numpy._core.function_base import (
  244. linspace,
  245. logspace,
  246. geomspace,
  247. )
  248. from numpy._core.fromnumeric import (
  249. take,
  250. reshape,
  251. choose,
  252. repeat,
  253. put,
  254. swapaxes,
  255. transpose,
  256. matrix_transpose,
  257. partition,
  258. argpartition,
  259. sort,
  260. argsort,
  261. argmax,
  262. argmin,
  263. searchsorted,
  264. resize,
  265. squeeze,
  266. diagonal,
  267. trace,
  268. ravel,
  269. nonzero,
  270. shape,
  271. compress,
  272. clip,
  273. sum,
  274. all,
  275. any,
  276. cumsum,
  277. cumulative_sum,
  278. ptp,
  279. max,
  280. min,
  281. amax,
  282. amin,
  283. prod,
  284. cumprod,
  285. cumulative_prod,
  286. ndim,
  287. size,
  288. around,
  289. round,
  290. mean,
  291. std,
  292. var,
  293. )
  294. from numpy._core._asarray import (
  295. require,
  296. )
  297. from numpy._core._type_aliases import (
  298. sctypeDict,
  299. )
  300. from numpy._core._ufunc_config import (
  301. seterr,
  302. geterr,
  303. setbufsize,
  304. getbufsize,
  305. seterrcall,
  306. geterrcall,
  307. _ErrKind,
  308. _ErrCall,
  309. )
  310. from numpy._core.arrayprint import (
  311. set_printoptions,
  312. get_printoptions,
  313. array2string,
  314. format_float_scientific,
  315. format_float_positional,
  316. array_repr,
  317. array_str,
  318. printoptions,
  319. )
  320. from numpy._core.einsumfunc import (
  321. einsum,
  322. einsum_path,
  323. )
  324. from numpy._core.multiarray import (
  325. array,
  326. empty_like,
  327. empty,
  328. zeros,
  329. concatenate,
  330. inner,
  331. where,
  332. lexsort,
  333. can_cast,
  334. min_scalar_type,
  335. result_type,
  336. dot,
  337. vdot,
  338. bincount,
  339. copyto,
  340. putmask,
  341. packbits,
  342. unpackbits,
  343. shares_memory,
  344. may_share_memory,
  345. asarray,
  346. asanyarray,
  347. ascontiguousarray,
  348. asfortranarray,
  349. arange,
  350. busday_count,
  351. busday_offset,
  352. datetime_as_string,
  353. datetime_data,
  354. frombuffer,
  355. fromfile,
  356. fromiter,
  357. is_busday,
  358. promote_types,
  359. fromstring,
  360. frompyfunc,
  361. nested_iters,
  362. flagsobj,
  363. )
  364. from numpy._core.numeric import (
  365. zeros_like,
  366. ones,
  367. ones_like,
  368. full,
  369. full_like,
  370. count_nonzero,
  371. isfortran,
  372. argwhere,
  373. flatnonzero,
  374. correlate,
  375. convolve,
  376. outer,
  377. tensordot,
  378. roll,
  379. rollaxis,
  380. moveaxis,
  381. cross,
  382. indices,
  383. fromfunction,
  384. isscalar,
  385. binary_repr,
  386. base_repr,
  387. identity,
  388. allclose,
  389. isclose,
  390. array_equal,
  391. array_equiv,
  392. astype,
  393. )
  394. from numpy._core.numerictypes import (
  395. isdtype,
  396. issubdtype,
  397. ScalarType,
  398. typecodes,
  399. )
  400. from numpy._core.shape_base import (
  401. atleast_1d,
  402. atleast_2d,
  403. atleast_3d,
  404. block,
  405. hstack,
  406. stack,
  407. vstack,
  408. unstack,
  409. )
  410. from ._expired_attrs_2_0 import __expired_attributes__ as __expired_attributes__
  411. from numpy.lib import (
  412. scimath as emath,
  413. )
  414. from numpy.lib._arraypad_impl import (
  415. pad,
  416. )
  417. from numpy.lib._arraysetops_impl import (
  418. ediff1d,
  419. in1d,
  420. intersect1d,
  421. isin,
  422. setdiff1d,
  423. setxor1d,
  424. union1d,
  425. unique,
  426. unique_all,
  427. unique_counts,
  428. unique_inverse,
  429. unique_values,
  430. )
  431. from numpy.lib._function_base_impl import (
  432. select,
  433. piecewise,
  434. trim_zeros,
  435. copy,
  436. iterable,
  437. percentile,
  438. diff,
  439. gradient,
  440. angle,
  441. unwrap,
  442. sort_complex,
  443. flip,
  444. rot90,
  445. extract,
  446. place,
  447. asarray_chkfinite,
  448. average,
  449. digitize,
  450. cov,
  451. corrcoef,
  452. median,
  453. sinc,
  454. hamming,
  455. hanning,
  456. bartlett,
  457. blackman,
  458. kaiser,
  459. trapezoid,
  460. trapz,
  461. i0,
  462. meshgrid,
  463. delete,
  464. insert,
  465. append,
  466. interp,
  467. quantile,
  468. )
  469. from numpy._globals import _CopyMode
  470. from numpy.lib._histograms_impl import (
  471. histogram_bin_edges,
  472. histogram,
  473. histogramdd,
  474. )
  475. from numpy.lib._index_tricks_impl import (
  476. ndenumerate,
  477. ndindex,
  478. ravel_multi_index,
  479. unravel_index,
  480. mgrid,
  481. ogrid,
  482. r_,
  483. c_,
  484. s_,
  485. index_exp,
  486. ix_,
  487. fill_diagonal,
  488. diag_indices,
  489. diag_indices_from,
  490. )
  491. from numpy.lib._nanfunctions_impl import (
  492. nansum,
  493. nanmax,
  494. nanmin,
  495. nanargmax,
  496. nanargmin,
  497. nanmean,
  498. nanmedian,
  499. nanpercentile,
  500. nanvar,
  501. nanstd,
  502. nanprod,
  503. nancumsum,
  504. nancumprod,
  505. nanquantile,
  506. )
  507. from numpy.lib._npyio_impl import (
  508. savetxt,
  509. loadtxt,
  510. genfromtxt,
  511. load,
  512. save,
  513. savez,
  514. savez_compressed,
  515. fromregex,
  516. )
  517. from numpy.lib._polynomial_impl import (
  518. poly,
  519. roots,
  520. polyint,
  521. polyder,
  522. polyadd,
  523. polysub,
  524. polymul,
  525. polydiv,
  526. polyval,
  527. polyfit,
  528. )
  529. from numpy.lib._shape_base_impl import (
  530. column_stack,
  531. row_stack,
  532. dstack,
  533. array_split,
  534. split,
  535. hsplit,
  536. vsplit,
  537. dsplit,
  538. apply_over_axes,
  539. expand_dims,
  540. apply_along_axis,
  541. kron,
  542. tile,
  543. take_along_axis,
  544. put_along_axis,
  545. )
  546. from numpy.lib._stride_tricks_impl import (
  547. broadcast_to,
  548. broadcast_arrays,
  549. broadcast_shapes,
  550. )
  551. from numpy.lib._twodim_base_impl import (
  552. diag,
  553. diagflat,
  554. eye,
  555. fliplr,
  556. flipud,
  557. tri,
  558. triu,
  559. tril,
  560. vander,
  561. histogram2d,
  562. mask_indices,
  563. tril_indices,
  564. tril_indices_from,
  565. triu_indices,
  566. triu_indices_from,
  567. )
  568. from numpy.lib._type_check_impl import (
  569. mintypecode,
  570. real,
  571. imag,
  572. iscomplex,
  573. isreal,
  574. iscomplexobj,
  575. isrealobj,
  576. nan_to_num,
  577. real_if_close,
  578. typename,
  579. common_type,
  580. )
  581. from numpy.lib._ufunclike_impl import (
  582. fix,
  583. isposinf,
  584. isneginf,
  585. )
  586. from numpy.lib._utils_impl import (
  587. get_include,
  588. info,
  589. show_runtime,
  590. )
  591. from numpy.matrixlib import (
  592. asmatrix,
  593. bmat,
  594. )
  595. __all__ = [ # noqa: RUF022
  596. # __numpy_submodules__
  597. "char", "core", "ctypeslib", "dtypes", "exceptions", "f2py", "fft", "lib", "linalg",
  598. "ma", "polynomial", "random", "rec", "strings", "test", "testing", "typing",
  599. # _core.__all__
  600. "abs", "acos", "acosh", "asin", "asinh", "atan", "atanh", "atan2", "bitwise_invert",
  601. "bitwise_left_shift", "bitwise_right_shift", "concat", "pow", "permute_dims",
  602. "memmap", "sctypeDict", "record", "recarray",
  603. # _core.numeric.__all__
  604. "newaxis", "ndarray", "flatiter", "nditer", "nested_iters", "ufunc", "arange",
  605. "array", "asarray", "asanyarray", "ascontiguousarray", "asfortranarray", "zeros",
  606. "count_nonzero", "empty", "broadcast", "dtype", "fromstring", "fromfile",
  607. "frombuffer", "from_dlpack", "where", "argwhere", "copyto", "concatenate",
  608. "lexsort", "astype", "can_cast", "promote_types", "min_scalar_type", "result_type",
  609. "isfortran", "empty_like", "zeros_like", "ones_like", "correlate", "convolve",
  610. "inner", "dot", "outer", "vdot", "roll", "rollaxis", "moveaxis", "cross",
  611. "tensordot", "little_endian", "fromiter", "array_equal", "array_equiv", "indices",
  612. "fromfunction", "isclose", "isscalar", "binary_repr", "base_repr", "ones",
  613. "identity", "allclose", "putmask", "flatnonzero", "inf", "nan", "False_", "True_",
  614. "bitwise_not", "full", "full_like", "matmul", "vecdot", "vecmat",
  615. "shares_memory", "may_share_memory",
  616. "all", "amax", "amin", "any", "argmax", "argmin", "argpartition", "argsort",
  617. "around", "choose", "clip", "compress", "cumprod", "cumsum", "cumulative_prod",
  618. "cumulative_sum", "diagonal", "mean", "max", "min", "matrix_transpose", "ndim",
  619. "nonzero", "partition", "prod", "ptp", "put", "ravel", "repeat", "reshape",
  620. "resize", "round", "searchsorted", "shape", "size", "sort", "squeeze", "std", "sum",
  621. "swapaxes", "take", "trace", "transpose", "var",
  622. "absolute", "add", "arccos", "arccosh", "arcsin", "arcsinh", "arctan", "arctan2",
  623. "arctanh", "bitwise_and", "bitwise_or", "bitwise_xor", "cbrt", "ceil", "conj",
  624. "conjugate", "copysign", "cos", "cosh", "bitwise_count", "deg2rad", "degrees",
  625. "divide", "divmod", "e", "equal", "euler_gamma", "exp", "exp2", "expm1", "fabs",
  626. "floor", "floor_divide", "float_power", "fmax", "fmin", "fmod", "frexp",
  627. "frompyfunc", "gcd", "greater", "greater_equal", "heaviside", "hypot", "invert",
  628. "isfinite", "isinf", "isnan", "isnat", "lcm", "ldexp", "left_shift", "less",
  629. "less_equal", "log", "log10", "log1p", "log2", "logaddexp", "logaddexp2",
  630. "logical_and", "logical_not", "logical_or", "logical_xor", "matvec", "maximum", "minimum",
  631. "mod", "modf", "multiply", "negative", "nextafter", "not_equal", "pi", "positive",
  632. "power", "rad2deg", "radians", "reciprocal", "remainder", "right_shift", "rint",
  633. "sign", "signbit", "sin", "sinh", "spacing", "sqrt", "square", "subtract", "tan",
  634. "tanh", "true_divide", "trunc", "ScalarType", "typecodes", "issubdtype",
  635. "datetime_data", "datetime_as_string", "busday_offset", "busday_count", "is_busday",
  636. "busdaycalendar", "isdtype",
  637. "complexfloating", "character", "unsignedinteger", "inexact", "generic", "floating",
  638. "integer", "signedinteger", "number", "flexible", "bool", "float16", "float32",
  639. "float64", "longdouble", "complex64", "complex128", "clongdouble",
  640. "bytes_", "str_", "void", "object_", "datetime64", "timedelta64", "int8", "byte",
  641. "uint8", "ubyte", "int16", "short", "uint16", "ushort", "int32", "intc", "uint32",
  642. "uintc", "int64", "long", "uint64", "ulong", "longlong", "ulonglong", "intp",
  643. "uintp", "double", "cdouble", "single", "csingle", "half", "bool_", "int_", "uint",
  644. "float96", "float128", "complex192", "complex256",
  645. "array2string", "array_str", "array_repr", "set_printoptions", "get_printoptions",
  646. "printoptions", "format_float_positional", "format_float_scientific", "require",
  647. "seterr", "geterr", "setbufsize", "getbufsize", "seterrcall", "geterrcall",
  648. "errstate",
  649. # _core.function_base.__all__
  650. "logspace", "linspace", "geomspace",
  651. # _core.getlimits.__all__
  652. "finfo", "iinfo",
  653. # _core.shape_base.__all__
  654. "atleast_1d", "atleast_2d", "atleast_3d", "block", "hstack", "stack", "unstack",
  655. "vstack",
  656. # _core.einsumfunc.__all__
  657. "einsum", "einsum_path",
  658. # matrixlib.__all__
  659. "matrix", "bmat", "asmatrix",
  660. # lib._histograms_impl.__all__
  661. "histogram", "histogramdd", "histogram_bin_edges",
  662. # lib._nanfunctions_impl.__all__
  663. "nansum", "nanmax", "nanmin", "nanargmax", "nanargmin", "nanmean", "nanmedian",
  664. "nanpercentile", "nanvar", "nanstd", "nanprod", "nancumsum", "nancumprod",
  665. "nanquantile",
  666. # lib._function_base_impl.__all__
  667. "select", "piecewise", "trim_zeros", "copy", "iterable", "percentile", "diff",
  668. "gradient", "angle", "unwrap", "sort_complex", "flip", "rot90", "extract", "place",
  669. "vectorize", "asarray_chkfinite", "average", "bincount", "digitize", "cov",
  670. "corrcoef", "median", "sinc", "hamming", "hanning", "bartlett", "blackman",
  671. "kaiser", "trapezoid", "trapz", "i0", "meshgrid", "delete", "insert", "append",
  672. "interp", "quantile",
  673. # lib._twodim_base_impl.__all__
  674. "diag", "diagflat", "eye", "fliplr", "flipud", "tri", "triu", "tril", "vander",
  675. "histogram2d", "mask_indices", "tril_indices", "tril_indices_from", "triu_indices",
  676. "triu_indices_from",
  677. # lib._shape_base_impl.__all__
  678. "column_stack", "dstack", "array_split", "split", "hsplit", "vsplit", "dsplit",
  679. "apply_over_axes", "expand_dims", "apply_along_axis", "kron", "tile",
  680. "take_along_axis", "put_along_axis", "row_stack",
  681. # lib._type_check_impl.__all__
  682. "iscomplexobj", "isrealobj", "imag", "iscomplex", "isreal", "nan_to_num", "real",
  683. "real_if_close", "typename", "mintypecode", "common_type",
  684. # lib._arraysetops_impl.__all__
  685. "ediff1d", "in1d", "intersect1d", "isin", "setdiff1d", "setxor1d", "union1d",
  686. "unique", "unique_all", "unique_counts", "unique_inverse", "unique_values",
  687. # lib._ufunclike_impl.__all__
  688. "fix", "isneginf", "isposinf",
  689. # lib._arraypad_impl.__all__
  690. "pad",
  691. # lib._utils_impl.__all__
  692. "get_include", "info", "show_runtime",
  693. # lib._stride_tricks_impl.__all__
  694. "broadcast_to", "broadcast_arrays", "broadcast_shapes",
  695. # lib._polynomial_impl.__all__
  696. "poly", "roots", "polyint", "polyder", "polyadd", "polysub", "polymul", "polydiv",
  697. "polyval", "poly1d", "polyfit",
  698. # lib._npyio_impl.__all__
  699. "savetxt", "loadtxt", "genfromtxt", "load", "save", "savez", "savez_compressed",
  700. "packbits", "unpackbits", "fromregex",
  701. # lib._index_tricks_impl.__all__
  702. "ravel_multi_index", "unravel_index", "mgrid", "ogrid", "r_", "c_", "s_",
  703. "index_exp", "ix_", "ndenumerate", "ndindex", "fill_diagonal", "diag_indices",
  704. "diag_indices_from",
  705. # __init__.__all__
  706. "emath", "show_config", "__version__", "__array_namespace_info__",
  707. ] # fmt: skip
  708. ### Constrained types (for internal use only)
  709. # Only use these for functions; never as generic type parameter.
  710. _AnyStr = TypeVar("_AnyStr", LiteralString, str, bytes)
  711. _AnyShapeT = TypeVar(
  712. "_AnyShapeT",
  713. tuple[()], # 0-d
  714. tuple[int], # 1-d
  715. tuple[int, int], # 2-d
  716. tuple[int, int, int], # 3-d
  717. tuple[int, int, int, int], # 4-d
  718. tuple[int, int, int, int, int], # 5-d
  719. tuple[int, int, int, int, int, int], # 6-d
  720. tuple[int, int, int, int, int, int, int], # 7-d
  721. tuple[int, int, int, int, int, int, int, int], # 8-d
  722. tuple[int, ...], # N-d
  723. )
  724. _AnyTD64Item = TypeVar("_AnyTD64Item", dt.timedelta, int, None, dt.timedelta | int | None)
  725. _AnyDT64Arg = TypeVar("_AnyDT64Arg", dt.datetime, dt.date, None)
  726. _AnyDT64Item = TypeVar("_AnyDT64Item", dt.datetime, dt.date, int, None, dt.date, int | None)
  727. _AnyDate = TypeVar("_AnyDate", dt.date, dt.datetime)
  728. _AnyDateOrTime = TypeVar("_AnyDateOrTime", dt.date, dt.datetime, dt.timedelta)
  729. ### Type parameters (for internal use only)
  730. _T = TypeVar("_T")
  731. _T_co = TypeVar("_T_co", covariant=True)
  732. _T_contra = TypeVar("_T_contra", contravariant=True)
  733. _RealT_co = TypeVar("_RealT_co", covariant=True)
  734. _ImagT_co = TypeVar("_ImagT_co", covariant=True)
  735. _CallableT = TypeVar("_CallableT", bound=Callable[..., object])
  736. _DTypeT = TypeVar("_DTypeT", bound=dtype)
  737. _DTypeT_co = TypeVar("_DTypeT_co", bound=dtype, default=dtype, covariant=True)
  738. _FlexDTypeT = TypeVar("_FlexDTypeT", bound=dtype[flexible])
  739. _ArrayT = TypeVar("_ArrayT", bound=ndarray)
  740. _ArrayT_co = TypeVar("_ArrayT_co", bound=ndarray, default=ndarray, covariant=True)
  741. _IntegralArrayT = TypeVar("_IntegralArrayT", bound=NDArray[integer | np.bool | object_])
  742. _RealArrayT = TypeVar("_RealArrayT", bound=NDArray[floating | integer | timedelta64 | np.bool | object_])
  743. _NumericArrayT = TypeVar("_NumericArrayT", bound=NDArray[number | timedelta64 | object_])
  744. _ShapeT = TypeVar("_ShapeT", bound=_Shape)
  745. _ShapeT_co = TypeVar("_ShapeT_co", bound=_Shape, default=_AnyShape, covariant=True)
  746. _1DShapeT = TypeVar("_1DShapeT", bound=_1D)
  747. _2DShapeT_co = TypeVar("_2DShapeT_co", bound=_2D, default=_2D, covariant=True)
  748. _1NShapeT = TypeVar("_1NShapeT", bound=tuple[L[1], *tuple[L[1], ...]]) # (1,) | (1, 1) | (1, 1, 1) | ...
  749. _ScalarT = TypeVar("_ScalarT", bound=generic)
  750. _ScalarT_co = TypeVar("_ScalarT_co", bound=generic, default=Any, covariant=True)
  751. _NumberT = TypeVar("_NumberT", bound=number)
  752. _RealNumberT = TypeVar("_RealNumberT", bound=floating | integer)
  753. _FloatingT_co = TypeVar("_FloatingT_co", bound=floating, default=floating, covariant=True)
  754. _IntegerT = TypeVar("_IntegerT", bound=integer)
  755. _IntegerT_co = TypeVar("_IntegerT_co", bound=integer, default=integer, covariant=True)
  756. _NonObjectScalarT = TypeVar("_NonObjectScalarT", bound=np.bool | number | flexible | datetime64 | timedelta64)
  757. _NBit = TypeVar("_NBit", bound=NBitBase, default=Any) # pyright: ignore[reportDeprecated]
  758. _NBit1 = TypeVar("_NBit1", bound=NBitBase, default=Any) # pyright: ignore[reportDeprecated]
  759. _NBit2 = TypeVar("_NBit2", bound=NBitBase, default=_NBit1) # pyright: ignore[reportDeprecated]
  760. _ItemT_co = TypeVar("_ItemT_co", default=Any, covariant=True)
  761. _BoolItemT = TypeVar("_BoolItemT", bound=builtins.bool)
  762. _BoolItemT_co = TypeVar("_BoolItemT_co", bound=builtins.bool, default=builtins.bool, covariant=True)
  763. _NumberItemT_co = TypeVar("_NumberItemT_co", bound=complex, default=int | float | complex, covariant=True)
  764. _InexactItemT_co = TypeVar("_InexactItemT_co", bound=complex, default=float | complex, covariant=True)
  765. _FlexibleItemT_co = TypeVar(
  766. "_FlexibleItemT_co",
  767. bound=_CharLike_co | tuple[Any, ...],
  768. default=_CharLike_co | tuple[Any, ...],
  769. covariant=True,
  770. )
  771. _CharacterItemT_co = TypeVar("_CharacterItemT_co", bound=_CharLike_co, default=_CharLike_co, covariant=True)
  772. _TD64ItemT_co = TypeVar("_TD64ItemT_co", bound=dt.timedelta | int | None, default=dt.timedelta | int | None, covariant=True)
  773. _DT64ItemT_co = TypeVar("_DT64ItemT_co", bound=dt.date | int | None, default=dt.date | int | None, covariant=True)
  774. _TD64UnitT = TypeVar("_TD64UnitT", bound=_TD64Unit, default=_TD64Unit)
  775. _BoolOrIntArrayT = TypeVar("_BoolOrIntArrayT", bound=NDArray[integer | np.bool])
  776. ### Type Aliases (for internal use only)
  777. _Falsy: TypeAlias = L[False, 0] | np.bool[L[False]]
  778. _Truthy: TypeAlias = L[True, 1] | np.bool[L[True]]
  779. _1D: TypeAlias = tuple[int]
  780. _2D: TypeAlias = tuple[int, int]
  781. _2Tuple: TypeAlias = tuple[_T, _T]
  782. _ArrayUInt_co: TypeAlias = NDArray[unsignedinteger | np.bool]
  783. _ArrayInt_co: TypeAlias = NDArray[integer | np.bool]
  784. _ArrayFloat64_co: TypeAlias = NDArray[floating[_64Bit] | float32 | float16 | integer | np.bool]
  785. _ArrayFloat_co: TypeAlias = NDArray[floating | integer | np.bool]
  786. _ArrayComplex128_co: TypeAlias = NDArray[number[_64Bit] | number[_32Bit] | float16 | integer | np.bool]
  787. _ArrayComplex_co: TypeAlias = NDArray[inexact | integer | np.bool]
  788. _ArrayNumber_co: TypeAlias = NDArray[number | np.bool]
  789. _ArrayTD64_co: TypeAlias = NDArray[timedelta64 | integer | np.bool]
  790. _Float64_co: TypeAlias = float | floating[_64Bit] | float32 | float16 | integer | np.bool
  791. _Complex64_co: TypeAlias = number[_32Bit] | number[_16Bit] | number[_8Bit] | builtins.bool | np.bool
  792. _Complex128_co: TypeAlias = complex | number[_64Bit] | _Complex64_co
  793. _ToIndex: TypeAlias = SupportsIndex | slice | EllipsisType | _ArrayLikeInt_co | None
  794. _ToIndices: TypeAlias = _ToIndex | tuple[_ToIndex, ...]
  795. _UnsignedIntegerCType: TypeAlias = type[
  796. ct.c_uint8 | ct.c_uint16 | ct.c_uint32 | ct.c_uint64
  797. | ct.c_ushort | ct.c_uint | ct.c_ulong | ct.c_ulonglong
  798. | ct.c_size_t | ct.c_void_p
  799. ] # fmt: skip
  800. _SignedIntegerCType: TypeAlias = type[
  801. ct.c_int8 | ct.c_int16 | ct.c_int32 | ct.c_int64
  802. | ct.c_short | ct.c_int | ct.c_long | ct.c_longlong
  803. | ct.c_ssize_t
  804. ] # fmt: skip
  805. _FloatingCType: TypeAlias = type[ct.c_float | ct.c_double | ct.c_longdouble]
  806. _IntegerCType: TypeAlias = _UnsignedIntegerCType | _SignedIntegerCType
  807. _NumberCType: TypeAlias = _IntegerCType
  808. _GenericCType: TypeAlias = _NumberCType | type[ct.c_bool | ct.c_char | ct.py_object[Any]]
  809. # some commonly used builtin types that are known to result in a
  810. # `dtype[object_]`, when their *type* is passed to the `dtype` constructor
  811. # NOTE: `builtins.object` should not be included here
  812. _BuiltinObjectLike: TypeAlias = (
  813. slice | Decimal | Fraction | UUID
  814. | dt.date | dt.time | dt.timedelta | dt.tzinfo
  815. | tuple[Any, ...] | list[Any] | set[Any] | frozenset[Any] | dict[Any, Any]
  816. ) # fmt: skip
  817. # Introduce an alias for `dtype` to avoid naming conflicts.
  818. _dtype: TypeAlias = dtype[_ScalarT]
  819. _ByteOrderChar: TypeAlias = L["<", ">", "=", "|"]
  820. # can be anything, is case-insensitive, and only the first character matters
  821. _ByteOrder: TypeAlias = L[
  822. "S", # swap the current order (default)
  823. "<", "L", "little", # little-endian
  824. ">", "B", "big", # big endian
  825. "=", "N", "native", # native order
  826. "|", "I", # ignore
  827. ] # fmt: skip
  828. _DTypeKind: TypeAlias = L[
  829. "b", # boolean
  830. "i", # signed integer
  831. "u", # unsigned integer
  832. "f", # floating-point
  833. "c", # complex floating-point
  834. "m", # timedelta64
  835. "M", # datetime64
  836. "O", # python object
  837. "S", # byte-string (fixed-width)
  838. "U", # unicode-string (fixed-width)
  839. "V", # void
  840. "T", # unicode-string (variable-width)
  841. ]
  842. _DTypeChar: TypeAlias = L[
  843. "?", # bool
  844. "b", # byte
  845. "B", # ubyte
  846. "h", # short
  847. "H", # ushort
  848. "i", # intc
  849. "I", # uintc
  850. "l", # long
  851. "L", # ulong
  852. "q", # longlong
  853. "Q", # ulonglong
  854. "e", # half
  855. "f", # single
  856. "d", # double
  857. "g", # longdouble
  858. "F", # csingle
  859. "D", # cdouble
  860. "G", # clongdouble
  861. "O", # object
  862. "S", # bytes_ (S0)
  863. "a", # bytes_ (deprecated)
  864. "U", # str_
  865. "V", # void
  866. "M", # datetime64
  867. "m", # timedelta64
  868. "c", # bytes_ (S1)
  869. "T", # StringDType
  870. ]
  871. _DTypeNum: TypeAlias = L[
  872. 0, # bool
  873. 1, # byte
  874. 2, # ubyte
  875. 3, # short
  876. 4, # ushort
  877. 5, # intc
  878. 6, # uintc
  879. 7, # long
  880. 8, # ulong
  881. 9, # longlong
  882. 10, # ulonglong
  883. 23, # half
  884. 11, # single
  885. 12, # double
  886. 13, # longdouble
  887. 14, # csingle
  888. 15, # cdouble
  889. 16, # clongdouble
  890. 17, # object
  891. 18, # bytes_
  892. 19, # str_
  893. 20, # void
  894. 21, # datetime64
  895. 22, # timedelta64
  896. 25, # no type
  897. 256, # user-defined
  898. 2056, # StringDType
  899. ]
  900. _DTypeBuiltinKind: TypeAlias = L[0, 1, 2]
  901. _ArrayAPIVersion: TypeAlias = L["2021.12", "2022.12", "2023.12", "2024.12"]
  902. _CastingKind: TypeAlias = L["no", "equiv", "safe", "same_kind", "unsafe"]
  903. _OrderKACF: TypeAlias = L["K", "A", "C", "F"] | None
  904. _OrderACF: TypeAlias = L["A", "C", "F"] | None
  905. _OrderCF: TypeAlias = L["C", "F"] | None
  906. _ModeKind: TypeAlias = L["raise", "wrap", "clip"]
  907. _PartitionKind: TypeAlias = L["introselect"]
  908. # in practice, only the first case-insensitive character is considered (so e.g.
  909. # "QuantumSort3000" will be interpreted as quicksort).
  910. _SortKind: TypeAlias = L[
  911. "Q", "quick", "quicksort",
  912. "M", "merge", "mergesort",
  913. "H", "heap", "heapsort",
  914. "S", "stable", "stablesort",
  915. ]
  916. _SortSide: TypeAlias = L["left", "right"]
  917. _ConvertibleToInt: TypeAlias = SupportsInt | SupportsIndex | _CharLike_co
  918. _ConvertibleToFloat: TypeAlias = SupportsFloat | SupportsIndex | _CharLike_co
  919. _ConvertibleToComplex: TypeAlias = SupportsComplex | SupportsFloat | SupportsIndex | _CharLike_co
  920. _ConvertibleToTD64: TypeAlias = dt.timedelta | int | _CharLike_co | character | number | timedelta64 | np.bool | None
  921. _ConvertibleToDT64: TypeAlias = dt.date | int | _CharLike_co | character | number | datetime64 | np.bool | None
  922. _NDIterFlagsKind: TypeAlias = L[
  923. "buffered",
  924. "c_index",
  925. "copy_if_overlap",
  926. "common_dtype",
  927. "delay_bufalloc",
  928. "external_loop",
  929. "f_index",
  930. "grow_inner", "growinner",
  931. "multi_index",
  932. "ranged",
  933. "refs_ok",
  934. "reduce_ok",
  935. "zerosize_ok",
  936. ]
  937. _NDIterFlagsOp: TypeAlias = L[
  938. "aligned",
  939. "allocate",
  940. "arraymask",
  941. "copy",
  942. "config",
  943. "nbo",
  944. "no_subtype",
  945. "no_broadcast",
  946. "overlap_assume_elementwise",
  947. "readonly",
  948. "readwrite",
  949. "updateifcopy",
  950. "virtual",
  951. "writeonly",
  952. "writemasked"
  953. ]
  954. _MemMapModeKind: TypeAlias = L[
  955. "readonly", "r",
  956. "copyonwrite", "c",
  957. "readwrite", "r+",
  958. "write", "w+",
  959. ]
  960. _DT64Date: TypeAlias = _HasDateAttributes | L["TODAY", "today", b"TODAY", b"today"]
  961. _DT64Now: TypeAlias = L["NOW", "now", b"NOW", b"now"]
  962. _NaTValue: TypeAlias = L["NAT", "NaT", "nat", b"NAT", b"NaT", b"nat"]
  963. _MonthUnit: TypeAlias = L["Y", "M", b"Y", b"M"]
  964. _DayUnit: TypeAlias = L["W", "D", b"W", b"D"]
  965. _DateUnit: TypeAlias = L[_MonthUnit, _DayUnit]
  966. _NativeTimeUnit: TypeAlias = L["h", "m", "s", "ms", "us", "μs", b"h", b"m", b"s", b"ms", b"us"]
  967. _IntTimeUnit: TypeAlias = L["ns", "ps", "fs", "as", b"ns", b"ps", b"fs", b"as"]
  968. _TimeUnit: TypeAlias = L[_NativeTimeUnit, _IntTimeUnit]
  969. _NativeTD64Unit: TypeAlias = L[_DayUnit, _NativeTimeUnit]
  970. _IntTD64Unit: TypeAlias = L[_MonthUnit, _IntTimeUnit]
  971. _TD64Unit: TypeAlias = L[_DateUnit, _TimeUnit]
  972. _TimeUnitSpec: TypeAlias = _TD64UnitT | tuple[_TD64UnitT, SupportsIndex]
  973. ### TypedDict's (for internal use only)
  974. @type_check_only
  975. class _FormerAttrsDict(TypedDict):
  976. object: LiteralString
  977. float: LiteralString
  978. complex: LiteralString
  979. str: LiteralString
  980. int: LiteralString
  981. ### Protocols (for internal use only)
  982. @type_check_only
  983. class _SupportsFileMethods(SupportsFlush, Protocol):
  984. # Protocol for representing file-like-objects accepted by `ndarray.tofile` and `fromfile`
  985. def fileno(self) -> SupportsIndex: ...
  986. def tell(self) -> SupportsIndex: ...
  987. def seek(self, offset: int, whence: int, /) -> object: ...
  988. @type_check_only
  989. class _SupportsFileMethodsRW(SupportsWrite[bytes], _SupportsFileMethods, Protocol): ...
  990. @type_check_only
  991. class _SupportsItem(Protocol[_T_co]):
  992. def item(self, /) -> _T_co: ...
  993. @type_check_only
  994. class _SupportsDLPack(Protocol[_T_contra]):
  995. def __dlpack__(self, /, *, stream: _T_contra | None = None) -> CapsuleType: ...
  996. @type_check_only
  997. class _HasDType(Protocol[_T_co]):
  998. @property
  999. def dtype(self, /) -> _T_co: ...
  1000. @type_check_only
  1001. class _HasRealAndImag(Protocol[_RealT_co, _ImagT_co]):
  1002. @property
  1003. def real(self, /) -> _RealT_co: ...
  1004. @property
  1005. def imag(self, /) -> _ImagT_co: ...
  1006. @type_check_only
  1007. class _HasTypeWithRealAndImag(Protocol[_RealT_co, _ImagT_co]):
  1008. @property
  1009. def type(self, /) -> type[_HasRealAndImag[_RealT_co, _ImagT_co]]: ...
  1010. @type_check_only
  1011. class _HasDTypeWithRealAndImag(Protocol[_RealT_co, _ImagT_co]):
  1012. @property
  1013. def dtype(self, /) -> _HasTypeWithRealAndImag[_RealT_co, _ImagT_co]: ...
  1014. @type_check_only
  1015. class _HasDateAttributes(Protocol):
  1016. # The `datetime64` constructors requires an object with the three attributes below,
  1017. # and thus supports datetime duck typing
  1018. @property
  1019. def day(self) -> int: ...
  1020. @property
  1021. def month(self) -> int: ...
  1022. @property
  1023. def year(self) -> int: ...
  1024. ### Mixins (for internal use only)
  1025. @type_check_only
  1026. class _RealMixin:
  1027. @property
  1028. def real(self) -> Self: ...
  1029. @property
  1030. def imag(self) -> Self: ...
  1031. @type_check_only
  1032. class _RoundMixin:
  1033. @overload
  1034. def __round__(self, /, ndigits: None = None) -> int: ...
  1035. @overload
  1036. def __round__(self, /, ndigits: SupportsIndex) -> Self: ...
  1037. @type_check_only
  1038. class _IntegralMixin(_RealMixin):
  1039. @property
  1040. def numerator(self) -> Self: ...
  1041. @property
  1042. def denominator(self) -> L[1]: ...
  1043. def is_integer(self, /) -> L[True]: ...
  1044. ### Public API
  1045. __version__: Final[LiteralString] = ...
  1046. e: Final[float] = ...
  1047. euler_gamma: Final[float] = ...
  1048. pi: Final[float] = ...
  1049. inf: Final[float] = ...
  1050. nan: Final[float] = ...
  1051. little_endian: Final[builtins.bool] = ...
  1052. False_: Final[np.bool[L[False]]] = ...
  1053. True_: Final[np.bool[L[True]]] = ...
  1054. newaxis: Final[None] = None
  1055. # not in __all__
  1056. __NUMPY_SETUP__: Final[L[False]] = False
  1057. __numpy_submodules__: Final[set[LiteralString]] = ...
  1058. __former_attrs__: Final[_FormerAttrsDict] = ...
  1059. __future_scalars__: Final[set[L["bytes", "str", "object"]]] = ...
  1060. __array_api_version__: Final[L["2024.12"]] = "2024.12"
  1061. test: Final[PytestTester] = ...
  1062. @type_check_only
  1063. class _DTypeMeta(type):
  1064. @property
  1065. def type(cls, /) -> type[generic] | None: ...
  1066. @property
  1067. def _abstract(cls, /) -> bool: ...
  1068. @property
  1069. def _is_numeric(cls, /) -> bool: ...
  1070. @property
  1071. def _parametric(cls, /) -> bool: ...
  1072. @property
  1073. def _legacy(cls, /) -> bool: ...
  1074. @final
  1075. class dtype(Generic[_ScalarT_co], metaclass=_DTypeMeta):
  1076. names: tuple[builtins.str, ...] | None
  1077. def __hash__(self) -> int: ...
  1078. # `None` results in the default dtype
  1079. @overload
  1080. def __new__(
  1081. cls,
  1082. dtype: type[float64] | None,
  1083. align: builtins.bool = ...,
  1084. copy: builtins.bool = ...,
  1085. metadata: dict[builtins.str, Any] = ...
  1086. ) -> dtype[float64]: ...
  1087. # Overload for `dtype` instances, scalar types, and instances that have a
  1088. # `dtype: dtype[_ScalarT]` attribute
  1089. @overload
  1090. def __new__(
  1091. cls,
  1092. dtype: _DTypeLike[_ScalarT],
  1093. align: builtins.bool = ...,
  1094. copy: builtins.bool = ...,
  1095. metadata: dict[builtins.str, Any] = ...,
  1096. ) -> dtype[_ScalarT]: ...
  1097. # Builtin types
  1098. #
  1099. # NOTE: Typecheckers act as if `bool <: int <: float <: complex <: object`,
  1100. # even though at runtime `int`, `float`, and `complex` aren't subtypes..
  1101. # This makes it impossible to express e.g. "a float that isn't an int",
  1102. # since type checkers treat `_: float` like `_: float | int`.
  1103. #
  1104. # For more details, see:
  1105. # - https://github.com/numpy/numpy/issues/27032#issuecomment-2278958251
  1106. # - https://typing.readthedocs.io/en/latest/spec/special-types.html#special-cases-for-float-and-complex
  1107. @overload
  1108. def __new__(
  1109. cls,
  1110. dtype: type[builtins.bool | np.bool],
  1111. align: builtins.bool = ...,
  1112. copy: builtins.bool = ...,
  1113. metadata: dict[str, Any] = ...,
  1114. ) -> dtype[np.bool]: ...
  1115. # NOTE: `_: type[int]` also accepts `type[int | bool]`
  1116. @overload
  1117. def __new__(
  1118. cls,
  1119. dtype: type[int | int_ | np.bool],
  1120. align: builtins.bool = ...,
  1121. copy: builtins.bool = ...,
  1122. metadata: dict[str, Any] = ...,
  1123. ) -> dtype[int_ | np.bool]: ...
  1124. # NOTE: `_: type[float]` also accepts `type[float | int | bool]`
  1125. # NOTE: `float64` inherits from `float` at runtime; but this isn't
  1126. # reflected in these stubs. So an explicit `float64` is required here.
  1127. @overload
  1128. def __new__(
  1129. cls,
  1130. dtype: type[float | float64 | int_ | np.bool] | None,
  1131. align: builtins.bool = ...,
  1132. copy: builtins.bool = ...,
  1133. metadata: dict[str, Any] = ...,
  1134. ) -> dtype[float64 | int_ | np.bool]: ...
  1135. # NOTE: `_: type[complex]` also accepts `type[complex | float | int | bool]`
  1136. @overload
  1137. def __new__(
  1138. cls,
  1139. dtype: type[complex | complex128 | float64 | int_ | np.bool],
  1140. align: builtins.bool = ...,
  1141. copy: builtins.bool = ...,
  1142. metadata: dict[str, Any] = ...,
  1143. ) -> dtype[complex128 | float64 | int_ | np.bool]: ...
  1144. @overload
  1145. def __new__(
  1146. cls,
  1147. dtype: type[bytes], # also includes `type[bytes_]`
  1148. align: builtins.bool = ...,
  1149. copy: builtins.bool = ...,
  1150. metadata: dict[str, Any] = ...,
  1151. ) -> dtype[bytes_]: ...
  1152. @overload
  1153. def __new__(
  1154. cls,
  1155. dtype: type[str], # also includes `type[str_]`
  1156. align: builtins.bool = ...,
  1157. copy: builtins.bool = ...,
  1158. metadata: dict[str, Any] = ...,
  1159. ) -> dtype[str_]: ...
  1160. # NOTE: These `memoryview` overloads assume PEP 688, which requires mypy to
  1161. # be run with the (undocumented) `--disable-memoryview-promotion` flag,
  1162. # This will be the default in a future mypy release, see:
  1163. # https://github.com/python/mypy/issues/15313
  1164. # Pyright / Pylance requires setting `disableBytesTypePromotions=true`,
  1165. # which is the default in strict mode
  1166. @overload
  1167. def __new__(
  1168. cls,
  1169. dtype: type[memoryview | void],
  1170. align: builtins.bool = ...,
  1171. copy: builtins.bool = ...,
  1172. metadata: dict[str, Any] = ...,
  1173. ) -> dtype[void]: ...
  1174. # NOTE: `_: type[object]` would also accept e.g. `type[object | complex]`,
  1175. # and is therefore not included here
  1176. @overload
  1177. def __new__(
  1178. cls,
  1179. dtype: type[_BuiltinObjectLike | object_],
  1180. align: builtins.bool = ...,
  1181. copy: builtins.bool = ...,
  1182. metadata: dict[str, Any] = ...,
  1183. ) -> dtype[object_]: ...
  1184. # Unions of builtins.
  1185. @overload
  1186. def __new__(
  1187. cls,
  1188. dtype: type[bytes | str],
  1189. align: builtins.bool = ...,
  1190. copy: builtins.bool = ...,
  1191. metadata: dict[str, Any] = ...,
  1192. ) -> dtype[character]: ...
  1193. @overload
  1194. def __new__(
  1195. cls,
  1196. dtype: type[bytes | str | memoryview],
  1197. align: builtins.bool = ...,
  1198. copy: builtins.bool = ...,
  1199. metadata: dict[str, Any] = ...,
  1200. ) -> dtype[flexible]: ...
  1201. @overload
  1202. def __new__(
  1203. cls,
  1204. dtype: type[complex | bytes | str | memoryview | _BuiltinObjectLike],
  1205. align: builtins.bool = ...,
  1206. copy: builtins.bool = ...,
  1207. metadata: dict[str, Any] = ...,
  1208. ) -> dtype[np.bool | int_ | float64 | complex128 | flexible | object_]: ...
  1209. # `unsignedinteger` string-based representations and ctypes
  1210. @overload
  1211. def __new__(cls, dtype: _UInt8Codes | type[ct.c_uint8], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[uint8]: ...
  1212. @overload
  1213. def __new__(cls, dtype: _UInt16Codes | type[ct.c_uint16], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[uint16]: ...
  1214. @overload
  1215. def __new__(cls, dtype: _UInt32Codes | type[ct.c_uint32], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[uint32]: ...
  1216. @overload
  1217. def __new__(cls, dtype: _UInt64Codes | type[ct.c_uint64], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[uint64]: ...
  1218. @overload
  1219. def __new__(cls, dtype: _UByteCodes | type[ct.c_ubyte], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[ubyte]: ...
  1220. @overload
  1221. def __new__(cls, dtype: _UShortCodes | type[ct.c_ushort], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[ushort]: ...
  1222. @overload
  1223. def __new__(cls, dtype: _UIntCCodes | type[ct.c_uint], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[uintc]: ...
  1224. # NOTE: We're assuming here that `uint_ptr_t == size_t`,
  1225. # an assumption that does not hold in rare cases (same for `ssize_t`)
  1226. @overload
  1227. def __new__(cls, dtype: _UIntPCodes | type[ct.c_void_p] | type[ct.c_size_t], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[uintp]: ...
  1228. @overload
  1229. def __new__(cls, dtype: _ULongCodes | type[ct.c_ulong], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[ulong]: ...
  1230. @overload
  1231. def __new__(cls, dtype: _ULongLongCodes | type[ct.c_ulonglong], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[ulonglong]: ...
  1232. # `signedinteger` string-based representations and ctypes
  1233. @overload
  1234. def __new__(cls, dtype: _Int8Codes | type[ct.c_int8], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[int8]: ...
  1235. @overload
  1236. def __new__(cls, dtype: _Int16Codes | type[ct.c_int16], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[int16]: ...
  1237. @overload
  1238. def __new__(cls, dtype: _Int32Codes | type[ct.c_int32], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[int32]: ...
  1239. @overload
  1240. def __new__(cls, dtype: _Int64Codes | type[ct.c_int64], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[int64]: ...
  1241. @overload
  1242. def __new__(cls, dtype: _ByteCodes | type[ct.c_byte], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[byte]: ...
  1243. @overload
  1244. def __new__(cls, dtype: _ShortCodes | type[ct.c_short], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[short]: ...
  1245. @overload
  1246. def __new__(cls, dtype: _IntCCodes | type[ct.c_int], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[intc]: ...
  1247. @overload
  1248. def __new__(cls, dtype: _IntPCodes | type[ct.c_ssize_t], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[intp]: ...
  1249. @overload
  1250. def __new__(cls, dtype: _LongCodes | type[ct.c_long], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[long]: ...
  1251. @overload
  1252. def __new__(cls, dtype: _LongLongCodes | type[ct.c_longlong], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[longlong]: ...
  1253. # `floating` string-based representations and ctypes
  1254. @overload
  1255. def __new__(cls, dtype: _Float16Codes, align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[float16]: ...
  1256. @overload
  1257. def __new__(cls, dtype: _Float32Codes, align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[float32]: ...
  1258. @overload
  1259. def __new__(cls, dtype: _Float64Codes, align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[float64]: ...
  1260. @overload
  1261. def __new__(cls, dtype: _HalfCodes, align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[half]: ...
  1262. @overload
  1263. def __new__(cls, dtype: _SingleCodes | type[ct.c_float], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[single]: ...
  1264. @overload
  1265. def __new__(cls, dtype: _DoubleCodes | type[ct.c_double], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[double]: ...
  1266. @overload
  1267. def __new__(cls, dtype: _LongDoubleCodes | type[ct.c_longdouble], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[longdouble]: ...
  1268. # `complexfloating` string-based representations
  1269. @overload
  1270. def __new__(cls, dtype: _Complex64Codes, align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[complex64]: ...
  1271. @overload
  1272. def __new__(cls, dtype: _Complex128Codes, align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[complex128]: ...
  1273. @overload
  1274. def __new__(cls, dtype: _CSingleCodes, align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[csingle]: ...
  1275. @overload
  1276. def __new__(cls, dtype: _CDoubleCodes, align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[cdouble]: ...
  1277. @overload
  1278. def __new__(cls, dtype: _CLongDoubleCodes, align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[clongdouble]: ...
  1279. # Miscellaneous string-based representations and ctypes
  1280. @overload
  1281. def __new__(cls, dtype: _BoolCodes | type[ct.c_bool], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[np.bool]: ...
  1282. @overload
  1283. def __new__(cls, dtype: _TD64Codes, align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[timedelta64]: ...
  1284. @overload
  1285. def __new__(cls, dtype: _DT64Codes, align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[datetime64]: ...
  1286. @overload
  1287. def __new__(cls, dtype: _StrCodes, align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[str_]: ...
  1288. @overload
  1289. def __new__(cls, dtype: _BytesCodes | type[ct.c_char], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[bytes_]: ...
  1290. @overload
  1291. def __new__(cls, dtype: _VoidCodes | _VoidDTypeLike, align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[void]: ...
  1292. @overload
  1293. def __new__(cls, dtype: _ObjectCodes | type[ct.py_object[Any]], align: builtins.bool = ..., copy: builtins.bool = ..., metadata: dict[builtins.str, Any] = ...) -> dtype[object_]: ...
  1294. # `StringDType` requires special treatment because it has no scalar type
  1295. @overload
  1296. def __new__(
  1297. cls,
  1298. dtype: dtypes.StringDType | _StringCodes,
  1299. align: builtins.bool = ...,
  1300. copy: builtins.bool = ...,
  1301. metadata: dict[builtins.str, Any] = ...
  1302. ) -> dtypes.StringDType: ...
  1303. # Combined char-codes and ctypes, analogous to the scalar-type hierarchy
  1304. @overload
  1305. def __new__(
  1306. cls,
  1307. dtype: _UnsignedIntegerCodes | _UnsignedIntegerCType,
  1308. align: builtins.bool = ...,
  1309. copy: builtins.bool = ...,
  1310. metadata: dict[builtins.str, Any] = ...,
  1311. ) -> dtype[unsignedinteger]: ...
  1312. @overload
  1313. def __new__(
  1314. cls,
  1315. dtype: _SignedIntegerCodes | _SignedIntegerCType,
  1316. align: builtins.bool = ...,
  1317. copy: builtins.bool = ...,
  1318. metadata: dict[builtins.str, Any] = ...,
  1319. ) -> dtype[signedinteger]: ...
  1320. @overload
  1321. def __new__(
  1322. cls,
  1323. dtype: _IntegerCodes | _IntegerCType,
  1324. align: builtins.bool = ...,
  1325. copy: builtins.bool = ...,
  1326. metadata: dict[builtins.str, Any] = ...,
  1327. ) -> dtype[integer]: ...
  1328. @overload
  1329. def __new__(
  1330. cls,
  1331. dtype: _FloatingCodes | _FloatingCType,
  1332. align: builtins.bool = ...,
  1333. copy: builtins.bool = ...,
  1334. metadata: dict[builtins.str, Any] = ...,
  1335. ) -> dtype[floating]: ...
  1336. @overload
  1337. def __new__(
  1338. cls,
  1339. dtype: _ComplexFloatingCodes,
  1340. align: builtins.bool = ...,
  1341. copy: builtins.bool = ...,
  1342. metadata: dict[builtins.str, Any] = ...,
  1343. ) -> dtype[complexfloating]: ...
  1344. @overload
  1345. def __new__(
  1346. cls,
  1347. dtype: _InexactCodes | _FloatingCType,
  1348. align: builtins.bool = ...,
  1349. copy: builtins.bool = ...,
  1350. metadata: dict[builtins.str, Any] = ...,
  1351. ) -> dtype[inexact]: ...
  1352. @overload
  1353. def __new__(
  1354. cls,
  1355. dtype: _NumberCodes | _NumberCType,
  1356. align: builtins.bool = ...,
  1357. copy: builtins.bool = ...,
  1358. metadata: dict[builtins.str, Any] = ...,
  1359. ) -> dtype[number]: ...
  1360. @overload
  1361. def __new__(
  1362. cls,
  1363. dtype: _CharacterCodes | type[ct.c_char],
  1364. align: builtins.bool = ...,
  1365. copy: builtins.bool = ...,
  1366. metadata: dict[builtins.str, Any] = ...,
  1367. ) -> dtype[character]: ...
  1368. @overload
  1369. def __new__(
  1370. cls,
  1371. dtype: _FlexibleCodes | type[ct.c_char],
  1372. align: builtins.bool = ...,
  1373. copy: builtins.bool = ...,
  1374. metadata: dict[builtins.str, Any] = ...,
  1375. ) -> dtype[flexible]: ...
  1376. @overload
  1377. def __new__(
  1378. cls,
  1379. dtype: _GenericCodes | _GenericCType,
  1380. align: builtins.bool = ...,
  1381. copy: builtins.bool = ...,
  1382. metadata: dict[builtins.str, Any] = ...,
  1383. ) -> dtype[generic]: ...
  1384. # Handle strings that can't be expressed as literals; i.e. "S1", "S2", ...
  1385. @overload
  1386. def __new__(
  1387. cls,
  1388. dtype: builtins.str,
  1389. align: builtins.bool = ...,
  1390. copy: builtins.bool = ...,
  1391. metadata: dict[builtins.str, Any] = ...,
  1392. ) -> dtype: ...
  1393. # Catch-all overload for object-likes
  1394. # NOTE: `object_ | Any` is *not* equivalent to `Any` -- it describes some
  1395. # (static) type `T` s.t. `object_ <: T <: builtins.object` (`<:` denotes
  1396. # the subtyping relation, the (gradual) typing analogue of `issubclass()`).
  1397. # https://typing.readthedocs.io/en/latest/spec/concepts.html#union-types
  1398. @overload
  1399. def __new__(
  1400. cls,
  1401. dtype: type[object],
  1402. align: builtins.bool = ...,
  1403. copy: builtins.bool = ...,
  1404. metadata: dict[builtins.str, Any] = ...,
  1405. ) -> dtype[object_ | Any]: ...
  1406. def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
  1407. @overload
  1408. def __getitem__(self: dtype[void], key: list[builtins.str], /) -> dtype[void]: ...
  1409. @overload
  1410. def __getitem__(self: dtype[void], key: builtins.str | SupportsIndex, /) -> dtype: ...
  1411. # NOTE: In the future 1-based multiplications will also yield `flexible` dtypes
  1412. @overload
  1413. def __mul__(self: _DTypeT, value: L[1], /) -> _DTypeT: ...
  1414. @overload
  1415. def __mul__(self: _FlexDTypeT, value: SupportsIndex, /) -> _FlexDTypeT: ...
  1416. @overload
  1417. def __mul__(self, value: SupportsIndex, /) -> dtype[void]: ...
  1418. # NOTE: `__rmul__` seems to be broken when used in combination with
  1419. # literals as of mypy 0.902. Set the return-type to `dtype` for
  1420. # now for non-flexible dtypes.
  1421. @overload
  1422. def __rmul__(self: _FlexDTypeT, value: SupportsIndex, /) -> _FlexDTypeT: ...
  1423. @overload
  1424. def __rmul__(self, value: SupportsIndex, /) -> dtype: ...
  1425. def __gt__(self, other: DTypeLike, /) -> builtins.bool: ...
  1426. def __ge__(self, other: DTypeLike, /) -> builtins.bool: ...
  1427. def __lt__(self, other: DTypeLike, /) -> builtins.bool: ...
  1428. def __le__(self, other: DTypeLike, /) -> builtins.bool: ...
  1429. # Explicitly defined `__eq__` and `__ne__` to get around mypy's
  1430. # `strict_equality` option; even though their signatures are
  1431. # identical to their `object`-based counterpart
  1432. def __eq__(self, other: Any, /) -> builtins.bool: ...
  1433. def __ne__(self, other: Any, /) -> builtins.bool: ...
  1434. @property
  1435. def alignment(self) -> int: ...
  1436. @property
  1437. def base(self) -> dtype: ...
  1438. @property
  1439. def byteorder(self) -> _ByteOrderChar: ...
  1440. @property
  1441. def char(self) -> _DTypeChar: ...
  1442. @property
  1443. def descr(self) -> list[tuple[LiteralString, LiteralString] | tuple[LiteralString, LiteralString, _Shape]]: ...
  1444. @property
  1445. def fields(self,) -> MappingProxyType[LiteralString, tuple[dtype, int] | tuple[dtype, int, Any]] | None: ...
  1446. @property
  1447. def flags(self) -> int: ...
  1448. @property
  1449. def hasobject(self) -> builtins.bool: ...
  1450. @property
  1451. def isbuiltin(self) -> _DTypeBuiltinKind: ...
  1452. @property
  1453. def isnative(self) -> builtins.bool: ...
  1454. @property
  1455. def isalignedstruct(self) -> builtins.bool: ...
  1456. @property
  1457. def itemsize(self) -> int: ...
  1458. @property
  1459. def kind(self) -> _DTypeKind: ...
  1460. @property
  1461. def metadata(self) -> MappingProxyType[builtins.str, Any] | None: ...
  1462. @property
  1463. def name(self) -> LiteralString: ...
  1464. @property
  1465. def num(self) -> _DTypeNum: ...
  1466. @property
  1467. def shape(self) -> _AnyShape: ...
  1468. @property
  1469. def ndim(self) -> int: ...
  1470. @property
  1471. def subdtype(self) -> tuple[dtype, _AnyShape] | None: ...
  1472. def newbyteorder(self, new_order: _ByteOrder = ..., /) -> Self: ...
  1473. @property
  1474. def str(self) -> LiteralString: ...
  1475. @property
  1476. def type(self) -> type[_ScalarT_co]: ...
  1477. @final
  1478. class flatiter(Generic[_ArrayT_co]):
  1479. __hash__: ClassVar[None]
  1480. @property
  1481. def base(self) -> _ArrayT_co: ...
  1482. @property
  1483. def coords(self) -> _Shape: ...
  1484. @property
  1485. def index(self) -> int: ...
  1486. def copy(self) -> _ArrayT_co: ...
  1487. def __iter__(self) -> Self: ...
  1488. def __next__(self: flatiter[NDArray[_ScalarT]]) -> _ScalarT: ...
  1489. def __len__(self) -> int: ...
  1490. @overload
  1491. def __getitem__(
  1492. self: flatiter[NDArray[_ScalarT]],
  1493. key: int | integer | tuple[int | integer],
  1494. ) -> _ScalarT: ...
  1495. @overload
  1496. def __getitem__(
  1497. self,
  1498. key: _ArrayLikeInt | slice | EllipsisType | tuple[_ArrayLikeInt | slice | EllipsisType],
  1499. ) -> _ArrayT_co: ...
  1500. # TODO: `__setitem__` operates via `unsafe` casting rules, and can
  1501. # thus accept any type accepted by the relevant underlying `np.generic`
  1502. # constructor.
  1503. # This means that `value` must in reality be a supertype of `npt.ArrayLike`.
  1504. def __setitem__(
  1505. self,
  1506. key: _ArrayLikeInt | slice | EllipsisType | tuple[_ArrayLikeInt | slice | EllipsisType],
  1507. value: Any,
  1508. ) -> None: ...
  1509. @overload
  1510. def __array__(self: flatiter[ndarray[_1DShapeT, _DTypeT]], dtype: None = ..., /) -> ndarray[_1DShapeT, _DTypeT]: ...
  1511. @overload
  1512. def __array__(self: flatiter[ndarray[_1DShapeT, Any]], dtype: _DTypeT, /) -> ndarray[_1DShapeT, _DTypeT]: ...
  1513. @overload
  1514. def __array__(self: flatiter[ndarray[Any, _DTypeT]], dtype: None = ..., /) -> ndarray[_AnyShape, _DTypeT]: ...
  1515. @overload
  1516. def __array__(self, dtype: _DTypeT, /) -> ndarray[_AnyShape, _DTypeT]: ...
  1517. @type_check_only
  1518. class _ArrayOrScalarCommon:
  1519. @property
  1520. def real(self, /) -> Any: ...
  1521. @property
  1522. def imag(self, /) -> Any: ...
  1523. @property
  1524. def T(self) -> Self: ...
  1525. @property
  1526. def mT(self) -> Self: ...
  1527. @property
  1528. def data(self) -> memoryview: ...
  1529. @property
  1530. def flags(self) -> flagsobj: ...
  1531. @property
  1532. def itemsize(self) -> int: ...
  1533. @property
  1534. def nbytes(self) -> int: ...
  1535. @property
  1536. def device(self) -> L["cpu"]: ...
  1537. def __bool__(self, /) -> builtins.bool: ...
  1538. def __int__(self, /) -> int: ...
  1539. def __float__(self, /) -> float: ...
  1540. def __copy__(self) -> Self: ...
  1541. def __deepcopy__(self, memo: dict[int, Any] | None, /) -> Self: ...
  1542. # TODO: How to deal with the non-commutative nature of `==` and `!=`?
  1543. # xref numpy/numpy#17368
  1544. def __eq__(self, other: Any, /) -> Any: ...
  1545. def __ne__(self, other: Any, /) -> Any: ...
  1546. def copy(self, order: _OrderKACF = ...) -> Self: ...
  1547. def dump(self, file: StrOrBytesPath | SupportsWrite[bytes]) -> None: ...
  1548. def dumps(self) -> bytes: ...
  1549. def tobytes(self, order: _OrderKACF = ...) -> bytes: ...
  1550. def tofile(self, fid: StrOrBytesPath | _SupportsFileMethods, sep: str = ..., format: str = ...) -> None: ...
  1551. # generics and 0d arrays return builtin scalars
  1552. def tolist(self) -> Any: ...
  1553. def to_device(self, device: L["cpu"], /, *, stream: int | Any | None = ...) -> Self: ...
  1554. @property
  1555. def __array_interface__(self) -> dict[str, Any]: ...
  1556. @property
  1557. def __array_priority__(self) -> float: ...
  1558. @property
  1559. def __array_struct__(self) -> CapsuleType: ... # builtins.PyCapsule
  1560. def __array_namespace__(self, /, *, api_version: _ArrayAPIVersion | None = None) -> ModuleType: ...
  1561. def __setstate__(self, state: tuple[
  1562. SupportsIndex, # version
  1563. _ShapeLike, # Shape
  1564. _DTypeT_co, # DType
  1565. np.bool, # F-continuous
  1566. bytes | list[Any], # Data
  1567. ], /) -> None: ...
  1568. def conj(self) -> Self: ...
  1569. def conjugate(self) -> Self: ...
  1570. def argsort(
  1571. self,
  1572. axis: SupportsIndex | None = ...,
  1573. kind: _SortKind | None = ...,
  1574. order: str | Sequence[str] | None = ...,
  1575. *,
  1576. stable: bool | None = ...,
  1577. ) -> NDArray[Any]: ...
  1578. @overload # axis=None (default), out=None (default), keepdims=False (default)
  1579. def argmax(self, /, axis: None = None, out: None = None, *, keepdims: L[False] = False) -> intp: ...
  1580. @overload # axis=index, out=None (default)
  1581. def argmax(self, /, axis: SupportsIndex, out: None = None, *, keepdims: builtins.bool = False) -> Any: ...
  1582. @overload # axis=index, out=ndarray
  1583. def argmax(self, /, axis: SupportsIndex | None, out: _BoolOrIntArrayT, *, keepdims: builtins.bool = False) -> _BoolOrIntArrayT: ...
  1584. @overload
  1585. def argmax(self, /, axis: SupportsIndex | None = None, *, out: _BoolOrIntArrayT, keepdims: builtins.bool = False) -> _BoolOrIntArrayT: ...
  1586. @overload # axis=None (default), out=None (default), keepdims=False (default)
  1587. def argmin(self, /, axis: None = None, out: None = None, *, keepdims: L[False] = False) -> intp: ...
  1588. @overload # axis=index, out=None (default)
  1589. def argmin(self, /, axis: SupportsIndex, out: None = None, *, keepdims: builtins.bool = False) -> Any: ...
  1590. @overload # axis=index, out=ndarray
  1591. def argmin(self, /, axis: SupportsIndex | None, out: _BoolOrIntArrayT, *, keepdims: builtins.bool = False) -> _BoolOrIntArrayT: ...
  1592. @overload
  1593. def argmin(self, /, axis: SupportsIndex | None = None, *, out: _BoolOrIntArrayT, keepdims: builtins.bool = False) -> _BoolOrIntArrayT: ...
  1594. @overload # out=None (default)
  1595. def round(self, /, decimals: SupportsIndex = 0, out: None = None) -> Self: ...
  1596. @overload # out=ndarray
  1597. def round(self, /, decimals: SupportsIndex, out: _ArrayT) -> _ArrayT: ...
  1598. @overload
  1599. def round(self, /, decimals: SupportsIndex = 0, *, out: _ArrayT) -> _ArrayT: ...
  1600. @overload # out=None (default)
  1601. def choose(self, /, choices: ArrayLike, out: None = None, mode: _ModeKind = "raise") -> NDArray[Any]: ...
  1602. @overload # out=ndarray
  1603. def choose(self, /, choices: ArrayLike, out: _ArrayT, mode: _ModeKind = "raise") -> _ArrayT: ...
  1604. # TODO: Annotate kwargs with an unpacked `TypedDict`
  1605. @overload # out: None (default)
  1606. def clip(self, /, min: ArrayLike, max: ArrayLike | None = None, out: None = None, **kwargs: Any) -> NDArray[Any]: ...
  1607. @overload
  1608. def clip(self, /, min: None, max: ArrayLike, out: None = None, **kwargs: Any) -> NDArray[Any]: ...
  1609. @overload
  1610. def clip(self, /, min: None = None, *, max: ArrayLike, out: None = None, **kwargs: Any) -> NDArray[Any]: ...
  1611. @overload # out: ndarray
  1612. def clip(self, /, min: ArrayLike, max: ArrayLike | None, out: _ArrayT, **kwargs: Any) -> _ArrayT: ...
  1613. @overload
  1614. def clip(self, /, min: ArrayLike, max: ArrayLike | None = None, *, out: _ArrayT, **kwargs: Any) -> _ArrayT: ...
  1615. @overload
  1616. def clip(self, /, min: None, max: ArrayLike, out: _ArrayT, **kwargs: Any) -> _ArrayT: ...
  1617. @overload
  1618. def clip(self, /, min: None = None, *, max: ArrayLike, out: _ArrayT, **kwargs: Any) -> _ArrayT: ...
  1619. @overload
  1620. def compress(self, /, condition: _ArrayLikeInt_co, axis: SupportsIndex | None = None, out: None = None) -> NDArray[Any]: ...
  1621. @overload
  1622. def compress(self, /, condition: _ArrayLikeInt_co, axis: SupportsIndex | None, out: _ArrayT) -> _ArrayT: ...
  1623. @overload
  1624. def compress(self, /, condition: _ArrayLikeInt_co, axis: SupportsIndex | None = None, *, out: _ArrayT) -> _ArrayT: ...
  1625. @overload # out: None (default)
  1626. def cumprod(self, /, axis: SupportsIndex | None = None, dtype: DTypeLike | None = None, out: None = None) -> NDArray[Any]: ...
  1627. @overload # out: ndarray
  1628. def cumprod(self, /, axis: SupportsIndex | None, dtype: DTypeLike | None, out: _ArrayT) -> _ArrayT: ...
  1629. @overload
  1630. def cumprod(self, /, axis: SupportsIndex | None = None, dtype: DTypeLike | None = None, *, out: _ArrayT) -> _ArrayT: ...
  1631. @overload # out: None (default)
  1632. def cumsum(self, /, axis: SupportsIndex | None = None, dtype: DTypeLike | None = None, out: None = None) -> NDArray[Any]: ...
  1633. @overload # out: ndarray
  1634. def cumsum(self, /, axis: SupportsIndex | None, dtype: DTypeLike | None, out: _ArrayT) -> _ArrayT: ...
  1635. @overload
  1636. def cumsum(self, /, axis: SupportsIndex | None = None, dtype: DTypeLike | None = None, *, out: _ArrayT) -> _ArrayT: ...
  1637. @overload
  1638. def max(
  1639. self,
  1640. /,
  1641. axis: _ShapeLike | None = None,
  1642. out: None = None,
  1643. keepdims: builtins.bool = False,
  1644. initial: _NumberLike_co = ...,
  1645. where: _ArrayLikeBool_co = True,
  1646. ) -> Any: ...
  1647. @overload
  1648. def max(
  1649. self,
  1650. /,
  1651. axis: _ShapeLike | None,
  1652. out: _ArrayT,
  1653. keepdims: builtins.bool = False,
  1654. initial: _NumberLike_co = ...,
  1655. where: _ArrayLikeBool_co = True,
  1656. ) -> _ArrayT: ...
  1657. @overload
  1658. def max(
  1659. self,
  1660. /,
  1661. axis: _ShapeLike | None = None,
  1662. *,
  1663. out: _ArrayT,
  1664. keepdims: builtins.bool = False,
  1665. initial: _NumberLike_co = ...,
  1666. where: _ArrayLikeBool_co = True,
  1667. ) -> _ArrayT: ...
  1668. @overload
  1669. def min(
  1670. self,
  1671. /,
  1672. axis: _ShapeLike | None = None,
  1673. out: None = None,
  1674. keepdims: builtins.bool = False,
  1675. initial: _NumberLike_co = ...,
  1676. where: _ArrayLikeBool_co = True,
  1677. ) -> Any: ...
  1678. @overload
  1679. def min(
  1680. self,
  1681. /,
  1682. axis: _ShapeLike | None,
  1683. out: _ArrayT,
  1684. keepdims: builtins.bool = False,
  1685. initial: _NumberLike_co = ...,
  1686. where: _ArrayLikeBool_co = True,
  1687. ) -> _ArrayT: ...
  1688. @overload
  1689. def min(
  1690. self,
  1691. /,
  1692. axis: _ShapeLike | None = None,
  1693. *,
  1694. out: _ArrayT,
  1695. keepdims: builtins.bool = False,
  1696. initial: _NumberLike_co = ...,
  1697. where: _ArrayLikeBool_co = True,
  1698. ) -> _ArrayT: ...
  1699. @overload
  1700. def sum(
  1701. self,
  1702. /,
  1703. axis: _ShapeLike | None = None,
  1704. dtype: DTypeLike | None = None,
  1705. out: None = None,
  1706. keepdims: builtins.bool = False,
  1707. initial: _NumberLike_co = 0,
  1708. where: _ArrayLikeBool_co = True,
  1709. ) -> Any: ...
  1710. @overload
  1711. def sum(
  1712. self,
  1713. /,
  1714. axis: _ShapeLike | None,
  1715. dtype: DTypeLike | None,
  1716. out: _ArrayT,
  1717. keepdims: builtins.bool = False,
  1718. initial: _NumberLike_co = 0,
  1719. where: _ArrayLikeBool_co = True,
  1720. ) -> _ArrayT: ...
  1721. @overload
  1722. def sum(
  1723. self,
  1724. /,
  1725. axis: _ShapeLike | None = None,
  1726. dtype: DTypeLike | None = None,
  1727. *,
  1728. out: _ArrayT,
  1729. keepdims: builtins.bool = False,
  1730. initial: _NumberLike_co = 0,
  1731. where: _ArrayLikeBool_co = True,
  1732. ) -> _ArrayT: ...
  1733. @overload
  1734. def prod(
  1735. self,
  1736. /,
  1737. axis: _ShapeLike | None = None,
  1738. dtype: DTypeLike | None = None,
  1739. out: None = None,
  1740. keepdims: builtins.bool = False,
  1741. initial: _NumberLike_co = 1,
  1742. where: _ArrayLikeBool_co = True,
  1743. ) -> Any: ...
  1744. @overload
  1745. def prod(
  1746. self,
  1747. /,
  1748. axis: _ShapeLike | None,
  1749. dtype: DTypeLike | None,
  1750. out: _ArrayT,
  1751. keepdims: builtins.bool = False,
  1752. initial: _NumberLike_co = 1,
  1753. where: _ArrayLikeBool_co = True,
  1754. ) -> _ArrayT: ...
  1755. @overload
  1756. def prod(
  1757. self,
  1758. /,
  1759. axis: _ShapeLike | None = None,
  1760. dtype: DTypeLike | None = None,
  1761. *,
  1762. out: _ArrayT,
  1763. keepdims: builtins.bool = False,
  1764. initial: _NumberLike_co = 1,
  1765. where: _ArrayLikeBool_co = True,
  1766. ) -> _ArrayT: ...
  1767. @overload
  1768. def mean(
  1769. self,
  1770. axis: _ShapeLike | None = None,
  1771. dtype: DTypeLike | None = None,
  1772. out: None = None,
  1773. keepdims: builtins.bool = False,
  1774. *,
  1775. where: _ArrayLikeBool_co = True,
  1776. ) -> Any: ...
  1777. @overload
  1778. def mean(
  1779. self,
  1780. /,
  1781. axis: _ShapeLike | None,
  1782. dtype: DTypeLike | None,
  1783. out: _ArrayT,
  1784. keepdims: builtins.bool = False,
  1785. *,
  1786. where: _ArrayLikeBool_co = True,
  1787. ) -> _ArrayT: ...
  1788. @overload
  1789. def mean(
  1790. self,
  1791. /,
  1792. axis: _ShapeLike | None = None,
  1793. dtype: DTypeLike | None = None,
  1794. *,
  1795. out: _ArrayT,
  1796. keepdims: builtins.bool = False,
  1797. where: _ArrayLikeBool_co = True,
  1798. ) -> _ArrayT: ...
  1799. @overload
  1800. def std(
  1801. self,
  1802. axis: _ShapeLike | None = None,
  1803. dtype: DTypeLike | None = None,
  1804. out: None = None,
  1805. ddof: float = 0,
  1806. keepdims: builtins.bool = False,
  1807. *,
  1808. where: _ArrayLikeBool_co = True,
  1809. mean: _ArrayLikeNumber_co = ...,
  1810. correction: float = ...,
  1811. ) -> Any: ...
  1812. @overload
  1813. def std(
  1814. self,
  1815. axis: _ShapeLike | None,
  1816. dtype: DTypeLike | None,
  1817. out: _ArrayT,
  1818. ddof: float = 0,
  1819. keepdims: builtins.bool = False,
  1820. *,
  1821. where: _ArrayLikeBool_co = True,
  1822. mean: _ArrayLikeNumber_co = ...,
  1823. correction: float = ...,
  1824. ) -> _ArrayT: ...
  1825. @overload
  1826. def std(
  1827. self,
  1828. axis: _ShapeLike | None = None,
  1829. dtype: DTypeLike | None = None,
  1830. *,
  1831. out: _ArrayT,
  1832. ddof: float = 0,
  1833. keepdims: builtins.bool = False,
  1834. where: _ArrayLikeBool_co = True,
  1835. mean: _ArrayLikeNumber_co = ...,
  1836. correction: float = ...,
  1837. ) -> _ArrayT: ...
  1838. @overload
  1839. def var(
  1840. self,
  1841. axis: _ShapeLike | None = None,
  1842. dtype: DTypeLike | None = None,
  1843. out: None = None,
  1844. ddof: float = 0,
  1845. keepdims: builtins.bool = False,
  1846. *,
  1847. where: _ArrayLikeBool_co = True,
  1848. mean: _ArrayLikeNumber_co = ...,
  1849. correction: float = ...,
  1850. ) -> Any: ...
  1851. @overload
  1852. def var(
  1853. self,
  1854. axis: _ShapeLike | None,
  1855. dtype: DTypeLike | None,
  1856. out: _ArrayT,
  1857. ddof: float = 0,
  1858. keepdims: builtins.bool = False,
  1859. *,
  1860. where: _ArrayLikeBool_co = True,
  1861. mean: _ArrayLikeNumber_co = ...,
  1862. correction: float = ...,
  1863. ) -> _ArrayT: ...
  1864. @overload
  1865. def var(
  1866. self,
  1867. axis: _ShapeLike | None = None,
  1868. dtype: DTypeLike | None = None,
  1869. *,
  1870. out: _ArrayT,
  1871. ddof: float = 0,
  1872. keepdims: builtins.bool = False,
  1873. where: _ArrayLikeBool_co = True,
  1874. mean: _ArrayLikeNumber_co = ...,
  1875. correction: float = ...,
  1876. ) -> _ArrayT: ...
  1877. class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
  1878. __hash__: ClassVar[None] # type: ignore[assignment] # pyright: ignore[reportIncompatibleMethodOverride]
  1879. @property
  1880. def base(self) -> NDArray[Any] | None: ...
  1881. @property
  1882. def ndim(self) -> int: ...
  1883. @property
  1884. def size(self) -> int: ...
  1885. @property
  1886. def real(self: _HasDTypeWithRealAndImag[_ScalarT, object], /) -> ndarray[_ShapeT_co, dtype[_ScalarT]]: ...
  1887. @real.setter
  1888. def real(self, value: ArrayLike, /) -> None: ...
  1889. @property
  1890. def imag(self: _HasDTypeWithRealAndImag[object, _ScalarT], /) -> ndarray[_ShapeT_co, dtype[_ScalarT]]: ...
  1891. @imag.setter
  1892. def imag(self, value: ArrayLike, /) -> None: ...
  1893. def __new__(
  1894. cls,
  1895. shape: _ShapeLike,
  1896. dtype: DTypeLike = ...,
  1897. buffer: _SupportsBuffer | None = ...,
  1898. offset: SupportsIndex = ...,
  1899. strides: _ShapeLike | None = ...,
  1900. order: _OrderKACF = ...,
  1901. ) -> Self: ...
  1902. if sys.version_info >= (3, 12):
  1903. def __buffer__(self, flags: int, /) -> memoryview: ...
  1904. def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
  1905. @overload
  1906. def __array__(self, dtype: None = None, /, *, copy: builtins.bool | None = None) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  1907. @overload
  1908. def __array__(self, dtype: _DTypeT, /, *, copy: builtins.bool | None = None) -> ndarray[_ShapeT_co, _DTypeT]: ...
  1909. def __array_ufunc__(
  1910. self,
  1911. ufunc: ufunc,
  1912. method: L["__call__", "reduce", "reduceat", "accumulate", "outer", "at"],
  1913. *inputs: Any,
  1914. **kwargs: Any,
  1915. ) -> Any: ...
  1916. def __array_function__(
  1917. self,
  1918. func: Callable[..., Any],
  1919. types: Iterable[type],
  1920. args: Iterable[Any],
  1921. kwargs: Mapping[str, Any],
  1922. ) -> Any: ...
  1923. # NOTE: In practice any object is accepted by `obj`, but as `__array_finalize__`
  1924. # is a pseudo-abstract method the type has been narrowed down in order to
  1925. # grant subclasses a bit more flexibility
  1926. def __array_finalize__(self, obj: NDArray[Any] | None, /) -> None: ...
  1927. def __array_wrap__(
  1928. self,
  1929. array: ndarray[_ShapeT, _DTypeT],
  1930. context: tuple[ufunc, tuple[Any, ...], int] | None = ...,
  1931. return_scalar: builtins.bool = ...,
  1932. /,
  1933. ) -> ndarray[_ShapeT, _DTypeT]: ...
  1934. @overload
  1935. def __getitem__(self, key: _ArrayInt_co | tuple[_ArrayInt_co, ...], /) -> ndarray[_AnyShape, _DTypeT_co]: ...
  1936. @overload
  1937. def __getitem__(self, key: SupportsIndex | tuple[SupportsIndex, ...], /) -> Any: ...
  1938. @overload
  1939. def __getitem__(self, key: _ToIndices, /) -> ndarray[_AnyShape, _DTypeT_co]: ...
  1940. @overload
  1941. def __getitem__(self: NDArray[void], key: str, /) -> ndarray[_ShapeT_co, np.dtype]: ...
  1942. @overload
  1943. def __getitem__(self: NDArray[void], key: list[str], /) -> ndarray[_ShapeT_co, _dtype[void]]: ...
  1944. @overload # flexible | object_ | bool
  1945. def __setitem__(
  1946. self: ndarray[Any, dtype[flexible | object_ | np.bool] | dtypes.StringDType],
  1947. key: _ToIndices,
  1948. value: object,
  1949. /,
  1950. ) -> None: ...
  1951. @overload # integer
  1952. def __setitem__(
  1953. self: NDArray[integer],
  1954. key: _ToIndices,
  1955. value: _ConvertibleToInt | _NestedSequence[_ConvertibleToInt] | _ArrayLikeInt_co,
  1956. /,
  1957. ) -> None: ...
  1958. @overload # floating
  1959. def __setitem__(
  1960. self: NDArray[floating],
  1961. key: _ToIndices,
  1962. value: _ConvertibleToFloat | _NestedSequence[_ConvertibleToFloat | None] | _ArrayLikeFloat_co | None,
  1963. /,
  1964. ) -> None: ...
  1965. @overload # complexfloating
  1966. def __setitem__(
  1967. self: NDArray[complexfloating],
  1968. key: _ToIndices,
  1969. value: _ConvertibleToComplex | _NestedSequence[_ConvertibleToComplex | None] | _ArrayLikeNumber_co | None,
  1970. /,
  1971. ) -> None: ...
  1972. @overload # timedelta64
  1973. def __setitem__(
  1974. self: NDArray[timedelta64],
  1975. key: _ToIndices,
  1976. value: _ConvertibleToTD64 | _NestedSequence[_ConvertibleToTD64],
  1977. /,
  1978. ) -> None: ...
  1979. @overload # datetime64
  1980. def __setitem__(
  1981. self: NDArray[datetime64],
  1982. key: _ToIndices,
  1983. value: _ConvertibleToDT64 | _NestedSequence[_ConvertibleToDT64],
  1984. /,
  1985. ) -> None: ...
  1986. @overload # void
  1987. def __setitem__(self: NDArray[void], key: str | list[str], value: object, /) -> None: ...
  1988. @overload # catch-all
  1989. def __setitem__(self, key: _ToIndices, value: ArrayLike, /) -> None: ...
  1990. @property
  1991. def ctypes(self) -> _ctypes[int]: ...
  1992. @property
  1993. def shape(self) -> _ShapeT_co: ...
  1994. @shape.setter
  1995. def shape(self, value: _ShapeLike) -> None: ...
  1996. @property
  1997. def strides(self) -> _Shape: ...
  1998. @strides.setter
  1999. def strides(self, value: _ShapeLike) -> None: ...
  2000. def byteswap(self, inplace: builtins.bool = ...) -> Self: ...
  2001. def fill(self, value: Any) -> None: ...
  2002. @property
  2003. def flat(self) -> flatiter[Self]: ...
  2004. @overload # use the same output type as that of the underlying `generic`
  2005. def item(self: NDArray[generic[_T]], i0: SupportsIndex | tuple[SupportsIndex, ...] = ..., /, *args: SupportsIndex) -> _T: ...
  2006. @overload # special casing for `StringDType`, which has no scalar type
  2007. def item(
  2008. self: ndarray[Any, dtypes.StringDType],
  2009. arg0: SupportsIndex | tuple[SupportsIndex, ...] = ...,
  2010. /,
  2011. *args: SupportsIndex,
  2012. ) -> str: ...
  2013. @overload # this first overload prevents mypy from over-eagerly selecting `tuple[()]` in case of `_AnyShape`
  2014. def tolist(self: ndarray[tuple[Never], dtype[generic[_T]]], /) -> Any: ...
  2015. @overload
  2016. def tolist(self: ndarray[tuple[()], dtype[generic[_T]]], /) -> _T: ...
  2017. @overload
  2018. def tolist(self: ndarray[tuple[int], dtype[generic[_T]]], /) -> list[_T]: ...
  2019. @overload
  2020. def tolist(self: ndarray[tuple[int, int], dtype[generic[_T]]], /) -> list[list[_T]]: ...
  2021. @overload
  2022. def tolist(self: ndarray[tuple[int, int, int], dtype[generic[_T]]], /) -> list[list[list[_T]]]: ...
  2023. @overload
  2024. def tolist(self, /) -> Any: ...
  2025. @overload
  2026. def resize(self, new_shape: _ShapeLike, /, *, refcheck: builtins.bool = ...) -> None: ...
  2027. @overload
  2028. def resize(self, /, *new_shape: SupportsIndex, refcheck: builtins.bool = ...) -> None: ...
  2029. def setflags(self, write: builtins.bool = ..., align: builtins.bool = ..., uic: builtins.bool = ...) -> None: ...
  2030. def squeeze(
  2031. self,
  2032. axis: SupportsIndex | tuple[SupportsIndex, ...] | None = ...,
  2033. ) -> ndarray[_AnyShape, _DTypeT_co]: ...
  2034. def swapaxes(
  2035. self,
  2036. axis1: SupportsIndex,
  2037. axis2: SupportsIndex,
  2038. ) -> ndarray[_AnyShape, _DTypeT_co]: ...
  2039. @overload
  2040. def transpose(self, axes: _ShapeLike | None, /) -> Self: ...
  2041. @overload
  2042. def transpose(self, *axes: SupportsIndex) -> Self: ...
  2043. @overload
  2044. def all(
  2045. self,
  2046. axis: None = None,
  2047. out: None = None,
  2048. keepdims: L[False, 0] = False,
  2049. *,
  2050. where: _ArrayLikeBool_co = True
  2051. ) -> np.bool: ...
  2052. @overload
  2053. def all(
  2054. self,
  2055. axis: int | tuple[int, ...] | None = None,
  2056. out: None = None,
  2057. keepdims: SupportsIndex = False,
  2058. *,
  2059. where: _ArrayLikeBool_co = True,
  2060. ) -> np.bool | NDArray[np.bool]: ...
  2061. @overload
  2062. def all(
  2063. self,
  2064. axis: int | tuple[int, ...] | None,
  2065. out: _ArrayT,
  2066. keepdims: SupportsIndex = False,
  2067. *,
  2068. where: _ArrayLikeBool_co = True,
  2069. ) -> _ArrayT: ...
  2070. @overload
  2071. def all(
  2072. self,
  2073. axis: int | tuple[int, ...] | None = None,
  2074. *,
  2075. out: _ArrayT,
  2076. keepdims: SupportsIndex = False,
  2077. where: _ArrayLikeBool_co = True,
  2078. ) -> _ArrayT: ...
  2079. @overload
  2080. def any(
  2081. self,
  2082. axis: None = None,
  2083. out: None = None,
  2084. keepdims: L[False, 0] = False,
  2085. *,
  2086. where: _ArrayLikeBool_co = True
  2087. ) -> np.bool: ...
  2088. @overload
  2089. def any(
  2090. self,
  2091. axis: int | tuple[int, ...] | None = None,
  2092. out: None = None,
  2093. keepdims: SupportsIndex = False,
  2094. *,
  2095. where: _ArrayLikeBool_co = True,
  2096. ) -> np.bool | NDArray[np.bool]: ...
  2097. @overload
  2098. def any(
  2099. self,
  2100. axis: int | tuple[int, ...] | None,
  2101. out: _ArrayT,
  2102. keepdims: SupportsIndex = False,
  2103. *,
  2104. where: _ArrayLikeBool_co = True,
  2105. ) -> _ArrayT: ...
  2106. @overload
  2107. def any(
  2108. self,
  2109. axis: int | tuple[int, ...] | None = None,
  2110. *,
  2111. out: _ArrayT,
  2112. keepdims: SupportsIndex = False,
  2113. where: _ArrayLikeBool_co = True,
  2114. ) -> _ArrayT: ...
  2115. #
  2116. @overload
  2117. def partition(
  2118. self,
  2119. /,
  2120. kth: _ArrayLikeInt,
  2121. axis: SupportsIndex = -1,
  2122. kind: _PartitionKind = "introselect",
  2123. order: None = None,
  2124. ) -> None: ...
  2125. @overload
  2126. def partition(
  2127. self: NDArray[void],
  2128. /,
  2129. kth: _ArrayLikeInt,
  2130. axis: SupportsIndex = -1,
  2131. kind: _PartitionKind = "introselect",
  2132. order: str | Sequence[str] | None = None,
  2133. ) -> None: ...
  2134. #
  2135. @overload
  2136. def argpartition(
  2137. self,
  2138. /,
  2139. kth: _ArrayLikeInt,
  2140. axis: SupportsIndex | None = -1,
  2141. kind: _PartitionKind = "introselect",
  2142. order: None = None,
  2143. ) -> NDArray[intp]: ...
  2144. @overload
  2145. def argpartition(
  2146. self: NDArray[void],
  2147. /,
  2148. kth: _ArrayLikeInt,
  2149. axis: SupportsIndex | None = -1,
  2150. kind: _PartitionKind = "introselect",
  2151. order: str | Sequence[str] | None = None,
  2152. ) -> NDArray[intp]: ...
  2153. #
  2154. def diagonal(
  2155. self,
  2156. offset: SupportsIndex = ...,
  2157. axis1: SupportsIndex = ...,
  2158. axis2: SupportsIndex = ...,
  2159. ) -> ndarray[_AnyShape, _DTypeT_co]: ...
  2160. # 1D + 1D returns a scalar;
  2161. # all other with at least 1 non-0D array return an ndarray.
  2162. @overload
  2163. def dot(self, b: _ScalarLike_co, out: None = ...) -> NDArray[Any]: ...
  2164. @overload
  2165. def dot(self, b: ArrayLike, out: None = ...) -> Any: ... # type: ignore[misc]
  2166. @overload
  2167. def dot(self, b: ArrayLike, out: _ArrayT) -> _ArrayT: ...
  2168. # `nonzero()` is deprecated for 0d arrays/generics
  2169. def nonzero(self) -> tuple[NDArray[intp], ...]: ...
  2170. # `put` is technically available to `generic`,
  2171. # but is pointless as `generic`s are immutable
  2172. def put(self, /, indices: _ArrayLikeInt_co, values: ArrayLike, mode: _ModeKind = "raise") -> None: ...
  2173. @overload
  2174. def searchsorted( # type: ignore[misc]
  2175. self, # >= 1D array
  2176. v: _ScalarLike_co, # 0D array-like
  2177. side: _SortSide = ...,
  2178. sorter: _ArrayLikeInt_co | None = ...,
  2179. ) -> intp: ...
  2180. @overload
  2181. def searchsorted(
  2182. self, # >= 1D array
  2183. v: ArrayLike,
  2184. side: _SortSide = ...,
  2185. sorter: _ArrayLikeInt_co | None = ...,
  2186. ) -> NDArray[intp]: ...
  2187. def sort(
  2188. self,
  2189. axis: SupportsIndex = ...,
  2190. kind: _SortKind | None = ...,
  2191. order: str | Sequence[str] | None = ...,
  2192. *,
  2193. stable: bool | None = ...,
  2194. ) -> None: ...
  2195. @overload
  2196. def trace(
  2197. self, # >= 2D array
  2198. offset: SupportsIndex = ...,
  2199. axis1: SupportsIndex = ...,
  2200. axis2: SupportsIndex = ...,
  2201. dtype: DTypeLike = ...,
  2202. out: None = ...,
  2203. ) -> Any: ...
  2204. @overload
  2205. def trace(
  2206. self, # >= 2D array
  2207. offset: SupportsIndex = ...,
  2208. axis1: SupportsIndex = ...,
  2209. axis2: SupportsIndex = ...,
  2210. dtype: DTypeLike = ...,
  2211. out: _ArrayT = ...,
  2212. ) -> _ArrayT: ...
  2213. @overload
  2214. def take( # type: ignore[misc]
  2215. self: NDArray[_ScalarT],
  2216. indices: _IntLike_co,
  2217. axis: SupportsIndex | None = ...,
  2218. out: None = ...,
  2219. mode: _ModeKind = ...,
  2220. ) -> _ScalarT: ...
  2221. @overload
  2222. def take( # type: ignore[misc]
  2223. self,
  2224. indices: _ArrayLikeInt_co,
  2225. axis: SupportsIndex | None = ...,
  2226. out: None = ...,
  2227. mode: _ModeKind = ...,
  2228. ) -> ndarray[_AnyShape, _DTypeT_co]: ...
  2229. @overload
  2230. def take(
  2231. self,
  2232. indices: _ArrayLikeInt_co,
  2233. axis: SupportsIndex | None = ...,
  2234. out: _ArrayT = ...,
  2235. mode: _ModeKind = ...,
  2236. ) -> _ArrayT: ...
  2237. @overload
  2238. def repeat(
  2239. self,
  2240. repeats: _ArrayLikeInt_co,
  2241. axis: None = None,
  2242. ) -> ndarray[tuple[int], _DTypeT_co]: ...
  2243. @overload
  2244. def repeat(
  2245. self,
  2246. repeats: _ArrayLikeInt_co,
  2247. axis: SupportsIndex,
  2248. ) -> ndarray[_AnyShape, _DTypeT_co]: ...
  2249. def flatten(self, /, order: _OrderKACF = "C") -> ndarray[tuple[int], _DTypeT_co]: ...
  2250. def ravel(self, /, order: _OrderKACF = "C") -> ndarray[tuple[int], _DTypeT_co]: ...
  2251. # NOTE: reshape also accepts negative integers, so we can't use integer literals
  2252. @overload # (None)
  2253. def reshape(self, shape: None, /, *, order: _OrderACF = "C", copy: builtins.bool | None = None) -> Self: ...
  2254. @overload # (empty_sequence)
  2255. def reshape( # type: ignore[overload-overlap] # mypy false positive
  2256. self,
  2257. shape: Sequence[Never],
  2258. /,
  2259. *,
  2260. order: _OrderACF = "C",
  2261. copy: builtins.bool | None = None,
  2262. ) -> ndarray[tuple[()], _DTypeT_co]: ...
  2263. @overload # (() | (int) | (int, int) | ....) # up to 8-d
  2264. def reshape(
  2265. self,
  2266. shape: _AnyShapeT,
  2267. /,
  2268. *,
  2269. order: _OrderACF = "C",
  2270. copy: builtins.bool | None = None,
  2271. ) -> ndarray[_AnyShapeT, _DTypeT_co]: ...
  2272. @overload # (index)
  2273. def reshape(
  2274. self,
  2275. size1: SupportsIndex,
  2276. /,
  2277. *,
  2278. order: _OrderACF = "C",
  2279. copy: builtins.bool | None = None,
  2280. ) -> ndarray[tuple[int], _DTypeT_co]: ...
  2281. @overload # (index, index)
  2282. def reshape(
  2283. self,
  2284. size1: SupportsIndex,
  2285. size2: SupportsIndex,
  2286. /,
  2287. *,
  2288. order: _OrderACF = "C",
  2289. copy: builtins.bool | None = None,
  2290. ) -> ndarray[tuple[int, int], _DTypeT_co]: ...
  2291. @overload # (index, index, index)
  2292. def reshape(
  2293. self,
  2294. size1: SupportsIndex,
  2295. size2: SupportsIndex,
  2296. size3: SupportsIndex,
  2297. /,
  2298. *,
  2299. order: _OrderACF = "C",
  2300. copy: builtins.bool | None = None,
  2301. ) -> ndarray[tuple[int, int, int], _DTypeT_co]: ...
  2302. @overload # (index, index, index, index)
  2303. def reshape(
  2304. self,
  2305. size1: SupportsIndex,
  2306. size2: SupportsIndex,
  2307. size3: SupportsIndex,
  2308. size4: SupportsIndex,
  2309. /,
  2310. *,
  2311. order: _OrderACF = "C",
  2312. copy: builtins.bool | None = None,
  2313. ) -> ndarray[tuple[int, int, int, int], _DTypeT_co]: ...
  2314. @overload # (int, *(index, ...))
  2315. def reshape(
  2316. self,
  2317. size0: SupportsIndex,
  2318. /,
  2319. *shape: SupportsIndex,
  2320. order: _OrderACF = "C",
  2321. copy: builtins.bool | None = None,
  2322. ) -> ndarray[_AnyShape, _DTypeT_co]: ...
  2323. @overload # (sequence[index])
  2324. def reshape(
  2325. self,
  2326. shape: Sequence[SupportsIndex],
  2327. /,
  2328. *,
  2329. order: _OrderACF = "C",
  2330. copy: builtins.bool | None = None,
  2331. ) -> ndarray[_AnyShape, _DTypeT_co]: ...
  2332. @overload
  2333. def astype(
  2334. self,
  2335. dtype: _DTypeLike[_ScalarT],
  2336. order: _OrderKACF = ...,
  2337. casting: _CastingKind = ...,
  2338. subok: builtins.bool = ...,
  2339. copy: builtins.bool | _CopyMode = ...,
  2340. ) -> ndarray[_ShapeT_co, dtype[_ScalarT]]: ...
  2341. @overload
  2342. def astype(
  2343. self,
  2344. dtype: DTypeLike,
  2345. order: _OrderKACF = ...,
  2346. casting: _CastingKind = ...,
  2347. subok: builtins.bool = ...,
  2348. copy: builtins.bool | _CopyMode = ...,
  2349. ) -> ndarray[_ShapeT_co, dtype]: ...
  2350. #
  2351. @overload # ()
  2352. def view(self, /) -> Self: ...
  2353. @overload # (dtype: T)
  2354. def view(self, /, dtype: _DTypeT | _HasDType[_DTypeT]) -> ndarray[_ShapeT_co, _DTypeT]: ...
  2355. @overload # (dtype: dtype[T])
  2356. def view(self, /, dtype: _DTypeLike[_ScalarT]) -> NDArray[_ScalarT]: ...
  2357. @overload # (type: T)
  2358. def view(self, /, *, type: type[_ArrayT]) -> _ArrayT: ...
  2359. @overload # (_: T)
  2360. def view(self, /, dtype: type[_ArrayT]) -> _ArrayT: ...
  2361. @overload # (dtype: ?)
  2362. def view(self, /, dtype: DTypeLike) -> ndarray[_ShapeT_co, dtype]: ...
  2363. @overload # (dtype: ?, type: type[T])
  2364. def view(self, /, dtype: DTypeLike, type: type[_ArrayT]) -> _ArrayT: ...
  2365. def setfield(self, /, val: ArrayLike, dtype: DTypeLike, offset: SupportsIndex = 0) -> None: ...
  2366. @overload
  2367. def getfield(self, dtype: _DTypeLike[_ScalarT], offset: SupportsIndex = 0) -> NDArray[_ScalarT]: ...
  2368. @overload
  2369. def getfield(self, dtype: DTypeLike, offset: SupportsIndex = 0) -> NDArray[Any]: ...
  2370. def __index__(self: NDArray[integer], /) -> int: ...
  2371. def __complex__(self: NDArray[number | np.bool | object_], /) -> complex: ...
  2372. def __len__(self) -> int: ...
  2373. def __contains__(self, value: object, /) -> builtins.bool: ...
  2374. # NOTE: This weird `Never` tuple works around a strange mypy issue where it assigns
  2375. # `tuple[int]` to `tuple[Never]` or `tuple[int, int]` to `tuple[Never, Never]`.
  2376. # This way the bug only occurs for 9-D arrays, which are probably not very common.
  2377. @overload
  2378. def __iter__(self: ndarray[tuple[Never, Never, Never, Never, Never, Never, Never, Never, Never]], /) -> Iterator[Any]: ...
  2379. @overload # == 1-d & dtype[T \ object_]
  2380. def __iter__(self: ndarray[tuple[int], dtype[_NonObjectScalarT]], /) -> Iterator[_NonObjectScalarT]: ...
  2381. @overload # >= 2-d
  2382. def __iter__(self: ndarray[tuple[int, int, *tuple[int, ...]], dtype[_ScalarT]], /) -> Iterator[NDArray[_ScalarT]]: ...
  2383. @overload # ?-d
  2384. def __iter__(self, /) -> Iterator[Any]: ...
  2385. #
  2386. @overload
  2387. def __lt__(self: _ArrayNumber_co, other: _ArrayLikeNumber_co, /) -> NDArray[np.bool]: ...
  2388. @overload
  2389. def __lt__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co, /) -> NDArray[np.bool]: ...
  2390. @overload
  2391. def __lt__(self: NDArray[datetime64], other: _ArrayLikeDT64_co, /) -> NDArray[np.bool]: ...
  2392. @overload
  2393. def __lt__(self: NDArray[bytes_], other: _ArrayLikeBytes_co, /) -> NDArray[np.bool]: ...
  2394. @overload
  2395. def __lt__(
  2396. self: ndarray[Any, dtype[str_] | dtypes.StringDType], other: _ArrayLikeStr_co | _ArrayLikeString_co, /
  2397. ) -> NDArray[np.bool]: ...
  2398. @overload
  2399. def __lt__(self: NDArray[object_], other: object, /) -> NDArray[np.bool]: ...
  2400. @overload
  2401. def __lt__(self, other: _ArrayLikeObject_co, /) -> NDArray[np.bool]: ...
  2402. #
  2403. @overload
  2404. def __le__(self: _ArrayNumber_co, other: _ArrayLikeNumber_co, /) -> NDArray[np.bool]: ...
  2405. @overload
  2406. def __le__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co, /) -> NDArray[np.bool]: ...
  2407. @overload
  2408. def __le__(self: NDArray[datetime64], other: _ArrayLikeDT64_co, /) -> NDArray[np.bool]: ...
  2409. @overload
  2410. def __le__(self: NDArray[bytes_], other: _ArrayLikeBytes_co, /) -> NDArray[np.bool]: ...
  2411. @overload
  2412. def __le__(
  2413. self: ndarray[Any, dtype[str_] | dtypes.StringDType], other: _ArrayLikeStr_co | _ArrayLikeString_co, /
  2414. ) -> NDArray[np.bool]: ...
  2415. @overload
  2416. def __le__(self: NDArray[object_], other: object, /) -> NDArray[np.bool]: ...
  2417. @overload
  2418. def __le__(self, other: _ArrayLikeObject_co, /) -> NDArray[np.bool]: ...
  2419. #
  2420. @overload
  2421. def __gt__(self: _ArrayNumber_co, other: _ArrayLikeNumber_co, /) -> NDArray[np.bool]: ...
  2422. @overload
  2423. def __gt__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co, /) -> NDArray[np.bool]: ...
  2424. @overload
  2425. def __gt__(self: NDArray[datetime64], other: _ArrayLikeDT64_co, /) -> NDArray[np.bool]: ...
  2426. @overload
  2427. def __gt__(self: NDArray[bytes_], other: _ArrayLikeBytes_co, /) -> NDArray[np.bool]: ...
  2428. @overload
  2429. def __gt__(
  2430. self: ndarray[Any, dtype[str_] | dtypes.StringDType], other: _ArrayLikeStr_co | _ArrayLikeString_co, /
  2431. ) -> NDArray[np.bool]: ...
  2432. @overload
  2433. def __gt__(self: NDArray[object_], other: object, /) -> NDArray[np.bool]: ...
  2434. @overload
  2435. def __gt__(self, other: _ArrayLikeObject_co, /) -> NDArray[np.bool]: ...
  2436. #
  2437. @overload
  2438. def __ge__(self: _ArrayNumber_co, other: _ArrayLikeNumber_co, /) -> NDArray[np.bool]: ...
  2439. @overload
  2440. def __ge__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co, /) -> NDArray[np.bool]: ...
  2441. @overload
  2442. def __ge__(self: NDArray[datetime64], other: _ArrayLikeDT64_co, /) -> NDArray[np.bool]: ...
  2443. @overload
  2444. def __ge__(self: NDArray[bytes_], other: _ArrayLikeBytes_co, /) -> NDArray[np.bool]: ...
  2445. @overload
  2446. def __ge__(
  2447. self: ndarray[Any, dtype[str_] | dtypes.StringDType], other: _ArrayLikeStr_co | _ArrayLikeString_co, /
  2448. ) -> NDArray[np.bool]: ...
  2449. @overload
  2450. def __ge__(self: NDArray[object_], other: object, /) -> NDArray[np.bool]: ...
  2451. @overload
  2452. def __ge__(self, other: _ArrayLikeObject_co, /) -> NDArray[np.bool]: ...
  2453. # Unary ops
  2454. # TODO: Uncomment once https://github.com/python/mypy/issues/14070 is fixed
  2455. # @overload
  2456. # def __abs__(self: ndarray[_ShapeT, dtypes.Complex64DType], /) -> ndarray[_ShapeT, dtypes.Float32DType]: ...
  2457. # @overload
  2458. # def __abs__(self: ndarray[_ShapeT, dtypes.Complex128DType], /) -> ndarray[_ShapeT, dtypes.Float64DType]: ...
  2459. # @overload
  2460. # def __abs__(self: ndarray[_ShapeT, dtypes.CLongDoubleDType], /) -> ndarray[_ShapeT, dtypes.LongDoubleDType]: ...
  2461. # @overload
  2462. # def __abs__(self: ndarray[_ShapeT, dtype[complex128]], /) -> ndarray[_ShapeT, dtype[float64]]: ...
  2463. @overload
  2464. def __abs__(self: ndarray[_ShapeT, dtype[complexfloating[_NBit]]], /) -> ndarray[_ShapeT, dtype[floating[_NBit]]]: ...
  2465. @overload
  2466. def __abs__(self: _RealArrayT, /) -> _RealArrayT: ...
  2467. def __invert__(self: _IntegralArrayT, /) -> _IntegralArrayT: ... # noqa: PYI019
  2468. def __neg__(self: _NumericArrayT, /) -> _NumericArrayT: ... # noqa: PYI019
  2469. def __pos__(self: _NumericArrayT, /) -> _NumericArrayT: ... # noqa: PYI019
  2470. # Binary ops
  2471. # TODO: Support the "1d @ 1d -> scalar" case
  2472. @overload
  2473. def __matmul__(self: NDArray[_NumberT], other: _ArrayLikeBool_co, /) -> NDArray[_NumberT]: ...
  2474. @overload
  2475. def __matmul__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[np.bool]: ... # type: ignore[overload-overlap]
  2476. @overload
  2477. def __matmul__(self: NDArray[np.bool], other: _ArrayLike[_NumberT], /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  2478. @overload
  2479. def __matmul__(self: NDArray[floating[_64Bit]], other: _ArrayLikeFloat64_co, /) -> NDArray[float64]: ...
  2480. @overload
  2481. def __matmul__(self: _ArrayFloat64_co, other: _ArrayLike[floating[_64Bit]], /) -> NDArray[float64]: ...
  2482. @overload
  2483. def __matmul__(self: NDArray[complexfloating[_64Bit]], other: _ArrayLikeComplex128_co, /) -> NDArray[complex128]: ...
  2484. @overload
  2485. def __matmul__(self: _ArrayComplex128_co, other: _ArrayLike[complexfloating[_64Bit]], /) -> NDArray[complex128]: ...
  2486. @overload
  2487. def __matmul__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[overload-overlap]
  2488. @overload
  2489. def __matmul__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ... # type: ignore[overload-overlap]
  2490. @overload
  2491. def __matmul__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co, /) -> NDArray[floating]: ... # type: ignore[overload-overlap]
  2492. @overload
  2493. def __matmul__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co, /) -> NDArray[complexfloating]: ...
  2494. @overload
  2495. def __matmul__(self: NDArray[number], other: _ArrayLikeNumber_co, /) -> NDArray[number]: ...
  2496. @overload
  2497. def __matmul__(self: NDArray[object_], other: Any, /) -> Any: ...
  2498. @overload
  2499. def __matmul__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  2500. @overload # signature equivalent to __matmul__
  2501. def __rmatmul__(self: NDArray[_NumberT], other: _ArrayLikeBool_co, /) -> NDArray[_NumberT]: ...
  2502. @overload
  2503. def __rmatmul__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[np.bool]: ... # type: ignore[overload-overlap]
  2504. @overload
  2505. def __rmatmul__(self: NDArray[np.bool], other: _ArrayLike[_NumberT], /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  2506. @overload
  2507. def __rmatmul__(self: NDArray[floating[_64Bit]], other: _ArrayLikeFloat64_co, /) -> NDArray[float64]: ...
  2508. @overload
  2509. def __rmatmul__(self: _ArrayFloat64_co, other: _ArrayLike[floating[_64Bit]], /) -> NDArray[float64]: ...
  2510. @overload
  2511. def __rmatmul__(self: NDArray[complexfloating[_64Bit]], other: _ArrayLikeComplex128_co, /) -> NDArray[complex128]: ...
  2512. @overload
  2513. def __rmatmul__(self: _ArrayComplex128_co, other: _ArrayLike[complexfloating[_64Bit]], /) -> NDArray[complex128]: ...
  2514. @overload
  2515. def __rmatmul__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[overload-overlap]
  2516. @overload
  2517. def __rmatmul__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ... # type: ignore[overload-overlap]
  2518. @overload
  2519. def __rmatmul__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co, /) -> NDArray[floating]: ... # type: ignore[overload-overlap]
  2520. @overload
  2521. def __rmatmul__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co, /) -> NDArray[complexfloating]: ...
  2522. @overload
  2523. def __rmatmul__(self: NDArray[number], other: _ArrayLikeNumber_co, /) -> NDArray[number]: ...
  2524. @overload
  2525. def __rmatmul__(self: NDArray[object_], other: Any, /) -> Any: ...
  2526. @overload
  2527. def __rmatmul__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  2528. @overload
  2529. def __mod__(self: NDArray[_RealNumberT], other: int | np.bool, /) -> ndarray[_ShapeT_co, dtype[_RealNumberT]]: ...
  2530. @overload
  2531. def __mod__(self: NDArray[_RealNumberT], other: _ArrayLikeBool_co, /) -> NDArray[_RealNumberT]: ... # type: ignore[overload-overlap]
  2532. @overload
  2533. def __mod__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[int8]: ... # type: ignore[overload-overlap]
  2534. @overload
  2535. def __mod__(self: NDArray[np.bool], other: _ArrayLike[_RealNumberT], /) -> NDArray[_RealNumberT]: ... # type: ignore[overload-overlap]
  2536. @overload
  2537. def __mod__(self: NDArray[float64], other: _ArrayLikeFloat64_co, /) -> NDArray[float64]: ...
  2538. @overload
  2539. def __mod__(self: _ArrayFloat64_co, other: _ArrayLike[floating[_64Bit]], /) -> NDArray[float64]: ...
  2540. @overload
  2541. def __mod__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[overload-overlap]
  2542. @overload
  2543. def __mod__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ... # type: ignore[overload-overlap]
  2544. @overload
  2545. def __mod__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co, /) -> NDArray[floating]: ...
  2546. @overload
  2547. def __mod__(self: NDArray[timedelta64], other: _ArrayLike[timedelta64], /) -> NDArray[timedelta64]: ...
  2548. @overload
  2549. def __mod__(self: NDArray[object_], other: Any, /) -> Any: ...
  2550. @overload
  2551. def __mod__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  2552. @overload # signature equivalent to __mod__
  2553. def __rmod__(self: NDArray[_RealNumberT], other: int | np.bool, /) -> ndarray[_ShapeT_co, dtype[_RealNumberT]]: ...
  2554. @overload
  2555. def __rmod__(self: NDArray[_RealNumberT], other: _ArrayLikeBool_co, /) -> NDArray[_RealNumberT]: ... # type: ignore[overload-overlap]
  2556. @overload
  2557. def __rmod__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[int8]: ... # type: ignore[overload-overlap]
  2558. @overload
  2559. def __rmod__(self: NDArray[np.bool], other: _ArrayLike[_RealNumberT], /) -> NDArray[_RealNumberT]: ... # type: ignore[overload-overlap]
  2560. @overload
  2561. def __rmod__(self: NDArray[float64], other: _ArrayLikeFloat64_co, /) -> NDArray[float64]: ...
  2562. @overload
  2563. def __rmod__(self: _ArrayFloat64_co, other: _ArrayLike[floating[_64Bit]], /) -> NDArray[float64]: ...
  2564. @overload
  2565. def __rmod__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[overload-overlap]
  2566. @overload
  2567. def __rmod__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ... # type: ignore[overload-overlap]
  2568. @overload
  2569. def __rmod__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co, /) -> NDArray[floating]: ...
  2570. @overload
  2571. def __rmod__(self: NDArray[timedelta64], other: _ArrayLike[timedelta64], /) -> NDArray[timedelta64]: ...
  2572. @overload
  2573. def __rmod__(self: NDArray[object_], other: Any, /) -> Any: ...
  2574. @overload
  2575. def __rmod__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  2576. @overload
  2577. def __divmod__(self: NDArray[_RealNumberT], rhs: int | np.bool, /) -> _2Tuple[ndarray[_ShapeT_co, dtype[_RealNumberT]]]: ...
  2578. @overload
  2579. def __divmod__(self: NDArray[_RealNumberT], rhs: _ArrayLikeBool_co, /) -> _2Tuple[NDArray[_RealNumberT]]: ... # type: ignore[overload-overlap]
  2580. @overload
  2581. def __divmod__(self: NDArray[np.bool], rhs: _ArrayLikeBool_co, /) -> _2Tuple[NDArray[int8]]: ... # type: ignore[overload-overlap]
  2582. @overload
  2583. def __divmod__(self: NDArray[np.bool], rhs: _ArrayLike[_RealNumberT], /) -> _2Tuple[NDArray[_RealNumberT]]: ... # type: ignore[overload-overlap]
  2584. @overload
  2585. def __divmod__(self: NDArray[float64], rhs: _ArrayLikeFloat64_co, /) -> _2Tuple[NDArray[float64]]: ...
  2586. @overload
  2587. def __divmod__(self: _ArrayFloat64_co, rhs: _ArrayLike[floating[_64Bit]], /) -> _2Tuple[NDArray[float64]]: ...
  2588. @overload
  2589. def __divmod__(self: _ArrayUInt_co, rhs: _ArrayLikeUInt_co, /) -> _2Tuple[NDArray[unsignedinteger]]: ... # type: ignore[overload-overlap]
  2590. @overload
  2591. def __divmod__(self: _ArrayInt_co, rhs: _ArrayLikeInt_co, /) -> _2Tuple[NDArray[signedinteger]]: ... # type: ignore[overload-overlap]
  2592. @overload
  2593. def __divmod__(self: _ArrayFloat_co, rhs: _ArrayLikeFloat_co, /) -> _2Tuple[NDArray[floating]]: ...
  2594. @overload
  2595. def __divmod__(self: NDArray[timedelta64], rhs: _ArrayLike[timedelta64], /) -> tuple[NDArray[int64], NDArray[timedelta64]]: ...
  2596. @overload # signature equivalent to __divmod__
  2597. def __rdivmod__(self: NDArray[_RealNumberT], lhs: int | np.bool, /) -> _2Tuple[ndarray[_ShapeT_co, dtype[_RealNumberT]]]: ...
  2598. @overload
  2599. def __rdivmod__(self: NDArray[_RealNumberT], lhs: _ArrayLikeBool_co, /) -> _2Tuple[NDArray[_RealNumberT]]: ... # type: ignore[overload-overlap]
  2600. @overload
  2601. def __rdivmod__(self: NDArray[np.bool], lhs: _ArrayLikeBool_co, /) -> _2Tuple[NDArray[int8]]: ... # type: ignore[overload-overlap]
  2602. @overload
  2603. def __rdivmod__(self: NDArray[np.bool], lhs: _ArrayLike[_RealNumberT], /) -> _2Tuple[NDArray[_RealNumberT]]: ... # type: ignore[overload-overlap]
  2604. @overload
  2605. def __rdivmod__(self: NDArray[float64], lhs: _ArrayLikeFloat64_co, /) -> _2Tuple[NDArray[float64]]: ...
  2606. @overload
  2607. def __rdivmod__(self: _ArrayFloat64_co, lhs: _ArrayLike[floating[_64Bit]], /) -> _2Tuple[NDArray[float64]]: ...
  2608. @overload
  2609. def __rdivmod__(self: _ArrayUInt_co, lhs: _ArrayLikeUInt_co, /) -> _2Tuple[NDArray[unsignedinteger]]: ... # type: ignore[overload-overlap]
  2610. @overload
  2611. def __rdivmod__(self: _ArrayInt_co, lhs: _ArrayLikeInt_co, /) -> _2Tuple[NDArray[signedinteger]]: ... # type: ignore[overload-overlap]
  2612. @overload
  2613. def __rdivmod__(self: _ArrayFloat_co, lhs: _ArrayLikeFloat_co, /) -> _2Tuple[NDArray[floating]]: ...
  2614. @overload
  2615. def __rdivmod__(self: NDArray[timedelta64], lhs: _ArrayLike[timedelta64], /) -> tuple[NDArray[int64], NDArray[timedelta64]]: ...
  2616. @overload
  2617. def __add__(self: NDArray[_NumberT], other: int | np.bool, /) -> ndarray[_ShapeT_co, dtype[_NumberT]]: ...
  2618. @overload
  2619. def __add__(self: NDArray[_NumberT], other: _ArrayLikeBool_co, /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  2620. @overload
  2621. def __add__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[np.bool]: ... # type: ignore[overload-overlap]
  2622. @overload
  2623. def __add__(self: NDArray[np.bool], other: _ArrayLike[_NumberT], /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  2624. @overload
  2625. def __add__(self: NDArray[float64], other: _ArrayLikeFloat64_co, /) -> NDArray[float64]: ...
  2626. @overload
  2627. def __add__(self: _ArrayFloat64_co, other: _ArrayLike[floating[_64Bit]], /) -> NDArray[float64]: ...
  2628. @overload
  2629. def __add__(self: NDArray[complex128], other: _ArrayLikeComplex128_co, /) -> NDArray[complex128]: ...
  2630. @overload
  2631. def __add__(self: _ArrayComplex128_co, other: _ArrayLike[complexfloating[_64Bit]], /) -> NDArray[complex128]: ...
  2632. @overload
  2633. def __add__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[overload-overlap]
  2634. @overload
  2635. def __add__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ... # type: ignore[overload-overlap]
  2636. @overload
  2637. def __add__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co, /) -> NDArray[floating]: ... # type: ignore[overload-overlap]
  2638. @overload
  2639. def __add__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co, /) -> NDArray[complexfloating]: ... # type: ignore[overload-overlap]
  2640. @overload
  2641. def __add__(self: NDArray[number], other: _ArrayLikeNumber_co, /) -> NDArray[number]: ... # type: ignore[overload-overlap]
  2642. @overload
  2643. def __add__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co, /) -> NDArray[timedelta64]: ...
  2644. @overload
  2645. def __add__(self: _ArrayTD64_co, other: _ArrayLikeDT64_co, /) -> NDArray[datetime64]: ...
  2646. @overload
  2647. def __add__(self: NDArray[datetime64], other: _ArrayLikeTD64_co, /) -> NDArray[datetime64]: ...
  2648. @overload
  2649. def __add__(self: NDArray[bytes_], other: _ArrayLikeBytes_co, /) -> NDArray[bytes_]: ...
  2650. @overload
  2651. def __add__(self: NDArray[str_], other: _ArrayLikeStr_co, /) -> NDArray[str_]: ...
  2652. @overload
  2653. def __add__(
  2654. self: ndarray[Any, dtypes.StringDType],
  2655. other: _ArrayLikeStr_co | _ArrayLikeString_co,
  2656. /,
  2657. ) -> ndarray[tuple[Any, ...], dtypes.StringDType]: ...
  2658. @overload
  2659. def __add__(self: NDArray[object_], other: Any, /) -> Any: ...
  2660. @overload
  2661. def __add__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  2662. @overload # signature equivalent to __add__
  2663. def __radd__(self: NDArray[_NumberT], other: int | np.bool, /) -> ndarray[_ShapeT_co, dtype[_NumberT]]: ...
  2664. @overload
  2665. def __radd__(self: NDArray[_NumberT], other: _ArrayLikeBool_co, /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  2666. @overload
  2667. def __radd__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[np.bool]: ... # type: ignore[overload-overlap]
  2668. @overload
  2669. def __radd__(self: NDArray[np.bool], other: _ArrayLike[_NumberT], /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  2670. @overload
  2671. def __radd__(self: NDArray[float64], other: _ArrayLikeFloat64_co, /) -> NDArray[float64]: ...
  2672. @overload
  2673. def __radd__(self: _ArrayFloat64_co, other: _ArrayLike[floating[_64Bit]], /) -> NDArray[float64]: ...
  2674. @overload
  2675. def __radd__(self: NDArray[complex128], other: _ArrayLikeComplex128_co, /) -> NDArray[complex128]: ...
  2676. @overload
  2677. def __radd__(self: _ArrayComplex128_co, other: _ArrayLike[complexfloating[_64Bit]], /) -> NDArray[complex128]: ...
  2678. @overload
  2679. def __radd__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[overload-overlap]
  2680. @overload
  2681. def __radd__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ... # type: ignore[overload-overlap]
  2682. @overload
  2683. def __radd__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co, /) -> NDArray[floating]: ... # type: ignore[overload-overlap]
  2684. @overload
  2685. def __radd__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co, /) -> NDArray[complexfloating]: ... # type: ignore[overload-overlap]
  2686. @overload
  2687. def __radd__(self: NDArray[number], other: _ArrayLikeNumber_co, /) -> NDArray[number]: ... # type: ignore[overload-overlap]
  2688. @overload
  2689. def __radd__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co, /) -> NDArray[timedelta64]: ...
  2690. @overload
  2691. def __radd__(self: _ArrayTD64_co, other: _ArrayLikeDT64_co, /) -> NDArray[datetime64]: ...
  2692. @overload
  2693. def __radd__(self: NDArray[datetime64], other: _ArrayLikeTD64_co, /) -> NDArray[datetime64]: ...
  2694. @overload
  2695. def __radd__(self: NDArray[bytes_], other: _ArrayLikeBytes_co, /) -> NDArray[bytes_]: ...
  2696. @overload
  2697. def __radd__(self: NDArray[str_], other: _ArrayLikeStr_co, /) -> NDArray[str_]: ...
  2698. @overload
  2699. def __radd__(
  2700. self: ndarray[Any, dtypes.StringDType],
  2701. other: _ArrayLikeStr_co | _ArrayLikeString_co,
  2702. /,
  2703. ) -> ndarray[tuple[Any, ...], dtypes.StringDType]: ...
  2704. @overload
  2705. def __radd__(self: NDArray[object_], other: Any, /) -> Any: ...
  2706. @overload
  2707. def __radd__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  2708. @overload
  2709. def __sub__(self: NDArray[_NumberT], other: int | np.bool, /) -> ndarray[_ShapeT_co, dtype[_NumberT]]: ...
  2710. @overload
  2711. def __sub__(self: NDArray[_NumberT], other: _ArrayLikeBool_co, /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  2712. @overload
  2713. def __sub__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NoReturn: ...
  2714. @overload
  2715. def __sub__(self: NDArray[np.bool], other: _ArrayLike[_NumberT], /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  2716. @overload
  2717. def __sub__(self: NDArray[float64], other: _ArrayLikeFloat64_co, /) -> NDArray[float64]: ...
  2718. @overload
  2719. def __sub__(self: _ArrayFloat64_co, other: _ArrayLike[floating[_64Bit]], /) -> NDArray[float64]: ...
  2720. @overload
  2721. def __sub__(self: NDArray[complex128], other: _ArrayLikeComplex128_co, /) -> NDArray[complex128]: ...
  2722. @overload
  2723. def __sub__(self: _ArrayComplex128_co, other: _ArrayLike[complexfloating[_64Bit]], /) -> NDArray[complex128]: ...
  2724. @overload
  2725. def __sub__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[overload-overlap]
  2726. @overload
  2727. def __sub__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ... # type: ignore[overload-overlap]
  2728. @overload
  2729. def __sub__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co, /) -> NDArray[floating]: ... # type: ignore[overload-overlap]
  2730. @overload
  2731. def __sub__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co, /) -> NDArray[complexfloating]: ... # type: ignore[overload-overlap]
  2732. @overload
  2733. def __sub__(self: NDArray[number], other: _ArrayLikeNumber_co, /) -> NDArray[number]: ... # type: ignore[overload-overlap]
  2734. @overload
  2735. def __sub__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co, /) -> NDArray[timedelta64]: ...
  2736. @overload
  2737. def __sub__(self: NDArray[datetime64], other: _ArrayLikeTD64_co, /) -> NDArray[datetime64]: ...
  2738. @overload
  2739. def __sub__(self: NDArray[datetime64], other: _ArrayLikeDT64_co, /) -> NDArray[timedelta64]: ...
  2740. @overload
  2741. def __sub__(self: NDArray[object_], other: Any, /) -> Any: ...
  2742. @overload
  2743. def __sub__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  2744. @overload
  2745. def __rsub__(self: NDArray[_NumberT], other: int | np.bool, /) -> ndarray[_ShapeT_co, dtype[_NumberT]]: ...
  2746. @overload
  2747. def __rsub__(self: NDArray[_NumberT], other: _ArrayLikeBool_co, /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  2748. @overload
  2749. def __rsub__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NoReturn: ...
  2750. @overload
  2751. def __rsub__(self: NDArray[np.bool], other: _ArrayLike[_NumberT], /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  2752. @overload
  2753. def __rsub__(self: NDArray[float64], other: _ArrayLikeFloat64_co, /) -> NDArray[float64]: ...
  2754. @overload
  2755. def __rsub__(self: _ArrayFloat64_co, other: _ArrayLike[floating[_64Bit]], /) -> NDArray[float64]: ...
  2756. @overload
  2757. def __rsub__(self: NDArray[complex128], other: _ArrayLikeComplex128_co, /) -> NDArray[complex128]: ...
  2758. @overload
  2759. def __rsub__(self: _ArrayComplex128_co, other: _ArrayLike[complexfloating[_64Bit]], /) -> NDArray[complex128]: ...
  2760. @overload
  2761. def __rsub__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[overload-overlap]
  2762. @overload
  2763. def __rsub__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ... # type: ignore[overload-overlap]
  2764. @overload
  2765. def __rsub__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co, /) -> NDArray[floating]: ... # type: ignore[overload-overlap]
  2766. @overload
  2767. def __rsub__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co, /) -> NDArray[complexfloating]: ... # type: ignore[overload-overlap]
  2768. @overload
  2769. def __rsub__(self: NDArray[number], other: _ArrayLikeNumber_co, /) -> NDArray[number]: ... # type: ignore[overload-overlap]
  2770. @overload
  2771. def __rsub__(self: _ArrayTD64_co, other: _ArrayLikeTD64_co, /) -> NDArray[timedelta64]: ...
  2772. @overload
  2773. def __rsub__(self: _ArrayTD64_co, other: _ArrayLikeDT64_co, /) -> NDArray[datetime64]: ...
  2774. @overload
  2775. def __rsub__(self: NDArray[datetime64], other: _ArrayLikeDT64_co, /) -> NDArray[timedelta64]: ...
  2776. @overload
  2777. def __rsub__(self: NDArray[object_], other: Any, /) -> Any: ...
  2778. @overload
  2779. def __rsub__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  2780. @overload
  2781. def __mul__(self: NDArray[_NumberT], other: int | np.bool, /) -> ndarray[_ShapeT_co, dtype[_NumberT]]: ...
  2782. @overload
  2783. def __mul__(self: NDArray[_NumberT], other: _ArrayLikeBool_co, /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  2784. @overload
  2785. def __mul__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[np.bool]: ... # type: ignore[overload-overlap]
  2786. @overload
  2787. def __mul__(self: NDArray[np.bool], other: _ArrayLike[_NumberT], /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  2788. @overload
  2789. def __mul__(self: NDArray[float64], other: _ArrayLikeFloat64_co, /) -> NDArray[float64]: ...
  2790. @overload
  2791. def __mul__(self: _ArrayFloat64_co, other: _ArrayLike[floating[_64Bit]], /) -> NDArray[float64]: ...
  2792. @overload
  2793. def __mul__(self: NDArray[complex128], other: _ArrayLikeComplex128_co, /) -> NDArray[complex128]: ...
  2794. @overload
  2795. def __mul__(self: _ArrayComplex128_co, other: _ArrayLike[complexfloating[_64Bit]], /) -> NDArray[complex128]: ...
  2796. @overload
  2797. def __mul__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[overload-overlap]
  2798. @overload
  2799. def __mul__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ... # type: ignore[overload-overlap]
  2800. @overload
  2801. def __mul__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co, /) -> NDArray[floating]: ... # type: ignore[overload-overlap]
  2802. @overload
  2803. def __mul__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co, /) -> NDArray[complexfloating]: ... # type: ignore[overload-overlap]
  2804. @overload
  2805. def __mul__(self: NDArray[number], other: _ArrayLikeNumber_co, /) -> NDArray[number]: ...
  2806. @overload
  2807. def __mul__(self: NDArray[timedelta64], other: _ArrayLikeFloat_co, /) -> NDArray[timedelta64]: ...
  2808. @overload
  2809. def __mul__(self: _ArrayFloat_co, other: _ArrayLike[timedelta64], /) -> NDArray[timedelta64]: ...
  2810. @overload
  2811. def __mul__(
  2812. self: ndarray[Any, dtype[character] | dtypes.StringDType],
  2813. other: _ArrayLikeInt,
  2814. /,
  2815. ) -> ndarray[tuple[Any, ...], _DTypeT_co]: ...
  2816. @overload
  2817. def __mul__(self: NDArray[object_], other: Any, /) -> Any: ...
  2818. @overload
  2819. def __mul__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  2820. @overload # signature equivalent to __mul__
  2821. def __rmul__(self: NDArray[_NumberT], other: int | np.bool, /) -> ndarray[_ShapeT_co, dtype[_NumberT]]: ...
  2822. @overload
  2823. def __rmul__(self: NDArray[_NumberT], other: _ArrayLikeBool_co, /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  2824. @overload
  2825. def __rmul__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[np.bool]: ... # type: ignore[overload-overlap]
  2826. @overload
  2827. def __rmul__(self: NDArray[np.bool], other: _ArrayLike[_NumberT], /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  2828. @overload
  2829. def __rmul__(self: NDArray[float64], other: _ArrayLikeFloat64_co, /) -> NDArray[float64]: ...
  2830. @overload
  2831. def __rmul__(self: _ArrayFloat64_co, other: _ArrayLike[floating[_64Bit]], /) -> NDArray[float64]: ...
  2832. @overload
  2833. def __rmul__(self: NDArray[complex128], other: _ArrayLikeComplex128_co, /) -> NDArray[complex128]: ...
  2834. @overload
  2835. def __rmul__(self: _ArrayComplex128_co, other: _ArrayLike[complexfloating[_64Bit]], /) -> NDArray[complex128]: ...
  2836. @overload
  2837. def __rmul__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[overload-overlap]
  2838. @overload
  2839. def __rmul__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ... # type: ignore[overload-overlap]
  2840. @overload
  2841. def __rmul__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co, /) -> NDArray[floating]: ... # type: ignore[overload-overlap]
  2842. @overload
  2843. def __rmul__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co, /) -> NDArray[complexfloating]: ... # type: ignore[overload-overlap]
  2844. @overload
  2845. def __rmul__(self: NDArray[number], other: _ArrayLikeNumber_co, /) -> NDArray[number]: ...
  2846. @overload
  2847. def __rmul__(self: NDArray[timedelta64], other: _ArrayLikeFloat_co, /) -> NDArray[timedelta64]: ...
  2848. @overload
  2849. def __rmul__(self: _ArrayFloat_co, other: _ArrayLike[timedelta64], /) -> NDArray[timedelta64]: ...
  2850. @overload
  2851. def __rmul__(
  2852. self: ndarray[Any, dtype[character] | dtypes.StringDType],
  2853. other: _ArrayLikeInt,
  2854. /,
  2855. ) -> ndarray[tuple[Any, ...], _DTypeT_co]: ...
  2856. @overload
  2857. def __rmul__(self: NDArray[object_], other: Any, /) -> Any: ...
  2858. @overload
  2859. def __rmul__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  2860. @overload
  2861. def __truediv__(self: _ArrayInt_co | NDArray[float64], other: _ArrayLikeFloat64_co, /) -> NDArray[float64]: ...
  2862. @overload
  2863. def __truediv__(self: _ArrayFloat64_co, other: _ArrayLikeInt_co | _ArrayLike[floating[_64Bit]], /) -> NDArray[float64]: ...
  2864. @overload
  2865. def __truediv__(self: NDArray[complex128], other: _ArrayLikeComplex128_co, /) -> NDArray[complex128]: ...
  2866. @overload
  2867. def __truediv__(self: _ArrayComplex128_co, other: _ArrayLike[complexfloating[_64Bit]], /) -> NDArray[complex128]: ...
  2868. @overload
  2869. def __truediv__(self: NDArray[floating], other: _ArrayLikeFloat_co, /) -> NDArray[floating]: ...
  2870. @overload
  2871. def __truediv__(self: _ArrayFloat_co, other: _ArrayLike[floating], /) -> NDArray[floating]: ...
  2872. @overload
  2873. def __truediv__(self: NDArray[complexfloating], other: _ArrayLikeNumber_co, /) -> NDArray[complexfloating]: ...
  2874. @overload
  2875. def __truediv__(self: _ArrayNumber_co, other: _ArrayLike[complexfloating], /) -> NDArray[complexfloating]: ...
  2876. @overload
  2877. def __truediv__(self: NDArray[inexact], other: _ArrayLikeNumber_co, /) -> NDArray[inexact]: ...
  2878. @overload
  2879. def __truediv__(self: NDArray[number], other: _ArrayLikeNumber_co, /) -> NDArray[number]: ...
  2880. @overload
  2881. def __truediv__(self: NDArray[timedelta64], other: _ArrayLike[timedelta64], /) -> NDArray[float64]: ...
  2882. @overload
  2883. def __truediv__(self: NDArray[timedelta64], other: _ArrayLikeBool_co, /) -> NoReturn: ...
  2884. @overload
  2885. def __truediv__(self: NDArray[timedelta64], other: _ArrayLikeFloat_co, /) -> NDArray[timedelta64]: ...
  2886. @overload
  2887. def __truediv__(self: NDArray[object_], other: Any, /) -> Any: ...
  2888. @overload
  2889. def __truediv__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  2890. @overload
  2891. def __rtruediv__(self: _ArrayInt_co | NDArray[float64], other: _ArrayLikeFloat64_co, /) -> NDArray[float64]: ...
  2892. @overload
  2893. def __rtruediv__(self: _ArrayFloat64_co, other: _ArrayLikeInt_co | _ArrayLike[floating[_64Bit]], /) -> NDArray[float64]: ...
  2894. @overload
  2895. def __rtruediv__(self: NDArray[complex128], other: _ArrayLikeComplex128_co, /) -> NDArray[complex128]: ...
  2896. @overload
  2897. def __rtruediv__(self: _ArrayComplex128_co, other: _ArrayLike[complexfloating[_64Bit]], /) -> NDArray[complex128]: ...
  2898. @overload
  2899. def __rtruediv__(self: NDArray[floating], other: _ArrayLikeFloat_co, /) -> NDArray[floating]: ...
  2900. @overload
  2901. def __rtruediv__(self: _ArrayFloat_co, other: _ArrayLike[floating], /) -> NDArray[floating]: ...
  2902. @overload
  2903. def __rtruediv__(self: NDArray[complexfloating], other: _ArrayLikeNumber_co, /) -> NDArray[complexfloating]: ...
  2904. @overload
  2905. def __rtruediv__(self: _ArrayNumber_co, other: _ArrayLike[complexfloating], /) -> NDArray[complexfloating]: ...
  2906. @overload
  2907. def __rtruediv__(self: NDArray[inexact], other: _ArrayLikeNumber_co, /) -> NDArray[inexact]: ...
  2908. @overload
  2909. def __rtruediv__(self: NDArray[number], other: _ArrayLikeNumber_co, /) -> NDArray[number]: ...
  2910. @overload
  2911. def __rtruediv__(self: NDArray[timedelta64], other: _ArrayLike[timedelta64], /) -> NDArray[float64]: ...
  2912. @overload
  2913. def __rtruediv__(self: NDArray[integer | floating], other: _ArrayLike[timedelta64], /) -> NDArray[timedelta64]: ...
  2914. @overload
  2915. def __rtruediv__(self: NDArray[object_], other: Any, /) -> Any: ...
  2916. @overload
  2917. def __rtruediv__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  2918. @overload
  2919. def __floordiv__(self: NDArray[_RealNumberT], other: int | np.bool, /) -> ndarray[_ShapeT_co, dtype[_RealNumberT]]: ...
  2920. @overload
  2921. def __floordiv__(self: NDArray[_RealNumberT], other: _ArrayLikeBool_co, /) -> NDArray[_RealNumberT]: ... # type: ignore[overload-overlap]
  2922. @overload
  2923. def __floordiv__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[int8]: ... # type: ignore[overload-overlap]
  2924. @overload
  2925. def __floordiv__(self: NDArray[np.bool], other: _ArrayLike[_RealNumberT], /) -> NDArray[_RealNumberT]: ... # type: ignore[overload-overlap]
  2926. @overload
  2927. def __floordiv__(self: NDArray[float64], other: _ArrayLikeFloat64_co, /) -> NDArray[float64]: ...
  2928. @overload
  2929. def __floordiv__(self: _ArrayFloat64_co, other: _ArrayLike[floating[_64Bit]], /) -> NDArray[float64]: ...
  2930. @overload
  2931. def __floordiv__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[overload-overlap]
  2932. @overload
  2933. def __floordiv__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ... # type: ignore[overload-overlap]
  2934. @overload
  2935. def __floordiv__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co, /) -> NDArray[floating]: ...
  2936. @overload
  2937. def __floordiv__(self: NDArray[timedelta64], other: _ArrayLike[timedelta64], /) -> NDArray[int64]: ...
  2938. @overload
  2939. def __floordiv__(self: NDArray[timedelta64], other: _ArrayLikeBool_co, /) -> NoReturn: ...
  2940. @overload
  2941. def __floordiv__(self: NDArray[timedelta64], other: _ArrayLikeFloat_co, /) -> NDArray[timedelta64]: ...
  2942. @overload
  2943. def __floordiv__(self: NDArray[object_], other: Any, /) -> Any: ...
  2944. @overload
  2945. def __floordiv__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  2946. @overload
  2947. def __rfloordiv__(self: NDArray[_RealNumberT], other: int | np.bool, /) -> ndarray[_ShapeT_co, dtype[_RealNumberT]]: ...
  2948. @overload
  2949. def __rfloordiv__(self: NDArray[_RealNumberT], other: _ArrayLikeBool_co, /) -> NDArray[_RealNumberT]: ... # type: ignore[overload-overlap]
  2950. @overload
  2951. def __rfloordiv__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[int8]: ... # type: ignore[overload-overlap]
  2952. @overload
  2953. def __rfloordiv__(self: NDArray[np.bool], other: _ArrayLike[_RealNumberT], /) -> NDArray[_RealNumberT]: ... # type: ignore[overload-overlap]
  2954. @overload
  2955. def __rfloordiv__(self: NDArray[float64], other: _ArrayLikeFloat64_co, /) -> NDArray[float64]: ...
  2956. @overload
  2957. def __rfloordiv__(self: _ArrayFloat64_co, other: _ArrayLike[floating[_64Bit]], /) -> NDArray[float64]: ...
  2958. @overload
  2959. def __rfloordiv__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[overload-overlap]
  2960. @overload
  2961. def __rfloordiv__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ... # type: ignore[overload-overlap]
  2962. @overload
  2963. def __rfloordiv__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co, /) -> NDArray[floating]: ... # type: ignore[overload-overlap]
  2964. @overload
  2965. def __rfloordiv__(self: NDArray[timedelta64], other: _ArrayLike[timedelta64], /) -> NDArray[int64]: ...
  2966. @overload
  2967. def __rfloordiv__(self: NDArray[floating | integer], other: _ArrayLike[timedelta64], /) -> NDArray[timedelta64]: ...
  2968. @overload
  2969. def __rfloordiv__(self: NDArray[object_], other: Any, /) -> Any: ...
  2970. @overload
  2971. def __rfloordiv__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  2972. @overload
  2973. def __pow__(self: NDArray[_NumberT], other: int | np.bool, mod: None = None, /) -> ndarray[_ShapeT_co, dtype[_NumberT]]: ...
  2974. @overload
  2975. def __pow__(self: NDArray[_NumberT], other: _ArrayLikeBool_co, mod: None = None, /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  2976. @overload
  2977. def __pow__(self: NDArray[np.bool], other: _ArrayLikeBool_co, mod: None = None, /) -> NDArray[int8]: ... # type: ignore[overload-overlap]
  2978. @overload
  2979. def __pow__(self: NDArray[np.bool], other: _ArrayLike[_NumberT], mod: None = None, /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  2980. @overload
  2981. def __pow__(self: NDArray[float64], other: _ArrayLikeFloat64_co, mod: None = None, /) -> NDArray[float64]: ...
  2982. @overload
  2983. def __pow__(self: _ArrayFloat64_co, other: _ArrayLike[floating[_64Bit]], mod: None = None, /) -> NDArray[float64]: ...
  2984. @overload
  2985. def __pow__(self: NDArray[complex128], other: _ArrayLikeComplex128_co, mod: None = None, /) -> NDArray[complex128]: ...
  2986. @overload
  2987. def __pow__(
  2988. self: _ArrayComplex128_co, other: _ArrayLike[complexfloating[_64Bit]], mod: None = None, /
  2989. ) -> NDArray[complex128]: ...
  2990. @overload
  2991. def __pow__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, mod: None = None, /) -> NDArray[unsignedinteger]: ... # type: ignore[overload-overlap]
  2992. @overload
  2993. def __pow__(self: _ArrayInt_co, other: _ArrayLikeInt_co, mod: None = None, /) -> NDArray[signedinteger]: ... # type: ignore[overload-overlap]
  2994. @overload
  2995. def __pow__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co, mod: None = None, /) -> NDArray[floating]: ... # type: ignore[overload-overlap]
  2996. @overload
  2997. def __pow__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co, mod: None = None, /) -> NDArray[complexfloating]: ...
  2998. @overload
  2999. def __pow__(self: NDArray[number], other: _ArrayLikeNumber_co, mod: None = None, /) -> NDArray[number]: ...
  3000. @overload
  3001. def __pow__(self: NDArray[object_], other: Any, mod: None = None, /) -> Any: ...
  3002. @overload
  3003. def __pow__(self: NDArray[Any], other: _ArrayLikeObject_co, mod: None = None, /) -> Any: ...
  3004. @overload
  3005. def __rpow__(self: NDArray[_NumberT], other: int | np.bool, mod: None = None, /) -> ndarray[_ShapeT_co, dtype[_NumberT]]: ...
  3006. @overload
  3007. def __rpow__(self: NDArray[_NumberT], other: _ArrayLikeBool_co, mod: None = None, /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  3008. @overload
  3009. def __rpow__(self: NDArray[np.bool], other: _ArrayLikeBool_co, mod: None = None, /) -> NDArray[int8]: ... # type: ignore[overload-overlap]
  3010. @overload
  3011. def __rpow__(self: NDArray[np.bool], other: _ArrayLike[_NumberT], mod: None = None, /) -> NDArray[_NumberT]: ... # type: ignore[overload-overlap]
  3012. @overload
  3013. def __rpow__(self: NDArray[float64], other: _ArrayLikeFloat64_co, mod: None = None, /) -> NDArray[float64]: ...
  3014. @overload
  3015. def __rpow__(self: _ArrayFloat64_co, other: _ArrayLike[floating[_64Bit]], mod: None = None, /) -> NDArray[float64]: ...
  3016. @overload
  3017. def __rpow__(self: NDArray[complex128], other: _ArrayLikeComplex128_co, mod: None = None, /) -> NDArray[complex128]: ...
  3018. @overload
  3019. def __rpow__(
  3020. self: _ArrayComplex128_co, other: _ArrayLike[complexfloating[_64Bit]], mod: None = None, /
  3021. ) -> NDArray[complex128]: ...
  3022. @overload
  3023. def __rpow__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, mod: None = None, /) -> NDArray[unsignedinteger]: ... # type: ignore[overload-overlap]
  3024. @overload
  3025. def __rpow__(self: _ArrayInt_co, other: _ArrayLikeInt_co, mod: None = None, /) -> NDArray[signedinteger]: ... # type: ignore[overload-overlap]
  3026. @overload
  3027. def __rpow__(self: _ArrayFloat_co, other: _ArrayLikeFloat_co, mod: None = None, /) -> NDArray[floating]: ... # type: ignore[overload-overlap]
  3028. @overload
  3029. def __rpow__(self: _ArrayComplex_co, other: _ArrayLikeComplex_co, mod: None = None, /) -> NDArray[complexfloating]: ...
  3030. @overload
  3031. def __rpow__(self: NDArray[number], other: _ArrayLikeNumber_co, mod: None = None, /) -> NDArray[number]: ...
  3032. @overload
  3033. def __rpow__(self: NDArray[object_], other: Any, mod: None = None, /) -> Any: ...
  3034. @overload
  3035. def __rpow__(self: NDArray[Any], other: _ArrayLikeObject_co, mod: None = None, /) -> Any: ...
  3036. @overload
  3037. def __lshift__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[int8]: ... # type: ignore[misc]
  3038. @overload
  3039. def __lshift__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[misc]
  3040. @overload
  3041. def __lshift__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ...
  3042. @overload
  3043. def __lshift__(self: NDArray[object_], other: Any, /) -> Any: ...
  3044. @overload
  3045. def __lshift__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  3046. @overload
  3047. def __rlshift__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[int8]: ... # type: ignore[misc]
  3048. @overload
  3049. def __rlshift__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[misc]
  3050. @overload
  3051. def __rlshift__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ...
  3052. @overload
  3053. def __rlshift__(self: NDArray[object_], other: Any, /) -> Any: ...
  3054. @overload
  3055. def __rlshift__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  3056. @overload
  3057. def __rshift__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[int8]: ... # type: ignore[misc]
  3058. @overload
  3059. def __rshift__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[misc]
  3060. @overload
  3061. def __rshift__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ...
  3062. @overload
  3063. def __rshift__(self: NDArray[object_], other: Any, /) -> Any: ...
  3064. @overload
  3065. def __rshift__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  3066. @overload
  3067. def __rrshift__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[int8]: ... # type: ignore[misc]
  3068. @overload
  3069. def __rrshift__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[misc]
  3070. @overload
  3071. def __rrshift__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ...
  3072. @overload
  3073. def __rrshift__(self: NDArray[object_], other: Any, /) -> Any: ...
  3074. @overload
  3075. def __rrshift__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  3076. @overload
  3077. def __and__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[np.bool]: ... # type: ignore[misc]
  3078. @overload
  3079. def __and__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[misc]
  3080. @overload
  3081. def __and__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ...
  3082. @overload
  3083. def __and__(self: NDArray[object_], other: Any, /) -> Any: ...
  3084. @overload
  3085. def __and__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  3086. @overload
  3087. def __rand__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[np.bool]: ... # type: ignore[misc]
  3088. @overload
  3089. def __rand__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[misc]
  3090. @overload
  3091. def __rand__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ...
  3092. @overload
  3093. def __rand__(self: NDArray[object_], other: Any, /) -> Any: ...
  3094. @overload
  3095. def __rand__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  3096. @overload
  3097. def __xor__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[np.bool]: ... # type: ignore[misc]
  3098. @overload
  3099. def __xor__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[misc]
  3100. @overload
  3101. def __xor__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ...
  3102. @overload
  3103. def __xor__(self: NDArray[object_], other: Any, /) -> Any: ...
  3104. @overload
  3105. def __xor__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  3106. @overload
  3107. def __rxor__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[np.bool]: ... # type: ignore[misc]
  3108. @overload
  3109. def __rxor__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[misc]
  3110. @overload
  3111. def __rxor__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ...
  3112. @overload
  3113. def __rxor__(self: NDArray[object_], other: Any, /) -> Any: ...
  3114. @overload
  3115. def __rxor__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  3116. @overload
  3117. def __or__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[np.bool]: ... # type: ignore[misc]
  3118. @overload
  3119. def __or__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[misc]
  3120. @overload
  3121. def __or__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ...
  3122. @overload
  3123. def __or__(self: NDArray[object_], other: Any, /) -> Any: ...
  3124. @overload
  3125. def __or__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  3126. @overload
  3127. def __ror__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> NDArray[np.bool]: ... # type: ignore[misc]
  3128. @overload
  3129. def __ror__(self: _ArrayUInt_co, other: _ArrayLikeUInt_co, /) -> NDArray[unsignedinteger]: ... # type: ignore[misc]
  3130. @overload
  3131. def __ror__(self: _ArrayInt_co, other: _ArrayLikeInt_co, /) -> NDArray[signedinteger]: ...
  3132. @overload
  3133. def __ror__(self: NDArray[object_], other: Any, /) -> Any: ...
  3134. @overload
  3135. def __ror__(self: NDArray[Any], other: _ArrayLikeObject_co, /) -> Any: ...
  3136. # `np.generic` does not support inplace operations
  3137. # NOTE: Inplace ops generally use "same_kind" casting w.r.t. to the left
  3138. # operand. An exception to this rule are unsigned integers though, which
  3139. # also accepts a signed integer for the right operand as long it is a 0D
  3140. # object and its value is >= 0
  3141. # NOTE: Due to a mypy bug, overloading on e.g. `self: NDArray[SCT_floating]` won't
  3142. # work, as this will lead to `false negatives` when using these inplace ops.
  3143. @overload
  3144. def __iadd__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3145. @overload
  3146. def __iadd__(self: NDArray[integer], other: _ArrayLikeInt_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3147. @overload
  3148. def __iadd__(self: NDArray[floating], other: _ArrayLikeFloat_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3149. @overload
  3150. def __iadd__(self: NDArray[complexfloating], other: _ArrayLikeComplex_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3151. @overload
  3152. def __iadd__(self: NDArray[timedelta64 | datetime64], other: _ArrayLikeTD64_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3153. @overload
  3154. def __iadd__(self: NDArray[bytes_], other: _ArrayLikeBytes_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3155. @overload
  3156. def __iadd__(
  3157. self: ndarray[Any, dtype[str_] | dtypes.StringDType],
  3158. other: _ArrayLikeStr_co | _ArrayLikeString_co,
  3159. /,
  3160. ) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3161. @overload
  3162. def __iadd__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3163. #
  3164. @overload
  3165. def __isub__(self: NDArray[integer], other: _ArrayLikeInt_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3166. @overload
  3167. def __isub__(self: NDArray[floating], other: _ArrayLikeFloat_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3168. @overload
  3169. def __isub__(self: NDArray[complexfloating], other: _ArrayLikeComplex_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3170. @overload
  3171. def __isub__(self: NDArray[timedelta64 | datetime64], other: _ArrayLikeTD64_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3172. @overload
  3173. def __isub__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3174. #
  3175. @overload
  3176. def __imul__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3177. @overload
  3178. def __imul__(
  3179. self: ndarray[Any, dtype[integer | character] | dtypes.StringDType], other: _ArrayLikeInt_co, /
  3180. ) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3181. @overload
  3182. def __imul__(self: NDArray[floating | timedelta64], other: _ArrayLikeFloat_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3183. @overload
  3184. def __imul__(self: NDArray[complexfloating], other: _ArrayLikeComplex_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3185. @overload
  3186. def __imul__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3187. @overload
  3188. def __ipow__(self: NDArray[integer], other: _ArrayLikeInt_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3189. @overload
  3190. def __ipow__(self: NDArray[floating], other: _ArrayLikeFloat_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3191. @overload
  3192. def __ipow__(self: NDArray[complexfloating], other: _ArrayLikeComplex_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3193. @overload
  3194. def __ipow__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3195. #
  3196. @overload
  3197. def __itruediv__(self: NDArray[floating | timedelta64], other: _ArrayLikeFloat_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3198. @overload
  3199. def __itruediv__(self: NDArray[complexfloating], other: _ArrayLikeComplex_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3200. @overload
  3201. def __itruediv__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3202. # keep in sync with `__imod__`
  3203. @overload
  3204. def __ifloordiv__(self: NDArray[integer], other: _ArrayLikeInt_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3205. @overload
  3206. def __ifloordiv__(self: NDArray[floating | timedelta64], other: _ArrayLikeFloat_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3207. @overload
  3208. def __ifloordiv__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3209. # keep in sync with `__ifloordiv__`
  3210. @overload
  3211. def __imod__(self: NDArray[integer], other: _ArrayLikeInt_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3212. @overload
  3213. def __imod__(self: NDArray[floating], other: _ArrayLikeFloat_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3214. @overload
  3215. def __imod__(
  3216. self: NDArray[timedelta64],
  3217. other: _SupportsArray[_dtype[timedelta64]] | _NestedSequence[_SupportsArray[_dtype[timedelta64]]],
  3218. /,
  3219. ) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3220. @overload
  3221. def __imod__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3222. # keep in sync with `__irshift__`
  3223. @overload
  3224. def __ilshift__(self: NDArray[integer], other: _ArrayLikeInt_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3225. @overload
  3226. def __ilshift__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3227. # keep in sync with `__ilshift__`
  3228. @overload
  3229. def __irshift__(self: NDArray[integer], other: _ArrayLikeInt_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3230. @overload
  3231. def __irshift__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3232. # keep in sync with `__ixor__` and `__ior__`
  3233. @overload
  3234. def __iand__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3235. @overload
  3236. def __iand__(self: NDArray[integer], other: _ArrayLikeInt_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3237. @overload
  3238. def __iand__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3239. # keep in sync with `__iand__` and `__ior__`
  3240. @overload
  3241. def __ixor__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3242. @overload
  3243. def __ixor__(self: NDArray[integer], other: _ArrayLikeInt_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3244. @overload
  3245. def __ixor__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3246. # keep in sync with `__iand__` and `__ixor__`
  3247. @overload
  3248. def __ior__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3249. @overload
  3250. def __ior__(self: NDArray[integer], other: _ArrayLikeInt_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3251. @overload
  3252. def __ior__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3253. #
  3254. @overload
  3255. def __imatmul__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3256. @overload
  3257. def __imatmul__(self: NDArray[integer], other: _ArrayLikeInt_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3258. @overload
  3259. def __imatmul__(self: NDArray[floating], other: _ArrayLikeFloat_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3260. @overload
  3261. def __imatmul__(self: NDArray[complexfloating], other: _ArrayLikeComplex_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3262. @overload
  3263. def __imatmul__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
  3264. #
  3265. def __dlpack__(
  3266. self: NDArray[number],
  3267. /,
  3268. *,
  3269. stream: int | Any | None = None,
  3270. max_version: tuple[int, int] | None = None,
  3271. dl_device: tuple[int, int] | None = None,
  3272. copy: builtins.bool | None = None,
  3273. ) -> CapsuleType: ...
  3274. def __dlpack_device__(self, /) -> tuple[L[1], L[0]]: ...
  3275. # Keep `dtype` at the bottom to avoid name conflicts with `np.dtype`
  3276. @property
  3277. def dtype(self) -> _DTypeT_co: ...
  3278. # NOTE: while `np.generic` is not technically an instance of `ABCMeta`,
  3279. # the `@abstractmethod` decorator is herein used to (forcefully) deny
  3280. # the creation of `np.generic` instances.
  3281. # The `# type: ignore` comments are necessary to silence mypy errors regarding
  3282. # the missing `ABCMeta` metaclass.
  3283. # See https://github.com/numpy/numpy-stubs/pull/80 for more details.
  3284. class generic(_ArrayOrScalarCommon, Generic[_ItemT_co]):
  3285. @abstractmethod
  3286. def __init__(self, *args: Any, **kwargs: Any) -> None: ...
  3287. def __hash__(self) -> int: ...
  3288. @overload
  3289. def __array__(self, dtype: None = None, /) -> ndarray[tuple[()], dtype[Self]]: ...
  3290. @overload
  3291. def __array__(self, dtype: _DTypeT, /) -> ndarray[tuple[()], _DTypeT]: ...
  3292. if sys.version_info >= (3, 12):
  3293. def __buffer__(self, flags: int, /) -> memoryview: ...
  3294. @property
  3295. def base(self) -> None: ...
  3296. @property
  3297. def ndim(self) -> L[0]: ...
  3298. @property
  3299. def size(self) -> L[1]: ...
  3300. @property
  3301. def shape(self) -> tuple[()]: ...
  3302. @property
  3303. def strides(self) -> tuple[()]: ...
  3304. @property
  3305. def flat(self) -> flatiter[ndarray[tuple[int], dtype[Self]]]: ...
  3306. @overload
  3307. def item(self, /) -> _ItemT_co: ...
  3308. @overload
  3309. def item(self, arg0: L[0, -1] | tuple[L[0, -1]] | tuple[()] = ..., /) -> _ItemT_co: ...
  3310. def tolist(self, /) -> _ItemT_co: ...
  3311. def byteswap(self, inplace: L[False] = ...) -> Self: ...
  3312. @overload
  3313. def astype(
  3314. self,
  3315. dtype: _DTypeLike[_ScalarT],
  3316. order: _OrderKACF = ...,
  3317. casting: _CastingKind = ...,
  3318. subok: builtins.bool = ...,
  3319. copy: builtins.bool | _CopyMode = ...,
  3320. ) -> _ScalarT: ...
  3321. @overload
  3322. def astype(
  3323. self,
  3324. dtype: DTypeLike,
  3325. order: _OrderKACF = ...,
  3326. casting: _CastingKind = ...,
  3327. subok: builtins.bool = ...,
  3328. copy: builtins.bool | _CopyMode = ...,
  3329. ) -> Any: ...
  3330. # NOTE: `view` will perform a 0D->scalar cast,
  3331. # thus the array `type` is irrelevant to the output type
  3332. @overload
  3333. def view(self, type: type[NDArray[Any]] = ...) -> Self: ...
  3334. @overload
  3335. def view(
  3336. self,
  3337. dtype: _DTypeLike[_ScalarT],
  3338. type: type[NDArray[Any]] = ...,
  3339. ) -> _ScalarT: ...
  3340. @overload
  3341. def view(
  3342. self,
  3343. dtype: DTypeLike,
  3344. type: type[NDArray[Any]] = ...,
  3345. ) -> Any: ...
  3346. @overload
  3347. def getfield(
  3348. self,
  3349. dtype: _DTypeLike[_ScalarT],
  3350. offset: SupportsIndex = ...
  3351. ) -> _ScalarT: ...
  3352. @overload
  3353. def getfield(
  3354. self,
  3355. dtype: DTypeLike,
  3356. offset: SupportsIndex = ...
  3357. ) -> Any: ...
  3358. @overload
  3359. def take( # type: ignore[misc]
  3360. self,
  3361. indices: _IntLike_co,
  3362. axis: SupportsIndex | None = ...,
  3363. out: None = ...,
  3364. mode: _ModeKind = ...,
  3365. ) -> Self: ...
  3366. @overload
  3367. def take( # type: ignore[misc]
  3368. self,
  3369. indices: _ArrayLikeInt_co,
  3370. axis: SupportsIndex | None = ...,
  3371. out: None = ...,
  3372. mode: _ModeKind = ...,
  3373. ) -> NDArray[Self]: ...
  3374. @overload
  3375. def take(
  3376. self,
  3377. indices: _ArrayLikeInt_co,
  3378. axis: SupportsIndex | None = ...,
  3379. out: _ArrayT = ...,
  3380. mode: _ModeKind = ...,
  3381. ) -> _ArrayT: ...
  3382. def repeat(self, repeats: _ArrayLikeInt_co, axis: SupportsIndex | None = None) -> ndarray[tuple[int], dtype[Self]]: ...
  3383. def flatten(self, /, order: _OrderKACF = "C") -> ndarray[tuple[int], dtype[Self]]: ...
  3384. def ravel(self, /, order: _OrderKACF = "C") -> ndarray[tuple[int], dtype[Self]]: ...
  3385. @overload # (() | [])
  3386. def reshape(
  3387. self,
  3388. shape: tuple[()] | list[Never],
  3389. /,
  3390. *,
  3391. order: _OrderACF = "C",
  3392. copy: builtins.bool | None = None,
  3393. ) -> Self: ...
  3394. @overload # ((1, *(1, ...))@_ShapeT)
  3395. def reshape(
  3396. self,
  3397. shape: _1NShapeT,
  3398. /,
  3399. *,
  3400. order: _OrderACF = "C",
  3401. copy: builtins.bool | None = None,
  3402. ) -> ndarray[_1NShapeT, dtype[Self]]: ...
  3403. @overload # (Sequence[index, ...]) # not recommended
  3404. def reshape(
  3405. self,
  3406. shape: Sequence[SupportsIndex],
  3407. /,
  3408. *,
  3409. order: _OrderACF = "C",
  3410. copy: builtins.bool | None = None,
  3411. ) -> Self | ndarray[tuple[L[1], ...], dtype[Self]]: ...
  3412. @overload # _(index)
  3413. def reshape(
  3414. self,
  3415. size1: SupportsIndex,
  3416. /,
  3417. *,
  3418. order: _OrderACF = "C",
  3419. copy: builtins.bool | None = None,
  3420. ) -> ndarray[tuple[L[1]], dtype[Self]]: ...
  3421. @overload # _(index, index)
  3422. def reshape(
  3423. self,
  3424. size1: SupportsIndex,
  3425. size2: SupportsIndex,
  3426. /,
  3427. *,
  3428. order: _OrderACF = "C",
  3429. copy: builtins.bool | None = None,
  3430. ) -> ndarray[tuple[L[1], L[1]], dtype[Self]]: ...
  3431. @overload # _(index, index, index)
  3432. def reshape(
  3433. self,
  3434. size1: SupportsIndex,
  3435. size2: SupportsIndex,
  3436. size3: SupportsIndex,
  3437. /,
  3438. *,
  3439. order: _OrderACF = "C",
  3440. copy: builtins.bool | None = None,
  3441. ) -> ndarray[tuple[L[1], L[1], L[1]], dtype[Self]]: ...
  3442. @overload # _(index, index, index, index)
  3443. def reshape(
  3444. self,
  3445. size1: SupportsIndex,
  3446. size2: SupportsIndex,
  3447. size3: SupportsIndex,
  3448. size4: SupportsIndex,
  3449. /,
  3450. *,
  3451. order: _OrderACF = "C",
  3452. copy: builtins.bool | None = None,
  3453. ) -> ndarray[tuple[L[1], L[1], L[1], L[1]], dtype[Self]]: ...
  3454. @overload # _(index, index, index, index, index, *index) # ndim >= 5
  3455. def reshape(
  3456. self,
  3457. size1: SupportsIndex,
  3458. size2: SupportsIndex,
  3459. size3: SupportsIndex,
  3460. size4: SupportsIndex,
  3461. size5: SupportsIndex,
  3462. /,
  3463. *sizes6_: SupportsIndex,
  3464. order: _OrderACF = "C",
  3465. copy: builtins.bool | None = None,
  3466. ) -> ndarray[tuple[L[1], L[1], L[1], L[1], L[1], *tuple[L[1], ...]], dtype[Self]]: ...
  3467. def squeeze(self, axis: L[0] | tuple[()] | None = ...) -> Self: ...
  3468. def transpose(self, axes: tuple[()] | None = ..., /) -> Self: ...
  3469. @overload
  3470. def all(
  3471. self,
  3472. /,
  3473. axis: L[0, -1] | tuple[()] | None = None,
  3474. out: None = None,
  3475. keepdims: SupportsIndex = False,
  3476. *,
  3477. where: builtins.bool | np.bool | ndarray[tuple[()], dtype[np.bool]] = True
  3478. ) -> np.bool: ...
  3479. @overload
  3480. def all(
  3481. self,
  3482. /,
  3483. axis: L[0, -1] | tuple[()] | None,
  3484. out: ndarray[tuple[()], dtype[_ScalarT]],
  3485. keepdims: SupportsIndex = False,
  3486. *,
  3487. where: builtins.bool | np.bool | ndarray[tuple[()], dtype[np.bool]] = True,
  3488. ) -> _ScalarT: ...
  3489. @overload
  3490. def all(
  3491. self,
  3492. /,
  3493. axis: L[0, -1] | tuple[()] | None = None,
  3494. *,
  3495. out: ndarray[tuple[()], dtype[_ScalarT]],
  3496. keepdims: SupportsIndex = False,
  3497. where: builtins.bool | np.bool | ndarray[tuple[()], dtype[np.bool]] = True,
  3498. ) -> _ScalarT: ...
  3499. @overload
  3500. def any(
  3501. self,
  3502. /,
  3503. axis: L[0, -1] | tuple[()] | None = None,
  3504. out: None = None,
  3505. keepdims: SupportsIndex = False,
  3506. *,
  3507. where: builtins.bool | np.bool | ndarray[tuple[()], dtype[np.bool]] = True
  3508. ) -> np.bool: ...
  3509. @overload
  3510. def any(
  3511. self,
  3512. /,
  3513. axis: L[0, -1] | tuple[()] | None,
  3514. out: ndarray[tuple[()], dtype[_ScalarT]],
  3515. keepdims: SupportsIndex = False,
  3516. *,
  3517. where: builtins.bool | np.bool | ndarray[tuple[()], dtype[np.bool]] = True,
  3518. ) -> _ScalarT: ...
  3519. @overload
  3520. def any(
  3521. self,
  3522. /,
  3523. axis: L[0, -1] | tuple[()] | None = None,
  3524. *,
  3525. out: ndarray[tuple[()], dtype[_ScalarT]],
  3526. keepdims: SupportsIndex = False,
  3527. where: builtins.bool | np.bool | ndarray[tuple[()], dtype[np.bool]] = True,
  3528. ) -> _ScalarT: ...
  3529. # Keep `dtype` at the bottom to avoid name conflicts with `np.dtype`
  3530. @property
  3531. def dtype(self) -> _dtype[Self]: ...
  3532. class number(generic[_NumberItemT_co], Generic[_NBit, _NumberItemT_co]):
  3533. @abstractmethod
  3534. def __init__(self, value: _NumberItemT_co, /) -> None: ...
  3535. def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
  3536. def __neg__(self) -> Self: ...
  3537. def __pos__(self) -> Self: ...
  3538. def __abs__(self) -> Self: ...
  3539. __add__: _NumberOp
  3540. __radd__: _NumberOp
  3541. __sub__: _NumberOp
  3542. __rsub__: _NumberOp
  3543. __mul__: _NumberOp
  3544. __rmul__: _NumberOp
  3545. __floordiv__: _NumberOp
  3546. __rfloordiv__: _NumberOp
  3547. __pow__: _NumberOp
  3548. __rpow__: _NumberOp
  3549. __truediv__: _NumberOp
  3550. __rtruediv__: _NumberOp
  3551. __lt__: _ComparisonOpLT[_NumberLike_co, _ArrayLikeNumber_co]
  3552. __le__: _ComparisonOpLE[_NumberLike_co, _ArrayLikeNumber_co]
  3553. __gt__: _ComparisonOpGT[_NumberLike_co, _ArrayLikeNumber_co]
  3554. __ge__: _ComparisonOpGE[_NumberLike_co, _ArrayLikeNumber_co]
  3555. class bool(generic[_BoolItemT_co], Generic[_BoolItemT_co]):
  3556. @property
  3557. def itemsize(self) -> L[1]: ...
  3558. @property
  3559. def nbytes(self) -> L[1]: ...
  3560. @property
  3561. def real(self) -> Self: ...
  3562. @property
  3563. def imag(self) -> np.bool[L[False]]: ...
  3564. @overload # mypy bug workaround: https://github.com/numpy/numpy/issues/29245
  3565. def __init__(self: np.bool[builtins.bool], value: Never, /) -> None: ...
  3566. @overload
  3567. def __init__(self: np.bool[L[False]], value: _Falsy = ..., /) -> None: ...
  3568. @overload
  3569. def __init__(self: np.bool[L[True]], value: _Truthy, /) -> None: ...
  3570. @overload
  3571. def __init__(self: np.bool[builtins.bool], value: object, /) -> None: ...
  3572. def __bool__(self, /) -> _BoolItemT_co: ...
  3573. @overload
  3574. def __int__(self: np.bool[L[False]], /) -> L[0]: ...
  3575. @overload
  3576. def __int__(self: np.bool[L[True]], /) -> L[1]: ...
  3577. @overload
  3578. def __int__(self, /) -> L[0, 1]: ...
  3579. def __abs__(self) -> Self: ...
  3580. @overload
  3581. def __invert__(self: np.bool[L[False]], /) -> np.bool[L[True]]: ...
  3582. @overload
  3583. def __invert__(self: np.bool[L[True]], /) -> np.bool[L[False]]: ...
  3584. @overload
  3585. def __invert__(self, /) -> np.bool: ...
  3586. __add__: _BoolOp[np.bool]
  3587. __radd__: _BoolOp[np.bool]
  3588. __sub__: _BoolSub
  3589. __rsub__: _BoolSub
  3590. __mul__: _BoolOp[np.bool]
  3591. __rmul__: _BoolOp[np.bool]
  3592. __truediv__: _BoolTrueDiv
  3593. __rtruediv__: _BoolTrueDiv
  3594. __floordiv__: _BoolOp[int8]
  3595. __rfloordiv__: _BoolOp[int8]
  3596. __pow__: _BoolOp[int8]
  3597. __rpow__: _BoolOp[int8]
  3598. __lshift__: _BoolBitOp[int8]
  3599. __rlshift__: _BoolBitOp[int8]
  3600. __rshift__: _BoolBitOp[int8]
  3601. __rrshift__: _BoolBitOp[int8]
  3602. @overload
  3603. def __and__(self: np.bool[L[False]], other: builtins.bool | np.bool, /) -> np.bool[L[False]]: ...
  3604. @overload
  3605. def __and__(self, other: L[False] | np.bool[L[False]], /) -> np.bool[L[False]]: ...
  3606. @overload
  3607. def __and__(self, other: L[True] | np.bool[L[True]], /) -> Self: ...
  3608. @overload
  3609. def __and__(self, other: builtins.bool | np.bool, /) -> np.bool: ...
  3610. @overload
  3611. def __and__(self, other: _IntegerT, /) -> _IntegerT: ...
  3612. @overload
  3613. def __and__(self, other: int, /) -> np.bool | intp: ...
  3614. __rand__ = __and__
  3615. @overload
  3616. def __xor__(self: np.bool[L[False]], other: _BoolItemT | np.bool[_BoolItemT], /) -> np.bool[_BoolItemT]: ...
  3617. @overload
  3618. def __xor__(self: np.bool[L[True]], other: L[True] | np.bool[L[True]], /) -> np.bool[L[False]]: ...
  3619. @overload
  3620. def __xor__(self, other: L[False] | np.bool[L[False]], /) -> Self: ...
  3621. @overload
  3622. def __xor__(self, other: builtins.bool | np.bool, /) -> np.bool: ...
  3623. @overload
  3624. def __xor__(self, other: _IntegerT, /) -> _IntegerT: ...
  3625. @overload
  3626. def __xor__(self, other: int, /) -> np.bool | intp: ...
  3627. __rxor__ = __xor__
  3628. @overload
  3629. def __or__(self: np.bool[L[True]], other: builtins.bool | np.bool, /) -> np.bool[L[True]]: ...
  3630. @overload
  3631. def __or__(self, other: L[False] | np.bool[L[False]], /) -> Self: ...
  3632. @overload
  3633. def __or__(self, other: L[True] | np.bool[L[True]], /) -> np.bool[L[True]]: ...
  3634. @overload
  3635. def __or__(self, other: builtins.bool | np.bool, /) -> np.bool: ...
  3636. @overload
  3637. def __or__(self, other: _IntegerT, /) -> _IntegerT: ...
  3638. @overload
  3639. def __or__(self, other: int, /) -> np.bool | intp: ...
  3640. __ror__ = __or__
  3641. __mod__: _BoolMod
  3642. __rmod__: _BoolMod
  3643. __divmod__: _BoolDivMod
  3644. __rdivmod__: _BoolDivMod
  3645. __lt__: _ComparisonOpLT[_NumberLike_co, _ArrayLikeNumber_co]
  3646. __le__: _ComparisonOpLE[_NumberLike_co, _ArrayLikeNumber_co]
  3647. __gt__: _ComparisonOpGT[_NumberLike_co, _ArrayLikeNumber_co]
  3648. __ge__: _ComparisonOpGE[_NumberLike_co, _ArrayLikeNumber_co]
  3649. # NOTE: This should _not_ be `Final` or a `TypeAlias`
  3650. bool_ = bool
  3651. # NOTE: The `object_` constructor returns the passed object, so instances with type
  3652. # `object_` cannot exists (at runtime).
  3653. # NOTE: Because mypy has some long-standing bugs related to `__new__`, `object_` can't
  3654. # be made generic.
  3655. @final
  3656. class object_(_RealMixin, generic):
  3657. @overload
  3658. def __new__(cls, nothing_to_see_here: None = None, /) -> None: ... # type: ignore[misc]
  3659. @overload
  3660. def __new__(cls, stringy: _AnyStr, /) -> _AnyStr: ... # type: ignore[misc]
  3661. @overload
  3662. def __new__(cls, array: ndarray[_ShapeT, Any], /) -> ndarray[_ShapeT, dtype[Self]]: ... # type: ignore[misc]
  3663. @overload
  3664. def __new__(cls, sequence: SupportsLenAndGetItem[object], /) -> NDArray[Self]: ... # type: ignore[misc]
  3665. @overload
  3666. def __new__(cls, value: _T, /) -> _T: ... # type: ignore[misc]
  3667. @overload # catch-all
  3668. def __new__(cls, value: Any = ..., /) -> object | NDArray[Self]: ... # type: ignore[misc]
  3669. def __init__(self, value: object = ..., /) -> None: ...
  3670. def __hash__(self, /) -> int: ...
  3671. def __abs__(self, /) -> object_: ... # this affects NDArray[object_].__abs__
  3672. def __call__(self, /, *args: object, **kwargs: object) -> Any: ...
  3673. if sys.version_info >= (3, 12):
  3674. def __release_buffer__(self, buffer: memoryview, /) -> None: ...
  3675. class integer(_IntegralMixin, _RoundMixin, number[_NBit, int]):
  3676. @abstractmethod
  3677. def __init__(self, value: _ConvertibleToInt = ..., /) -> None: ...
  3678. # NOTE: `bit_count` and `__index__` are technically defined in the concrete subtypes
  3679. def bit_count(self, /) -> int: ...
  3680. def __index__(self, /) -> int: ...
  3681. def __invert__(self, /) -> Self: ...
  3682. __truediv__: _IntTrueDiv[_NBit]
  3683. __rtruediv__: _IntTrueDiv[_NBit]
  3684. def __mod__(self, value: _IntLike_co, /) -> integer: ...
  3685. def __rmod__(self, value: _IntLike_co, /) -> integer: ...
  3686. # Ensure that objects annotated as `integer` support bit-wise operations
  3687. def __lshift__(self, other: _IntLike_co, /) -> integer: ...
  3688. def __rlshift__(self, other: _IntLike_co, /) -> integer: ...
  3689. def __rshift__(self, other: _IntLike_co, /) -> integer: ...
  3690. def __rrshift__(self, other: _IntLike_co, /) -> integer: ...
  3691. def __and__(self, other: _IntLike_co, /) -> integer: ...
  3692. def __rand__(self, other: _IntLike_co, /) -> integer: ...
  3693. def __or__(self, other: _IntLike_co, /) -> integer: ...
  3694. def __ror__(self, other: _IntLike_co, /) -> integer: ...
  3695. def __xor__(self, other: _IntLike_co, /) -> integer: ...
  3696. def __rxor__(self, other: _IntLike_co, /) -> integer: ...
  3697. class signedinteger(integer[_NBit1]):
  3698. def __init__(self, value: _ConvertibleToInt = ..., /) -> None: ...
  3699. __add__: _SignedIntOp[_NBit1]
  3700. __radd__: _SignedIntOp[_NBit1]
  3701. __sub__: _SignedIntOp[_NBit1]
  3702. __rsub__: _SignedIntOp[_NBit1]
  3703. __mul__: _SignedIntOp[_NBit1]
  3704. __rmul__: _SignedIntOp[_NBit1]
  3705. __floordiv__: _SignedIntOp[_NBit1]
  3706. __rfloordiv__: _SignedIntOp[_NBit1]
  3707. __pow__: _SignedIntOp[_NBit1]
  3708. __rpow__: _SignedIntOp[_NBit1]
  3709. __lshift__: _SignedIntBitOp[_NBit1]
  3710. __rlshift__: _SignedIntBitOp[_NBit1]
  3711. __rshift__: _SignedIntBitOp[_NBit1]
  3712. __rrshift__: _SignedIntBitOp[_NBit1]
  3713. __and__: _SignedIntBitOp[_NBit1]
  3714. __rand__: _SignedIntBitOp[_NBit1]
  3715. __xor__: _SignedIntBitOp[_NBit1]
  3716. __rxor__: _SignedIntBitOp[_NBit1]
  3717. __or__: _SignedIntBitOp[_NBit1]
  3718. __ror__: _SignedIntBitOp[_NBit1]
  3719. __mod__: _SignedIntMod[_NBit1]
  3720. __rmod__: _SignedIntMod[_NBit1]
  3721. __divmod__: _SignedIntDivMod[_NBit1]
  3722. __rdivmod__: _SignedIntDivMod[_NBit1]
  3723. int8 = signedinteger[_8Bit]
  3724. int16 = signedinteger[_16Bit]
  3725. int32 = signedinteger[_32Bit]
  3726. int64 = signedinteger[_64Bit]
  3727. byte = signedinteger[_NBitByte]
  3728. short = signedinteger[_NBitShort]
  3729. intc = signedinteger[_NBitIntC]
  3730. intp = signedinteger[_NBitIntP]
  3731. int_ = intp
  3732. long = signedinteger[_NBitLong]
  3733. longlong = signedinteger[_NBitLongLong]
  3734. class unsignedinteger(integer[_NBit1]):
  3735. # NOTE: `uint64 + signedinteger -> float64`
  3736. def __init__(self, value: _ConvertibleToInt = ..., /) -> None: ...
  3737. __add__: _UnsignedIntOp[_NBit1]
  3738. __radd__: _UnsignedIntOp[_NBit1]
  3739. __sub__: _UnsignedIntOp[_NBit1]
  3740. __rsub__: _UnsignedIntOp[_NBit1]
  3741. __mul__: _UnsignedIntOp[_NBit1]
  3742. __rmul__: _UnsignedIntOp[_NBit1]
  3743. __floordiv__: _UnsignedIntOp[_NBit1]
  3744. __rfloordiv__: _UnsignedIntOp[_NBit1]
  3745. __pow__: _UnsignedIntOp[_NBit1]
  3746. __rpow__: _UnsignedIntOp[_NBit1]
  3747. __lshift__: _UnsignedIntBitOp[_NBit1]
  3748. __rlshift__: _UnsignedIntBitOp[_NBit1]
  3749. __rshift__: _UnsignedIntBitOp[_NBit1]
  3750. __rrshift__: _UnsignedIntBitOp[_NBit1]
  3751. __and__: _UnsignedIntBitOp[_NBit1]
  3752. __rand__: _UnsignedIntBitOp[_NBit1]
  3753. __xor__: _UnsignedIntBitOp[_NBit1]
  3754. __rxor__: _UnsignedIntBitOp[_NBit1]
  3755. __or__: _UnsignedIntBitOp[_NBit1]
  3756. __ror__: _UnsignedIntBitOp[_NBit1]
  3757. __mod__: _UnsignedIntMod[_NBit1]
  3758. __rmod__: _UnsignedIntMod[_NBit1]
  3759. __divmod__: _UnsignedIntDivMod[_NBit1]
  3760. __rdivmod__: _UnsignedIntDivMod[_NBit1]
  3761. uint8: TypeAlias = unsignedinteger[_8Bit]
  3762. uint16: TypeAlias = unsignedinteger[_16Bit]
  3763. uint32: TypeAlias = unsignedinteger[_32Bit]
  3764. uint64: TypeAlias = unsignedinteger[_64Bit]
  3765. ubyte: TypeAlias = unsignedinteger[_NBitByte]
  3766. ushort: TypeAlias = unsignedinteger[_NBitShort]
  3767. uintc: TypeAlias = unsignedinteger[_NBitIntC]
  3768. uintp: TypeAlias = unsignedinteger[_NBitIntP]
  3769. uint: TypeAlias = uintp
  3770. ulong: TypeAlias = unsignedinteger[_NBitLong]
  3771. ulonglong: TypeAlias = unsignedinteger[_NBitLongLong]
  3772. class inexact(number[_NBit, _InexactItemT_co], Generic[_NBit, _InexactItemT_co]):
  3773. @abstractmethod
  3774. def __init__(self, value: _InexactItemT_co | None = ..., /) -> None: ...
  3775. class floating(_RealMixin, _RoundMixin, inexact[_NBit1, float]):
  3776. def __init__(self, value: _ConvertibleToFloat | None = ..., /) -> None: ...
  3777. __add__: _FloatOp[_NBit1]
  3778. __radd__: _FloatOp[_NBit1]
  3779. __sub__: _FloatOp[_NBit1]
  3780. __rsub__: _FloatOp[_NBit1]
  3781. __mul__: _FloatOp[_NBit1]
  3782. __rmul__: _FloatOp[_NBit1]
  3783. __truediv__: _FloatOp[_NBit1]
  3784. __rtruediv__: _FloatOp[_NBit1]
  3785. __floordiv__: _FloatOp[_NBit1]
  3786. __rfloordiv__: _FloatOp[_NBit1]
  3787. __pow__: _FloatOp[_NBit1]
  3788. __rpow__: _FloatOp[_NBit1]
  3789. __mod__: _FloatMod[_NBit1]
  3790. __rmod__: _FloatMod[_NBit1]
  3791. __divmod__: _FloatDivMod[_NBit1]
  3792. __rdivmod__: _FloatDivMod[_NBit1]
  3793. # NOTE: `is_integer` and `as_integer_ratio` are technically defined in the concrete subtypes
  3794. def is_integer(self, /) -> builtins.bool: ...
  3795. def as_integer_ratio(self, /) -> tuple[int, int]: ...
  3796. float16: TypeAlias = floating[_16Bit]
  3797. float32: TypeAlias = floating[_32Bit]
  3798. # either a C `double`, `float`, or `longdouble`
  3799. class float64(floating[_64Bit], float): # type: ignore[misc]
  3800. def __new__(cls, x: _ConvertibleToFloat | None = ..., /) -> Self: ...
  3801. #
  3802. @property
  3803. def itemsize(self) -> L[8]: ...
  3804. @property
  3805. def nbytes(self) -> L[8]: ...
  3806. # overrides for `floating` and `builtins.float` compatibility (`_RealMixin` doesn't work)
  3807. @property
  3808. def real(self) -> Self: ...
  3809. @property
  3810. def imag(self) -> Self: ...
  3811. def conjugate(self) -> Self: ...
  3812. def __getformat__(self, typestr: L["double", "float"], /) -> str: ...
  3813. def __getnewargs__(self, /) -> tuple[float]: ...
  3814. # float64-specific operator overrides
  3815. @overload
  3816. def __add__(self, other: _Float64_co, /) -> float64: ...
  3817. @overload
  3818. def __add__(self, other: complexfloating[_64Bit, _64Bit], /) -> complex128: ...
  3819. @overload
  3820. def __add__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
  3821. @overload
  3822. def __add__(self, other: complex, /) -> float64 | complex128: ...
  3823. @overload
  3824. def __radd__(self, other: _Float64_co, /) -> float64: ...
  3825. @overload
  3826. def __radd__(self, other: complexfloating[_64Bit, _64Bit], /) -> complex128: ...
  3827. @overload
  3828. def __radd__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
  3829. @overload
  3830. def __radd__(self, other: complex, /) -> float64 | complex128: ...
  3831. @overload
  3832. def __sub__(self, other: _Float64_co, /) -> float64: ...
  3833. @overload
  3834. def __sub__(self, other: complexfloating[_64Bit, _64Bit], /) -> complex128: ...
  3835. @overload
  3836. def __sub__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
  3837. @overload
  3838. def __sub__(self, other: complex, /) -> float64 | complex128: ...
  3839. @overload
  3840. def __rsub__(self, other: _Float64_co, /) -> float64: ...
  3841. @overload
  3842. def __rsub__(self, other: complexfloating[_64Bit, _64Bit], /) -> complex128: ...
  3843. @overload
  3844. def __rsub__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
  3845. @overload
  3846. def __rsub__(self, other: complex, /) -> float64 | complex128: ...
  3847. @overload
  3848. def __mul__(self, other: _Float64_co, /) -> float64: ...
  3849. @overload
  3850. def __mul__(self, other: complexfloating[_64Bit, _64Bit], /) -> complex128: ...
  3851. @overload
  3852. def __mul__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
  3853. @overload
  3854. def __mul__(self, other: complex, /) -> float64 | complex128: ...
  3855. @overload
  3856. def __rmul__(self, other: _Float64_co, /) -> float64: ...
  3857. @overload
  3858. def __rmul__(self, other: complexfloating[_64Bit, _64Bit], /) -> complex128: ...
  3859. @overload
  3860. def __rmul__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
  3861. @overload
  3862. def __rmul__(self, other: complex, /) -> float64 | complex128: ...
  3863. @overload
  3864. def __truediv__(self, other: _Float64_co, /) -> float64: ...
  3865. @overload
  3866. def __truediv__(self, other: complexfloating[_64Bit, _64Bit], /) -> complex128: ...
  3867. @overload
  3868. def __truediv__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
  3869. @overload
  3870. def __truediv__(self, other: complex, /) -> float64 | complex128: ...
  3871. @overload
  3872. def __rtruediv__(self, other: _Float64_co, /) -> float64: ...
  3873. @overload
  3874. def __rtruediv__(self, other: complexfloating[_64Bit, _64Bit], /) -> complex128: ...
  3875. @overload
  3876. def __rtruediv__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
  3877. @overload
  3878. def __rtruediv__(self, other: complex, /) -> float64 | complex128: ...
  3879. @overload
  3880. def __floordiv__(self, other: _Float64_co, /) -> float64: ...
  3881. @overload
  3882. def __floordiv__(self, other: complexfloating[_64Bit, _64Bit], /) -> complex128: ...
  3883. @overload
  3884. def __floordiv__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
  3885. @overload
  3886. def __floordiv__(self, other: complex, /) -> float64 | complex128: ...
  3887. @overload
  3888. def __rfloordiv__(self, other: _Float64_co, /) -> float64: ...
  3889. @overload
  3890. def __rfloordiv__(self, other: complexfloating[_64Bit, _64Bit], /) -> complex128: ...
  3891. @overload
  3892. def __rfloordiv__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
  3893. @overload
  3894. def __rfloordiv__(self, other: complex, /) -> float64 | complex128: ...
  3895. @overload
  3896. def __pow__(self, other: _Float64_co, mod: None = None, /) -> float64: ...
  3897. @overload
  3898. def __pow__(self, other: complexfloating[_64Bit, _64Bit], mod: None = None, /) -> complex128: ...
  3899. @overload
  3900. def __pow__(
  3901. self, other: complexfloating[_NBit1, _NBit2], mod: None = None, /
  3902. ) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
  3903. @overload
  3904. def __pow__(self, other: complex, mod: None = None, /) -> float64 | complex128: ...
  3905. @overload
  3906. def __rpow__(self, other: _Float64_co, mod: None = None, /) -> float64: ...
  3907. @overload
  3908. def __rpow__(self, other: complexfloating[_64Bit, _64Bit], mod: None = None, /) -> complex128: ...
  3909. @overload
  3910. def __rpow__(
  3911. self, other: complexfloating[_NBit1, _NBit2], mod: None = None, /
  3912. ) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
  3913. @overload
  3914. def __rpow__(self, other: complex, mod: None = None, /) -> float64 | complex128: ...
  3915. def __mod__(self, other: _Float64_co, /) -> float64: ... # type: ignore[override]
  3916. def __rmod__(self, other: _Float64_co, /) -> float64: ... # type: ignore[override]
  3917. def __divmod__(self, other: _Float64_co, /) -> _2Tuple[float64]: ... # type: ignore[override]
  3918. def __rdivmod__(self, other: _Float64_co, /) -> _2Tuple[float64]: ... # type: ignore[override]
  3919. half: TypeAlias = floating[_NBitHalf]
  3920. single: TypeAlias = floating[_NBitSingle]
  3921. double: TypeAlias = floating[_NBitDouble]
  3922. longdouble: TypeAlias = floating[_NBitLongDouble]
  3923. # The main reason for `complexfloating` having two typevars is cosmetic.
  3924. # It is used to clarify why `complex128`s precision is `_64Bit`, the latter
  3925. # describing the two 64 bit floats representing its real and imaginary component
  3926. class complexfloating(inexact[_NBit1, complex], Generic[_NBit1, _NBit2]):
  3927. @overload
  3928. def __init__(
  3929. self,
  3930. real: complex | SupportsComplex | SupportsFloat | SupportsIndex = ...,
  3931. imag: complex | SupportsFloat | SupportsIndex = ...,
  3932. /,
  3933. ) -> None: ...
  3934. @overload
  3935. def __init__(self, real: _ConvertibleToComplex | None = ..., /) -> None: ...
  3936. @property
  3937. def real(self) -> floating[_NBit1]: ... # type: ignore[override]
  3938. @property
  3939. def imag(self) -> floating[_NBit2]: ... # type: ignore[override]
  3940. # NOTE: `__complex__` is technically defined in the concrete subtypes
  3941. def __complex__(self, /) -> complex: ...
  3942. def __abs__(self, /) -> floating[_NBit1 | _NBit2]: ... # type: ignore[override]
  3943. @overload
  3944. def __add__(self, other: _Complex64_co, /) -> complexfloating[_NBit1, _NBit2]: ...
  3945. @overload
  3946. def __add__(self, other: complex | float64 | complex128, /) -> complexfloating[_NBit1, _NBit2] | complex128: ...
  3947. @overload
  3948. def __add__(self, other: number[_NBit], /) -> complexfloating[_NBit1, _NBit2] | complexfloating[_NBit, _NBit]: ...
  3949. @overload
  3950. def __radd__(self, other: _Complex64_co, /) -> complexfloating[_NBit1, _NBit2]: ...
  3951. @overload
  3952. def __radd__(self, other: complex, /) -> complexfloating[_NBit1, _NBit2] | complex128: ...
  3953. @overload
  3954. def __radd__(self, other: number[_NBit], /) -> complexfloating[_NBit1, _NBit2] | complexfloating[_NBit, _NBit]: ...
  3955. @overload
  3956. def __sub__(self, other: _Complex64_co, /) -> complexfloating[_NBit1, _NBit2]: ...
  3957. @overload
  3958. def __sub__(self, other: complex | float64 | complex128, /) -> complexfloating[_NBit1, _NBit2] | complex128: ...
  3959. @overload
  3960. def __sub__(self, other: number[_NBit], /) -> complexfloating[_NBit1, _NBit2] | complexfloating[_NBit, _NBit]: ...
  3961. @overload
  3962. def __rsub__(self, other: _Complex64_co, /) -> complexfloating[_NBit1, _NBit2]: ...
  3963. @overload
  3964. def __rsub__(self, other: complex, /) -> complexfloating[_NBit1, _NBit2] | complex128: ...
  3965. @overload
  3966. def __rsub__(self, other: number[_NBit], /) -> complexfloating[_NBit1, _NBit2] | complexfloating[_NBit, _NBit]: ...
  3967. @overload
  3968. def __mul__(self, other: _Complex64_co, /) -> complexfloating[_NBit1, _NBit2]: ...
  3969. @overload
  3970. def __mul__(self, other: complex | float64 | complex128, /) -> complexfloating[_NBit1, _NBit2] | complex128: ...
  3971. @overload
  3972. def __mul__(self, other: number[_NBit], /) -> complexfloating[_NBit1, _NBit2] | complexfloating[_NBit, _NBit]: ...
  3973. @overload
  3974. def __rmul__(self, other: _Complex64_co, /) -> complexfloating[_NBit1, _NBit2]: ...
  3975. @overload
  3976. def __rmul__(self, other: complex, /) -> complexfloating[_NBit1, _NBit2] | complex128: ...
  3977. @overload
  3978. def __rmul__(self, other: number[_NBit], /) -> complexfloating[_NBit1, _NBit2] | complexfloating[_NBit, _NBit]: ...
  3979. @overload
  3980. def __truediv__(self, other: _Complex64_co, /) -> complexfloating[_NBit1, _NBit2]: ...
  3981. @overload
  3982. def __truediv__(self, other: complex | float64 | complex128, /) -> complexfloating[_NBit1, _NBit2] | complex128: ...
  3983. @overload
  3984. def __truediv__(self, other: number[_NBit], /) -> complexfloating[_NBit1, _NBit2] | complexfloating[_NBit, _NBit]: ...
  3985. @overload
  3986. def __rtruediv__(self, other: _Complex64_co, /) -> complexfloating[_NBit1, _NBit2]: ...
  3987. @overload
  3988. def __rtruediv__(self, other: complex, /) -> complexfloating[_NBit1, _NBit2] | complex128: ...
  3989. @overload
  3990. def __rtruediv__(self, other: number[_NBit], /) -> complexfloating[_NBit1, _NBit2] | complexfloating[_NBit, _NBit]: ...
  3991. @overload
  3992. def __pow__(self, other: _Complex64_co, mod: None = None, /) -> complexfloating[_NBit1, _NBit2]: ...
  3993. @overload
  3994. def __pow__(
  3995. self, other: complex | float64 | complex128, mod: None = None, /
  3996. ) -> complexfloating[_NBit1, _NBit2] | complex128: ...
  3997. @overload
  3998. def __pow__(
  3999. self, other: number[_NBit], mod: None = None, /
  4000. ) -> complexfloating[_NBit1, _NBit2] | complexfloating[_NBit, _NBit]: ...
  4001. @overload
  4002. def __rpow__(self, other: _Complex64_co, mod: None = None, /) -> complexfloating[_NBit1, _NBit2]: ...
  4003. @overload
  4004. def __rpow__(self, other: complex, mod: None = None, /) -> complexfloating[_NBit1, _NBit2] | complex128: ...
  4005. @overload
  4006. def __rpow__(
  4007. self, other: number[_NBit], mod: None = None, /
  4008. ) -> complexfloating[_NBit1, _NBit2] | complexfloating[_NBit, _NBit]: ...
  4009. complex64: TypeAlias = complexfloating[_32Bit, _32Bit]
  4010. class complex128(complexfloating[_64Bit, _64Bit], complex): # type: ignore[misc]
  4011. @overload
  4012. def __new__(
  4013. cls,
  4014. real: complex | SupportsComplex | SupportsFloat | SupportsIndex = ...,
  4015. imag: complex | SupportsFloat | SupportsIndex = ...,
  4016. /,
  4017. ) -> Self: ...
  4018. @overload
  4019. def __new__(cls, real: _ConvertibleToComplex | None = ..., /) -> Self: ...
  4020. #
  4021. @property
  4022. def itemsize(self) -> L[16]: ...
  4023. @property
  4024. def nbytes(self) -> L[16]: ...
  4025. # overrides for `floating` and `builtins.float` compatibility
  4026. @property
  4027. def real(self) -> float64: ...
  4028. @property
  4029. def imag(self) -> float64: ...
  4030. def conjugate(self) -> Self: ...
  4031. def __abs__(self) -> float64: ... # type: ignore[override]
  4032. def __getnewargs__(self, /) -> tuple[float, float]: ...
  4033. # complex128-specific operator overrides
  4034. @overload
  4035. def __add__(self, other: _Complex128_co, /) -> complex128: ...
  4036. @overload
  4037. def __add__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
  4038. def __radd__(self, other: _Complex128_co, /) -> complex128: ...
  4039. @overload
  4040. def __sub__(self, other: _Complex128_co, /) -> complex128: ...
  4041. @overload
  4042. def __sub__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
  4043. def __rsub__(self, other: _Complex128_co, /) -> complex128: ...
  4044. @overload
  4045. def __mul__(self, other: _Complex128_co, /) -> complex128: ...
  4046. @overload
  4047. def __mul__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
  4048. def __rmul__(self, other: _Complex128_co, /) -> complex128: ...
  4049. @overload
  4050. def __truediv__(self, other: _Complex128_co, /) -> complex128: ...
  4051. @overload
  4052. def __truediv__(self, other: complexfloating[_NBit1, _NBit2], /) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
  4053. def __rtruediv__(self, other: _Complex128_co, /) -> complex128: ...
  4054. @overload
  4055. def __pow__(self, other: _Complex128_co, mod: None = None, /) -> complex128: ...
  4056. @overload
  4057. def __pow__(
  4058. self, other: complexfloating[_NBit1, _NBit2], mod: None = None, /
  4059. ) -> complexfloating[_NBit1 | _64Bit, _NBit2 | _64Bit]: ...
  4060. def __rpow__(self, other: _Complex128_co, mod: None = None, /) -> complex128: ...
  4061. csingle: TypeAlias = complexfloating[_NBitSingle, _NBitSingle]
  4062. cdouble: TypeAlias = complexfloating[_NBitDouble, _NBitDouble]
  4063. clongdouble: TypeAlias = complexfloating[_NBitLongDouble, _NBitLongDouble]
  4064. class timedelta64(_IntegralMixin, generic[_TD64ItemT_co], Generic[_TD64ItemT_co]):
  4065. @property
  4066. def itemsize(self) -> L[8]: ...
  4067. @property
  4068. def nbytes(self) -> L[8]: ...
  4069. @overload
  4070. def __init__(self, value: _TD64ItemT_co | timedelta64[_TD64ItemT_co], /) -> None: ...
  4071. @overload
  4072. def __init__(self: timedelta64[L[0]], /) -> None: ...
  4073. @overload
  4074. def __init__(self: timedelta64[None], value: _NaTValue | None, format: _TimeUnitSpec, /) -> None: ...
  4075. @overload
  4076. def __init__(self: timedelta64[L[0]], value: L[0], format: _TimeUnitSpec[_IntTD64Unit] = ..., /) -> None: ...
  4077. @overload
  4078. def __init__(self: timedelta64[int], value: _IntLike_co, format: _TimeUnitSpec[_IntTD64Unit] = ..., /) -> None: ...
  4079. @overload
  4080. def __init__(self: timedelta64[int], value: dt.timedelta, format: _TimeUnitSpec[_IntTimeUnit], /) -> None: ...
  4081. @overload
  4082. def __init__(
  4083. self: timedelta64[dt.timedelta],
  4084. value: dt.timedelta | _IntLike_co,
  4085. format: _TimeUnitSpec[_NativeTD64Unit] = ...,
  4086. /,
  4087. ) -> None: ...
  4088. @overload
  4089. def __init__(self, value: _ConvertibleToTD64, format: _TimeUnitSpec = ..., /) -> None: ...
  4090. # inherited at runtime from `signedinteger`
  4091. def __class_getitem__(cls, type_arg: type | object, /) -> GenericAlias: ...
  4092. # NOTE: Only a limited number of units support conversion
  4093. # to builtin scalar types: `Y`, `M`, `ns`, `ps`, `fs`, `as`
  4094. def __int__(self: timedelta64[int], /) -> int: ...
  4095. def __float__(self: timedelta64[int], /) -> float: ...
  4096. def __neg__(self, /) -> Self: ...
  4097. def __pos__(self, /) -> Self: ...
  4098. def __abs__(self, /) -> Self: ...
  4099. @overload
  4100. def __add__(self: timedelta64[None], x: _TD64Like_co, /) -> timedelta64[None]: ...
  4101. @overload
  4102. def __add__(self: timedelta64[int], x: timedelta64[int | dt.timedelta], /) -> timedelta64[int]: ...
  4103. @overload
  4104. def __add__(self: timedelta64[int], x: timedelta64, /) -> timedelta64[int | None]: ...
  4105. @overload
  4106. def __add__(self: timedelta64[dt.timedelta], x: _AnyDateOrTime, /) -> _AnyDateOrTime: ...
  4107. @overload
  4108. def __add__(self: timedelta64[_AnyTD64Item], x: timedelta64[_AnyTD64Item] | _IntLike_co, /) -> timedelta64[_AnyTD64Item]: ...
  4109. @overload
  4110. def __add__(self, x: timedelta64[None], /) -> timedelta64[None]: ...
  4111. __radd__ = __add__
  4112. @overload
  4113. def __mul__(self: timedelta64[_AnyTD64Item], x: int | np.integer | np.bool, /) -> timedelta64[_AnyTD64Item]: ...
  4114. @overload
  4115. def __mul__(self: timedelta64[_AnyTD64Item], x: float | np.floating, /) -> timedelta64[_AnyTD64Item | None]: ...
  4116. @overload
  4117. def __mul__(self, x: float | np.floating | np.integer | np.bool, /) -> timedelta64: ...
  4118. __rmul__ = __mul__
  4119. @overload
  4120. def __mod__(self, x: timedelta64[L[0] | None], /) -> timedelta64[None]: ...
  4121. @overload
  4122. def __mod__(self: timedelta64[None], x: timedelta64, /) -> timedelta64[None]: ...
  4123. @overload
  4124. def __mod__(self: timedelta64[int], x: timedelta64[int | dt.timedelta], /) -> timedelta64[int | None]: ...
  4125. @overload
  4126. def __mod__(self: timedelta64[dt.timedelta], x: timedelta64[_AnyTD64Item], /) -> timedelta64[_AnyTD64Item | None]: ...
  4127. @overload
  4128. def __mod__(self: timedelta64[dt.timedelta], x: dt.timedelta, /) -> dt.timedelta: ...
  4129. @overload
  4130. def __mod__(self, x: timedelta64[int], /) -> timedelta64[int | None]: ...
  4131. @overload
  4132. def __mod__(self, x: timedelta64, /) -> timedelta64: ...
  4133. # the L[0] makes __mod__ non-commutative, which the first two overloads reflect
  4134. @overload
  4135. def __rmod__(self, x: timedelta64[None], /) -> timedelta64[None]: ...
  4136. @overload
  4137. def __rmod__(self: timedelta64[L[0] | None], x: timedelta64, /) -> timedelta64[None]: ...
  4138. @overload
  4139. def __rmod__(self: timedelta64[int], x: timedelta64[int | dt.timedelta], /) -> timedelta64[int | None]: ...
  4140. @overload
  4141. def __rmod__(self: timedelta64[dt.timedelta], x: timedelta64[_AnyTD64Item], /) -> timedelta64[_AnyTD64Item | None]: ...
  4142. @overload
  4143. def __rmod__(self: timedelta64[dt.timedelta], x: dt.timedelta, /) -> dt.timedelta: ...
  4144. @overload
  4145. def __rmod__(self, x: timedelta64[int], /) -> timedelta64[int | None]: ...
  4146. @overload
  4147. def __rmod__(self, x: timedelta64, /) -> timedelta64: ...
  4148. # keep in sync with __mod__
  4149. @overload
  4150. def __divmod__(self, x: timedelta64[L[0] | None], /) -> tuple[int64, timedelta64[None]]: ...
  4151. @overload
  4152. def __divmod__(self: timedelta64[None], x: timedelta64, /) -> tuple[int64, timedelta64[None]]: ...
  4153. @overload
  4154. def __divmod__(self: timedelta64[int], x: timedelta64[int | dt.timedelta], /) -> tuple[int64, timedelta64[int | None]]: ...
  4155. @overload
  4156. def __divmod__(self: timedelta64[dt.timedelta], x: timedelta64[_AnyTD64Item], /) -> tuple[int64, timedelta64[_AnyTD64Item | None]]: ...
  4157. @overload
  4158. def __divmod__(self: timedelta64[dt.timedelta], x: dt.timedelta, /) -> tuple[int, dt.timedelta]: ...
  4159. @overload
  4160. def __divmod__(self, x: timedelta64[int], /) -> tuple[int64, timedelta64[int | None]]: ...
  4161. @overload
  4162. def __divmod__(self, x: timedelta64, /) -> tuple[int64, timedelta64]: ...
  4163. # keep in sync with __rmod__
  4164. @overload
  4165. def __rdivmod__(self, x: timedelta64[None], /) -> tuple[int64, timedelta64[None]]: ...
  4166. @overload
  4167. def __rdivmod__(self: timedelta64[L[0] | None], x: timedelta64, /) -> tuple[int64, timedelta64[None]]: ...
  4168. @overload
  4169. def __rdivmod__(self: timedelta64[int], x: timedelta64[int | dt.timedelta], /) -> tuple[int64, timedelta64[int | None]]: ...
  4170. @overload
  4171. def __rdivmod__(self: timedelta64[dt.timedelta], x: timedelta64[_AnyTD64Item], /) -> tuple[int64, timedelta64[_AnyTD64Item | None]]: ...
  4172. @overload
  4173. def __rdivmod__(self: timedelta64[dt.timedelta], x: dt.timedelta, /) -> tuple[int, dt.timedelta]: ...
  4174. @overload
  4175. def __rdivmod__(self, x: timedelta64[int], /) -> tuple[int64, timedelta64[int | None]]: ...
  4176. @overload
  4177. def __rdivmod__(self, x: timedelta64, /) -> tuple[int64, timedelta64]: ...
  4178. @overload
  4179. def __sub__(self: timedelta64[None], b: _TD64Like_co, /) -> timedelta64[None]: ...
  4180. @overload
  4181. def __sub__(self: timedelta64[int], b: timedelta64[int | dt.timedelta], /) -> timedelta64[int]: ...
  4182. @overload
  4183. def __sub__(self: timedelta64[int], b: timedelta64, /) -> timedelta64[int | None]: ...
  4184. @overload
  4185. def __sub__(self: timedelta64[dt.timedelta], b: dt.timedelta, /) -> dt.timedelta: ...
  4186. @overload
  4187. def __sub__(self: timedelta64[_AnyTD64Item], b: timedelta64[_AnyTD64Item] | _IntLike_co, /) -> timedelta64[_AnyTD64Item]: ...
  4188. @overload
  4189. def __sub__(self, b: timedelta64[None], /) -> timedelta64[None]: ...
  4190. @overload
  4191. def __rsub__(self: timedelta64[None], a: _TD64Like_co, /) -> timedelta64[None]: ...
  4192. @overload
  4193. def __rsub__(self: timedelta64[dt.timedelta], a: _AnyDateOrTime, /) -> _AnyDateOrTime: ...
  4194. @overload
  4195. def __rsub__(self: timedelta64[dt.timedelta], a: timedelta64[_AnyTD64Item], /) -> timedelta64[_AnyTD64Item]: ...
  4196. @overload
  4197. def __rsub__(self: timedelta64[_AnyTD64Item], a: timedelta64[_AnyTD64Item] | _IntLike_co, /) -> timedelta64[_AnyTD64Item]: ...
  4198. @overload
  4199. def __rsub__(self, a: timedelta64[None], /) -> timedelta64[None]: ...
  4200. @overload
  4201. def __rsub__(self, a: datetime64[None], /) -> datetime64[None]: ...
  4202. @overload
  4203. def __truediv__(self: timedelta64[dt.timedelta], b: dt.timedelta, /) -> float: ...
  4204. @overload
  4205. def __truediv__(self, b: timedelta64, /) -> float64: ...
  4206. @overload
  4207. def __truediv__(self: timedelta64[_AnyTD64Item], b: int | integer, /) -> timedelta64[_AnyTD64Item]: ...
  4208. @overload
  4209. def __truediv__(self: timedelta64[_AnyTD64Item], b: float | floating, /) -> timedelta64[_AnyTD64Item | None]: ...
  4210. @overload
  4211. def __truediv__(self, b: float | floating | integer, /) -> timedelta64: ...
  4212. @overload
  4213. def __rtruediv__(self: timedelta64[dt.timedelta], a: dt.timedelta, /) -> float: ...
  4214. @overload
  4215. def __rtruediv__(self, a: timedelta64, /) -> float64: ...
  4216. @overload
  4217. def __floordiv__(self: timedelta64[dt.timedelta], b: dt.timedelta, /) -> int: ...
  4218. @overload
  4219. def __floordiv__(self, b: timedelta64, /) -> int64: ...
  4220. @overload
  4221. def __floordiv__(self: timedelta64[_AnyTD64Item], b: int | integer, /) -> timedelta64[_AnyTD64Item]: ...
  4222. @overload
  4223. def __floordiv__(self: timedelta64[_AnyTD64Item], b: float | floating, /) -> timedelta64[_AnyTD64Item | None]: ...
  4224. @overload
  4225. def __rfloordiv__(self: timedelta64[dt.timedelta], a: dt.timedelta, /) -> int: ...
  4226. @overload
  4227. def __rfloordiv__(self, a: timedelta64, /) -> int64: ...
  4228. __lt__: _ComparisonOpLT[_TD64Like_co, _ArrayLikeTD64_co]
  4229. __le__: _ComparisonOpLE[_TD64Like_co, _ArrayLikeTD64_co]
  4230. __gt__: _ComparisonOpGT[_TD64Like_co, _ArrayLikeTD64_co]
  4231. __ge__: _ComparisonOpGE[_TD64Like_co, _ArrayLikeTD64_co]
  4232. class datetime64(_RealMixin, generic[_DT64ItemT_co], Generic[_DT64ItemT_co]):
  4233. @property
  4234. def itemsize(self) -> L[8]: ...
  4235. @property
  4236. def nbytes(self) -> L[8]: ...
  4237. @overload
  4238. def __init__(self, value: datetime64[_DT64ItemT_co], /) -> None: ...
  4239. @overload
  4240. def __init__(self: datetime64[_AnyDT64Arg], value: _AnyDT64Arg, /) -> None: ...
  4241. @overload
  4242. def __init__(self: datetime64[None], value: _NaTValue | None = ..., format: _TimeUnitSpec = ..., /) -> None: ...
  4243. @overload
  4244. def __init__(self: datetime64[dt.datetime], value: _DT64Now, format: _TimeUnitSpec[_NativeTimeUnit] = ..., /) -> None: ...
  4245. @overload
  4246. def __init__(self: datetime64[dt.date], value: _DT64Date, format: _TimeUnitSpec[_DateUnit] = ..., /) -> None: ...
  4247. @overload
  4248. def __init__(self: datetime64[int], value: int | bytes | str | dt.date, format: _TimeUnitSpec[_IntTimeUnit], /) -> None: ...
  4249. @overload
  4250. def __init__(
  4251. self: datetime64[dt.datetime], value: int | bytes | str | dt.date, format: _TimeUnitSpec[_NativeTimeUnit], /
  4252. ) -> None: ...
  4253. @overload
  4254. def __init__(self: datetime64[dt.date], value: int | bytes | str | dt.date, format: _TimeUnitSpec[_DateUnit], /) -> None: ...
  4255. @overload
  4256. def __init__(self, value: bytes | str | dt.date | None, format: _TimeUnitSpec = ..., /) -> None: ...
  4257. @overload
  4258. def __add__(self: datetime64[_AnyDT64Item], x: int | integer | np.bool, /) -> datetime64[_AnyDT64Item]: ...
  4259. @overload
  4260. def __add__(self: datetime64[None], x: _TD64Like_co, /) -> datetime64[None]: ...
  4261. @overload
  4262. def __add__(self: datetime64[int], x: timedelta64[int | dt.timedelta], /) -> datetime64[int]: ...
  4263. @overload
  4264. def __add__(self: datetime64[dt.datetime], x: timedelta64[dt.timedelta], /) -> datetime64[dt.datetime]: ...
  4265. @overload
  4266. def __add__(self: datetime64[dt.date], x: timedelta64[dt.timedelta], /) -> datetime64[dt.date]: ...
  4267. @overload
  4268. def __add__(self: datetime64[dt.date], x: timedelta64[int], /) -> datetime64[int]: ...
  4269. @overload
  4270. def __add__(self, x: datetime64[None], /) -> datetime64[None]: ...
  4271. @overload
  4272. def __add__(self, x: _TD64Like_co, /) -> datetime64: ...
  4273. __radd__ = __add__
  4274. @overload
  4275. def __sub__(self: datetime64[_AnyDT64Item], x: int | integer | np.bool, /) -> datetime64[_AnyDT64Item]: ...
  4276. @overload
  4277. def __sub__(self: datetime64[_AnyDate], x: _AnyDate, /) -> dt.timedelta: ...
  4278. @overload
  4279. def __sub__(self: datetime64[None], x: timedelta64, /) -> datetime64[None]: ...
  4280. @overload
  4281. def __sub__(self: datetime64[None], x: datetime64, /) -> timedelta64[None]: ...
  4282. @overload
  4283. def __sub__(self: datetime64[int], x: timedelta64, /) -> datetime64[int]: ...
  4284. @overload
  4285. def __sub__(self: datetime64[int], x: datetime64, /) -> timedelta64[int]: ...
  4286. @overload
  4287. def __sub__(self: datetime64[dt.datetime], x: timedelta64[int], /) -> datetime64[int]: ...
  4288. @overload
  4289. def __sub__(self: datetime64[dt.datetime], x: timedelta64[dt.timedelta], /) -> datetime64[dt.datetime]: ...
  4290. @overload
  4291. def __sub__(self: datetime64[dt.datetime], x: datetime64[int], /) -> timedelta64[int]: ...
  4292. @overload
  4293. def __sub__(self: datetime64[dt.date], x: timedelta64[int], /) -> datetime64[dt.date | int]: ...
  4294. @overload
  4295. def __sub__(self: datetime64[dt.date], x: timedelta64[dt.timedelta], /) -> datetime64[dt.date]: ...
  4296. @overload
  4297. def __sub__(self: datetime64[dt.date], x: datetime64[dt.date], /) -> timedelta64[dt.timedelta]: ...
  4298. @overload
  4299. def __sub__(self, x: timedelta64[None], /) -> datetime64[None]: ...
  4300. @overload
  4301. def __sub__(self, x: datetime64[None], /) -> timedelta64[None]: ...
  4302. @overload
  4303. def __sub__(self, x: _TD64Like_co, /) -> datetime64: ...
  4304. @overload
  4305. def __sub__(self, x: datetime64, /) -> timedelta64: ...
  4306. @overload
  4307. def __rsub__(self: datetime64[_AnyDT64Item], x: int | integer | np.bool, /) -> datetime64[_AnyDT64Item]: ...
  4308. @overload
  4309. def __rsub__(self: datetime64[_AnyDate], x: _AnyDate, /) -> dt.timedelta: ...
  4310. @overload
  4311. def __rsub__(self: datetime64[None], x: datetime64, /) -> timedelta64[None]: ...
  4312. @overload
  4313. def __rsub__(self: datetime64[int], x: datetime64, /) -> timedelta64[int]: ...
  4314. @overload
  4315. def __rsub__(self: datetime64[dt.datetime], x: datetime64[int], /) -> timedelta64[int]: ...
  4316. @overload
  4317. def __rsub__(self: datetime64[dt.datetime], x: datetime64[dt.date], /) -> timedelta64[dt.timedelta]: ...
  4318. @overload
  4319. def __rsub__(self, x: datetime64[None], /) -> timedelta64[None]: ...
  4320. @overload
  4321. def __rsub__(self, x: datetime64, /) -> timedelta64: ...
  4322. __lt__: _ComparisonOpLT[datetime64, _ArrayLikeDT64_co]
  4323. __le__: _ComparisonOpLE[datetime64, _ArrayLikeDT64_co]
  4324. __gt__: _ComparisonOpGT[datetime64, _ArrayLikeDT64_co]
  4325. __ge__: _ComparisonOpGE[datetime64, _ArrayLikeDT64_co]
  4326. class flexible(_RealMixin, generic[_FlexibleItemT_co], Generic[_FlexibleItemT_co]): ...
  4327. class void(flexible[bytes | tuple[Any, ...]]):
  4328. @overload
  4329. def __init__(self, value: _IntLike_co | bytes, /, dtype: None = None) -> None: ...
  4330. @overload
  4331. def __init__(self, value: Any, /, dtype: _DTypeLikeVoid) -> None: ...
  4332. @overload
  4333. def __getitem__(self, key: str | SupportsIndex, /) -> Any: ...
  4334. @overload
  4335. def __getitem__(self, key: list[str], /) -> void: ...
  4336. def __setitem__(self, key: str | list[str] | SupportsIndex, value: ArrayLike, /) -> None: ...
  4337. def setfield(self, val: ArrayLike, dtype: DTypeLike, offset: int = ...) -> None: ...
  4338. class character(flexible[_CharacterItemT_co], Generic[_CharacterItemT_co]):
  4339. @abstractmethod
  4340. def __init__(self, value: _CharacterItemT_co = ..., /) -> None: ...
  4341. # NOTE: Most `np.bytes_` / `np.str_` methods return their builtin `bytes` / `str` counterpart
  4342. class bytes_(character[bytes], bytes):
  4343. @overload
  4344. def __new__(cls, o: object = ..., /) -> Self: ...
  4345. @overload
  4346. def __new__(cls, s: str, /, encoding: str, errors: str = ...) -> Self: ...
  4347. #
  4348. @overload
  4349. def __init__(self, o: object = ..., /) -> None: ...
  4350. @overload
  4351. def __init__(self, s: str, /, encoding: str, errors: str = ...) -> None: ...
  4352. #
  4353. def __bytes__(self, /) -> bytes: ...
  4354. class str_(character[str], str):
  4355. @overload
  4356. def __new__(cls, value: object = ..., /) -> Self: ...
  4357. @overload
  4358. def __new__(cls, value: bytes, /, encoding: str = ..., errors: str = ...) -> Self: ...
  4359. #
  4360. @overload
  4361. def __init__(self, value: object = ..., /) -> None: ...
  4362. @overload
  4363. def __init__(self, value: bytes, /, encoding: str = ..., errors: str = ...) -> None: ...
  4364. # See `numpy._typing._ufunc` for more concrete nin-/nout-specific stubs
  4365. @final
  4366. class ufunc:
  4367. @property
  4368. def __name__(self) -> LiteralString: ...
  4369. @property
  4370. def __qualname__(self) -> LiteralString: ...
  4371. @property
  4372. def __doc__(self) -> str: ...
  4373. @property
  4374. def nin(self) -> int: ...
  4375. @property
  4376. def nout(self) -> int: ...
  4377. @property
  4378. def nargs(self) -> int: ...
  4379. @property
  4380. def ntypes(self) -> int: ...
  4381. @property
  4382. def types(self) -> list[LiteralString]: ...
  4383. # Broad return type because it has to encompass things like
  4384. #
  4385. # >>> np.logical_and.identity is True
  4386. # True
  4387. # >>> np.add.identity is 0
  4388. # True
  4389. # >>> np.sin.identity is None
  4390. # True
  4391. #
  4392. # and any user-defined ufuncs.
  4393. @property
  4394. def identity(self) -> Any: ...
  4395. # This is None for ufuncs and a string for gufuncs.
  4396. @property
  4397. def signature(self) -> LiteralString | None: ...
  4398. def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
  4399. # The next four methods will always exist, but they will just
  4400. # raise a ValueError ufuncs with that don't accept two input
  4401. # arguments and return one output argument. Because of that we
  4402. # can't type them very precisely.
  4403. def reduce(self, /, *args: Any, **kwargs: Any) -> Any: ...
  4404. def accumulate(self, /, *args: Any, **kwargs: Any) -> NDArray[Any]: ...
  4405. def reduceat(self, /, *args: Any, **kwargs: Any) -> NDArray[Any]: ...
  4406. def outer(self, *args: Any, **kwargs: Any) -> Any: ...
  4407. # Similarly at won't be defined for ufuncs that return multiple
  4408. # outputs, so we can't type it very precisely.
  4409. def at(self, /, *args: Any, **kwargs: Any) -> None: ...
  4410. #
  4411. def resolve_dtypes(
  4412. self,
  4413. /,
  4414. dtypes: tuple[dtype | type | None, ...],
  4415. *,
  4416. signature: tuple[dtype | None, ...] | None = None,
  4417. casting: _CastingKind | None = None,
  4418. reduction: builtins.bool = False,
  4419. ) -> tuple[dtype, ...]: ...
  4420. # Parameters: `__name__`, `ntypes` and `identity`
  4421. absolute: _UFunc_Nin1_Nout1[L['absolute'], L[20], None]
  4422. add: _UFunc_Nin2_Nout1[L['add'], L[22], L[0]]
  4423. arccos: _UFunc_Nin1_Nout1[L['arccos'], L[8], None]
  4424. arccosh: _UFunc_Nin1_Nout1[L['arccosh'], L[8], None]
  4425. arcsin: _UFunc_Nin1_Nout1[L['arcsin'], L[8], None]
  4426. arcsinh: _UFunc_Nin1_Nout1[L['arcsinh'], L[8], None]
  4427. arctan2: _UFunc_Nin2_Nout1[L['arctan2'], L[5], None]
  4428. arctan: _UFunc_Nin1_Nout1[L['arctan'], L[8], None]
  4429. arctanh: _UFunc_Nin1_Nout1[L['arctanh'], L[8], None]
  4430. bitwise_and: _UFunc_Nin2_Nout1[L['bitwise_and'], L[12], L[-1]]
  4431. bitwise_count: _UFunc_Nin1_Nout1[L['bitwise_count'], L[11], None]
  4432. bitwise_not: _UFunc_Nin1_Nout1[L['invert'], L[12], None]
  4433. bitwise_or: _UFunc_Nin2_Nout1[L['bitwise_or'], L[12], L[0]]
  4434. bitwise_xor: _UFunc_Nin2_Nout1[L['bitwise_xor'], L[12], L[0]]
  4435. cbrt: _UFunc_Nin1_Nout1[L['cbrt'], L[5], None]
  4436. ceil: _UFunc_Nin1_Nout1[L['ceil'], L[7], None]
  4437. conj: _UFunc_Nin1_Nout1[L['conjugate'], L[18], None]
  4438. conjugate: _UFunc_Nin1_Nout1[L['conjugate'], L[18], None]
  4439. copysign: _UFunc_Nin2_Nout1[L['copysign'], L[4], None]
  4440. cos: _UFunc_Nin1_Nout1[L['cos'], L[9], None]
  4441. cosh: _UFunc_Nin1_Nout1[L['cosh'], L[8], None]
  4442. deg2rad: _UFunc_Nin1_Nout1[L['deg2rad'], L[5], None]
  4443. degrees: _UFunc_Nin1_Nout1[L['degrees'], L[5], None]
  4444. divide: _UFunc_Nin2_Nout1[L['true_divide'], L[11], None]
  4445. divmod: _UFunc_Nin2_Nout2[L['divmod'], L[15], None]
  4446. equal: _UFunc_Nin2_Nout1[L['equal'], L[23], None]
  4447. exp2: _UFunc_Nin1_Nout1[L['exp2'], L[8], None]
  4448. exp: _UFunc_Nin1_Nout1[L['exp'], L[10], None]
  4449. expm1: _UFunc_Nin1_Nout1[L['expm1'], L[8], None]
  4450. fabs: _UFunc_Nin1_Nout1[L['fabs'], L[5], None]
  4451. float_power: _UFunc_Nin2_Nout1[L['float_power'], L[4], None]
  4452. floor: _UFunc_Nin1_Nout1[L['floor'], L[7], None]
  4453. floor_divide: _UFunc_Nin2_Nout1[L['floor_divide'], L[21], None]
  4454. fmax: _UFunc_Nin2_Nout1[L['fmax'], L[21], None]
  4455. fmin: _UFunc_Nin2_Nout1[L['fmin'], L[21], None]
  4456. fmod: _UFunc_Nin2_Nout1[L['fmod'], L[15], None]
  4457. frexp: _UFunc_Nin1_Nout2[L['frexp'], L[4], None]
  4458. gcd: _UFunc_Nin2_Nout1[L['gcd'], L[11], L[0]]
  4459. greater: _UFunc_Nin2_Nout1[L['greater'], L[23], None]
  4460. greater_equal: _UFunc_Nin2_Nout1[L['greater_equal'], L[23], None]
  4461. heaviside: _UFunc_Nin2_Nout1[L['heaviside'], L[4], None]
  4462. hypot: _UFunc_Nin2_Nout1[L['hypot'], L[5], L[0]]
  4463. invert: _UFunc_Nin1_Nout1[L['invert'], L[12], None]
  4464. isfinite: _UFunc_Nin1_Nout1[L['isfinite'], L[20], None]
  4465. isinf: _UFunc_Nin1_Nout1[L['isinf'], L[20], None]
  4466. isnan: _UFunc_Nin1_Nout1[L['isnan'], L[20], None]
  4467. isnat: _UFunc_Nin1_Nout1[L['isnat'], L[2], None]
  4468. lcm: _UFunc_Nin2_Nout1[L['lcm'], L[11], None]
  4469. ldexp: _UFunc_Nin2_Nout1[L['ldexp'], L[8], None]
  4470. left_shift: _UFunc_Nin2_Nout1[L['left_shift'], L[11], None]
  4471. less: _UFunc_Nin2_Nout1[L['less'], L[23], None]
  4472. less_equal: _UFunc_Nin2_Nout1[L['less_equal'], L[23], None]
  4473. log10: _UFunc_Nin1_Nout1[L['log10'], L[8], None]
  4474. log1p: _UFunc_Nin1_Nout1[L['log1p'], L[8], None]
  4475. log2: _UFunc_Nin1_Nout1[L['log2'], L[8], None]
  4476. log: _UFunc_Nin1_Nout1[L['log'], L[10], None]
  4477. logaddexp2: _UFunc_Nin2_Nout1[L['logaddexp2'], L[4], float]
  4478. logaddexp: _UFunc_Nin2_Nout1[L['logaddexp'], L[4], float]
  4479. logical_and: _UFunc_Nin2_Nout1[L['logical_and'], L[20], L[True]]
  4480. logical_not: _UFunc_Nin1_Nout1[L['logical_not'], L[20], None]
  4481. logical_or: _UFunc_Nin2_Nout1[L['logical_or'], L[20], L[False]]
  4482. logical_xor: _UFunc_Nin2_Nout1[L['logical_xor'], L[19], L[False]]
  4483. matmul: _GUFunc_Nin2_Nout1[L['matmul'], L[19], None, L["(n?,k),(k,m?)->(n?,m?)"]]
  4484. matvec: _GUFunc_Nin2_Nout1[L['matvec'], L[19], None, L["(m,n),(n)->(m)"]]
  4485. maximum: _UFunc_Nin2_Nout1[L['maximum'], L[21], None]
  4486. minimum: _UFunc_Nin2_Nout1[L['minimum'], L[21], None]
  4487. mod: _UFunc_Nin2_Nout1[L['remainder'], L[16], None]
  4488. modf: _UFunc_Nin1_Nout2[L['modf'], L[4], None]
  4489. multiply: _UFunc_Nin2_Nout1[L['multiply'], L[23], L[1]]
  4490. negative: _UFunc_Nin1_Nout1[L['negative'], L[19], None]
  4491. nextafter: _UFunc_Nin2_Nout1[L['nextafter'], L[4], None]
  4492. not_equal: _UFunc_Nin2_Nout1[L['not_equal'], L[23], None]
  4493. positive: _UFunc_Nin1_Nout1[L['positive'], L[19], None]
  4494. power: _UFunc_Nin2_Nout1[L['power'], L[18], None]
  4495. rad2deg: _UFunc_Nin1_Nout1[L['rad2deg'], L[5], None]
  4496. radians: _UFunc_Nin1_Nout1[L['radians'], L[5], None]
  4497. reciprocal: _UFunc_Nin1_Nout1[L['reciprocal'], L[18], None]
  4498. remainder: _UFunc_Nin2_Nout1[L['remainder'], L[16], None]
  4499. right_shift: _UFunc_Nin2_Nout1[L['right_shift'], L[11], None]
  4500. rint: _UFunc_Nin1_Nout1[L['rint'], L[10], None]
  4501. sign: _UFunc_Nin1_Nout1[L['sign'], L[19], None]
  4502. signbit: _UFunc_Nin1_Nout1[L['signbit'], L[4], None]
  4503. sin: _UFunc_Nin1_Nout1[L['sin'], L[9], None]
  4504. sinh: _UFunc_Nin1_Nout1[L['sinh'], L[8], None]
  4505. spacing: _UFunc_Nin1_Nout1[L['spacing'], L[4], None]
  4506. sqrt: _UFunc_Nin1_Nout1[L['sqrt'], L[10], None]
  4507. square: _UFunc_Nin1_Nout1[L['square'], L[18], None]
  4508. subtract: _UFunc_Nin2_Nout1[L['subtract'], L[21], None]
  4509. tan: _UFunc_Nin1_Nout1[L['tan'], L[8], None]
  4510. tanh: _UFunc_Nin1_Nout1[L['tanh'], L[8], None]
  4511. true_divide: _UFunc_Nin2_Nout1[L['true_divide'], L[11], None]
  4512. trunc: _UFunc_Nin1_Nout1[L['trunc'], L[7], None]
  4513. vecdot: _GUFunc_Nin2_Nout1[L['vecdot'], L[19], None, L["(n),(n)->()"]]
  4514. vecmat: _GUFunc_Nin2_Nout1[L['vecmat'], L[19], None, L["(n),(n,m)->(m)"]]
  4515. abs = absolute
  4516. acos = arccos
  4517. acosh = arccosh
  4518. asin = arcsin
  4519. asinh = arcsinh
  4520. atan = arctan
  4521. atanh = arctanh
  4522. atan2 = arctan2
  4523. concat = concatenate
  4524. bitwise_left_shift = left_shift
  4525. bitwise_invert = invert
  4526. bitwise_right_shift = right_shift
  4527. permute_dims = transpose
  4528. pow = power
  4529. class errstate:
  4530. def __init__(
  4531. self,
  4532. *,
  4533. call: _ErrCall = ...,
  4534. all: _ErrKind | None = ...,
  4535. divide: _ErrKind | None = ...,
  4536. over: _ErrKind | None = ...,
  4537. under: _ErrKind | None = ...,
  4538. invalid: _ErrKind | None = ...,
  4539. ) -> None: ...
  4540. def __enter__(self) -> None: ...
  4541. def __exit__(
  4542. self,
  4543. exc_type: type[BaseException] | None,
  4544. exc_value: BaseException | None,
  4545. traceback: TracebackType | None,
  4546. /,
  4547. ) -> None: ...
  4548. def __call__(self, func: _CallableT) -> _CallableT: ...
  4549. # TODO: The type of each `__next__` and `iters` return-type depends
  4550. # on the length and dtype of `args`; we can't describe this behavior yet
  4551. # as we lack variadics (PEP 646).
  4552. @final
  4553. class broadcast:
  4554. def __new__(cls, *args: ArrayLike) -> broadcast: ...
  4555. @property
  4556. def index(self) -> int: ...
  4557. @property
  4558. def iters(self) -> tuple[flatiter[Any], ...]: ...
  4559. @property
  4560. def nd(self) -> int: ...
  4561. @property
  4562. def ndim(self) -> int: ...
  4563. @property
  4564. def numiter(self) -> int: ...
  4565. @property
  4566. def shape(self) -> _AnyShape: ...
  4567. @property
  4568. def size(self) -> int: ...
  4569. def __next__(self) -> tuple[Any, ...]: ...
  4570. def __iter__(self) -> Self: ...
  4571. def reset(self) -> None: ...
  4572. @final
  4573. class busdaycalendar:
  4574. def __new__(
  4575. cls,
  4576. weekmask: ArrayLike = ...,
  4577. holidays: ArrayLike | dt.date | _NestedSequence[dt.date] = ...,
  4578. ) -> busdaycalendar: ...
  4579. @property
  4580. def weekmask(self) -> NDArray[np.bool]: ...
  4581. @property
  4582. def holidays(self) -> NDArray[datetime64]: ...
  4583. class finfo(Generic[_FloatingT_co]):
  4584. dtype: Final[dtype[_FloatingT_co]]
  4585. bits: Final[int]
  4586. eps: Final[_FloatingT_co]
  4587. epsneg: Final[_FloatingT_co]
  4588. iexp: Final[int]
  4589. machep: Final[int]
  4590. max: Final[_FloatingT_co]
  4591. maxexp: Final[int]
  4592. min: Final[_FloatingT_co]
  4593. minexp: Final[int]
  4594. negep: Final[int]
  4595. nexp: Final[int]
  4596. nmant: Final[int]
  4597. precision: Final[int]
  4598. resolution: Final[_FloatingT_co]
  4599. smallest_subnormal: Final[_FloatingT_co]
  4600. @property
  4601. def smallest_normal(self) -> _FloatingT_co: ...
  4602. @property
  4603. def tiny(self) -> _FloatingT_co: ...
  4604. @overload
  4605. def __new__(cls, dtype: inexact[_NBit1] | _DTypeLike[inexact[_NBit1]]) -> finfo[floating[_NBit1]]: ...
  4606. @overload
  4607. def __new__(cls, dtype: complex | type[complex]) -> finfo[float64]: ...
  4608. @overload
  4609. def __new__(cls, dtype: str) -> finfo[floating]: ...
  4610. class iinfo(Generic[_IntegerT_co]):
  4611. dtype: Final[dtype[_IntegerT_co]]
  4612. kind: Final[LiteralString]
  4613. bits: Final[int]
  4614. key: Final[LiteralString]
  4615. @property
  4616. def min(self) -> int: ...
  4617. @property
  4618. def max(self) -> int: ...
  4619. @overload
  4620. def __new__(
  4621. cls, dtype: _IntegerT_co | _DTypeLike[_IntegerT_co]
  4622. ) -> iinfo[_IntegerT_co]: ...
  4623. @overload
  4624. def __new__(cls, dtype: int | type[int]) -> iinfo[int_]: ...
  4625. @overload
  4626. def __new__(cls, dtype: str) -> iinfo[Any]: ...
  4627. @final
  4628. class nditer:
  4629. def __new__(
  4630. cls,
  4631. op: ArrayLike | Sequence[ArrayLike | None],
  4632. flags: Sequence[_NDIterFlagsKind] | None = ...,
  4633. op_flags: Sequence[Sequence[_NDIterFlagsOp]] | None = ...,
  4634. op_dtypes: DTypeLike | Sequence[DTypeLike] = ...,
  4635. order: _OrderKACF = ...,
  4636. casting: _CastingKind = ...,
  4637. op_axes: Sequence[Sequence[SupportsIndex]] | None = ...,
  4638. itershape: _ShapeLike | None = ...,
  4639. buffersize: SupportsIndex = ...,
  4640. ) -> nditer: ...
  4641. def __enter__(self) -> nditer: ...
  4642. def __exit__(
  4643. self,
  4644. exc_type: type[BaseException] | None,
  4645. exc_value: BaseException | None,
  4646. traceback: TracebackType | None,
  4647. ) -> None: ...
  4648. def __iter__(self) -> nditer: ...
  4649. def __next__(self) -> tuple[NDArray[Any], ...]: ...
  4650. def __len__(self) -> int: ...
  4651. def __copy__(self) -> nditer: ...
  4652. @overload
  4653. def __getitem__(self, index: SupportsIndex) -> NDArray[Any]: ...
  4654. @overload
  4655. def __getitem__(self, index: slice) -> tuple[NDArray[Any], ...]: ...
  4656. def __setitem__(self, index: slice | SupportsIndex, value: ArrayLike) -> None: ...
  4657. def close(self) -> None: ...
  4658. def copy(self) -> nditer: ...
  4659. def debug_print(self) -> None: ...
  4660. def enable_external_loop(self) -> None: ...
  4661. def iternext(self) -> builtins.bool: ...
  4662. def remove_axis(self, i: SupportsIndex, /) -> None: ...
  4663. def remove_multi_index(self) -> None: ...
  4664. def reset(self) -> None: ...
  4665. @property
  4666. def dtypes(self) -> tuple[dtype, ...]: ...
  4667. @property
  4668. def finished(self) -> builtins.bool: ...
  4669. @property
  4670. def has_delayed_bufalloc(self) -> builtins.bool: ...
  4671. @property
  4672. def has_index(self) -> builtins.bool: ...
  4673. @property
  4674. def has_multi_index(self) -> builtins.bool: ...
  4675. @property
  4676. def index(self) -> int: ...
  4677. @property
  4678. def iterationneedsapi(self) -> builtins.bool: ...
  4679. @property
  4680. def iterindex(self) -> int: ...
  4681. @property
  4682. def iterrange(self) -> tuple[int, ...]: ...
  4683. @property
  4684. def itersize(self) -> int: ...
  4685. @property
  4686. def itviews(self) -> tuple[NDArray[Any], ...]: ...
  4687. @property
  4688. def multi_index(self) -> tuple[int, ...]: ...
  4689. @property
  4690. def ndim(self) -> int: ...
  4691. @property
  4692. def nop(self) -> int: ...
  4693. @property
  4694. def operands(self) -> tuple[NDArray[Any], ...]: ...
  4695. @property
  4696. def shape(self) -> tuple[int, ...]: ...
  4697. @property
  4698. def value(self) -> tuple[NDArray[Any], ...]: ...
  4699. class memmap(ndarray[_ShapeT_co, _DTypeT_co]):
  4700. __array_priority__: ClassVar[float]
  4701. filename: str | None
  4702. offset: int
  4703. mode: str
  4704. @overload
  4705. def __new__(
  4706. subtype,
  4707. filename: StrOrBytesPath | _SupportsFileMethodsRW,
  4708. dtype: type[uint8] = ...,
  4709. mode: _MemMapModeKind = ...,
  4710. offset: int = ...,
  4711. shape: int | tuple[int, ...] | None = ...,
  4712. order: _OrderKACF = ...,
  4713. ) -> memmap[Any, dtype[uint8]]: ...
  4714. @overload
  4715. def __new__(
  4716. subtype,
  4717. filename: StrOrBytesPath | _SupportsFileMethodsRW,
  4718. dtype: _DTypeLike[_ScalarT],
  4719. mode: _MemMapModeKind = ...,
  4720. offset: int = ...,
  4721. shape: int | tuple[int, ...] | None = ...,
  4722. order: _OrderKACF = ...,
  4723. ) -> memmap[Any, dtype[_ScalarT]]: ...
  4724. @overload
  4725. def __new__(
  4726. subtype,
  4727. filename: StrOrBytesPath | _SupportsFileMethodsRW,
  4728. dtype: DTypeLike,
  4729. mode: _MemMapModeKind = ...,
  4730. offset: int = ...,
  4731. shape: int | tuple[int, ...] | None = ...,
  4732. order: _OrderKACF = ...,
  4733. ) -> memmap[Any, dtype]: ...
  4734. def __array_finalize__(self, obj: object) -> None: ...
  4735. def __array_wrap__(
  4736. self,
  4737. array: memmap[_ShapeT_co, _DTypeT_co],
  4738. context: tuple[ufunc, tuple[Any, ...], int] | None = ...,
  4739. return_scalar: builtins.bool = ...,
  4740. ) -> Any: ...
  4741. def flush(self) -> None: ...
  4742. # TODO: Add a mypy plugin for managing functions whose output type is dependent
  4743. # on the literal value of some sort of signature (e.g. `einsum` and `vectorize`)
  4744. class vectorize:
  4745. pyfunc: Callable[..., Any]
  4746. cache: builtins.bool
  4747. signature: LiteralString | None
  4748. otypes: LiteralString | None
  4749. excluded: set[int | str]
  4750. __doc__: str | None
  4751. def __init__(
  4752. self,
  4753. pyfunc: Callable[..., Any],
  4754. otypes: str | Iterable[DTypeLike] | None = ...,
  4755. doc: str | None = ...,
  4756. excluded: Iterable[int | str] | None = ...,
  4757. cache: builtins.bool = ...,
  4758. signature: str | None = ...,
  4759. ) -> None: ...
  4760. def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
  4761. class poly1d:
  4762. @property
  4763. def variable(self) -> LiteralString: ...
  4764. @property
  4765. def order(self) -> int: ...
  4766. @property
  4767. def o(self) -> int: ...
  4768. @property
  4769. def roots(self) -> NDArray[Any]: ...
  4770. @property
  4771. def r(self) -> NDArray[Any]: ...
  4772. @property
  4773. def coeffs(self) -> NDArray[Any]: ...
  4774. @coeffs.setter
  4775. def coeffs(self, value: NDArray[Any]) -> None: ...
  4776. @property
  4777. def c(self) -> NDArray[Any]: ...
  4778. @c.setter
  4779. def c(self, value: NDArray[Any]) -> None: ...
  4780. @property
  4781. def coef(self) -> NDArray[Any]: ...
  4782. @coef.setter
  4783. def coef(self, value: NDArray[Any]) -> None: ...
  4784. @property
  4785. def coefficients(self) -> NDArray[Any]: ...
  4786. @coefficients.setter
  4787. def coefficients(self, value: NDArray[Any]) -> None: ...
  4788. __hash__: ClassVar[None] # type: ignore[assignment] # pyright: ignore[reportIncompatibleMethodOverride]
  4789. @overload
  4790. def __array__(self, /, t: None = None, copy: builtins.bool | None = None) -> ndarray[tuple[int], dtype]: ...
  4791. @overload
  4792. def __array__(self, /, t: _DTypeT, copy: builtins.bool | None = None) -> ndarray[tuple[int], _DTypeT]: ...
  4793. @overload
  4794. def __call__(self, val: _ScalarLike_co) -> Any: ...
  4795. @overload
  4796. def __call__(self, val: poly1d) -> poly1d: ...
  4797. @overload
  4798. def __call__(self, val: ArrayLike) -> NDArray[Any]: ...
  4799. def __init__(
  4800. self,
  4801. c_or_r: ArrayLike,
  4802. r: builtins.bool = ...,
  4803. variable: str | None = ...,
  4804. ) -> None: ...
  4805. def __len__(self) -> int: ...
  4806. def __neg__(self) -> poly1d: ...
  4807. def __pos__(self) -> poly1d: ...
  4808. def __mul__(self, other: ArrayLike, /) -> poly1d: ...
  4809. def __rmul__(self, other: ArrayLike, /) -> poly1d: ...
  4810. def __add__(self, other: ArrayLike, /) -> poly1d: ...
  4811. def __radd__(self, other: ArrayLike, /) -> poly1d: ...
  4812. def __pow__(self, val: _FloatLike_co, /) -> poly1d: ... # Integral floats are accepted
  4813. def __sub__(self, other: ArrayLike, /) -> poly1d: ...
  4814. def __rsub__(self, other: ArrayLike, /) -> poly1d: ...
  4815. def __truediv__(self, other: ArrayLike, /) -> poly1d: ...
  4816. def __rtruediv__(self, other: ArrayLike, /) -> poly1d: ...
  4817. def __getitem__(self, val: int, /) -> Any: ...
  4818. def __setitem__(self, key: int, val: Any, /) -> None: ...
  4819. def __iter__(self) -> Iterator[Any]: ...
  4820. def deriv(self, m: SupportsInt | SupportsIndex = ...) -> poly1d: ...
  4821. def integ(
  4822. self,
  4823. m: SupportsInt | SupportsIndex = ...,
  4824. k: _ArrayLikeComplex_co | _ArrayLikeObject_co | None = ...,
  4825. ) -> poly1d: ...
  4826. class matrix(ndarray[_2DShapeT_co, _DTypeT_co]):
  4827. __array_priority__: ClassVar[float] = 10.0 # pyright: ignore[reportIncompatibleMethodOverride]
  4828. def __new__(
  4829. subtype, # pyright: ignore[reportSelfClsParameterName]
  4830. data: ArrayLike,
  4831. dtype: DTypeLike = ...,
  4832. copy: builtins.bool = ...,
  4833. ) -> matrix[_2D, Incomplete]: ...
  4834. def __array_finalize__(self, obj: object) -> None: ...
  4835. @overload # type: ignore[override]
  4836. def __getitem__(
  4837. self, key: SupportsIndex | _ArrayLikeInt_co | tuple[SupportsIndex | _ArrayLikeInt_co, ...], /
  4838. ) -> Incomplete: ...
  4839. @overload
  4840. def __getitem__(self, key: _ToIndices, /) -> matrix[_2D, _DTypeT_co]: ...
  4841. @overload
  4842. def __getitem__(self: matrix[Any, dtype[void]], key: str, /) -> matrix[_2D, dtype]: ...
  4843. @overload
  4844. def __getitem__(self: matrix[Any, dtype[void]], key: list[str], /) -> matrix[_2DShapeT_co, _DTypeT_co]: ... # pyright: ignore[reportIncompatibleMethodOverride]
  4845. #
  4846. def __mul__(self, other: ArrayLike, /) -> matrix[_2D, Incomplete]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
  4847. def __rmul__(self, other: ArrayLike, /) -> matrix[_2D, Incomplete]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
  4848. def __imul__(self, other: ArrayLike, /) -> Self: ...
  4849. #
  4850. def __pow__(self, other: ArrayLike, mod: None = None, /) -> matrix[_2D, Incomplete]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
  4851. def __rpow__(self, other: ArrayLike, mod: None = None, /) -> matrix[_2D, Incomplete]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
  4852. def __ipow__(self, other: ArrayLike, /) -> Self: ... # type: ignore[misc, override]
  4853. # keep in sync with `prod` and `mean`
  4854. @overload # type: ignore[override]
  4855. def sum(self, axis: None = None, dtype: DTypeLike | None = None, out: None = None) -> Incomplete: ...
  4856. @overload
  4857. def sum(self, axis: _ShapeLike, dtype: DTypeLike | None = None, out: None = None) -> matrix[_2D, Incomplete]: ...
  4858. @overload
  4859. def sum(self, axis: _ShapeLike | None, dtype: DTypeLike | None, out: _ArrayT) -> _ArrayT: ...
  4860. @overload
  4861. def sum(self, axis: _ShapeLike | None = None, dtype: DTypeLike | None = None, *, out: _ArrayT) -> _ArrayT: ... # pyright: ignore[reportIncompatibleMethodOverride]
  4862. # keep in sync with `sum` and `mean`
  4863. @overload # type: ignore[override]
  4864. def prod(self, axis: None = None, dtype: DTypeLike | None = None, out: None = None) -> Incomplete: ...
  4865. @overload
  4866. def prod(self, axis: _ShapeLike, dtype: DTypeLike | None = None, out: None = None) -> matrix[_2D, Incomplete]: ...
  4867. @overload
  4868. def prod(self, axis: _ShapeLike | None, dtype: DTypeLike | None, out: _ArrayT) -> _ArrayT: ...
  4869. @overload
  4870. def prod(self, axis: _ShapeLike | None = None, dtype: DTypeLike | None = None, *, out: _ArrayT) -> _ArrayT: ... # pyright: ignore[reportIncompatibleMethodOverride]
  4871. # keep in sync with `sum` and `prod`
  4872. @overload # type: ignore[override]
  4873. def mean(self, axis: None = None, dtype: DTypeLike | None = None, out: None = None) -> Incomplete: ...
  4874. @overload
  4875. def mean(self, axis: _ShapeLike, dtype: DTypeLike | None = None, out: None = None) -> matrix[_2D, Incomplete]: ...
  4876. @overload
  4877. def mean(self, axis: _ShapeLike | None, dtype: DTypeLike | None, out: _ArrayT) -> _ArrayT: ...
  4878. @overload
  4879. def mean(self, axis: _ShapeLike | None = None, dtype: DTypeLike | None = None, *, out: _ArrayT) -> _ArrayT: ... # pyright: ignore[reportIncompatibleMethodOverride]
  4880. # keep in sync with `var`
  4881. @overload # type: ignore[override]
  4882. def std(self, axis: None = None, dtype: DTypeLike | None = None, out: None = None, ddof: float = 0) -> Incomplete: ...
  4883. @overload
  4884. def std(
  4885. self, axis: _ShapeLike, dtype: DTypeLike | None = None, out: None = None, ddof: float = 0
  4886. ) -> matrix[_2D, Incomplete]: ...
  4887. @overload
  4888. def std(self, axis: _ShapeLike | None, dtype: DTypeLike | None, out: _ArrayT, ddof: float = 0) -> _ArrayT: ...
  4889. @overload
  4890. def std( # pyright: ignore[reportIncompatibleMethodOverride]
  4891. self, axis: _ShapeLike | None = None, dtype: DTypeLike | None = None, *, out: _ArrayT, ddof: float = 0
  4892. ) -> _ArrayT: ...
  4893. # keep in sync with `std`
  4894. @overload # type: ignore[override]
  4895. def var(self, axis: None = None, dtype: DTypeLike | None = None, out: None = None, ddof: float = 0) -> Incomplete: ...
  4896. @overload
  4897. def var(
  4898. self, axis: _ShapeLike, dtype: DTypeLike | None = None, out: None = None, ddof: float = 0
  4899. ) -> matrix[_2D, Incomplete]: ...
  4900. @overload
  4901. def var(self, axis: _ShapeLike | None, dtype: DTypeLike | None, out: _ArrayT, ddof: float = 0) -> _ArrayT: ...
  4902. @overload
  4903. def var( # pyright: ignore[reportIncompatibleMethodOverride]
  4904. self, axis: _ShapeLike | None = None, dtype: DTypeLike | None = None, *, out: _ArrayT, ddof: float = 0
  4905. ) -> _ArrayT: ...
  4906. # keep in sync with `all`
  4907. @overload # type: ignore[override]
  4908. def any(self, axis: None = None, out: None = None) -> np.bool: ...
  4909. @overload
  4910. def any(self, axis: _ShapeLike, out: None = None) -> matrix[_2D, dtype[np.bool]]: ...
  4911. @overload
  4912. def any(self, axis: _ShapeLike | None, out: _ArrayT) -> _ArrayT: ...
  4913. @overload
  4914. def any(self, axis: _ShapeLike | None = None, *, out: _ArrayT) -> _ArrayT: ... # pyright: ignore[reportIncompatibleMethodOverride]
  4915. # keep in sync with `any`
  4916. @overload # type: ignore[override]
  4917. def all(self, axis: None = None, out: None = None) -> np.bool: ...
  4918. @overload
  4919. def all(self, axis: _ShapeLike, out: None = None) -> matrix[_2D, dtype[np.bool]]: ...
  4920. @overload
  4921. def all(self, axis: _ShapeLike | None, out: _ArrayT) -> _ArrayT: ...
  4922. @overload
  4923. def all(self, axis: _ShapeLike | None = None, *, out: _ArrayT) -> _ArrayT: ... # pyright: ignore[reportIncompatibleMethodOverride]
  4924. # keep in sync with `min` and `ptp`
  4925. @overload # type: ignore[override]
  4926. def max(self: NDArray[_ScalarT], axis: None = None, out: None = None) -> _ScalarT: ...
  4927. @overload
  4928. def max(self, axis: _ShapeLike, out: None = None) -> matrix[_2D, _DTypeT_co]: ...
  4929. @overload
  4930. def max(self, axis: _ShapeLike | None, out: _ArrayT) -> _ArrayT: ...
  4931. @overload
  4932. def max(self, axis: _ShapeLike | None = None, *, out: _ArrayT) -> _ArrayT: ... # pyright: ignore[reportIncompatibleMethodOverride]
  4933. # keep in sync with `max` and `ptp`
  4934. @overload # type: ignore[override]
  4935. def min(self: NDArray[_ScalarT], axis: None = None, out: None = None) -> _ScalarT: ...
  4936. @overload
  4937. def min(self, axis: _ShapeLike, out: None = None) -> matrix[_2D, _DTypeT_co]: ...
  4938. @overload
  4939. def min(self, axis: _ShapeLike | None, out: _ArrayT) -> _ArrayT: ...
  4940. @overload
  4941. def min(self, axis: _ShapeLike | None = None, *, out: _ArrayT) -> _ArrayT: ... # pyright: ignore[reportIncompatibleMethodOverride]
  4942. # keep in sync with `max` and `min`
  4943. @overload
  4944. def ptp(self: NDArray[_ScalarT], axis: None = None, out: None = None) -> _ScalarT: ...
  4945. @overload
  4946. def ptp(self, axis: _ShapeLike, out: None = None) -> matrix[_2D, _DTypeT_co]: ...
  4947. @overload
  4948. def ptp(self, axis: _ShapeLike | None, out: _ArrayT) -> _ArrayT: ...
  4949. @overload
  4950. def ptp(self, axis: _ShapeLike | None = None, *, out: _ArrayT) -> _ArrayT: ... # pyright: ignore[reportIncompatibleMethodOverride]
  4951. # keep in sync with `argmin`
  4952. @overload # type: ignore[override]
  4953. def argmax(self: NDArray[_ScalarT], axis: None = None, out: None = None) -> intp: ...
  4954. @overload
  4955. def argmax(self, axis: _ShapeLike, out: None = None) -> matrix[_2D, dtype[intp]]: ...
  4956. @overload
  4957. def argmax(self, axis: _ShapeLike | None, out: _BoolOrIntArrayT) -> _BoolOrIntArrayT: ...
  4958. @overload
  4959. def argmax(self, axis: _ShapeLike | None = None, *, out: _BoolOrIntArrayT) -> _BoolOrIntArrayT: ... # pyright: ignore[reportIncompatibleMethodOverride]
  4960. # keep in sync with `argmax`
  4961. @overload # type: ignore[override]
  4962. def argmin(self: NDArray[_ScalarT], axis: None = None, out: None = None) -> intp: ...
  4963. @overload
  4964. def argmin(self, axis: _ShapeLike, out: None = None) -> matrix[_2D, dtype[intp]]: ...
  4965. @overload
  4966. def argmin(self, axis: _ShapeLike | None, out: _BoolOrIntArrayT) -> _BoolOrIntArrayT: ...
  4967. @overload
  4968. def argmin(self, axis: _ShapeLike | None = None, *, out: _BoolOrIntArrayT) -> _BoolOrIntArrayT: ... # pyright: ignore[reportIncompatibleMethodOverride]
  4969. #the second overload handles the (rare) case that the matrix is not 2-d
  4970. @overload
  4971. def tolist(self: matrix[_2D, dtype[generic[_T]]]) -> list[list[_T]]: ... # pyright: ignore[reportIncompatibleMethodOverride]
  4972. @overload
  4973. def tolist(self) -> Incomplete: ... # pyright: ignore[reportIncompatibleMethodOverride]
  4974. # these three methods will at least return a `2-d` array of shape (1, n)
  4975. def squeeze(self, axis: _ShapeLike | None = None) -> matrix[_2D, _DTypeT_co]: ...
  4976. def ravel(self, /, order: _OrderKACF = "C") -> matrix[_2D, _DTypeT_co]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
  4977. def flatten(self, /, order: _OrderKACF = "C") -> matrix[_2D, _DTypeT_co]: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
  4978. # matrix.T is inherited from _ScalarOrArrayCommon
  4979. def getT(self) -> Self: ...
  4980. @property
  4981. def I(self) -> matrix[_2D, Incomplete]: ... # noqa: E743
  4982. def getI(self) -> matrix[_2D, Incomplete]: ...
  4983. @property
  4984. def A(self) -> ndarray[_2DShapeT_co, _DTypeT_co]: ...
  4985. def getA(self) -> ndarray[_2DShapeT_co, _DTypeT_co]: ...
  4986. @property
  4987. def A1(self) -> ndarray[_AnyShape, _DTypeT_co]: ...
  4988. def getA1(self) -> ndarray[_AnyShape, _DTypeT_co]: ...
  4989. @property
  4990. def H(self) -> matrix[_2D, _DTypeT_co]: ...
  4991. def getH(self) -> matrix[_2D, _DTypeT_co]: ...
  4992. def from_dlpack(
  4993. x: _SupportsDLPack[None],
  4994. /,
  4995. *,
  4996. device: L["cpu"] | None = None,
  4997. copy: builtins.bool | None = None,
  4998. ) -> NDArray[number | np.bool]: ...