__init__.pyi 207 KB

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