_mask.c 663 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184
  1. /* Generated by Cython 0.29.6 */
  2. #define PY_SSIZE_T_CLEAN
  3. #include "Python.h"
  4. #ifndef Py_PYTHON_H
  5. #error Python headers needed to compile C extensions, please install development version of Python.
  6. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
  7. #error Cython requires Python 2.6+ or Python 3.3+.
  8. #else
  9. #define CYTHON_ABI "0_29_6"
  10. #define CYTHON_HEX_VERSION 0x001D06F0
  11. #define CYTHON_FUTURE_DIVISION 0
  12. #include <stddef.h>
  13. #ifndef offsetof
  14. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  15. #endif
  16. #if !defined(WIN32) && !defined(MS_WINDOWS)
  17. #ifndef __stdcall
  18. #define __stdcall
  19. #endif
  20. #ifndef __cdecl
  21. #define __cdecl
  22. #endif
  23. #ifndef __fastcall
  24. #define __fastcall
  25. #endif
  26. #endif
  27. #ifndef DL_IMPORT
  28. #define DL_IMPORT(t) t
  29. #endif
  30. #ifndef DL_EXPORT
  31. #define DL_EXPORT(t) t
  32. #endif
  33. #define __PYX_COMMA ,
  34. #ifndef HAVE_LONG_LONG
  35. #if PY_VERSION_HEX >= 0x02070000
  36. #define HAVE_LONG_LONG
  37. #endif
  38. #endif
  39. #ifndef PY_LONG_LONG
  40. #define PY_LONG_LONG LONG_LONG
  41. #endif
  42. #ifndef Py_HUGE_VAL
  43. #define Py_HUGE_VAL HUGE_VAL
  44. #endif
  45. #ifdef PYPY_VERSION
  46. #define CYTHON_COMPILING_IN_PYPY 1
  47. #define CYTHON_COMPILING_IN_PYSTON 0
  48. #define CYTHON_COMPILING_IN_CPYTHON 0
  49. #undef CYTHON_USE_TYPE_SLOTS
  50. #define CYTHON_USE_TYPE_SLOTS 0
  51. #undef CYTHON_USE_PYTYPE_LOOKUP
  52. #define CYTHON_USE_PYTYPE_LOOKUP 0
  53. #if PY_VERSION_HEX < 0x03050000
  54. #undef CYTHON_USE_ASYNC_SLOTS
  55. #define CYTHON_USE_ASYNC_SLOTS 0
  56. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  57. #define CYTHON_USE_ASYNC_SLOTS 1
  58. #endif
  59. #undef CYTHON_USE_PYLIST_INTERNALS
  60. #define CYTHON_USE_PYLIST_INTERNALS 0
  61. #undef CYTHON_USE_UNICODE_INTERNALS
  62. #define CYTHON_USE_UNICODE_INTERNALS 0
  63. #undef CYTHON_USE_UNICODE_WRITER
  64. #define CYTHON_USE_UNICODE_WRITER 0
  65. #undef CYTHON_USE_PYLONG_INTERNALS
  66. #define CYTHON_USE_PYLONG_INTERNALS 0
  67. #undef CYTHON_AVOID_BORROWED_REFS
  68. #define CYTHON_AVOID_BORROWED_REFS 1
  69. #undef CYTHON_ASSUME_SAFE_MACROS
  70. #define CYTHON_ASSUME_SAFE_MACROS 0
  71. #undef CYTHON_UNPACK_METHODS
  72. #define CYTHON_UNPACK_METHODS 0
  73. #undef CYTHON_FAST_THREAD_STATE
  74. #define CYTHON_FAST_THREAD_STATE 0
  75. #undef CYTHON_FAST_PYCALL
  76. #define CYTHON_FAST_PYCALL 0
  77. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  78. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  79. #undef CYTHON_USE_TP_FINALIZE
  80. #define CYTHON_USE_TP_FINALIZE 0
  81. #undef CYTHON_USE_DICT_VERSIONS
  82. #define CYTHON_USE_DICT_VERSIONS 0
  83. #undef CYTHON_USE_EXC_INFO_STACK
  84. #define CYTHON_USE_EXC_INFO_STACK 0
  85. #elif defined(PYSTON_VERSION)
  86. #define CYTHON_COMPILING_IN_PYPY 0
  87. #define CYTHON_COMPILING_IN_PYSTON 1
  88. #define CYTHON_COMPILING_IN_CPYTHON 0
  89. #ifndef CYTHON_USE_TYPE_SLOTS
  90. #define CYTHON_USE_TYPE_SLOTS 1
  91. #endif
  92. #undef CYTHON_USE_PYTYPE_LOOKUP
  93. #define CYTHON_USE_PYTYPE_LOOKUP 0
  94. #undef CYTHON_USE_ASYNC_SLOTS
  95. #define CYTHON_USE_ASYNC_SLOTS 0
  96. #undef CYTHON_USE_PYLIST_INTERNALS
  97. #define CYTHON_USE_PYLIST_INTERNALS 0
  98. #ifndef CYTHON_USE_UNICODE_INTERNALS
  99. #define CYTHON_USE_UNICODE_INTERNALS 1
  100. #endif
  101. #undef CYTHON_USE_UNICODE_WRITER
  102. #define CYTHON_USE_UNICODE_WRITER 0
  103. #undef CYTHON_USE_PYLONG_INTERNALS
  104. #define CYTHON_USE_PYLONG_INTERNALS 0
  105. #ifndef CYTHON_AVOID_BORROWED_REFS
  106. #define CYTHON_AVOID_BORROWED_REFS 0
  107. #endif
  108. #ifndef CYTHON_ASSUME_SAFE_MACROS
  109. #define CYTHON_ASSUME_SAFE_MACROS 1
  110. #endif
  111. #ifndef CYTHON_UNPACK_METHODS
  112. #define CYTHON_UNPACK_METHODS 1
  113. #endif
  114. #undef CYTHON_FAST_THREAD_STATE
  115. #define CYTHON_FAST_THREAD_STATE 0
  116. #undef CYTHON_FAST_PYCALL
  117. #define CYTHON_FAST_PYCALL 0
  118. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  119. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  120. #undef CYTHON_USE_TP_FINALIZE
  121. #define CYTHON_USE_TP_FINALIZE 0
  122. #undef CYTHON_USE_DICT_VERSIONS
  123. #define CYTHON_USE_DICT_VERSIONS 0
  124. #undef CYTHON_USE_EXC_INFO_STACK
  125. #define CYTHON_USE_EXC_INFO_STACK 0
  126. #else
  127. #define CYTHON_COMPILING_IN_PYPY 0
  128. #define CYTHON_COMPILING_IN_PYSTON 0
  129. #define CYTHON_COMPILING_IN_CPYTHON 1
  130. #ifndef CYTHON_USE_TYPE_SLOTS
  131. #define CYTHON_USE_TYPE_SLOTS 1
  132. #endif
  133. #if PY_VERSION_HEX < 0x02070000
  134. #undef CYTHON_USE_PYTYPE_LOOKUP
  135. #define CYTHON_USE_PYTYPE_LOOKUP 0
  136. #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
  137. #define CYTHON_USE_PYTYPE_LOOKUP 1
  138. #endif
  139. #if PY_MAJOR_VERSION < 3
  140. #undef CYTHON_USE_ASYNC_SLOTS
  141. #define CYTHON_USE_ASYNC_SLOTS 0
  142. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  143. #define CYTHON_USE_ASYNC_SLOTS 1
  144. #endif
  145. #if PY_VERSION_HEX < 0x02070000
  146. #undef CYTHON_USE_PYLONG_INTERNALS
  147. #define CYTHON_USE_PYLONG_INTERNALS 0
  148. #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
  149. #define CYTHON_USE_PYLONG_INTERNALS 1
  150. #endif
  151. #ifndef CYTHON_USE_PYLIST_INTERNALS
  152. #define CYTHON_USE_PYLIST_INTERNALS 1
  153. #endif
  154. #ifndef CYTHON_USE_UNICODE_INTERNALS
  155. #define CYTHON_USE_UNICODE_INTERNALS 1
  156. #endif
  157. #if PY_VERSION_HEX < 0x030300F0
  158. #undef CYTHON_USE_UNICODE_WRITER
  159. #define CYTHON_USE_UNICODE_WRITER 0
  160. #elif !defined(CYTHON_USE_UNICODE_WRITER)
  161. #define CYTHON_USE_UNICODE_WRITER 1
  162. #endif
  163. #ifndef CYTHON_AVOID_BORROWED_REFS
  164. #define CYTHON_AVOID_BORROWED_REFS 0
  165. #endif
  166. #ifndef CYTHON_ASSUME_SAFE_MACROS
  167. #define CYTHON_ASSUME_SAFE_MACROS 1
  168. #endif
  169. #ifndef CYTHON_UNPACK_METHODS
  170. #define CYTHON_UNPACK_METHODS 1
  171. #endif
  172. #ifndef CYTHON_FAST_THREAD_STATE
  173. #define CYTHON_FAST_THREAD_STATE 1
  174. #endif
  175. #ifndef CYTHON_FAST_PYCALL
  176. #define CYTHON_FAST_PYCALL 1
  177. #endif
  178. #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
  179. #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  180. #endif
  181. #ifndef CYTHON_USE_TP_FINALIZE
  182. #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  183. #endif
  184. #ifndef CYTHON_USE_DICT_VERSIONS
  185. #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
  186. #endif
  187. #ifndef CYTHON_USE_EXC_INFO_STACK
  188. #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  189. #endif
  190. #endif
  191. #if !defined(CYTHON_FAST_PYCCALL)
  192. #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
  193. #endif
  194. #if CYTHON_USE_PYLONG_INTERNALS
  195. #include "longintrepr.h"
  196. #undef SHIFT
  197. #undef BASE
  198. #undef MASK
  199. #ifdef SIZEOF_VOID_P
  200. enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  201. #endif
  202. #endif
  203. #ifndef __has_attribute
  204. #define __has_attribute(x) 0
  205. #endif
  206. #ifndef __has_cpp_attribute
  207. #define __has_cpp_attribute(x) 0
  208. #endif
  209. #ifndef CYTHON_RESTRICT
  210. #if defined(__GNUC__)
  211. #define CYTHON_RESTRICT __restrict__
  212. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  213. #define CYTHON_RESTRICT __restrict
  214. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  215. #define CYTHON_RESTRICT restrict
  216. #else
  217. #define CYTHON_RESTRICT
  218. #endif
  219. #endif
  220. #ifndef CYTHON_UNUSED
  221. # if defined(__GNUC__)
  222. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  223. # define CYTHON_UNUSED __attribute__ ((__unused__))
  224. # else
  225. # define CYTHON_UNUSED
  226. # endif
  227. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  228. # define CYTHON_UNUSED __attribute__ ((__unused__))
  229. # else
  230. # define CYTHON_UNUSED
  231. # endif
  232. #endif
  233. #ifndef CYTHON_MAYBE_UNUSED_VAR
  234. # if defined(__cplusplus)
  235. template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
  236. # else
  237. # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
  238. # endif
  239. #endif
  240. #ifndef CYTHON_NCP_UNUSED
  241. # if CYTHON_COMPILING_IN_CPYTHON
  242. # define CYTHON_NCP_UNUSED
  243. # else
  244. # define CYTHON_NCP_UNUSED CYTHON_UNUSED
  245. # endif
  246. #endif
  247. #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
  248. #ifdef _MSC_VER
  249. #ifndef _MSC_STDINT_H_
  250. #if _MSC_VER < 1300
  251. typedef unsigned char uint8_t;
  252. typedef unsigned int uint32_t;
  253. #else
  254. typedef unsigned __int8 uint8_t;
  255. typedef unsigned __int32 uint32_t;
  256. #endif
  257. #endif
  258. #else
  259. #include <stdint.h>
  260. #endif
  261. #ifndef CYTHON_FALLTHROUGH
  262. #if defined(__cplusplus) && __cplusplus >= 201103L
  263. #if __has_cpp_attribute(fallthrough)
  264. #define CYTHON_FALLTHROUGH [[fallthrough]]
  265. #elif __has_cpp_attribute(clang::fallthrough)
  266. #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
  267. #elif __has_cpp_attribute(gnu::fallthrough)
  268. #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
  269. #endif
  270. #endif
  271. #ifndef CYTHON_FALLTHROUGH
  272. #if __has_attribute(fallthrough)
  273. #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
  274. #else
  275. #define CYTHON_FALLTHROUGH
  276. #endif
  277. #endif
  278. #if defined(__clang__ ) && defined(__apple_build_version__)
  279. #if __apple_build_version__ < 7000000
  280. #undef CYTHON_FALLTHROUGH
  281. #define CYTHON_FALLTHROUGH
  282. #endif
  283. #endif
  284. #endif
  285. #ifndef CYTHON_INLINE
  286. #if defined(__clang__)
  287. #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  288. #elif defined(__GNUC__)
  289. #define CYTHON_INLINE __inline__
  290. #elif defined(_MSC_VER)
  291. #define CYTHON_INLINE __inline
  292. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  293. #define CYTHON_INLINE inline
  294. #else
  295. #define CYTHON_INLINE
  296. #endif
  297. #endif
  298. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  299. #define Py_OptimizeFlag 0
  300. #endif
  301. #define __PYX_BUILD_PY_SSIZE_T "n"
  302. #define CYTHON_FORMAT_SSIZE_T "z"
  303. #if PY_MAJOR_VERSION < 3
  304. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  305. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  306. PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  307. #define __Pyx_DefaultClassType PyClass_Type
  308. #else
  309. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  310. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  311. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  312. #define __Pyx_DefaultClassType PyType_Type
  313. #endif
  314. #ifndef Py_TPFLAGS_CHECKTYPES
  315. #define Py_TPFLAGS_CHECKTYPES 0
  316. #endif
  317. #ifndef Py_TPFLAGS_HAVE_INDEX
  318. #define Py_TPFLAGS_HAVE_INDEX 0
  319. #endif
  320. #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  321. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  322. #endif
  323. #ifndef Py_TPFLAGS_HAVE_FINALIZE
  324. #define Py_TPFLAGS_HAVE_FINALIZE 0
  325. #endif
  326. #ifndef METH_STACKLESS
  327. #define METH_STACKLESS 0
  328. #endif
  329. #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  330. #ifndef METH_FASTCALL
  331. #define METH_FASTCALL 0x80
  332. #endif
  333. typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  334. typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
  335. Py_ssize_t nargs, PyObject *kwnames);
  336. #else
  337. #define __Pyx_PyCFunctionFast _PyCFunctionFast
  338. #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
  339. #endif
  340. #if CYTHON_FAST_PYCCALL
  341. #define __Pyx_PyFastCFunction_Check(func)\
  342. ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
  343. #else
  344. #define __Pyx_PyFastCFunction_Check(func) 0
  345. #endif
  346. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  347. #define PyObject_Malloc(s) PyMem_Malloc(s)
  348. #define PyObject_Free(p) PyMem_Free(p)
  349. #define PyObject_Realloc(p) PyMem_Realloc(p)
  350. #endif
  351. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  352. #define PyMem_RawMalloc(n) PyMem_Malloc(n)
  353. #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
  354. #define PyMem_RawFree(p) PyMem_Free(p)
  355. #endif
  356. #if CYTHON_COMPILING_IN_PYSTON
  357. #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
  358. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
  359. #else
  360. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  361. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
  362. #endif
  363. #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  364. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  365. #elif PY_VERSION_HEX >= 0x03060000
  366. #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
  367. #elif PY_VERSION_HEX >= 0x03000000
  368. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  369. #else
  370. #define __Pyx_PyThreadState_Current _PyThreadState_Current
  371. #endif
  372. #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
  373. #include "pythread.h"
  374. #define Py_tss_NEEDS_INIT 0
  375. typedef int Py_tss_t;
  376. static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  377. *key = PyThread_create_key();
  378. return 0;
  379. }
  380. static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  381. Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  382. *key = Py_tss_NEEDS_INIT;
  383. return key;
  384. }
  385. static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  386. PyObject_Free(key);
  387. }
  388. static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  389. return *key != Py_tss_NEEDS_INIT;
  390. }
  391. static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  392. PyThread_delete_key(*key);
  393. *key = Py_tss_NEEDS_INIT;
  394. }
  395. static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  396. return PyThread_set_key_value(*key, value);
  397. }
  398. static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  399. return PyThread_get_key_value(*key);
  400. }
  401. #endif
  402. #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
  403. #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
  404. #else
  405. #define __Pyx_PyDict_NewPresized(n) PyDict_New()
  406. #endif
  407. #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  408. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  409. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  410. #else
  411. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  412. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  413. #endif
  414. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
  415. #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
  416. #else
  417. #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
  418. #endif
  419. #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  420. #define CYTHON_PEP393_ENABLED 1
  421. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
  422. 0 : _PyUnicode_Ready((PyObject *)(op)))
  423. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  424. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  425. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
  426. #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
  427. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  428. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  429. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
  430. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  431. #else
  432. #define CYTHON_PEP393_ENABLED 0
  433. #define PyUnicode_1BYTE_KIND 1
  434. #define PyUnicode_2BYTE_KIND 2
  435. #define PyUnicode_4BYTE_KIND 4
  436. #define __Pyx_PyUnicode_READY(op) (0)
  437. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
  438. #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  439. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  440. #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
  441. #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
  442. #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  443. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  444. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
  445. #endif
  446. #if CYTHON_COMPILING_IN_PYPY
  447. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  448. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  449. #else
  450. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  451. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
  452. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  453. #endif
  454. #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  455. #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
  456. #endif
  457. #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  458. #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
  459. #endif
  460. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  461. #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
  462. #endif
  463. #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
  464. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  465. #if PY_MAJOR_VERSION >= 3
  466. #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
  467. #else
  468. #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
  469. #endif
  470. #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  471. #define PyObject_ASCII(o) PyObject_Repr(o)
  472. #endif
  473. #if PY_MAJOR_VERSION >= 3
  474. #define PyBaseString_Type PyUnicode_Type
  475. #define PyStringObject PyUnicodeObject
  476. #define PyString_Type PyUnicode_Type
  477. #define PyString_Check PyUnicode_Check
  478. #define PyString_CheckExact PyUnicode_CheckExact
  479. #define PyObject_Unicode PyObject_Str
  480. #endif
  481. #if PY_MAJOR_VERSION >= 3
  482. #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  483. #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
  484. #else
  485. #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  486. #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
  487. #endif
  488. #ifndef PySet_CheckExact
  489. #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
  490. #endif
  491. #if CYTHON_ASSUME_SAFE_MACROS
  492. #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
  493. #else
  494. #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
  495. #endif
  496. #if PY_MAJOR_VERSION >= 3
  497. #define PyIntObject PyLongObject
  498. #define PyInt_Type PyLong_Type
  499. #define PyInt_Check(op) PyLong_Check(op)
  500. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  501. #define PyInt_FromString PyLong_FromString
  502. #define PyInt_FromUnicode PyLong_FromUnicode
  503. #define PyInt_FromLong PyLong_FromLong
  504. #define PyInt_FromSize_t PyLong_FromSize_t
  505. #define PyInt_FromSsize_t PyLong_FromSsize_t
  506. #define PyInt_AsLong PyLong_AsLong
  507. #define PyInt_AS_LONG PyLong_AS_LONG
  508. #define PyInt_AsSsize_t PyLong_AsSsize_t
  509. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  510. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  511. #define PyNumber_Int PyNumber_Long
  512. #endif
  513. #if PY_MAJOR_VERSION >= 3
  514. #define PyBoolObject PyLongObject
  515. #endif
  516. #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  517. #ifndef PyUnicode_InternFromString
  518. #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  519. #endif
  520. #endif
  521. #if PY_VERSION_HEX < 0x030200A4
  522. typedef long Py_hash_t;
  523. #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  524. #define __Pyx_PyInt_AsHash_t PyInt_AsLong
  525. #else
  526. #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  527. #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
  528. #endif
  529. #if PY_MAJOR_VERSION >= 3
  530. #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
  531. #else
  532. #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
  533. #endif
  534. #if CYTHON_USE_ASYNC_SLOTS
  535. #if PY_VERSION_HEX >= 0x030500B1
  536. #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
  537. #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  538. #else
  539. #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  540. #endif
  541. #else
  542. #define __Pyx_PyType_AsAsync(obj) NULL
  543. #endif
  544. #ifndef __Pyx_PyAsyncMethodsStruct
  545. typedef struct {
  546. unaryfunc am_await;
  547. unaryfunc am_aiter;
  548. unaryfunc am_anext;
  549. } __Pyx_PyAsyncMethodsStruct;
  550. #endif
  551. #if defined(WIN32) || defined(MS_WINDOWS)
  552. #define _USE_MATH_DEFINES
  553. #endif
  554. #include <math.h>
  555. #ifdef NAN
  556. #define __PYX_NAN() ((float) NAN)
  557. #else
  558. static CYTHON_INLINE float __PYX_NAN() {
  559. float value;
  560. memset(&value, 0xFF, sizeof(value));
  561. return value;
  562. }
  563. #endif
  564. #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
  565. #define __Pyx_truncl trunc
  566. #else
  567. #define __Pyx_truncl truncl
  568. #endif
  569. #define __PYX_ERR(f_index, lineno, Ln_error) \
  570. { \
  571. __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
  572. }
  573. #ifndef __PYX_EXTERN_C
  574. #ifdef __cplusplus
  575. #define __PYX_EXTERN_C extern "C"
  576. #else
  577. #define __PYX_EXTERN_C extern
  578. #endif
  579. #endif
  580. #define __PYX_HAVE__pycocotools___mask
  581. #define __PYX_HAVE_API__pycocotools___mask
  582. /* Early includes */
  583. #include <string.h>
  584. #include <stdio.h>
  585. #include "numpy/arrayobject.h"
  586. #include "numpy/ufuncobject.h"
  587. #include <stdlib.h>
  588. #include "maskApi.h"
  589. #ifdef _OPENMP
  590. #include <omp.h>
  591. #endif /* _OPENMP */
  592. #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
  593. #define CYTHON_WITHOUT_ASSERTIONS
  594. #endif
  595. typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
  596. const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
  597. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  598. #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
  599. #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
  600. #define __PYX_DEFAULT_STRING_ENCODING ""
  601. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  602. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  603. #define __Pyx_uchar_cast(c) ((unsigned char)c)
  604. #define __Pyx_long_cast(x) ((long)x)
  605. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
  606. (sizeof(type) < sizeof(Py_ssize_t)) ||\
  607. (sizeof(type) > sizeof(Py_ssize_t) &&\
  608. likely(v < (type)PY_SSIZE_T_MAX ||\
  609. v == (type)PY_SSIZE_T_MAX) &&\
  610. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
  611. v == (type)PY_SSIZE_T_MIN))) ||\
  612. (sizeof(type) == sizeof(Py_ssize_t) &&\
  613. (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
  614. v == (type)PY_SSIZE_T_MAX))) )
  615. static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
  616. return (size_t) i < (size_t) limit;
  617. }
  618. #if defined (__cplusplus) && __cplusplus >= 201103L
  619. #include <cstdlib>
  620. #define __Pyx_sst_abs(value) std::abs(value)
  621. #elif SIZEOF_INT >= SIZEOF_SIZE_T
  622. #define __Pyx_sst_abs(value) abs(value)
  623. #elif SIZEOF_LONG >= SIZEOF_SIZE_T
  624. #define __Pyx_sst_abs(value) labs(value)
  625. #elif defined (_MSC_VER)
  626. #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
  627. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  628. #define __Pyx_sst_abs(value) llabs(value)
  629. #elif defined (__GNUC__)
  630. #define __Pyx_sst_abs(value) __builtin_llabs(value)
  631. #else
  632. #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
  633. #endif
  634. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
  635. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  636. #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
  637. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  638. #define __Pyx_PyBytes_FromString PyBytes_FromString
  639. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  640. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
  641. #if PY_MAJOR_VERSION < 3
  642. #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
  643. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  644. #else
  645. #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
  646. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
  647. #endif
  648. #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
  649. #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
  650. #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
  651. #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
  652. #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
  653. #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
  654. #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
  655. #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
  656. #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
  657. #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
  658. #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
  659. #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
  660. #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
  661. #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
  662. #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
  663. #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
  664. static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
  665. const Py_UNICODE *u_end = u;
  666. while (*u_end++) ;
  667. return (size_t)(u_end - u - 1);
  668. }
  669. #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
  670. #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
  671. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  672. #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
  673. #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
  674. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
  675. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  676. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
  677. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
  678. #define __Pyx_PySequence_Tuple(obj)\
  679. (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
  680. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  681. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  682. #if CYTHON_ASSUME_SAFE_MACROS
  683. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  684. #else
  685. #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  686. #endif
  687. #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
  688. #if PY_MAJOR_VERSION >= 3
  689. #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
  690. #else
  691. #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
  692. #endif
  693. #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
  694. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  695. static int __Pyx_sys_getdefaultencoding_not_ascii;
  696. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  697. PyObject* sys;
  698. PyObject* default_encoding = NULL;
  699. PyObject* ascii_chars_u = NULL;
  700. PyObject* ascii_chars_b = NULL;
  701. const char* default_encoding_c;
  702. sys = PyImport_ImportModule("sys");
  703. if (!sys) goto bad;
  704. default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
  705. Py_DECREF(sys);
  706. if (!default_encoding) goto bad;
  707. default_encoding_c = PyBytes_AsString(default_encoding);
  708. if (!default_encoding_c) goto bad;
  709. if (strcmp(default_encoding_c, "ascii") == 0) {
  710. __Pyx_sys_getdefaultencoding_not_ascii = 0;
  711. } else {
  712. char ascii_chars[128];
  713. int c;
  714. for (c = 0; c < 128; c++) {
  715. ascii_chars[c] = c;
  716. }
  717. __Pyx_sys_getdefaultencoding_not_ascii = 1;
  718. ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
  719. if (!ascii_chars_u) goto bad;
  720. ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
  721. if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
  722. PyErr_Format(
  723. PyExc_ValueError,
  724. "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
  725. default_encoding_c);
  726. goto bad;
  727. }
  728. Py_DECREF(ascii_chars_u);
  729. Py_DECREF(ascii_chars_b);
  730. }
  731. Py_DECREF(default_encoding);
  732. return 0;
  733. bad:
  734. Py_XDECREF(default_encoding);
  735. Py_XDECREF(ascii_chars_u);
  736. Py_XDECREF(ascii_chars_b);
  737. return -1;
  738. }
  739. #endif
  740. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
  741. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  742. #else
  743. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  744. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  745. static char* __PYX_DEFAULT_STRING_ENCODING;
  746. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  747. PyObject* sys;
  748. PyObject* default_encoding = NULL;
  749. char* default_encoding_c;
  750. sys = PyImport_ImportModule("sys");
  751. if (!sys) goto bad;
  752. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  753. Py_DECREF(sys);
  754. if (!default_encoding) goto bad;
  755. default_encoding_c = PyBytes_AsString(default_encoding);
  756. if (!default_encoding_c) goto bad;
  757. __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
  758. if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
  759. strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
  760. Py_DECREF(default_encoding);
  761. return 0;
  762. bad:
  763. Py_XDECREF(default_encoding);
  764. return -1;
  765. }
  766. #endif
  767. #endif
  768. /* Test for GCC > 2.95 */
  769. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  770. #define likely(x) __builtin_expect(!!(x), 1)
  771. #define unlikely(x) __builtin_expect(!!(x), 0)
  772. #else /* !__GNUC__ or GCC < 2.95 */
  773. #define likely(x) (x)
  774. #define unlikely(x) (x)
  775. #endif /* __GNUC__ */
  776. static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
  777. static PyObject *__pyx_m = NULL;
  778. static PyObject *__pyx_d;
  779. static PyObject *__pyx_b;
  780. static PyObject *__pyx_cython_runtime = NULL;
  781. static PyObject *__pyx_empty_tuple;
  782. static PyObject *__pyx_empty_bytes;
  783. static PyObject *__pyx_empty_unicode;
  784. static int __pyx_lineno;
  785. static int __pyx_clineno = 0;
  786. static const char * __pyx_cfilenm= __FILE__;
  787. static const char *__pyx_filename;
  788. /* Header.proto */
  789. #if !defined(CYTHON_CCOMPLEX)
  790. #if defined(__cplusplus)
  791. #define CYTHON_CCOMPLEX 1
  792. #elif defined(_Complex_I)
  793. #define CYTHON_CCOMPLEX 1
  794. #else
  795. #define CYTHON_CCOMPLEX 0
  796. #endif
  797. #endif
  798. #if CYTHON_CCOMPLEX
  799. #ifdef __cplusplus
  800. #include <complex>
  801. #else
  802. #include <complex.h>
  803. #endif
  804. #endif
  805. #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
  806. #undef _Complex_I
  807. #define _Complex_I 1.0fj
  808. #endif
  809. static const char *__pyx_f[] = {
  810. "pycocotools\\_mask.pyx",
  811. "stringsource",
  812. "__init__.pxd",
  813. "type.pxd",
  814. };
  815. /* BufferFormatStructs.proto */
  816. #define IS_UNSIGNED(type) (((type) -1) > 0)
  817. struct __Pyx_StructField_;
  818. #define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
  819. typedef struct {
  820. const char* name;
  821. struct __Pyx_StructField_* fields;
  822. size_t size;
  823. size_t arraysize[8];
  824. int ndim;
  825. char typegroup;
  826. char is_unsigned;
  827. int flags;
  828. } __Pyx_TypeInfo;
  829. typedef struct __Pyx_StructField_ {
  830. __Pyx_TypeInfo* type;
  831. const char* name;
  832. size_t offset;
  833. } __Pyx_StructField;
  834. typedef struct {
  835. __Pyx_StructField* field;
  836. size_t parent_offset;
  837. } __Pyx_BufFmt_StackElem;
  838. typedef struct {
  839. __Pyx_StructField root;
  840. __Pyx_BufFmt_StackElem* head;
  841. size_t fmt_offset;
  842. size_t new_count, enc_count;
  843. size_t struct_alignment;
  844. int is_complex;
  845. char enc_type;
  846. char new_packmode;
  847. char enc_packmode;
  848. char is_valid_array;
  849. } __Pyx_BufFmt_Context;
  850. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":776
  851. * # in Cython to enable them only on the right systems.
  852. *
  853. * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<<
  854. * ctypedef npy_int16 int16_t
  855. * ctypedef npy_int32 int32_t
  856. */
  857. typedef npy_int8 __pyx_t_5numpy_int8_t;
  858. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":777
  859. *
  860. * ctypedef npy_int8 int8_t
  861. * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<<
  862. * ctypedef npy_int32 int32_t
  863. * ctypedef npy_int64 int64_t
  864. */
  865. typedef npy_int16 __pyx_t_5numpy_int16_t;
  866. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":778
  867. * ctypedef npy_int8 int8_t
  868. * ctypedef npy_int16 int16_t
  869. * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<<
  870. * ctypedef npy_int64 int64_t
  871. * #ctypedef npy_int96 int96_t
  872. */
  873. typedef npy_int32 __pyx_t_5numpy_int32_t;
  874. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":779
  875. * ctypedef npy_int16 int16_t
  876. * ctypedef npy_int32 int32_t
  877. * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<<
  878. * #ctypedef npy_int96 int96_t
  879. * #ctypedef npy_int128 int128_t
  880. */
  881. typedef npy_int64 __pyx_t_5numpy_int64_t;
  882. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":783
  883. * #ctypedef npy_int128 int128_t
  884. *
  885. * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<<
  886. * ctypedef npy_uint16 uint16_t
  887. * ctypedef npy_uint32 uint32_t
  888. */
  889. typedef npy_uint8 __pyx_t_5numpy_uint8_t;
  890. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":784
  891. *
  892. * ctypedef npy_uint8 uint8_t
  893. * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<<
  894. * ctypedef npy_uint32 uint32_t
  895. * ctypedef npy_uint64 uint64_t
  896. */
  897. typedef npy_uint16 __pyx_t_5numpy_uint16_t;
  898. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":785
  899. * ctypedef npy_uint8 uint8_t
  900. * ctypedef npy_uint16 uint16_t
  901. * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<<
  902. * ctypedef npy_uint64 uint64_t
  903. * #ctypedef npy_uint96 uint96_t
  904. */
  905. typedef npy_uint32 __pyx_t_5numpy_uint32_t;
  906. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":786
  907. * ctypedef npy_uint16 uint16_t
  908. * ctypedef npy_uint32 uint32_t
  909. * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<<
  910. * #ctypedef npy_uint96 uint96_t
  911. * #ctypedef npy_uint128 uint128_t
  912. */
  913. typedef npy_uint64 __pyx_t_5numpy_uint64_t;
  914. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":790
  915. * #ctypedef npy_uint128 uint128_t
  916. *
  917. * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<<
  918. * ctypedef npy_float64 float64_t
  919. * #ctypedef npy_float80 float80_t
  920. */
  921. typedef npy_float32 __pyx_t_5numpy_float32_t;
  922. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":791
  923. *
  924. * ctypedef npy_float32 float32_t
  925. * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<<
  926. * #ctypedef npy_float80 float80_t
  927. * #ctypedef npy_float128 float128_t
  928. */
  929. typedef npy_float64 __pyx_t_5numpy_float64_t;
  930. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":800
  931. * # The int types are mapped a bit surprising --
  932. * # numpy.int corresponds to 'l' and numpy.long to 'q'
  933. * ctypedef npy_long int_t # <<<<<<<<<<<<<<
  934. * ctypedef npy_longlong long_t
  935. * ctypedef npy_longlong longlong_t
  936. */
  937. typedef npy_long __pyx_t_5numpy_int_t;
  938. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":801
  939. * # numpy.int corresponds to 'l' and numpy.long to 'q'
  940. * ctypedef npy_long int_t
  941. * ctypedef npy_longlong long_t # <<<<<<<<<<<<<<
  942. * ctypedef npy_longlong longlong_t
  943. *
  944. */
  945. typedef npy_longlong __pyx_t_5numpy_long_t;
  946. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":802
  947. * ctypedef npy_long int_t
  948. * ctypedef npy_longlong long_t
  949. * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<<
  950. *
  951. * ctypedef npy_ulong uint_t
  952. */
  953. typedef npy_longlong __pyx_t_5numpy_longlong_t;
  954. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":804
  955. * ctypedef npy_longlong longlong_t
  956. *
  957. * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<<
  958. * ctypedef npy_ulonglong ulong_t
  959. * ctypedef npy_ulonglong ulonglong_t
  960. */
  961. typedef npy_ulong __pyx_t_5numpy_uint_t;
  962. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":805
  963. *
  964. * ctypedef npy_ulong uint_t
  965. * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<<
  966. * ctypedef npy_ulonglong ulonglong_t
  967. *
  968. */
  969. typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
  970. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":806
  971. * ctypedef npy_ulong uint_t
  972. * ctypedef npy_ulonglong ulong_t
  973. * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<<
  974. *
  975. * ctypedef npy_intp intp_t
  976. */
  977. typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
  978. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":808
  979. * ctypedef npy_ulonglong ulonglong_t
  980. *
  981. * ctypedef npy_intp intp_t # <<<<<<<<<<<<<<
  982. * ctypedef npy_uintp uintp_t
  983. *
  984. */
  985. typedef npy_intp __pyx_t_5numpy_intp_t;
  986. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":809
  987. *
  988. * ctypedef npy_intp intp_t
  989. * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<<
  990. *
  991. * ctypedef npy_double float_t
  992. */
  993. typedef npy_uintp __pyx_t_5numpy_uintp_t;
  994. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":811
  995. * ctypedef npy_uintp uintp_t
  996. *
  997. * ctypedef npy_double float_t # <<<<<<<<<<<<<<
  998. * ctypedef npy_double double_t
  999. * ctypedef npy_longdouble longdouble_t
  1000. */
  1001. typedef npy_double __pyx_t_5numpy_float_t;
  1002. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":812
  1003. *
  1004. * ctypedef npy_double float_t
  1005. * ctypedef npy_double double_t # <<<<<<<<<<<<<<
  1006. * ctypedef npy_longdouble longdouble_t
  1007. *
  1008. */
  1009. typedef npy_double __pyx_t_5numpy_double_t;
  1010. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":813
  1011. * ctypedef npy_double float_t
  1012. * ctypedef npy_double double_t
  1013. * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<<
  1014. *
  1015. * ctypedef npy_cfloat cfloat_t
  1016. */
  1017. typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
  1018. /* Declarations.proto */
  1019. #if CYTHON_CCOMPLEX
  1020. #ifdef __cplusplus
  1021. typedef ::std::complex< float > __pyx_t_float_complex;
  1022. #else
  1023. typedef float _Complex __pyx_t_float_complex;
  1024. #endif
  1025. #else
  1026. typedef struct { float real, imag; } __pyx_t_float_complex;
  1027. #endif
  1028. static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
  1029. /* Declarations.proto */
  1030. #if CYTHON_CCOMPLEX
  1031. #ifdef __cplusplus
  1032. typedef ::std::complex< double > __pyx_t_double_complex;
  1033. #else
  1034. typedef double _Complex __pyx_t_double_complex;
  1035. #endif
  1036. #else
  1037. typedef struct { double real, imag; } __pyx_t_double_complex;
  1038. #endif
  1039. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
  1040. /*--- Type declarations ---*/
  1041. struct __pyx_obj_11pycocotools_5_mask_RLEs;
  1042. struct __pyx_obj_11pycocotools_5_mask_Masks;
  1043. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":815
  1044. * ctypedef npy_longdouble longdouble_t
  1045. *
  1046. * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<<
  1047. * ctypedef npy_cdouble cdouble_t
  1048. * ctypedef npy_clongdouble clongdouble_t
  1049. */
  1050. typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
  1051. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":816
  1052. *
  1053. * ctypedef npy_cfloat cfloat_t
  1054. * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<<
  1055. * ctypedef npy_clongdouble clongdouble_t
  1056. *
  1057. */
  1058. typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
  1059. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":817
  1060. * ctypedef npy_cfloat cfloat_t
  1061. * ctypedef npy_cdouble cdouble_t
  1062. * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<<
  1063. *
  1064. * ctypedef npy_cdouble complex_t
  1065. */
  1066. typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
  1067. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":819
  1068. * ctypedef npy_clongdouble clongdouble_t
  1069. *
  1070. * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<<
  1071. *
  1072. * cdef inline object PyArray_MultiIterNew1(a):
  1073. */
  1074. typedef npy_cdouble __pyx_t_5numpy_complex_t;
  1075. /* "pycocotools/_mask.pyx":53
  1076. * # python class to wrap RLE array in C
  1077. * # the class handles the memory allocation and deallocation
  1078. * cdef class RLEs: # <<<<<<<<<<<<<<
  1079. * cdef RLE *_R
  1080. * cdef siz _n
  1081. */
  1082. struct __pyx_obj_11pycocotools_5_mask_RLEs {
  1083. PyObject_HEAD
  1084. RLE *_R;
  1085. siz _n;
  1086. };
  1087. /* "pycocotools/_mask.pyx":74
  1088. * # python class to wrap Mask array in C
  1089. * # the class handles the memory allocation and deallocation
  1090. * cdef class Masks: # <<<<<<<<<<<<<<
  1091. * cdef byte *_mask
  1092. * cdef siz _h
  1093. */
  1094. struct __pyx_obj_11pycocotools_5_mask_Masks {
  1095. PyObject_HEAD
  1096. byte *_mask;
  1097. siz _h;
  1098. siz _w;
  1099. siz _n;
  1100. };
  1101. /* --- Runtime support code (head) --- */
  1102. /* Refnanny.proto */
  1103. #ifndef CYTHON_REFNANNY
  1104. #define CYTHON_REFNANNY 0
  1105. #endif
  1106. #if CYTHON_REFNANNY
  1107. typedef struct {
  1108. void (*INCREF)(void*, PyObject*, int);
  1109. void (*DECREF)(void*, PyObject*, int);
  1110. void (*GOTREF)(void*, PyObject*, int);
  1111. void (*GIVEREF)(void*, PyObject*, int);
  1112. void* (*SetupContext)(const char*, int, const char*);
  1113. void (*FinishContext)(void**);
  1114. } __Pyx_RefNannyAPIStruct;
  1115. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  1116. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  1117. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  1118. #ifdef WITH_THREAD
  1119. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  1120. if (acquire_gil) {\
  1121. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  1122. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  1123. PyGILState_Release(__pyx_gilstate_save);\
  1124. } else {\
  1125. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  1126. }
  1127. #else
  1128. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  1129. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  1130. #endif
  1131. #define __Pyx_RefNannyFinishContext()\
  1132. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  1133. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1134. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1135. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1136. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  1137. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  1138. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  1139. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  1140. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  1141. #else
  1142. #define __Pyx_RefNannyDeclarations
  1143. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  1144. #define __Pyx_RefNannyFinishContext()
  1145. #define __Pyx_INCREF(r) Py_INCREF(r)
  1146. #define __Pyx_DECREF(r) Py_DECREF(r)
  1147. #define __Pyx_GOTREF(r)
  1148. #define __Pyx_GIVEREF(r)
  1149. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  1150. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  1151. #define __Pyx_XGOTREF(r)
  1152. #define __Pyx_XGIVEREF(r)
  1153. #endif
  1154. #define __Pyx_XDECREF_SET(r, v) do {\
  1155. PyObject *tmp = (PyObject *) r;\
  1156. r = v; __Pyx_XDECREF(tmp);\
  1157. } while (0)
  1158. #define __Pyx_DECREF_SET(r, v) do {\
  1159. PyObject *tmp = (PyObject *) r;\
  1160. r = v; __Pyx_DECREF(tmp);\
  1161. } while (0)
  1162. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  1163. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  1164. /* PyObjectGetAttrStr.proto */
  1165. #if CYTHON_USE_TYPE_SLOTS
  1166. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
  1167. #else
  1168. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  1169. #endif
  1170. /* GetBuiltinName.proto */
  1171. static PyObject *__Pyx_GetBuiltinName(PyObject *name);
  1172. /* RaiseDoubleKeywords.proto */
  1173. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
  1174. /* ParseKeywords.proto */
  1175. static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
  1176. PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
  1177. const char* function_name);
  1178. /* RaiseArgTupleInvalid.proto */
  1179. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  1180. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
  1181. /* IncludeStringH.proto */
  1182. #include <string.h>
  1183. /* BytesEquals.proto */
  1184. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
  1185. /* UnicodeEquals.proto */
  1186. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
  1187. /* StrEquals.proto */
  1188. #if PY_MAJOR_VERSION >= 3
  1189. #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
  1190. #else
  1191. #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
  1192. #endif
  1193. /* PyCFunctionFastCall.proto */
  1194. #if CYTHON_FAST_PYCCALL
  1195. static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
  1196. #else
  1197. #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
  1198. #endif
  1199. /* PyFunctionFastCall.proto */
  1200. #if CYTHON_FAST_PYCALL
  1201. #define __Pyx_PyFunction_FastCall(func, args, nargs)\
  1202. __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
  1203. #if 1 || PY_VERSION_HEX < 0x030600B1
  1204. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
  1205. #else
  1206. #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
  1207. #endif
  1208. #define __Pyx_BUILD_ASSERT_EXPR(cond)\
  1209. (sizeof(char [1 - 2*!(cond)]) - 1)
  1210. #ifndef Py_MEMBER_SIZE
  1211. #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
  1212. #endif
  1213. static size_t __pyx_pyframe_localsplus_offset = 0;
  1214. #include "frameobject.h"
  1215. #define __Pxy_PyFrame_Initialize_Offsets()\
  1216. ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
  1217. (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
  1218. #define __Pyx_PyFrame_GetLocalsplus(frame)\
  1219. (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
  1220. #endif
  1221. /* PyObjectCall.proto */
  1222. #if CYTHON_COMPILING_IN_CPYTHON
  1223. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
  1224. #else
  1225. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  1226. #endif
  1227. /* PyObjectCallMethO.proto */
  1228. #if CYTHON_COMPILING_IN_CPYTHON
  1229. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
  1230. #endif
  1231. /* PyObjectCallOneArg.proto */
  1232. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
  1233. /* PyThreadStateGet.proto */
  1234. #if CYTHON_FAST_THREAD_STATE
  1235. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  1236. #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
  1237. #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
  1238. #else
  1239. #define __Pyx_PyThreadState_declare
  1240. #define __Pyx_PyThreadState_assign
  1241. #define __Pyx_PyErr_Occurred() PyErr_Occurred()
  1242. #endif
  1243. /* PyErrFetchRestore.proto */
  1244. #if CYTHON_FAST_THREAD_STATE
  1245. #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
  1246. #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
  1247. #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
  1248. #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
  1249. #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
  1250. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1251. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1252. #if CYTHON_COMPILING_IN_CPYTHON
  1253. #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
  1254. #else
  1255. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1256. #endif
  1257. #else
  1258. #define __Pyx_PyErr_Clear() PyErr_Clear()
  1259. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1260. #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
  1261. #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
  1262. #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
  1263. #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
  1264. #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
  1265. #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
  1266. #endif
  1267. /* RaiseException.proto */
  1268. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
  1269. /* ExtTypeTest.proto */
  1270. static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
  1271. /* ArgTypeTest.proto */
  1272. #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
  1273. ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
  1274. __Pyx__ArgTypeTest(obj, type, name, exact))
  1275. static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
  1276. /* ListAppend.proto */
  1277. #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
  1278. static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
  1279. PyListObject* L = (PyListObject*) list;
  1280. Py_ssize_t len = Py_SIZE(list);
  1281. if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
  1282. Py_INCREF(x);
  1283. PyList_SET_ITEM(list, len, x);
  1284. Py_SIZE(list) = len+1;
  1285. return 0;
  1286. }
  1287. return PyList_Append(list, x);
  1288. }
  1289. #else
  1290. #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
  1291. #endif
  1292. /* PyIntBinop.proto */
  1293. #if !CYTHON_COMPILING_IN_PYPY
  1294. static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
  1295. #else
  1296. #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
  1297. (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
  1298. #endif
  1299. /* DictGetItem.proto */
  1300. #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
  1301. static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
  1302. #define __Pyx_PyObject_Dict_GetItem(obj, name)\
  1303. (likely(PyDict_CheckExact(obj)) ?\
  1304. __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
  1305. #else
  1306. #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
  1307. #define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name)
  1308. #endif
  1309. /* GetItemInt.proto */
  1310. #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
  1311. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1312. __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
  1313. (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
  1314. __Pyx_GetItemInt_Generic(o, to_py_func(i))))
  1315. #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
  1316. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1317. __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
  1318. (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
  1319. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  1320. int wraparound, int boundscheck);
  1321. #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
  1322. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1323. __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
  1324. (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
  1325. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  1326. int wraparound, int boundscheck);
  1327. static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
  1328. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
  1329. int is_list, int wraparound, int boundscheck);
  1330. /* IsLittleEndian.proto */
  1331. static CYTHON_INLINE int __Pyx_Is_Little_Endian(void);
  1332. /* BufferFormatCheck.proto */
  1333. static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
  1334. static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
  1335. __Pyx_BufFmt_StackElem* stack,
  1336. __Pyx_TypeInfo* type);
  1337. /* BufferGetAndValidate.proto */
  1338. #define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\
  1339. ((obj == Py_None || obj == NULL) ?\
  1340. (__Pyx_ZeroBuffer(buf), 0) :\
  1341. __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack))
  1342. static int __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
  1343. __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
  1344. static void __Pyx_ZeroBuffer(Py_buffer* buf);
  1345. static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
  1346. static Py_ssize_t __Pyx_minusones[] = { -1, -1, -1, -1, -1, -1, -1, -1 };
  1347. static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
  1348. /* PyDictVersioning.proto */
  1349. #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
  1350. #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
  1351. #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
  1352. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
  1353. (version_var) = __PYX_GET_DICT_VERSION(dict);\
  1354. (cache_var) = (value);
  1355. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
  1356. static PY_UINT64_T __pyx_dict_version = 0;\
  1357. static PyObject *__pyx_dict_cached_value = NULL;\
  1358. if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
  1359. (VAR) = __pyx_dict_cached_value;\
  1360. } else {\
  1361. (VAR) = __pyx_dict_cached_value = (LOOKUP);\
  1362. __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
  1363. }\
  1364. }
  1365. static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
  1366. static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
  1367. static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
  1368. #else
  1369. #define __PYX_GET_DICT_VERSION(dict) (0)
  1370. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
  1371. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
  1372. #endif
  1373. /* GetModuleGlobalName.proto */
  1374. #if CYTHON_USE_DICT_VERSIONS
  1375. #define __Pyx_GetModuleGlobalName(var, name) {\
  1376. static PY_UINT64_T __pyx_dict_version = 0;\
  1377. static PyObject *__pyx_dict_cached_value = NULL;\
  1378. (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
  1379. (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
  1380. __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
  1381. }
  1382. #define __Pyx_GetModuleGlobalNameUncached(var, name) {\
  1383. PY_UINT64_T __pyx_dict_version;\
  1384. PyObject *__pyx_dict_cached_value;\
  1385. (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
  1386. }
  1387. static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
  1388. #else
  1389. #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
  1390. #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
  1391. static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
  1392. #endif
  1393. /* PyObjectCall2Args.proto */
  1394. static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
  1395. /* PyIntCompare.proto */
  1396. static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);
  1397. /* ListCompAppend.proto */
  1398. #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
  1399. static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
  1400. PyListObject* L = (PyListObject*) list;
  1401. Py_ssize_t len = Py_SIZE(list);
  1402. if (likely(L->allocated > len)) {
  1403. Py_INCREF(x);
  1404. PyList_SET_ITEM(list, len, x);
  1405. Py_SIZE(list) = len+1;
  1406. return 0;
  1407. }
  1408. return PyList_Append(list, x);
  1409. }
  1410. #else
  1411. #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
  1412. #endif
  1413. /* FetchCommonType.proto */
  1414. static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
  1415. /* CythonFunction.proto */
  1416. #define __Pyx_CyFunction_USED 1
  1417. #define __Pyx_CYFUNCTION_STATICMETHOD 0x01
  1418. #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
  1419. #define __Pyx_CYFUNCTION_CCLASS 0x04
  1420. #define __Pyx_CyFunction_GetClosure(f)\
  1421. (((__pyx_CyFunctionObject *) (f))->func_closure)
  1422. #define __Pyx_CyFunction_GetClassObj(f)\
  1423. (((__pyx_CyFunctionObject *) (f))->func_classobj)
  1424. #define __Pyx_CyFunction_Defaults(type, f)\
  1425. ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
  1426. #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
  1427. ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
  1428. typedef struct {
  1429. PyCFunctionObject func;
  1430. #if PY_VERSION_HEX < 0x030500A0
  1431. PyObject *func_weakreflist;
  1432. #endif
  1433. PyObject *func_dict;
  1434. PyObject *func_name;
  1435. PyObject *func_qualname;
  1436. PyObject *func_doc;
  1437. PyObject *func_globals;
  1438. PyObject *func_code;
  1439. PyObject *func_closure;
  1440. PyObject *func_classobj;
  1441. void *defaults;
  1442. int defaults_pyobjects;
  1443. int flags;
  1444. PyObject *defaults_tuple;
  1445. PyObject *defaults_kwdict;
  1446. PyObject *(*defaults_getter)(PyObject *);
  1447. PyObject *func_annotations;
  1448. } __pyx_CyFunctionObject;
  1449. static PyTypeObject *__pyx_CyFunctionType = 0;
  1450. #define __Pyx_CyFunction_Check(obj) (__Pyx_TypeCheck(obj, __pyx_CyFunctionType))
  1451. #define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
  1452. __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
  1453. static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
  1454. int flags, PyObject* qualname,
  1455. PyObject *self,
  1456. PyObject *module, PyObject *globals,
  1457. PyObject* code);
  1458. static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
  1459. size_t size,
  1460. int pyobjects);
  1461. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
  1462. PyObject *tuple);
  1463. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
  1464. PyObject *dict);
  1465. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
  1466. PyObject *dict);
  1467. static int __pyx_CyFunction_init(void);
  1468. /* BufferFallbackError.proto */
  1469. static void __Pyx_RaiseBufferFallbackError(void);
  1470. /* None.proto */
  1471. static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t);
  1472. /* BufferIndexError.proto */
  1473. static void __Pyx_RaiseBufferIndexError(int axis);
  1474. #define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0)
  1475. /* RaiseTooManyValuesToUnpack.proto */
  1476. static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
  1477. /* RaiseNeedMoreValuesToUnpack.proto */
  1478. static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
  1479. /* RaiseNoneIterError.proto */
  1480. static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
  1481. /* GetTopmostException.proto */
  1482. #if CYTHON_USE_EXC_INFO_STACK
  1483. static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
  1484. #endif
  1485. /* SaveResetException.proto */
  1486. #if CYTHON_FAST_THREAD_STATE
  1487. #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
  1488. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1489. #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
  1490. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1491. #else
  1492. #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
  1493. #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
  1494. #endif
  1495. /* PyErrExceptionMatches.proto */
  1496. #if CYTHON_FAST_THREAD_STATE
  1497. #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
  1498. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
  1499. #else
  1500. #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
  1501. #endif
  1502. /* GetException.proto */
  1503. #if CYTHON_FAST_THREAD_STATE
  1504. #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
  1505. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1506. #else
  1507. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
  1508. #endif
  1509. /* PyObject_GenericGetAttrNoDict.proto */
  1510. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  1511. static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
  1512. #else
  1513. #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
  1514. #endif
  1515. /* PyObject_GenericGetAttr.proto */
  1516. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  1517. static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
  1518. #else
  1519. #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
  1520. #endif
  1521. /* SetupReduce.proto */
  1522. static int __Pyx_setup_reduce(PyObject* type_obj);
  1523. /* TypeImport.proto */
  1524. #ifndef __PYX_HAVE_RT_ImportType_proto
  1525. #define __PYX_HAVE_RT_ImportType_proto
  1526. enum __Pyx_ImportType_CheckSize {
  1527. __Pyx_ImportType_CheckSize_Error = 0,
  1528. __Pyx_ImportType_CheckSize_Warn = 1,
  1529. __Pyx_ImportType_CheckSize_Ignore = 2
  1530. };
  1531. static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
  1532. #endif
  1533. /* Import.proto */
  1534. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
  1535. /* CLineInTraceback.proto */
  1536. #ifdef CYTHON_CLINE_IN_TRACEBACK
  1537. #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
  1538. #else
  1539. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
  1540. #endif
  1541. /* CodeObjectCache.proto */
  1542. typedef struct {
  1543. PyCodeObject* code_object;
  1544. int code_line;
  1545. } __Pyx_CodeObjectCacheEntry;
  1546. struct __Pyx_CodeObjectCache {
  1547. int count;
  1548. int max_count;
  1549. __Pyx_CodeObjectCacheEntry* entries;
  1550. };
  1551. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  1552. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  1553. static PyCodeObject *__pyx_find_code_object(int code_line);
  1554. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  1555. /* AddTraceback.proto */
  1556. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  1557. int py_line, const char *filename);
  1558. /* BufferStructDeclare.proto */
  1559. typedef struct {
  1560. Py_ssize_t shape, strides, suboffsets;
  1561. } __Pyx_Buf_DimInfo;
  1562. typedef struct {
  1563. size_t refcount;
  1564. Py_buffer pybuffer;
  1565. } __Pyx_Buffer;
  1566. typedef struct {
  1567. __Pyx_Buffer *rcbuffer;
  1568. char *data;
  1569. __Pyx_Buf_DimInfo diminfo[8];
  1570. } __Pyx_LocalBuf_ND;
  1571. #if PY_MAJOR_VERSION < 3
  1572. static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
  1573. static void __Pyx_ReleaseBuffer(Py_buffer *view);
  1574. #else
  1575. #define __Pyx_GetBuffer PyObject_GetBuffer
  1576. #define __Pyx_ReleaseBuffer PyBuffer_Release
  1577. #endif
  1578. /* CIntToPy.proto */
  1579. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_siz(siz value);
  1580. /* CIntToPy.proto */
  1581. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  1582. /* CIntToPy.proto */
  1583. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value);
  1584. /* RealImag.proto */
  1585. #if CYTHON_CCOMPLEX
  1586. #ifdef __cplusplus
  1587. #define __Pyx_CREAL(z) ((z).real())
  1588. #define __Pyx_CIMAG(z) ((z).imag())
  1589. #else
  1590. #define __Pyx_CREAL(z) (__real__(z))
  1591. #define __Pyx_CIMAG(z) (__imag__(z))
  1592. #endif
  1593. #else
  1594. #define __Pyx_CREAL(z) ((z).real)
  1595. #define __Pyx_CIMAG(z) ((z).imag)
  1596. #endif
  1597. #if defined(__cplusplus) && CYTHON_CCOMPLEX\
  1598. && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
  1599. #define __Pyx_SET_CREAL(z,x) ((z).real(x))
  1600. #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
  1601. #else
  1602. #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
  1603. #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
  1604. #endif
  1605. /* Arithmetic.proto */
  1606. #if CYTHON_CCOMPLEX
  1607. #define __Pyx_c_eq_float(a, b) ((a)==(b))
  1608. #define __Pyx_c_sum_float(a, b) ((a)+(b))
  1609. #define __Pyx_c_diff_float(a, b) ((a)-(b))
  1610. #define __Pyx_c_prod_float(a, b) ((a)*(b))
  1611. #define __Pyx_c_quot_float(a, b) ((a)/(b))
  1612. #define __Pyx_c_neg_float(a) (-(a))
  1613. #ifdef __cplusplus
  1614. #define __Pyx_c_is_zero_float(z) ((z)==(float)0)
  1615. #define __Pyx_c_conj_float(z) (::std::conj(z))
  1616. #if 1
  1617. #define __Pyx_c_abs_float(z) (::std::abs(z))
  1618. #define __Pyx_c_pow_float(a, b) (::std::pow(a, b))
  1619. #endif
  1620. #else
  1621. #define __Pyx_c_is_zero_float(z) ((z)==0)
  1622. #define __Pyx_c_conj_float(z) (conjf(z))
  1623. #if 1
  1624. #define __Pyx_c_abs_float(z) (cabsf(z))
  1625. #define __Pyx_c_pow_float(a, b) (cpowf(a, b))
  1626. #endif
  1627. #endif
  1628. #else
  1629. static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex);
  1630. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex);
  1631. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex);
  1632. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex);
  1633. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex);
  1634. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex);
  1635. static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex);
  1636. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex);
  1637. #if 1
  1638. static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex);
  1639. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex);
  1640. #endif
  1641. #endif
  1642. /* Arithmetic.proto */
  1643. #if CYTHON_CCOMPLEX
  1644. #define __Pyx_c_eq_double(a, b) ((a)==(b))
  1645. #define __Pyx_c_sum_double(a, b) ((a)+(b))
  1646. #define __Pyx_c_diff_double(a, b) ((a)-(b))
  1647. #define __Pyx_c_prod_double(a, b) ((a)*(b))
  1648. #define __Pyx_c_quot_double(a, b) ((a)/(b))
  1649. #define __Pyx_c_neg_double(a) (-(a))
  1650. #ifdef __cplusplus
  1651. #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
  1652. #define __Pyx_c_conj_double(z) (::std::conj(z))
  1653. #if 1
  1654. #define __Pyx_c_abs_double(z) (::std::abs(z))
  1655. #define __Pyx_c_pow_double(a, b) (::std::pow(a, b))
  1656. #endif
  1657. #else
  1658. #define __Pyx_c_is_zero_double(z) ((z)==0)
  1659. #define __Pyx_c_conj_double(z) (conj(z))
  1660. #if 1
  1661. #define __Pyx_c_abs_double(z) (cabs(z))
  1662. #define __Pyx_c_pow_double(a, b) (cpow(a, b))
  1663. #endif
  1664. #endif
  1665. #else
  1666. static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
  1667. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
  1668. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
  1669. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
  1670. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
  1671. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
  1672. static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
  1673. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
  1674. #if 1
  1675. static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
  1676. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
  1677. #endif
  1678. #endif
  1679. /* CIntToPy.proto */
  1680. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
  1681. /* CIntToPy.proto */
  1682. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value);
  1683. /* CIntFromPy.proto */
  1684. static CYTHON_INLINE siz __Pyx_PyInt_As_siz(PyObject *);
  1685. /* CIntFromPy.proto */
  1686. static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);
  1687. /* CIntFromPy.proto */
  1688. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  1689. /* CIntFromPy.proto */
  1690. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  1691. /* FastTypeChecks.proto */
  1692. #if CYTHON_COMPILING_IN_CPYTHON
  1693. #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
  1694. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
  1695. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
  1696. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
  1697. #else
  1698. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  1699. #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
  1700. #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
  1701. #endif
  1702. #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
  1703. /* CheckBinaryVersion.proto */
  1704. static int __Pyx_check_binary_version(void);
  1705. /* InitStrings.proto */
  1706. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
  1707. /* Module declarations from 'cpython.buffer' */
  1708. /* Module declarations from 'libc.string' */
  1709. /* Module declarations from 'libc.stdio' */
  1710. /* Module declarations from '__builtin__' */
  1711. /* Module declarations from 'cpython.type' */
  1712. static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
  1713. /* Module declarations from 'cpython' */
  1714. /* Module declarations from 'cpython.object' */
  1715. /* Module declarations from 'cpython.ref' */
  1716. /* Module declarations from 'cpython.mem' */
  1717. /* Module declarations from 'numpy' */
  1718. /* Module declarations from 'numpy' */
  1719. static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
  1720. static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
  1721. static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
  1722. static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
  1723. static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
  1724. static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/
  1725. static CYTHON_INLINE int __pyx_f_5numpy_import_array(void); /*proto*/
  1726. /* Module declarations from 'libc.stdlib' */
  1727. /* Module declarations from 'pycocotools._mask' */
  1728. static PyTypeObject *__pyx_ptype_11pycocotools_5_mask_RLEs = 0;
  1729. static PyTypeObject *__pyx_ptype_11pycocotools_5_mask_Masks = 0;
  1730. static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t = { "uint8_t", NULL, sizeof(__pyx_t_5numpy_uint8_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_5numpy_uint8_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5numpy_uint8_t), 0 };
  1731. static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_double_t = { "double_t", NULL, sizeof(__pyx_t_5numpy_double_t), { 0 }, 0, 'R', 0, 0 };
  1732. static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_uint32_t = { "uint32_t", NULL, sizeof(__pyx_t_5numpy_uint32_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_5numpy_uint32_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5numpy_uint32_t), 0 };
  1733. #define __Pyx_MODULE_NAME "pycocotools._mask"
  1734. extern int __pyx_module_is_main_pycocotools___mask;
  1735. int __pyx_module_is_main_pycocotools___mask = 0;
  1736. /* Implementation of 'pycocotools._mask' */
  1737. static PyObject *__pyx_builtin_range;
  1738. static PyObject *__pyx_builtin_AttributeError;
  1739. static PyObject *__pyx_builtin_TypeError;
  1740. static PyObject *__pyx_builtin_enumerate;
  1741. static PyObject *__pyx_builtin_ValueError;
  1742. static PyObject *__pyx_builtin_RuntimeError;
  1743. static PyObject *__pyx_builtin_ImportError;
  1744. static const char __pyx_k_F[] = "F";
  1745. static const char __pyx_k_N[] = "N";
  1746. static const char __pyx_k_R[] = "R";
  1747. static const char __pyx_k_a[] = "_a";
  1748. static const char __pyx_k_h[] = "h";
  1749. static const char __pyx_k_i[] = "i";
  1750. static const char __pyx_k_j[] = "j";
  1751. static const char __pyx_k_m[] = "m";
  1752. static const char __pyx_k_n[] = "n";
  1753. static const char __pyx_k_p[] = "p";
  1754. static const char __pyx_k_w[] = "w";
  1755. static const char __pyx_k_Rs[] = "Rs";
  1756. static const char __pyx_k_bb[] = "bb";
  1757. static const char __pyx_k_dt[] = "dt";
  1758. static const char __pyx_k_gt[] = "gt";
  1759. static const char __pyx_k_np[] = "np";
  1760. static const char __pyx_k_a_2[] = "a";
  1761. static const char __pyx_k_all[] = "all";
  1762. static const char __pyx_k_iou[] = "_iou";
  1763. static const char __pyx_k_len[] = "_len";
  1764. static const char __pyx_k_obj[] = "obj";
  1765. static const char __pyx_k_RLEs[] = "RLEs";
  1766. static const char __pyx_k_area[] = "area";
  1767. static const char __pyx_k_bb_2[] = "_bb";
  1768. static const char __pyx_k_cnts[] = "cnts";
  1769. static const char __pyx_k_data[] = "data";
  1770. static const char __pyx_k_main[] = "__main__";
  1771. static const char __pyx_k_mask[] = "mask";
  1772. static const char __pyx_k_name[] = "__name__";
  1773. static const char __pyx_k_objs[] = "objs";
  1774. static const char __pyx_k_poly[] = "poly";
  1775. static const char __pyx_k_size[] = "size";
  1776. static const char __pyx_k_test[] = "__test__";
  1777. static const char __pyx_k_Masks[] = "Masks";
  1778. static const char __pyx_k_array[] = "array";
  1779. static const char __pyx_k_bbIou[] = "_bbIou";
  1780. static const char __pyx_k_dtype[] = "dtype";
  1781. static const char __pyx_k_iou_2[] = "iou";
  1782. static const char __pyx_k_isbox[] = "isbox";
  1783. static const char __pyx_k_isrle[] = "isrle";
  1784. static const char __pyx_k_masks[] = "masks";
  1785. static const char __pyx_k_merge[] = "merge";
  1786. static const char __pyx_k_numpy[] = "numpy";
  1787. static const char __pyx_k_order[] = "order";
  1788. static const char __pyx_k_pyobj[] = "pyobj";
  1789. static const char __pyx_k_range[] = "range";
  1790. static const char __pyx_k_shape[] = "shape";
  1791. static const char __pyx_k_uint8[] = "uint8";
  1792. static const char __pyx_k_zeros[] = "zeros";
  1793. static const char __pyx_k_astype[] = "astype";
  1794. static const char __pyx_k_author[] = "__author__";
  1795. static const char __pyx_k_counts[] = "counts";
  1796. static const char __pyx_k_decode[] = "decode";
  1797. static const char __pyx_k_double[] = "double";
  1798. static const char __pyx_k_encode[] = "encode";
  1799. static const char __pyx_k_frBbox[] = "frBbox";
  1800. static const char __pyx_k_frPoly[] = "frPoly";
  1801. static const char __pyx_k_import[] = "__import__";
  1802. static const char __pyx_k_iouFun[] = "_iouFun";
  1803. static const char __pyx_k_reduce[] = "__reduce__";
  1804. static const char __pyx_k_rleIou[] = "_rleIou";
  1805. static const char __pyx_k_toBbox[] = "toBbox";
  1806. static const char __pyx_k_ucRles[] = "ucRles";
  1807. static const char __pyx_k_uint32[] = "uint32";
  1808. static const char __pyx_k_iscrowd[] = "iscrowd";
  1809. static const char __pyx_k_np_poly[] = "np_poly";
  1810. static const char __pyx_k_preproc[] = "_preproc";
  1811. static const char __pyx_k_reshape[] = "reshape";
  1812. static const char __pyx_k_rleObjs[] = "rleObjs";
  1813. static const char __pyx_k_tsungyi[] = "tsungyi";
  1814. static const char __pyx_k_c_string[] = "c_string";
  1815. static const char __pyx_k_frString[] = "_frString";
  1816. static const char __pyx_k_getstate[] = "__getstate__";
  1817. static const char __pyx_k_setstate[] = "__setstate__";
  1818. static const char __pyx_k_toString[] = "_toString";
  1819. static const char __pyx_k_TypeError[] = "TypeError";
  1820. static const char __pyx_k_enumerate[] = "enumerate";
  1821. static const char __pyx_k_intersect[] = "intersect";
  1822. static const char __pyx_k_py_string[] = "py_string";
  1823. static const char __pyx_k_pyiscrowd[] = "pyiscrowd";
  1824. static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
  1825. static const char __pyx_k_ValueError[] = "ValueError";
  1826. static const char __pyx_k_ImportError[] = "ImportError";
  1827. static const char __pyx_k_frPyObjects[] = "frPyObjects";
  1828. static const char __pyx_k_RuntimeError[] = "RuntimeError";
  1829. static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
  1830. static const char __pyx_k_AttributeError[] = "AttributeError";
  1831. static const char __pyx_k_iou_locals__len[] = "iou.<locals>._len";
  1832. static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
  1833. static const char __pyx_k_frUncompressedRLE[] = "frUncompressedRLE";
  1834. static const char __pyx_k_iou_locals__bbIou[] = "iou.<locals>._bbIou";
  1835. static const char __pyx_k_pycocotools__mask[] = "pycocotools._mask";
  1836. static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
  1837. static const char __pyx_k_iou_locals__rleIou[] = "iou.<locals>._rleIou";
  1838. static const char __pyx_k_iou_locals__preproc[] = "iou.<locals>._preproc";
  1839. static const char __pyx_k_pycocotools__mask_pyx[] = "pycocotools\\_mask.pyx";
  1840. static const char __pyx_k_input_data_type_not_allowed[] = "input data type not allowed.";
  1841. static const char __pyx_k_input_type_is_not_supported[] = "input type is not supported.";
  1842. static const char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous";
  1843. static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import";
  1844. static const char __pyx_k_numpy_ndarray_input_is_only_for[] = "numpy ndarray input is only for *bounding boxes* and should have Nx4 dimension";
  1845. static const char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)";
  1846. static const char __pyx_k_unrecognized_type_The_following[] = "unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.";
  1847. static const char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd";
  1848. static const char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported";
  1849. static const char __pyx_k_The_dt_and_gt_should_have_the_sa[] = "The dt and gt should have the same data type, either RLEs, list or np.ndarray";
  1850. static const char __pyx_k_list_input_can_be_bounding_box_N[] = "list input can be bounding box (Nx4) or RLEs ([RLE])";
  1851. static const char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous";
  1852. static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
  1853. static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import";
  1854. static const char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short.";
  1855. static PyObject *__pyx_n_s_AttributeError;
  1856. static PyObject *__pyx_n_s_F;
  1857. static PyObject *__pyx_kp_u_Format_string_allocated_too_shor;
  1858. static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2;
  1859. static PyObject *__pyx_n_s_ImportError;
  1860. static PyObject *__pyx_n_s_Masks;
  1861. static PyObject *__pyx_n_s_N;
  1862. static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor;
  1863. static PyObject *__pyx_n_s_R;
  1864. static PyObject *__pyx_n_s_RLEs;
  1865. static PyObject *__pyx_n_s_Rs;
  1866. static PyObject *__pyx_n_s_RuntimeError;
  1867. static PyObject *__pyx_kp_s_The_dt_and_gt_should_have_the_sa;
  1868. static PyObject *__pyx_n_s_TypeError;
  1869. static PyObject *__pyx_n_s_ValueError;
  1870. static PyObject *__pyx_n_s_a;
  1871. static PyObject *__pyx_n_s_a_2;
  1872. static PyObject *__pyx_n_s_all;
  1873. static PyObject *__pyx_n_s_area;
  1874. static PyObject *__pyx_n_s_array;
  1875. static PyObject *__pyx_n_s_astype;
  1876. static PyObject *__pyx_n_s_author;
  1877. static PyObject *__pyx_n_s_bb;
  1878. static PyObject *__pyx_n_s_bbIou;
  1879. static PyObject *__pyx_n_s_bb_2;
  1880. static PyObject *__pyx_n_s_c_string;
  1881. static PyObject *__pyx_n_s_cline_in_traceback;
  1882. static PyObject *__pyx_n_s_cnts;
  1883. static PyObject *__pyx_n_s_counts;
  1884. static PyObject *__pyx_n_s_data;
  1885. static PyObject *__pyx_n_s_decode;
  1886. static PyObject *__pyx_n_s_double;
  1887. static PyObject *__pyx_n_s_dt;
  1888. static PyObject *__pyx_n_s_dtype;
  1889. static PyObject *__pyx_n_s_encode;
  1890. static PyObject *__pyx_n_s_enumerate;
  1891. static PyObject *__pyx_n_s_frBbox;
  1892. static PyObject *__pyx_n_s_frPoly;
  1893. static PyObject *__pyx_n_s_frPyObjects;
  1894. static PyObject *__pyx_n_s_frString;
  1895. static PyObject *__pyx_n_s_frUncompressedRLE;
  1896. static PyObject *__pyx_n_s_getstate;
  1897. static PyObject *__pyx_n_s_gt;
  1898. static PyObject *__pyx_n_s_h;
  1899. static PyObject *__pyx_n_s_i;
  1900. static PyObject *__pyx_n_s_import;
  1901. static PyObject *__pyx_kp_s_input_data_type_not_allowed;
  1902. static PyObject *__pyx_kp_s_input_type_is_not_supported;
  1903. static PyObject *__pyx_n_s_intersect;
  1904. static PyObject *__pyx_n_s_iou;
  1905. static PyObject *__pyx_n_s_iouFun;
  1906. static PyObject *__pyx_n_s_iou_2;
  1907. static PyObject *__pyx_n_s_iou_locals__bbIou;
  1908. static PyObject *__pyx_n_s_iou_locals__len;
  1909. static PyObject *__pyx_n_s_iou_locals__preproc;
  1910. static PyObject *__pyx_n_s_iou_locals__rleIou;
  1911. static PyObject *__pyx_n_s_isbox;
  1912. static PyObject *__pyx_n_s_iscrowd;
  1913. static PyObject *__pyx_n_s_isrle;
  1914. static PyObject *__pyx_n_s_j;
  1915. static PyObject *__pyx_n_s_len;
  1916. static PyObject *__pyx_kp_s_list_input_can_be_bounding_box_N;
  1917. static PyObject *__pyx_n_s_m;
  1918. static PyObject *__pyx_n_s_main;
  1919. static PyObject *__pyx_n_s_mask;
  1920. static PyObject *__pyx_n_s_masks;
  1921. static PyObject *__pyx_n_s_merge;
  1922. static PyObject *__pyx_n_s_n;
  1923. static PyObject *__pyx_n_s_name;
  1924. static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous;
  1925. static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou;
  1926. static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
  1927. static PyObject *__pyx_n_s_np;
  1928. static PyObject *__pyx_n_s_np_poly;
  1929. static PyObject *__pyx_n_s_numpy;
  1930. static PyObject *__pyx_kp_s_numpy_core_multiarray_failed_to;
  1931. static PyObject *__pyx_kp_s_numpy_core_umath_failed_to_impor;
  1932. static PyObject *__pyx_kp_s_numpy_ndarray_input_is_only_for;
  1933. static PyObject *__pyx_n_s_obj;
  1934. static PyObject *__pyx_n_s_objs;
  1935. static PyObject *__pyx_n_s_order;
  1936. static PyObject *__pyx_n_s_p;
  1937. static PyObject *__pyx_n_s_poly;
  1938. static PyObject *__pyx_n_s_preproc;
  1939. static PyObject *__pyx_n_s_py_string;
  1940. static PyObject *__pyx_n_s_pycocotools__mask;
  1941. static PyObject *__pyx_kp_s_pycocotools__mask_pyx;
  1942. static PyObject *__pyx_n_s_pyiscrowd;
  1943. static PyObject *__pyx_n_s_pyobj;
  1944. static PyObject *__pyx_n_s_range;
  1945. static PyObject *__pyx_n_s_reduce;
  1946. static PyObject *__pyx_n_s_reduce_cython;
  1947. static PyObject *__pyx_n_s_reduce_ex;
  1948. static PyObject *__pyx_n_s_reshape;
  1949. static PyObject *__pyx_n_s_rleIou;
  1950. static PyObject *__pyx_n_s_rleObjs;
  1951. static PyObject *__pyx_n_s_setstate;
  1952. static PyObject *__pyx_n_s_setstate_cython;
  1953. static PyObject *__pyx_n_s_shape;
  1954. static PyObject *__pyx_n_s_size;
  1955. static PyObject *__pyx_n_s_test;
  1956. static PyObject *__pyx_n_s_toBbox;
  1957. static PyObject *__pyx_n_s_toString;
  1958. static PyObject *__pyx_n_s_tsungyi;
  1959. static PyObject *__pyx_n_s_ucRles;
  1960. static PyObject *__pyx_n_s_uint32;
  1961. static PyObject *__pyx_n_s_uint8;
  1962. static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd;
  1963. static PyObject *__pyx_kp_s_unrecognized_type_The_following;
  1964. static PyObject *__pyx_n_s_w;
  1965. static PyObject *__pyx_n_s_zeros;
  1966. static int __pyx_pf_11pycocotools_5_mask_4RLEs___cinit__(struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_self, siz __pyx_v_n); /* proto */
  1967. static void __pyx_pf_11pycocotools_5_mask_4RLEs_2__dealloc__(struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_self); /* proto */
  1968. static PyObject *__pyx_pf_11pycocotools_5_mask_4RLEs_4__getattr__(struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
  1969. static PyObject *__pyx_pf_11pycocotools_5_mask_4RLEs_6__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_self); /* proto */
  1970. static PyObject *__pyx_pf_11pycocotools_5_mask_4RLEs_8__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
  1971. static int __pyx_pf_11pycocotools_5_mask_5Masks___cinit__(struct __pyx_obj_11pycocotools_5_mask_Masks *__pyx_v_self, PyObject *__pyx_v_h, PyObject *__pyx_v_w, PyObject *__pyx_v_n); /* proto */
  1972. static PyObject *__pyx_pf_11pycocotools_5_mask_5Masks_2__array__(struct __pyx_obj_11pycocotools_5_mask_Masks *__pyx_v_self); /* proto */
  1973. static PyObject *__pyx_pf_11pycocotools_5_mask_5Masks_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_11pycocotools_5_mask_Masks *__pyx_v_self); /* proto */
  1974. static PyObject *__pyx_pf_11pycocotools_5_mask_5Masks_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_11pycocotools_5_mask_Masks *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
  1975. static PyObject *__pyx_pf_11pycocotools_5_mask__toString(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_Rs); /* proto */
  1976. static PyObject *__pyx_pf_11pycocotools_5_mask_2_frString(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs); /* proto */
  1977. static PyObject *__pyx_pf_11pycocotools_5_mask_4encode(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_mask); /* proto */
  1978. static PyObject *__pyx_pf_11pycocotools_5_mask_6decode(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs); /* proto */
  1979. static PyObject *__pyx_pf_11pycocotools_5_mask_8merge(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs, int __pyx_v_intersect); /* proto */
  1980. static PyObject *__pyx_pf_11pycocotools_5_mask_10area(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs); /* proto */
  1981. static PyObject *__pyx_pf_11pycocotools_5_mask_3iou__preproc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objs); /* proto */
  1982. static PyObject *__pyx_pf_11pycocotools_5_mask_3iou_2_rleIou(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_dt, struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_gt, PyArrayObject *__pyx_v_iscrowd, siz __pyx_v_m, siz __pyx_v_n, PyArrayObject *__pyx_v__iou); /* proto */
  1983. static PyObject *__pyx_pf_11pycocotools_5_mask_3iou_4_bbIou(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_dt, PyArrayObject *__pyx_v_gt, PyArrayObject *__pyx_v_iscrowd, siz __pyx_v_m, siz __pyx_v_n, PyArrayObject *__pyx_v__iou); /* proto */
  1984. static PyObject *__pyx_pf_11pycocotools_5_mask_3iou_6_len(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj); /* proto */
  1985. static PyObject *__pyx_pf_11pycocotools_5_mask_12iou(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dt, PyObject *__pyx_v_gt, PyObject *__pyx_v_pyiscrowd); /* proto */
  1986. static PyObject *__pyx_pf_11pycocotools_5_mask_14toBbox(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs); /* proto */
  1987. static PyObject *__pyx_pf_11pycocotools_5_mask_16frBbox(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_bb, siz __pyx_v_h, siz __pyx_v_w); /* proto */
  1988. static PyObject *__pyx_pf_11pycocotools_5_mask_18frPoly(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_poly, siz __pyx_v_h, siz __pyx_v_w); /* proto */
  1989. static PyObject *__pyx_pf_11pycocotools_5_mask_20frUncompressedRLE(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ucRles, CYTHON_UNUSED siz __pyx_v_h, CYTHON_UNUSED siz __pyx_v_w); /* proto */
  1990. static PyObject *__pyx_pf_11pycocotools_5_mask_22frPyObjects(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_pyobj, siz __pyx_v_h, PyObject *__pyx_v_w); /* proto */
  1991. static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
  1992. static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */
  1993. static PyObject *__pyx_tp_new_11pycocotools_5_mask_RLEs(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  1994. static PyObject *__pyx_tp_new_11pycocotools_5_mask_Masks(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  1995. static PyObject *__pyx_int_0;
  1996. static PyObject *__pyx_int_1;
  1997. static PyObject *__pyx_int_4;
  1998. static PyObject *__pyx_tuple_;
  1999. static PyObject *__pyx_tuple__2;
  2000. static PyObject *__pyx_tuple__3;
  2001. static PyObject *__pyx_tuple__4;
  2002. static PyObject *__pyx_tuple__5;
  2003. static PyObject *__pyx_tuple__6;
  2004. static PyObject *__pyx_tuple__7;
  2005. static PyObject *__pyx_tuple__8;
  2006. static PyObject *__pyx_tuple__9;
  2007. static PyObject *__pyx_tuple__11;
  2008. static PyObject *__pyx_tuple__13;
  2009. static PyObject *__pyx_tuple__15;
  2010. static PyObject *__pyx_tuple__17;
  2011. static PyObject *__pyx_tuple__18;
  2012. static PyObject *__pyx_tuple__19;
  2013. static PyObject *__pyx_tuple__20;
  2014. static PyObject *__pyx_tuple__21;
  2015. static PyObject *__pyx_tuple__22;
  2016. static PyObject *__pyx_tuple__23;
  2017. static PyObject *__pyx_tuple__24;
  2018. static PyObject *__pyx_tuple__25;
  2019. static PyObject *__pyx_tuple__26;
  2020. static PyObject *__pyx_tuple__27;
  2021. static PyObject *__pyx_tuple__29;
  2022. static PyObject *__pyx_tuple__31;
  2023. static PyObject *__pyx_tuple__33;
  2024. static PyObject *__pyx_tuple__35;
  2025. static PyObject *__pyx_tuple__37;
  2026. static PyObject *__pyx_tuple__39;
  2027. static PyObject *__pyx_tuple__41;
  2028. static PyObject *__pyx_tuple__43;
  2029. static PyObject *__pyx_tuple__45;
  2030. static PyObject *__pyx_tuple__47;
  2031. static PyObject *__pyx_tuple__49;
  2032. static PyObject *__pyx_codeobj__10;
  2033. static PyObject *__pyx_codeobj__12;
  2034. static PyObject *__pyx_codeobj__14;
  2035. static PyObject *__pyx_codeobj__16;
  2036. static PyObject *__pyx_codeobj__28;
  2037. static PyObject *__pyx_codeobj__30;
  2038. static PyObject *__pyx_codeobj__32;
  2039. static PyObject *__pyx_codeobj__34;
  2040. static PyObject *__pyx_codeobj__36;
  2041. static PyObject *__pyx_codeobj__38;
  2042. static PyObject *__pyx_codeobj__40;
  2043. static PyObject *__pyx_codeobj__42;
  2044. static PyObject *__pyx_codeobj__44;
  2045. static PyObject *__pyx_codeobj__46;
  2046. static PyObject *__pyx_codeobj__48;
  2047. static PyObject *__pyx_codeobj__50;
  2048. /* Late includes */
  2049. /* "pycocotools/_mask.pyx":57
  2050. * cdef siz _n
  2051. *
  2052. * def __cinit__(self, siz n =0): # <<<<<<<<<<<<<<
  2053. * rlesInit(&self._R, n)
  2054. * self._n = n
  2055. */
  2056. /* Python wrapper */
  2057. static int __pyx_pw_11pycocotools_5_mask_4RLEs_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  2058. static int __pyx_pw_11pycocotools_5_mask_4RLEs_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  2059. siz __pyx_v_n;
  2060. int __pyx_r;
  2061. __Pyx_RefNannyDeclarations
  2062. __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  2063. {
  2064. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n,0};
  2065. PyObject* values[1] = {0};
  2066. if (unlikely(__pyx_kwds)) {
  2067. Py_ssize_t kw_args;
  2068. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  2069. switch (pos_args) {
  2070. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2071. CYTHON_FALLTHROUGH;
  2072. case 0: break;
  2073. default: goto __pyx_L5_argtuple_error;
  2074. }
  2075. kw_args = PyDict_Size(__pyx_kwds);
  2076. switch (pos_args) {
  2077. case 0:
  2078. if (kw_args > 0) {
  2079. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n);
  2080. if (value) { values[0] = value; kw_args--; }
  2081. }
  2082. }
  2083. if (unlikely(kw_args > 0)) {
  2084. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 57, __pyx_L3_error)
  2085. }
  2086. } else {
  2087. switch (PyTuple_GET_SIZE(__pyx_args)) {
  2088. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2089. CYTHON_FALLTHROUGH;
  2090. case 0: break;
  2091. default: goto __pyx_L5_argtuple_error;
  2092. }
  2093. }
  2094. if (values[0]) {
  2095. __pyx_v_n = __Pyx_PyInt_As_siz(values[0]); if (unlikely((__pyx_v_n == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 57, __pyx_L3_error)
  2096. } else {
  2097. __pyx_v_n = ((siz)0);
  2098. }
  2099. }
  2100. goto __pyx_L4_argument_unpacking_done;
  2101. __pyx_L5_argtuple_error:;
  2102. __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 57, __pyx_L3_error)
  2103. __pyx_L3_error:;
  2104. __Pyx_AddTraceback("pycocotools._mask.RLEs.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2105. __Pyx_RefNannyFinishContext();
  2106. return -1;
  2107. __pyx_L4_argument_unpacking_done:;
  2108. __pyx_r = __pyx_pf_11pycocotools_5_mask_4RLEs___cinit__(((struct __pyx_obj_11pycocotools_5_mask_RLEs *)__pyx_v_self), __pyx_v_n);
  2109. /* function exit code */
  2110. __Pyx_RefNannyFinishContext();
  2111. return __pyx_r;
  2112. }
  2113. static int __pyx_pf_11pycocotools_5_mask_4RLEs___cinit__(struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_self, siz __pyx_v_n) {
  2114. int __pyx_r;
  2115. __Pyx_RefNannyDeclarations
  2116. __Pyx_RefNannySetupContext("__cinit__", 0);
  2117. /* "pycocotools/_mask.pyx":58
  2118. *
  2119. * def __cinit__(self, siz n =0):
  2120. * rlesInit(&self._R, n) # <<<<<<<<<<<<<<
  2121. * self._n = n
  2122. *
  2123. */
  2124. rlesInit((&__pyx_v_self->_R), __pyx_v_n);
  2125. /* "pycocotools/_mask.pyx":59
  2126. * def __cinit__(self, siz n =0):
  2127. * rlesInit(&self._R, n)
  2128. * self._n = n # <<<<<<<<<<<<<<
  2129. *
  2130. * # free the RLE array here
  2131. */
  2132. __pyx_v_self->_n = __pyx_v_n;
  2133. /* "pycocotools/_mask.pyx":57
  2134. * cdef siz _n
  2135. *
  2136. * def __cinit__(self, siz n =0): # <<<<<<<<<<<<<<
  2137. * rlesInit(&self._R, n)
  2138. * self._n = n
  2139. */
  2140. /* function exit code */
  2141. __pyx_r = 0;
  2142. __Pyx_RefNannyFinishContext();
  2143. return __pyx_r;
  2144. }
  2145. /* "pycocotools/_mask.pyx":62
  2146. *
  2147. * # free the RLE array here
  2148. * def __dealloc__(self): # <<<<<<<<<<<<<<
  2149. * if self._R is not NULL:
  2150. * for i in range(self._n):
  2151. */
  2152. /* Python wrapper */
  2153. static void __pyx_pw_11pycocotools_5_mask_4RLEs_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
  2154. static void __pyx_pw_11pycocotools_5_mask_4RLEs_3__dealloc__(PyObject *__pyx_v_self) {
  2155. __Pyx_RefNannyDeclarations
  2156. __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  2157. __pyx_pf_11pycocotools_5_mask_4RLEs_2__dealloc__(((struct __pyx_obj_11pycocotools_5_mask_RLEs *)__pyx_v_self));
  2158. /* function exit code */
  2159. __Pyx_RefNannyFinishContext();
  2160. }
  2161. static void __pyx_pf_11pycocotools_5_mask_4RLEs_2__dealloc__(struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_self) {
  2162. siz __pyx_v_i;
  2163. __Pyx_RefNannyDeclarations
  2164. int __pyx_t_1;
  2165. siz __pyx_t_2;
  2166. siz __pyx_t_3;
  2167. siz __pyx_t_4;
  2168. __Pyx_RefNannySetupContext("__dealloc__", 0);
  2169. /* "pycocotools/_mask.pyx":63
  2170. * # free the RLE array here
  2171. * def __dealloc__(self):
  2172. * if self._R is not NULL: # <<<<<<<<<<<<<<
  2173. * for i in range(self._n):
  2174. * free(self._R[i].cnts)
  2175. */
  2176. __pyx_t_1 = ((__pyx_v_self->_R != NULL) != 0);
  2177. if (__pyx_t_1) {
  2178. /* "pycocotools/_mask.pyx":64
  2179. * def __dealloc__(self):
  2180. * if self._R is not NULL:
  2181. * for i in range(self._n): # <<<<<<<<<<<<<<
  2182. * free(self._R[i].cnts)
  2183. * free(self._R)
  2184. */
  2185. __pyx_t_2 = __pyx_v_self->_n;
  2186. __pyx_t_3 = __pyx_t_2;
  2187. for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
  2188. __pyx_v_i = __pyx_t_4;
  2189. /* "pycocotools/_mask.pyx":65
  2190. * if self._R is not NULL:
  2191. * for i in range(self._n):
  2192. * free(self._R[i].cnts) # <<<<<<<<<<<<<<
  2193. * free(self._R)
  2194. * def __getattr__(self, key):
  2195. */
  2196. free((__pyx_v_self->_R[__pyx_v_i]).cnts);
  2197. }
  2198. /* "pycocotools/_mask.pyx":66
  2199. * for i in range(self._n):
  2200. * free(self._R[i].cnts)
  2201. * free(self._R) # <<<<<<<<<<<<<<
  2202. * def __getattr__(self, key):
  2203. * if key == 'n':
  2204. */
  2205. free(__pyx_v_self->_R);
  2206. /* "pycocotools/_mask.pyx":63
  2207. * # free the RLE array here
  2208. * def __dealloc__(self):
  2209. * if self._R is not NULL: # <<<<<<<<<<<<<<
  2210. * for i in range(self._n):
  2211. * free(self._R[i].cnts)
  2212. */
  2213. }
  2214. /* "pycocotools/_mask.pyx":62
  2215. *
  2216. * # free the RLE array here
  2217. * def __dealloc__(self): # <<<<<<<<<<<<<<
  2218. * if self._R is not NULL:
  2219. * for i in range(self._n):
  2220. */
  2221. /* function exit code */
  2222. __Pyx_RefNannyFinishContext();
  2223. }
  2224. /* "pycocotools/_mask.pyx":67
  2225. * free(self._R[i].cnts)
  2226. * free(self._R)
  2227. * def __getattr__(self, key): # <<<<<<<<<<<<<<
  2228. * if key == 'n':
  2229. * return self._n
  2230. */
  2231. /* Python wrapper */
  2232. static PyObject *__pyx_pw_11pycocotools_5_mask_4RLEs_5__getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
  2233. static PyObject *__pyx_pw_11pycocotools_5_mask_4RLEs_5__getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  2234. PyObject *__pyx_r = 0;
  2235. __Pyx_RefNannyDeclarations
  2236. __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0);
  2237. __pyx_r = __pyx_pf_11pycocotools_5_mask_4RLEs_4__getattr__(((struct __pyx_obj_11pycocotools_5_mask_RLEs *)__pyx_v_self), ((PyObject *)__pyx_v_key));
  2238. /* function exit code */
  2239. __Pyx_RefNannyFinishContext();
  2240. return __pyx_r;
  2241. }
  2242. static PyObject *__pyx_pf_11pycocotools_5_mask_4RLEs_4__getattr__(struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_self, PyObject *__pyx_v_key) {
  2243. PyObject *__pyx_r = NULL;
  2244. __Pyx_RefNannyDeclarations
  2245. int __pyx_t_1;
  2246. PyObject *__pyx_t_2 = NULL;
  2247. __Pyx_RefNannySetupContext("__getattr__", 0);
  2248. /* "pycocotools/_mask.pyx":68
  2249. * free(self._R)
  2250. * def __getattr__(self, key):
  2251. * if key == 'n': # <<<<<<<<<<<<<<
  2252. * return self._n
  2253. * raise AttributeError(key)
  2254. */
  2255. __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_key, __pyx_n_s_n, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 68, __pyx_L1_error)
  2256. if (__pyx_t_1) {
  2257. /* "pycocotools/_mask.pyx":69
  2258. * def __getattr__(self, key):
  2259. * if key == 'n':
  2260. * return self._n # <<<<<<<<<<<<<<
  2261. * raise AttributeError(key)
  2262. *
  2263. */
  2264. __Pyx_XDECREF(__pyx_r);
  2265. __pyx_t_2 = __Pyx_PyInt_From_siz(__pyx_v_self->_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error)
  2266. __Pyx_GOTREF(__pyx_t_2);
  2267. __pyx_r = __pyx_t_2;
  2268. __pyx_t_2 = 0;
  2269. goto __pyx_L0;
  2270. /* "pycocotools/_mask.pyx":68
  2271. * free(self._R)
  2272. * def __getattr__(self, key):
  2273. * if key == 'n': # <<<<<<<<<<<<<<
  2274. * return self._n
  2275. * raise AttributeError(key)
  2276. */
  2277. }
  2278. /* "pycocotools/_mask.pyx":70
  2279. * if key == 'n':
  2280. * return self._n
  2281. * raise AttributeError(key) # <<<<<<<<<<<<<<
  2282. *
  2283. * # python class to wrap Mask array in C
  2284. */
  2285. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AttributeError, __pyx_v_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
  2286. __Pyx_GOTREF(__pyx_t_2);
  2287. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  2288. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2289. __PYX_ERR(0, 70, __pyx_L1_error)
  2290. /* "pycocotools/_mask.pyx":67
  2291. * free(self._R[i].cnts)
  2292. * free(self._R)
  2293. * def __getattr__(self, key): # <<<<<<<<<<<<<<
  2294. * if key == 'n':
  2295. * return self._n
  2296. */
  2297. /* function exit code */
  2298. __pyx_L1_error:;
  2299. __Pyx_XDECREF(__pyx_t_2);
  2300. __Pyx_AddTraceback("pycocotools._mask.RLEs.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2301. __pyx_r = NULL;
  2302. __pyx_L0:;
  2303. __Pyx_XGIVEREF(__pyx_r);
  2304. __Pyx_RefNannyFinishContext();
  2305. return __pyx_r;
  2306. }
  2307. /* "(tree fragment)":1
  2308. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  2309. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2310. * def __setstate_cython__(self, __pyx_state):
  2311. */
  2312. /* Python wrapper */
  2313. static PyObject *__pyx_pw_11pycocotools_5_mask_4RLEs_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  2314. static PyObject *__pyx_pw_11pycocotools_5_mask_4RLEs_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  2315. PyObject *__pyx_r = 0;
  2316. __Pyx_RefNannyDeclarations
  2317. __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  2318. __pyx_r = __pyx_pf_11pycocotools_5_mask_4RLEs_6__reduce_cython__(((struct __pyx_obj_11pycocotools_5_mask_RLEs *)__pyx_v_self));
  2319. /* function exit code */
  2320. __Pyx_RefNannyFinishContext();
  2321. return __pyx_r;
  2322. }
  2323. static PyObject *__pyx_pf_11pycocotools_5_mask_4RLEs_6__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_self) {
  2324. PyObject *__pyx_r = NULL;
  2325. __Pyx_RefNannyDeclarations
  2326. PyObject *__pyx_t_1 = NULL;
  2327. __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  2328. /* "(tree fragment)":2
  2329. * def __reduce_cython__(self):
  2330. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  2331. * def __setstate_cython__(self, __pyx_state):
  2332. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2333. */
  2334. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
  2335. __Pyx_GOTREF(__pyx_t_1);
  2336. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  2337. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2338. __PYX_ERR(1, 2, __pyx_L1_error)
  2339. /* "(tree fragment)":1
  2340. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  2341. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2342. * def __setstate_cython__(self, __pyx_state):
  2343. */
  2344. /* function exit code */
  2345. __pyx_L1_error:;
  2346. __Pyx_XDECREF(__pyx_t_1);
  2347. __Pyx_AddTraceback("pycocotools._mask.RLEs.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2348. __pyx_r = NULL;
  2349. __Pyx_XGIVEREF(__pyx_r);
  2350. __Pyx_RefNannyFinishContext();
  2351. return __pyx_r;
  2352. }
  2353. /* "(tree fragment)":3
  2354. * def __reduce_cython__(self):
  2355. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2356. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  2357. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2358. */
  2359. /* Python wrapper */
  2360. static PyObject *__pyx_pw_11pycocotools_5_mask_4RLEs_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
  2361. static PyObject *__pyx_pw_11pycocotools_5_mask_4RLEs_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  2362. PyObject *__pyx_r = 0;
  2363. __Pyx_RefNannyDeclarations
  2364. __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  2365. __pyx_r = __pyx_pf_11pycocotools_5_mask_4RLEs_8__setstate_cython__(((struct __pyx_obj_11pycocotools_5_mask_RLEs *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
  2366. /* function exit code */
  2367. __Pyx_RefNannyFinishContext();
  2368. return __pyx_r;
  2369. }
  2370. static PyObject *__pyx_pf_11pycocotools_5_mask_4RLEs_8__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  2371. PyObject *__pyx_r = NULL;
  2372. __Pyx_RefNannyDeclarations
  2373. PyObject *__pyx_t_1 = NULL;
  2374. __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  2375. /* "(tree fragment)":4
  2376. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2377. * def __setstate_cython__(self, __pyx_state):
  2378. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  2379. */
  2380. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  2381. __Pyx_GOTREF(__pyx_t_1);
  2382. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  2383. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2384. __PYX_ERR(1, 4, __pyx_L1_error)
  2385. /* "(tree fragment)":3
  2386. * def __reduce_cython__(self):
  2387. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2388. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  2389. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2390. */
  2391. /* function exit code */
  2392. __pyx_L1_error:;
  2393. __Pyx_XDECREF(__pyx_t_1);
  2394. __Pyx_AddTraceback("pycocotools._mask.RLEs.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2395. __pyx_r = NULL;
  2396. __Pyx_XGIVEREF(__pyx_r);
  2397. __Pyx_RefNannyFinishContext();
  2398. return __pyx_r;
  2399. }
  2400. /* "pycocotools/_mask.pyx":80
  2401. * cdef siz _n
  2402. *
  2403. * def __cinit__(self, h, w, n): # <<<<<<<<<<<<<<
  2404. * self._mask = <byte*> malloc(h*w*n* sizeof(byte))
  2405. * self._h = h
  2406. */
  2407. /* Python wrapper */
  2408. static int __pyx_pw_11pycocotools_5_mask_5Masks_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  2409. static int __pyx_pw_11pycocotools_5_mask_5Masks_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  2410. PyObject *__pyx_v_h = 0;
  2411. PyObject *__pyx_v_w = 0;
  2412. PyObject *__pyx_v_n = 0;
  2413. int __pyx_r;
  2414. __Pyx_RefNannyDeclarations
  2415. __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  2416. {
  2417. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_h,&__pyx_n_s_w,&__pyx_n_s_n,0};
  2418. PyObject* values[3] = {0,0,0};
  2419. if (unlikely(__pyx_kwds)) {
  2420. Py_ssize_t kw_args;
  2421. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  2422. switch (pos_args) {
  2423. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  2424. CYTHON_FALLTHROUGH;
  2425. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2426. CYTHON_FALLTHROUGH;
  2427. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2428. CYTHON_FALLTHROUGH;
  2429. case 0: break;
  2430. default: goto __pyx_L5_argtuple_error;
  2431. }
  2432. kw_args = PyDict_Size(__pyx_kwds);
  2433. switch (pos_args) {
  2434. case 0:
  2435. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_h)) != 0)) kw_args--;
  2436. else goto __pyx_L5_argtuple_error;
  2437. CYTHON_FALLTHROUGH;
  2438. case 1:
  2439. if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--;
  2440. else {
  2441. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, 1); __PYX_ERR(0, 80, __pyx_L3_error)
  2442. }
  2443. CYTHON_FALLTHROUGH;
  2444. case 2:
  2445. if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--;
  2446. else {
  2447. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, 2); __PYX_ERR(0, 80, __pyx_L3_error)
  2448. }
  2449. }
  2450. if (unlikely(kw_args > 0)) {
  2451. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 80, __pyx_L3_error)
  2452. }
  2453. } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
  2454. goto __pyx_L5_argtuple_error;
  2455. } else {
  2456. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2457. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2458. values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  2459. }
  2460. __pyx_v_h = values[0];
  2461. __pyx_v_w = values[1];
  2462. __pyx_v_n = values[2];
  2463. }
  2464. goto __pyx_L4_argument_unpacking_done;
  2465. __pyx_L5_argtuple_error:;
  2466. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 80, __pyx_L3_error)
  2467. __pyx_L3_error:;
  2468. __Pyx_AddTraceback("pycocotools._mask.Masks.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2469. __Pyx_RefNannyFinishContext();
  2470. return -1;
  2471. __pyx_L4_argument_unpacking_done:;
  2472. __pyx_r = __pyx_pf_11pycocotools_5_mask_5Masks___cinit__(((struct __pyx_obj_11pycocotools_5_mask_Masks *)__pyx_v_self), __pyx_v_h, __pyx_v_w, __pyx_v_n);
  2473. /* function exit code */
  2474. __Pyx_RefNannyFinishContext();
  2475. return __pyx_r;
  2476. }
  2477. static int __pyx_pf_11pycocotools_5_mask_5Masks___cinit__(struct __pyx_obj_11pycocotools_5_mask_Masks *__pyx_v_self, PyObject *__pyx_v_h, PyObject *__pyx_v_w, PyObject *__pyx_v_n) {
  2478. int __pyx_r;
  2479. __Pyx_RefNannyDeclarations
  2480. PyObject *__pyx_t_1 = NULL;
  2481. PyObject *__pyx_t_2 = NULL;
  2482. PyObject *__pyx_t_3 = NULL;
  2483. size_t __pyx_t_4;
  2484. siz __pyx_t_5;
  2485. __Pyx_RefNannySetupContext("__cinit__", 0);
  2486. /* "pycocotools/_mask.pyx":81
  2487. *
  2488. * def __cinit__(self, h, w, n):
  2489. * self._mask = <byte*> malloc(h*w*n* sizeof(byte)) # <<<<<<<<<<<<<<
  2490. * self._h = h
  2491. * self._w = w
  2492. */
  2493. __pyx_t_1 = PyNumber_Multiply(__pyx_v_h, __pyx_v_w); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error)
  2494. __Pyx_GOTREF(__pyx_t_1);
  2495. __pyx_t_2 = PyNumber_Multiply(__pyx_t_1, __pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error)
  2496. __Pyx_GOTREF(__pyx_t_2);
  2497. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2498. __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(byte))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error)
  2499. __Pyx_GOTREF(__pyx_t_1);
  2500. __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 81, __pyx_L1_error)
  2501. __Pyx_GOTREF(__pyx_t_3);
  2502. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2503. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2504. __pyx_t_4 = __Pyx_PyInt_As_size_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 81, __pyx_L1_error)
  2505. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2506. __pyx_v_self->_mask = ((byte *)malloc(__pyx_t_4));
  2507. /* "pycocotools/_mask.pyx":82
  2508. * def __cinit__(self, h, w, n):
  2509. * self._mask = <byte*> malloc(h*w*n* sizeof(byte))
  2510. * self._h = h # <<<<<<<<<<<<<<
  2511. * self._w = w
  2512. * self._n = n
  2513. */
  2514. __pyx_t_5 = __Pyx_PyInt_As_siz(__pyx_v_h); if (unlikely((__pyx_t_5 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 82, __pyx_L1_error)
  2515. __pyx_v_self->_h = __pyx_t_5;
  2516. /* "pycocotools/_mask.pyx":83
  2517. * self._mask = <byte*> malloc(h*w*n* sizeof(byte))
  2518. * self._h = h
  2519. * self._w = w # <<<<<<<<<<<<<<
  2520. * self._n = n
  2521. * # def __dealloc__(self):
  2522. */
  2523. __pyx_t_5 = __Pyx_PyInt_As_siz(__pyx_v_w); if (unlikely((__pyx_t_5 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 83, __pyx_L1_error)
  2524. __pyx_v_self->_w = __pyx_t_5;
  2525. /* "pycocotools/_mask.pyx":84
  2526. * self._h = h
  2527. * self._w = w
  2528. * self._n = n # <<<<<<<<<<<<<<
  2529. * # def __dealloc__(self):
  2530. * # the memory management of _mask has been passed to np.ndarray
  2531. */
  2532. __pyx_t_5 = __Pyx_PyInt_As_siz(__pyx_v_n); if (unlikely((__pyx_t_5 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 84, __pyx_L1_error)
  2533. __pyx_v_self->_n = __pyx_t_5;
  2534. /* "pycocotools/_mask.pyx":80
  2535. * cdef siz _n
  2536. *
  2537. * def __cinit__(self, h, w, n): # <<<<<<<<<<<<<<
  2538. * self._mask = <byte*> malloc(h*w*n* sizeof(byte))
  2539. * self._h = h
  2540. */
  2541. /* function exit code */
  2542. __pyx_r = 0;
  2543. goto __pyx_L0;
  2544. __pyx_L1_error:;
  2545. __Pyx_XDECREF(__pyx_t_1);
  2546. __Pyx_XDECREF(__pyx_t_2);
  2547. __Pyx_XDECREF(__pyx_t_3);
  2548. __Pyx_AddTraceback("pycocotools._mask.Masks.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2549. __pyx_r = -1;
  2550. __pyx_L0:;
  2551. __Pyx_RefNannyFinishContext();
  2552. return __pyx_r;
  2553. }
  2554. /* "pycocotools/_mask.pyx":90
  2555. *
  2556. * # called when passing into np.array() and return an np.ndarray in column-major order
  2557. * def __array__(self): # <<<<<<<<<<<<<<
  2558. * cdef np.npy_intp shape[1]
  2559. * shape[0] = <np.npy_intp> self._h*self._w*self._n
  2560. */
  2561. /* Python wrapper */
  2562. static PyObject *__pyx_pw_11pycocotools_5_mask_5Masks_3__array__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  2563. static PyObject *__pyx_pw_11pycocotools_5_mask_5Masks_3__array__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  2564. PyObject *__pyx_r = 0;
  2565. __Pyx_RefNannyDeclarations
  2566. __Pyx_RefNannySetupContext("__array__ (wrapper)", 0);
  2567. __pyx_r = __pyx_pf_11pycocotools_5_mask_5Masks_2__array__(((struct __pyx_obj_11pycocotools_5_mask_Masks *)__pyx_v_self));
  2568. /* function exit code */
  2569. __Pyx_RefNannyFinishContext();
  2570. return __pyx_r;
  2571. }
  2572. static PyObject *__pyx_pf_11pycocotools_5_mask_5Masks_2__array__(struct __pyx_obj_11pycocotools_5_mask_Masks *__pyx_v_self) {
  2573. npy_intp __pyx_v_shape[1];
  2574. PyObject *__pyx_v_ndarray = NULL;
  2575. PyObject *__pyx_r = NULL;
  2576. __Pyx_RefNannyDeclarations
  2577. PyObject *__pyx_t_1 = NULL;
  2578. PyObject *__pyx_t_2 = NULL;
  2579. PyObject *__pyx_t_3 = NULL;
  2580. PyObject *__pyx_t_4 = NULL;
  2581. PyObject *__pyx_t_5 = NULL;
  2582. __Pyx_RefNannySetupContext("__array__", 0);
  2583. /* "pycocotools/_mask.pyx":92
  2584. * def __array__(self):
  2585. * cdef np.npy_intp shape[1]
  2586. * shape[0] = <np.npy_intp> self._h*self._w*self._n # <<<<<<<<<<<<<<
  2587. * # Create a 1D array, and reshape it to fortran/Matlab column-major array
  2588. * ndarray = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT8, self._mask).reshape((self._h, self._w, self._n), order='F')
  2589. */
  2590. (__pyx_v_shape[0]) = ((((npy_intp)__pyx_v_self->_h) * __pyx_v_self->_w) * __pyx_v_self->_n);
  2591. /* "pycocotools/_mask.pyx":94
  2592. * shape[0] = <np.npy_intp> self._h*self._w*self._n
  2593. * # Create a 1D array, and reshape it to fortran/Matlab column-major array
  2594. * ndarray = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT8, self._mask).reshape((self._h, self._w, self._n), order='F') # <<<<<<<<<<<<<<
  2595. * # The _mask allocated by Masks is now handled by ndarray
  2596. * PyArray_ENABLEFLAGS(ndarray, np.NPY_OWNDATA)
  2597. */
  2598. __pyx_t_1 = PyArray_SimpleNewFromData(1, __pyx_v_shape, NPY_UINT8, __pyx_v_self->_mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error)
  2599. __Pyx_GOTREF(__pyx_t_1);
  2600. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_reshape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error)
  2601. __Pyx_GOTREF(__pyx_t_2);
  2602. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2603. __pyx_t_1 = __Pyx_PyInt_From_siz(__pyx_v_self->_h); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error)
  2604. __Pyx_GOTREF(__pyx_t_1);
  2605. __pyx_t_3 = __Pyx_PyInt_From_siz(__pyx_v_self->_w); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 94, __pyx_L1_error)
  2606. __Pyx_GOTREF(__pyx_t_3);
  2607. __pyx_t_4 = __Pyx_PyInt_From_siz(__pyx_v_self->_n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 94, __pyx_L1_error)
  2608. __Pyx_GOTREF(__pyx_t_4);
  2609. __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 94, __pyx_L1_error)
  2610. __Pyx_GOTREF(__pyx_t_5);
  2611. __Pyx_GIVEREF(__pyx_t_1);
  2612. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  2613. __Pyx_GIVEREF(__pyx_t_3);
  2614. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  2615. __Pyx_GIVEREF(__pyx_t_4);
  2616. PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  2617. __pyx_t_1 = 0;
  2618. __pyx_t_3 = 0;
  2619. __pyx_t_4 = 0;
  2620. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 94, __pyx_L1_error)
  2621. __Pyx_GOTREF(__pyx_t_4);
  2622. __Pyx_GIVEREF(__pyx_t_5);
  2623. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
  2624. __pyx_t_5 = 0;
  2625. __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 94, __pyx_L1_error)
  2626. __Pyx_GOTREF(__pyx_t_5);
  2627. if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_order, __pyx_n_s_F) < 0) __PYX_ERR(0, 94, __pyx_L1_error)
  2628. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 94, __pyx_L1_error)
  2629. __Pyx_GOTREF(__pyx_t_3);
  2630. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2631. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2632. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2633. __pyx_v_ndarray = __pyx_t_3;
  2634. __pyx_t_3 = 0;
  2635. /* "pycocotools/_mask.pyx":96
  2636. * ndarray = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT8, self._mask).reshape((self._h, self._w, self._n), order='F')
  2637. * # The _mask allocated by Masks is now handled by ndarray
  2638. * PyArray_ENABLEFLAGS(ndarray, np.NPY_OWNDATA) # <<<<<<<<<<<<<<
  2639. * return ndarray
  2640. *
  2641. */
  2642. if (!(likely(((__pyx_v_ndarray) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_ndarray, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 96, __pyx_L1_error)
  2643. PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v_ndarray), NPY_OWNDATA);
  2644. /* "pycocotools/_mask.pyx":97
  2645. * # The _mask allocated by Masks is now handled by ndarray
  2646. * PyArray_ENABLEFLAGS(ndarray, np.NPY_OWNDATA)
  2647. * return ndarray # <<<<<<<<<<<<<<
  2648. *
  2649. * # internal conversion from Python RLEs object to compressed RLE format
  2650. */
  2651. __Pyx_XDECREF(__pyx_r);
  2652. __Pyx_INCREF(__pyx_v_ndarray);
  2653. __pyx_r = __pyx_v_ndarray;
  2654. goto __pyx_L0;
  2655. /* "pycocotools/_mask.pyx":90
  2656. *
  2657. * # called when passing into np.array() and return an np.ndarray in column-major order
  2658. * def __array__(self): # <<<<<<<<<<<<<<
  2659. * cdef np.npy_intp shape[1]
  2660. * shape[0] = <np.npy_intp> self._h*self._w*self._n
  2661. */
  2662. /* function exit code */
  2663. __pyx_L1_error:;
  2664. __Pyx_XDECREF(__pyx_t_1);
  2665. __Pyx_XDECREF(__pyx_t_2);
  2666. __Pyx_XDECREF(__pyx_t_3);
  2667. __Pyx_XDECREF(__pyx_t_4);
  2668. __Pyx_XDECREF(__pyx_t_5);
  2669. __Pyx_AddTraceback("pycocotools._mask.Masks.__array__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2670. __pyx_r = NULL;
  2671. __pyx_L0:;
  2672. __Pyx_XDECREF(__pyx_v_ndarray);
  2673. __Pyx_XGIVEREF(__pyx_r);
  2674. __Pyx_RefNannyFinishContext();
  2675. return __pyx_r;
  2676. }
  2677. /* "(tree fragment)":1
  2678. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  2679. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2680. * def __setstate_cython__(self, __pyx_state):
  2681. */
  2682. /* Python wrapper */
  2683. static PyObject *__pyx_pw_11pycocotools_5_mask_5Masks_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  2684. static PyObject *__pyx_pw_11pycocotools_5_mask_5Masks_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  2685. PyObject *__pyx_r = 0;
  2686. __Pyx_RefNannyDeclarations
  2687. __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  2688. __pyx_r = __pyx_pf_11pycocotools_5_mask_5Masks_4__reduce_cython__(((struct __pyx_obj_11pycocotools_5_mask_Masks *)__pyx_v_self));
  2689. /* function exit code */
  2690. __Pyx_RefNannyFinishContext();
  2691. return __pyx_r;
  2692. }
  2693. static PyObject *__pyx_pf_11pycocotools_5_mask_5Masks_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_11pycocotools_5_mask_Masks *__pyx_v_self) {
  2694. PyObject *__pyx_r = NULL;
  2695. __Pyx_RefNannyDeclarations
  2696. PyObject *__pyx_t_1 = NULL;
  2697. __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  2698. /* "(tree fragment)":2
  2699. * def __reduce_cython__(self):
  2700. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  2701. * def __setstate_cython__(self, __pyx_state):
  2702. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2703. */
  2704. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
  2705. __Pyx_GOTREF(__pyx_t_1);
  2706. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  2707. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2708. __PYX_ERR(1, 2, __pyx_L1_error)
  2709. /* "(tree fragment)":1
  2710. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  2711. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2712. * def __setstate_cython__(self, __pyx_state):
  2713. */
  2714. /* function exit code */
  2715. __pyx_L1_error:;
  2716. __Pyx_XDECREF(__pyx_t_1);
  2717. __Pyx_AddTraceback("pycocotools._mask.Masks.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2718. __pyx_r = NULL;
  2719. __Pyx_XGIVEREF(__pyx_r);
  2720. __Pyx_RefNannyFinishContext();
  2721. return __pyx_r;
  2722. }
  2723. /* "(tree fragment)":3
  2724. * def __reduce_cython__(self):
  2725. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2726. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  2727. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2728. */
  2729. /* Python wrapper */
  2730. static PyObject *__pyx_pw_11pycocotools_5_mask_5Masks_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
  2731. static PyObject *__pyx_pw_11pycocotools_5_mask_5Masks_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  2732. PyObject *__pyx_r = 0;
  2733. __Pyx_RefNannyDeclarations
  2734. __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  2735. __pyx_r = __pyx_pf_11pycocotools_5_mask_5Masks_6__setstate_cython__(((struct __pyx_obj_11pycocotools_5_mask_Masks *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
  2736. /* function exit code */
  2737. __Pyx_RefNannyFinishContext();
  2738. return __pyx_r;
  2739. }
  2740. static PyObject *__pyx_pf_11pycocotools_5_mask_5Masks_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_11pycocotools_5_mask_Masks *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  2741. PyObject *__pyx_r = NULL;
  2742. __Pyx_RefNannyDeclarations
  2743. PyObject *__pyx_t_1 = NULL;
  2744. __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  2745. /* "(tree fragment)":4
  2746. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2747. * def __setstate_cython__(self, __pyx_state):
  2748. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  2749. */
  2750. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  2751. __Pyx_GOTREF(__pyx_t_1);
  2752. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  2753. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2754. __PYX_ERR(1, 4, __pyx_L1_error)
  2755. /* "(tree fragment)":3
  2756. * def __reduce_cython__(self):
  2757. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2758. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  2759. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2760. */
  2761. /* function exit code */
  2762. __pyx_L1_error:;
  2763. __Pyx_XDECREF(__pyx_t_1);
  2764. __Pyx_AddTraceback("pycocotools._mask.Masks.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2765. __pyx_r = NULL;
  2766. __Pyx_XGIVEREF(__pyx_r);
  2767. __Pyx_RefNannyFinishContext();
  2768. return __pyx_r;
  2769. }
  2770. /* "pycocotools/_mask.pyx":100
  2771. *
  2772. * # internal conversion from Python RLEs object to compressed RLE format
  2773. * def _toString(RLEs Rs): # <<<<<<<<<<<<<<
  2774. * cdef siz n = Rs.n
  2775. * cdef bytes py_string
  2776. */
  2777. /* Python wrapper */
  2778. static PyObject *__pyx_pw_11pycocotools_5_mask_1_toString(PyObject *__pyx_self, PyObject *__pyx_v_Rs); /*proto*/
  2779. static PyMethodDef __pyx_mdef_11pycocotools_5_mask_1_toString = {"_toString", (PyCFunction)__pyx_pw_11pycocotools_5_mask_1_toString, METH_O, 0};
  2780. static PyObject *__pyx_pw_11pycocotools_5_mask_1_toString(PyObject *__pyx_self, PyObject *__pyx_v_Rs) {
  2781. PyObject *__pyx_r = 0;
  2782. __Pyx_RefNannyDeclarations
  2783. __Pyx_RefNannySetupContext("_toString (wrapper)", 0);
  2784. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Rs), __pyx_ptype_11pycocotools_5_mask_RLEs, 1, "Rs", 0))) __PYX_ERR(0, 100, __pyx_L1_error)
  2785. __pyx_r = __pyx_pf_11pycocotools_5_mask__toString(__pyx_self, ((struct __pyx_obj_11pycocotools_5_mask_RLEs *)__pyx_v_Rs));
  2786. /* function exit code */
  2787. goto __pyx_L0;
  2788. __pyx_L1_error:;
  2789. __pyx_r = NULL;
  2790. __pyx_L0:;
  2791. __Pyx_RefNannyFinishContext();
  2792. return __pyx_r;
  2793. }
  2794. static PyObject *__pyx_pf_11pycocotools_5_mask__toString(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_Rs) {
  2795. siz __pyx_v_n;
  2796. PyObject *__pyx_v_py_string = 0;
  2797. char *__pyx_v_c_string;
  2798. PyObject *__pyx_v_objs = NULL;
  2799. siz __pyx_v_i;
  2800. PyObject *__pyx_r = NULL;
  2801. __Pyx_RefNannyDeclarations
  2802. PyObject *__pyx_t_1 = NULL;
  2803. siz __pyx_t_2;
  2804. siz __pyx_t_3;
  2805. siz __pyx_t_4;
  2806. PyObject *__pyx_t_5 = NULL;
  2807. PyObject *__pyx_t_6 = NULL;
  2808. PyObject *__pyx_t_7 = NULL;
  2809. int __pyx_t_8;
  2810. __Pyx_RefNannySetupContext("_toString", 0);
  2811. /* "pycocotools/_mask.pyx":101
  2812. * # internal conversion from Python RLEs object to compressed RLE format
  2813. * def _toString(RLEs Rs):
  2814. * cdef siz n = Rs.n # <<<<<<<<<<<<<<
  2815. * cdef bytes py_string
  2816. * cdef char* c_string
  2817. */
  2818. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_Rs), __pyx_n_s_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 101, __pyx_L1_error)
  2819. __Pyx_GOTREF(__pyx_t_1);
  2820. __pyx_t_2 = __Pyx_PyInt_As_siz(__pyx_t_1); if (unlikely((__pyx_t_2 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 101, __pyx_L1_error)
  2821. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2822. __pyx_v_n = __pyx_t_2;
  2823. /* "pycocotools/_mask.pyx":104
  2824. * cdef bytes py_string
  2825. * cdef char* c_string
  2826. * objs = [] # <<<<<<<<<<<<<<
  2827. * for i in range(n):
  2828. * c_string = rleToString( <RLE*> &Rs._R[i] )
  2829. */
  2830. __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
  2831. __Pyx_GOTREF(__pyx_t_1);
  2832. __pyx_v_objs = ((PyObject*)__pyx_t_1);
  2833. __pyx_t_1 = 0;
  2834. /* "pycocotools/_mask.pyx":105
  2835. * cdef char* c_string
  2836. * objs = []
  2837. * for i in range(n): # <<<<<<<<<<<<<<
  2838. * c_string = rleToString( <RLE*> &Rs._R[i] )
  2839. * py_string = c_string
  2840. */
  2841. __pyx_t_2 = __pyx_v_n;
  2842. __pyx_t_3 = __pyx_t_2;
  2843. for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
  2844. __pyx_v_i = __pyx_t_4;
  2845. /* "pycocotools/_mask.pyx":106
  2846. * objs = []
  2847. * for i in range(n):
  2848. * c_string = rleToString( <RLE*> &Rs._R[i] ) # <<<<<<<<<<<<<<
  2849. * py_string = c_string
  2850. * objs.append({
  2851. */
  2852. __pyx_v_c_string = rleToString(((RLE *)(&(__pyx_v_Rs->_R[__pyx_v_i]))));
  2853. /* "pycocotools/_mask.pyx":107
  2854. * for i in range(n):
  2855. * c_string = rleToString( <RLE*> &Rs._R[i] )
  2856. * py_string = c_string # <<<<<<<<<<<<<<
  2857. * objs.append({
  2858. * 'size': [Rs._R[i].h, Rs._R[i].w],
  2859. */
  2860. __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_c_string); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L1_error)
  2861. __Pyx_GOTREF(__pyx_t_1);
  2862. __Pyx_XDECREF_SET(__pyx_v_py_string, ((PyObject*)__pyx_t_1));
  2863. __pyx_t_1 = 0;
  2864. /* "pycocotools/_mask.pyx":109
  2865. * py_string = c_string
  2866. * objs.append({
  2867. * 'size': [Rs._R[i].h, Rs._R[i].w], # <<<<<<<<<<<<<<
  2868. * 'counts': py_string
  2869. * })
  2870. */
  2871. __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error)
  2872. __Pyx_GOTREF(__pyx_t_1);
  2873. __pyx_t_5 = __Pyx_PyInt_From_siz((__pyx_v_Rs->_R[__pyx_v_i]).h); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 109, __pyx_L1_error)
  2874. __Pyx_GOTREF(__pyx_t_5);
  2875. __pyx_t_6 = __Pyx_PyInt_From_siz((__pyx_v_Rs->_R[__pyx_v_i]).w); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 109, __pyx_L1_error)
  2876. __Pyx_GOTREF(__pyx_t_6);
  2877. __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 109, __pyx_L1_error)
  2878. __Pyx_GOTREF(__pyx_t_7);
  2879. __Pyx_GIVEREF(__pyx_t_5);
  2880. PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_5);
  2881. __Pyx_GIVEREF(__pyx_t_6);
  2882. PyList_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
  2883. __pyx_t_5 = 0;
  2884. __pyx_t_6 = 0;
  2885. if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_size, __pyx_t_7) < 0) __PYX_ERR(0, 109, __pyx_L1_error)
  2886. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2887. /* "pycocotools/_mask.pyx":110
  2888. * objs.append({
  2889. * 'size': [Rs._R[i].h, Rs._R[i].w],
  2890. * 'counts': py_string # <<<<<<<<<<<<<<
  2891. * })
  2892. * free(c_string)
  2893. */
  2894. if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_counts, __pyx_v_py_string) < 0) __PYX_ERR(0, 109, __pyx_L1_error)
  2895. /* "pycocotools/_mask.pyx":108
  2896. * c_string = rleToString( <RLE*> &Rs._R[i] )
  2897. * py_string = c_string
  2898. * objs.append({ # <<<<<<<<<<<<<<
  2899. * 'size': [Rs._R[i].h, Rs._R[i].w],
  2900. * 'counts': py_string
  2901. */
  2902. __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_objs, __pyx_t_1); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 108, __pyx_L1_error)
  2903. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2904. /* "pycocotools/_mask.pyx":112
  2905. * 'counts': py_string
  2906. * })
  2907. * free(c_string) # <<<<<<<<<<<<<<
  2908. * return objs
  2909. *
  2910. */
  2911. free(__pyx_v_c_string);
  2912. }
  2913. /* "pycocotools/_mask.pyx":113
  2914. * })
  2915. * free(c_string)
  2916. * return objs # <<<<<<<<<<<<<<
  2917. *
  2918. * # internal conversion from compressed RLE format to Python RLEs object
  2919. */
  2920. __Pyx_XDECREF(__pyx_r);
  2921. __Pyx_INCREF(__pyx_v_objs);
  2922. __pyx_r = __pyx_v_objs;
  2923. goto __pyx_L0;
  2924. /* "pycocotools/_mask.pyx":100
  2925. *
  2926. * # internal conversion from Python RLEs object to compressed RLE format
  2927. * def _toString(RLEs Rs): # <<<<<<<<<<<<<<
  2928. * cdef siz n = Rs.n
  2929. * cdef bytes py_string
  2930. */
  2931. /* function exit code */
  2932. __pyx_L1_error:;
  2933. __Pyx_XDECREF(__pyx_t_1);
  2934. __Pyx_XDECREF(__pyx_t_5);
  2935. __Pyx_XDECREF(__pyx_t_6);
  2936. __Pyx_XDECREF(__pyx_t_7);
  2937. __Pyx_AddTraceback("pycocotools._mask._toString", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2938. __pyx_r = NULL;
  2939. __pyx_L0:;
  2940. __Pyx_XDECREF(__pyx_v_py_string);
  2941. __Pyx_XDECREF(__pyx_v_objs);
  2942. __Pyx_XGIVEREF(__pyx_r);
  2943. __Pyx_RefNannyFinishContext();
  2944. return __pyx_r;
  2945. }
  2946. /* "pycocotools/_mask.pyx":116
  2947. *
  2948. * # internal conversion from compressed RLE format to Python RLEs object
  2949. * def _frString(rleObjs): # <<<<<<<<<<<<<<
  2950. * cdef siz n = len(rleObjs)
  2951. * Rs = RLEs(n)
  2952. */
  2953. /* Python wrapper */
  2954. static PyObject *__pyx_pw_11pycocotools_5_mask_3_frString(PyObject *__pyx_self, PyObject *__pyx_v_rleObjs); /*proto*/
  2955. static PyMethodDef __pyx_mdef_11pycocotools_5_mask_3_frString = {"_frString", (PyCFunction)__pyx_pw_11pycocotools_5_mask_3_frString, METH_O, 0};
  2956. static PyObject *__pyx_pw_11pycocotools_5_mask_3_frString(PyObject *__pyx_self, PyObject *__pyx_v_rleObjs) {
  2957. PyObject *__pyx_r = 0;
  2958. __Pyx_RefNannyDeclarations
  2959. __Pyx_RefNannySetupContext("_frString (wrapper)", 0);
  2960. __pyx_r = __pyx_pf_11pycocotools_5_mask_2_frString(__pyx_self, ((PyObject *)__pyx_v_rleObjs));
  2961. /* function exit code */
  2962. __Pyx_RefNannyFinishContext();
  2963. return __pyx_r;
  2964. }
  2965. static PyObject *__pyx_pf_11pycocotools_5_mask_2_frString(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs) {
  2966. siz __pyx_v_n;
  2967. struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_Rs = NULL;
  2968. PyObject *__pyx_v_py_string = 0;
  2969. char *__pyx_v_c_string;
  2970. PyObject *__pyx_v_i = NULL;
  2971. PyObject *__pyx_v_obj = NULL;
  2972. PyObject *__pyx_r = NULL;
  2973. __Pyx_RefNannyDeclarations
  2974. Py_ssize_t __pyx_t_1;
  2975. PyObject *__pyx_t_2 = NULL;
  2976. PyObject *__pyx_t_3 = NULL;
  2977. PyObject *(*__pyx_t_4)(PyObject *);
  2978. PyObject *__pyx_t_5 = NULL;
  2979. PyObject *__pyx_t_6 = NULL;
  2980. char *__pyx_t_7;
  2981. Py_ssize_t __pyx_t_8;
  2982. siz __pyx_t_9;
  2983. siz __pyx_t_10;
  2984. __Pyx_RefNannySetupContext("_frString", 0);
  2985. /* "pycocotools/_mask.pyx":117
  2986. * # internal conversion from compressed RLE format to Python RLEs object
  2987. * def _frString(rleObjs):
  2988. * cdef siz n = len(rleObjs) # <<<<<<<<<<<<<<
  2989. * Rs = RLEs(n)
  2990. * cdef bytes py_string
  2991. */
  2992. __pyx_t_1 = PyObject_Length(__pyx_v_rleObjs); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 117, __pyx_L1_error)
  2993. __pyx_v_n = __pyx_t_1;
  2994. /* "pycocotools/_mask.pyx":118
  2995. * def _frString(rleObjs):
  2996. * cdef siz n = len(rleObjs)
  2997. * Rs = RLEs(n) # <<<<<<<<<<<<<<
  2998. * cdef bytes py_string
  2999. * cdef char* c_string
  3000. */
  3001. __pyx_t_2 = __Pyx_PyInt_From_siz(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error)
  3002. __Pyx_GOTREF(__pyx_t_2);
  3003. __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_11pycocotools_5_mask_RLEs), __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 118, __pyx_L1_error)
  3004. __Pyx_GOTREF(__pyx_t_3);
  3005. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3006. __pyx_v_Rs = ((struct __pyx_obj_11pycocotools_5_mask_RLEs *)__pyx_t_3);
  3007. __pyx_t_3 = 0;
  3008. /* "pycocotools/_mask.pyx":121
  3009. * cdef bytes py_string
  3010. * cdef char* c_string
  3011. * for i, obj in enumerate(rleObjs): # <<<<<<<<<<<<<<
  3012. * py_string = str(obj['counts'])
  3013. * c_string = py_string
  3014. */
  3015. __Pyx_INCREF(__pyx_int_0);
  3016. __pyx_t_3 = __pyx_int_0;
  3017. if (likely(PyList_CheckExact(__pyx_v_rleObjs)) || PyTuple_CheckExact(__pyx_v_rleObjs)) {
  3018. __pyx_t_2 = __pyx_v_rleObjs; __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = 0;
  3019. __pyx_t_4 = NULL;
  3020. } else {
  3021. __pyx_t_1 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_rleObjs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error)
  3022. __Pyx_GOTREF(__pyx_t_2);
  3023. __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 121, __pyx_L1_error)
  3024. }
  3025. for (;;) {
  3026. if (likely(!__pyx_t_4)) {
  3027. if (likely(PyList_CheckExact(__pyx_t_2))) {
  3028. if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_2)) break;
  3029. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  3030. __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 121, __pyx_L1_error)
  3031. #else
  3032. __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 121, __pyx_L1_error)
  3033. __Pyx_GOTREF(__pyx_t_5);
  3034. #endif
  3035. } else {
  3036. if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
  3037. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  3038. __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 121, __pyx_L1_error)
  3039. #else
  3040. __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 121, __pyx_L1_error)
  3041. __Pyx_GOTREF(__pyx_t_5);
  3042. #endif
  3043. }
  3044. } else {
  3045. __pyx_t_5 = __pyx_t_4(__pyx_t_2);
  3046. if (unlikely(!__pyx_t_5)) {
  3047. PyObject* exc_type = PyErr_Occurred();
  3048. if (exc_type) {
  3049. if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  3050. else __PYX_ERR(0, 121, __pyx_L1_error)
  3051. }
  3052. break;
  3053. }
  3054. __Pyx_GOTREF(__pyx_t_5);
  3055. }
  3056. __Pyx_XDECREF_SET(__pyx_v_obj, __pyx_t_5);
  3057. __pyx_t_5 = 0;
  3058. __Pyx_INCREF(__pyx_t_3);
  3059. __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
  3060. __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 121, __pyx_L1_error)
  3061. __Pyx_GOTREF(__pyx_t_5);
  3062. __Pyx_DECREF(__pyx_t_3);
  3063. __pyx_t_3 = __pyx_t_5;
  3064. __pyx_t_5 = 0;
  3065. /* "pycocotools/_mask.pyx":122
  3066. * cdef char* c_string
  3067. * for i, obj in enumerate(rleObjs):
  3068. * py_string = str(obj['counts']) # <<<<<<<<<<<<<<
  3069. * c_string = py_string
  3070. * rleFrString( <RLE*> &Rs._R[i], <char*> c_string, obj['size'][0], obj['size'][1] )
  3071. */
  3072. __pyx_t_5 = __Pyx_PyObject_Dict_GetItem(__pyx_v_obj, __pyx_n_s_counts); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 122, __pyx_L1_error)
  3073. __Pyx_GOTREF(__pyx_t_5);
  3074. __pyx_t_6 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyString_Type)), __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 122, __pyx_L1_error)
  3075. __Pyx_GOTREF(__pyx_t_6);
  3076. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3077. if (!(likely(PyBytes_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_6)->tp_name), 0))) __PYX_ERR(0, 122, __pyx_L1_error)
  3078. __Pyx_XDECREF_SET(__pyx_v_py_string, ((PyObject*)__pyx_t_6));
  3079. __pyx_t_6 = 0;
  3080. /* "pycocotools/_mask.pyx":123
  3081. * for i, obj in enumerate(rleObjs):
  3082. * py_string = str(obj['counts'])
  3083. * c_string = py_string # <<<<<<<<<<<<<<
  3084. * rleFrString( <RLE*> &Rs._R[i], <char*> c_string, obj['size'][0], obj['size'][1] )
  3085. * return Rs
  3086. */
  3087. if (unlikely(__pyx_v_py_string == Py_None)) {
  3088. PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
  3089. __PYX_ERR(0, 123, __pyx_L1_error)
  3090. }
  3091. __pyx_t_7 = __Pyx_PyBytes_AsWritableString(__pyx_v_py_string); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(0, 123, __pyx_L1_error)
  3092. __pyx_v_c_string = __pyx_t_7;
  3093. /* "pycocotools/_mask.pyx":124
  3094. * py_string = str(obj['counts'])
  3095. * c_string = py_string
  3096. * rleFrString( <RLE*> &Rs._R[i], <char*> c_string, obj['size'][0], obj['size'][1] ) # <<<<<<<<<<<<<<
  3097. * return Rs
  3098. *
  3099. */
  3100. __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 124, __pyx_L1_error)
  3101. __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_v_obj, __pyx_n_s_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 124, __pyx_L1_error)
  3102. __Pyx_GOTREF(__pyx_t_6);
  3103. __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_6, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 124, __pyx_L1_error)
  3104. __Pyx_GOTREF(__pyx_t_5);
  3105. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3106. __pyx_t_9 = __Pyx_PyInt_As_siz(__pyx_t_5); if (unlikely((__pyx_t_9 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 124, __pyx_L1_error)
  3107. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3108. __pyx_t_5 = __Pyx_PyObject_Dict_GetItem(__pyx_v_obj, __pyx_n_s_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 124, __pyx_L1_error)
  3109. __Pyx_GOTREF(__pyx_t_5);
  3110. __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_5, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 124, __pyx_L1_error)
  3111. __Pyx_GOTREF(__pyx_t_6);
  3112. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3113. __pyx_t_10 = __Pyx_PyInt_As_siz(__pyx_t_6); if (unlikely((__pyx_t_10 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 124, __pyx_L1_error)
  3114. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3115. rleFrString(((RLE *)(&(__pyx_v_Rs->_R[__pyx_t_8]))), ((char *)__pyx_v_c_string), __pyx_t_9, __pyx_t_10);
  3116. /* "pycocotools/_mask.pyx":121
  3117. * cdef bytes py_string
  3118. * cdef char* c_string
  3119. * for i, obj in enumerate(rleObjs): # <<<<<<<<<<<<<<
  3120. * py_string = str(obj['counts'])
  3121. * c_string = py_string
  3122. */
  3123. }
  3124. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3125. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3126. /* "pycocotools/_mask.pyx":125
  3127. * c_string = py_string
  3128. * rleFrString( <RLE*> &Rs._R[i], <char*> c_string, obj['size'][0], obj['size'][1] )
  3129. * return Rs # <<<<<<<<<<<<<<
  3130. *
  3131. * # encode mask to RLEs objects
  3132. */
  3133. __Pyx_XDECREF(__pyx_r);
  3134. __Pyx_INCREF(((PyObject *)__pyx_v_Rs));
  3135. __pyx_r = ((PyObject *)__pyx_v_Rs);
  3136. goto __pyx_L0;
  3137. /* "pycocotools/_mask.pyx":116
  3138. *
  3139. * # internal conversion from compressed RLE format to Python RLEs object
  3140. * def _frString(rleObjs): # <<<<<<<<<<<<<<
  3141. * cdef siz n = len(rleObjs)
  3142. * Rs = RLEs(n)
  3143. */
  3144. /* function exit code */
  3145. __pyx_L1_error:;
  3146. __Pyx_XDECREF(__pyx_t_2);
  3147. __Pyx_XDECREF(__pyx_t_3);
  3148. __Pyx_XDECREF(__pyx_t_5);
  3149. __Pyx_XDECREF(__pyx_t_6);
  3150. __Pyx_AddTraceback("pycocotools._mask._frString", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3151. __pyx_r = NULL;
  3152. __pyx_L0:;
  3153. __Pyx_XDECREF((PyObject *)__pyx_v_Rs);
  3154. __Pyx_XDECREF(__pyx_v_py_string);
  3155. __Pyx_XDECREF(__pyx_v_i);
  3156. __Pyx_XDECREF(__pyx_v_obj);
  3157. __Pyx_XGIVEREF(__pyx_r);
  3158. __Pyx_RefNannyFinishContext();
  3159. return __pyx_r;
  3160. }
  3161. /* "pycocotools/_mask.pyx":129
  3162. * # encode mask to RLEs objects
  3163. * # list of RLE string can be generated by RLEs member function
  3164. * def encode(np.ndarray[np.uint8_t, ndim=3, mode='fortran'] mask): # <<<<<<<<<<<<<<
  3165. * h, w, n = mask.shape[0], mask.shape[1], mask.shape[2]
  3166. * cdef RLEs Rs = RLEs(n)
  3167. */
  3168. /* Python wrapper */
  3169. static PyObject *__pyx_pw_11pycocotools_5_mask_5encode(PyObject *__pyx_self, PyObject *__pyx_v_mask); /*proto*/
  3170. static PyMethodDef __pyx_mdef_11pycocotools_5_mask_5encode = {"encode", (PyCFunction)__pyx_pw_11pycocotools_5_mask_5encode, METH_O, 0};
  3171. static PyObject *__pyx_pw_11pycocotools_5_mask_5encode(PyObject *__pyx_self, PyObject *__pyx_v_mask) {
  3172. PyObject *__pyx_r = 0;
  3173. __Pyx_RefNannyDeclarations
  3174. __Pyx_RefNannySetupContext("encode (wrapper)", 0);
  3175. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mask), __pyx_ptype_5numpy_ndarray, 1, "mask", 0))) __PYX_ERR(0, 129, __pyx_L1_error)
  3176. __pyx_r = __pyx_pf_11pycocotools_5_mask_4encode(__pyx_self, ((PyArrayObject *)__pyx_v_mask));
  3177. /* function exit code */
  3178. goto __pyx_L0;
  3179. __pyx_L1_error:;
  3180. __pyx_r = NULL;
  3181. __pyx_L0:;
  3182. __Pyx_RefNannyFinishContext();
  3183. return __pyx_r;
  3184. }
  3185. static PyObject *__pyx_pf_11pycocotools_5_mask_4encode(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_mask) {
  3186. npy_intp __pyx_v_h;
  3187. npy_intp __pyx_v_w;
  3188. npy_intp __pyx_v_n;
  3189. struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_Rs = 0;
  3190. PyObject *__pyx_v_objs = NULL;
  3191. __Pyx_LocalBuf_ND __pyx_pybuffernd_mask;
  3192. __Pyx_Buffer __pyx_pybuffer_mask;
  3193. PyObject *__pyx_r = NULL;
  3194. __Pyx_RefNannyDeclarations
  3195. npy_intp __pyx_t_1;
  3196. npy_intp __pyx_t_2;
  3197. npy_intp __pyx_t_3;
  3198. PyObject *__pyx_t_4 = NULL;
  3199. PyObject *__pyx_t_5 = NULL;
  3200. PyObject *__pyx_t_6 = NULL;
  3201. __Pyx_RefNannySetupContext("encode", 0);
  3202. __pyx_pybuffer_mask.pybuffer.buf = NULL;
  3203. __pyx_pybuffer_mask.refcount = 0;
  3204. __pyx_pybuffernd_mask.data = NULL;
  3205. __pyx_pybuffernd_mask.rcbuffer = &__pyx_pybuffer_mask;
  3206. {
  3207. __Pyx_BufFmt_StackElem __pyx_stack[1];
  3208. if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_v_mask, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t, PyBUF_FORMAT| PyBUF_F_CONTIGUOUS, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 129, __pyx_L1_error)
  3209. }
  3210. __pyx_pybuffernd_mask.diminfo[0].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mask.diminfo[0].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_mask.diminfo[1].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_mask.diminfo[1].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_mask.diminfo[2].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_mask.diminfo[2].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[2];
  3211. /* "pycocotools/_mask.pyx":130
  3212. * # list of RLE string can be generated by RLEs member function
  3213. * def encode(np.ndarray[np.uint8_t, ndim=3, mode='fortran'] mask):
  3214. * h, w, n = mask.shape[0], mask.shape[1], mask.shape[2] # <<<<<<<<<<<<<<
  3215. * cdef RLEs Rs = RLEs(n)
  3216. * rleEncode(Rs._R,<byte*>mask.data,h,w,n)
  3217. */
  3218. __pyx_t_1 = (__pyx_v_mask->dimensions[0]);
  3219. __pyx_t_2 = (__pyx_v_mask->dimensions[1]);
  3220. __pyx_t_3 = (__pyx_v_mask->dimensions[2]);
  3221. __pyx_v_h = __pyx_t_1;
  3222. __pyx_v_w = __pyx_t_2;
  3223. __pyx_v_n = __pyx_t_3;
  3224. /* "pycocotools/_mask.pyx":131
  3225. * def encode(np.ndarray[np.uint8_t, ndim=3, mode='fortran'] mask):
  3226. * h, w, n = mask.shape[0], mask.shape[1], mask.shape[2]
  3227. * cdef RLEs Rs = RLEs(n) # <<<<<<<<<<<<<<
  3228. * rleEncode(Rs._R,<byte*>mask.data,h,w,n)
  3229. * objs = _toString(Rs)
  3230. */
  3231. __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 131, __pyx_L1_error)
  3232. __Pyx_GOTREF(__pyx_t_4);
  3233. __pyx_t_5 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_11pycocotools_5_mask_RLEs), __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 131, __pyx_L1_error)
  3234. __Pyx_GOTREF(__pyx_t_5);
  3235. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3236. __pyx_v_Rs = ((struct __pyx_obj_11pycocotools_5_mask_RLEs *)__pyx_t_5);
  3237. __pyx_t_5 = 0;
  3238. /* "pycocotools/_mask.pyx":132
  3239. * h, w, n = mask.shape[0], mask.shape[1], mask.shape[2]
  3240. * cdef RLEs Rs = RLEs(n)
  3241. * rleEncode(Rs._R,<byte*>mask.data,h,w,n) # <<<<<<<<<<<<<<
  3242. * objs = _toString(Rs)
  3243. * return objs
  3244. */
  3245. rleEncode(__pyx_v_Rs->_R, ((byte *)__pyx_v_mask->data), __pyx_v_h, __pyx_v_w, __pyx_v_n);
  3246. /* "pycocotools/_mask.pyx":133
  3247. * cdef RLEs Rs = RLEs(n)
  3248. * rleEncode(Rs._R,<byte*>mask.data,h,w,n)
  3249. * objs = _toString(Rs) # <<<<<<<<<<<<<<
  3250. * return objs
  3251. *
  3252. */
  3253. __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_toString); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 133, __pyx_L1_error)
  3254. __Pyx_GOTREF(__pyx_t_4);
  3255. __pyx_t_6 = NULL;
  3256. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  3257. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
  3258. if (likely(__pyx_t_6)) {
  3259. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  3260. __Pyx_INCREF(__pyx_t_6);
  3261. __Pyx_INCREF(function);
  3262. __Pyx_DECREF_SET(__pyx_t_4, function);
  3263. }
  3264. }
  3265. __pyx_t_5 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, ((PyObject *)__pyx_v_Rs)) : __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_Rs));
  3266. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3267. if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 133, __pyx_L1_error)
  3268. __Pyx_GOTREF(__pyx_t_5);
  3269. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3270. __pyx_v_objs = __pyx_t_5;
  3271. __pyx_t_5 = 0;
  3272. /* "pycocotools/_mask.pyx":134
  3273. * rleEncode(Rs._R,<byte*>mask.data,h,w,n)
  3274. * objs = _toString(Rs)
  3275. * return objs # <<<<<<<<<<<<<<
  3276. *
  3277. * # decode mask from compressed list of RLE string or RLEs object
  3278. */
  3279. __Pyx_XDECREF(__pyx_r);
  3280. __Pyx_INCREF(__pyx_v_objs);
  3281. __pyx_r = __pyx_v_objs;
  3282. goto __pyx_L0;
  3283. /* "pycocotools/_mask.pyx":129
  3284. * # encode mask to RLEs objects
  3285. * # list of RLE string can be generated by RLEs member function
  3286. * def encode(np.ndarray[np.uint8_t, ndim=3, mode='fortran'] mask): # <<<<<<<<<<<<<<
  3287. * h, w, n = mask.shape[0], mask.shape[1], mask.shape[2]
  3288. * cdef RLEs Rs = RLEs(n)
  3289. */
  3290. /* function exit code */
  3291. __pyx_L1_error:;
  3292. __Pyx_XDECREF(__pyx_t_4);
  3293. __Pyx_XDECREF(__pyx_t_5);
  3294. __Pyx_XDECREF(__pyx_t_6);
  3295. { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
  3296. __Pyx_PyThreadState_declare
  3297. __Pyx_PyThreadState_assign
  3298. __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
  3299. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer);
  3300. __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  3301. __Pyx_AddTraceback("pycocotools._mask.encode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3302. __pyx_r = NULL;
  3303. goto __pyx_L2;
  3304. __pyx_L0:;
  3305. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer);
  3306. __pyx_L2:;
  3307. __Pyx_XDECREF((PyObject *)__pyx_v_Rs);
  3308. __Pyx_XDECREF(__pyx_v_objs);
  3309. __Pyx_XGIVEREF(__pyx_r);
  3310. __Pyx_RefNannyFinishContext();
  3311. return __pyx_r;
  3312. }
  3313. /* "pycocotools/_mask.pyx":137
  3314. *
  3315. * # decode mask from compressed list of RLE string or RLEs object
  3316. * def decode(rleObjs): # <<<<<<<<<<<<<<
  3317. * cdef RLEs Rs = _frString(rleObjs)
  3318. * h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n
  3319. */
  3320. /* Python wrapper */
  3321. static PyObject *__pyx_pw_11pycocotools_5_mask_7decode(PyObject *__pyx_self, PyObject *__pyx_v_rleObjs); /*proto*/
  3322. static PyMethodDef __pyx_mdef_11pycocotools_5_mask_7decode = {"decode", (PyCFunction)__pyx_pw_11pycocotools_5_mask_7decode, METH_O, 0};
  3323. static PyObject *__pyx_pw_11pycocotools_5_mask_7decode(PyObject *__pyx_self, PyObject *__pyx_v_rleObjs) {
  3324. PyObject *__pyx_r = 0;
  3325. __Pyx_RefNannyDeclarations
  3326. __Pyx_RefNannySetupContext("decode (wrapper)", 0);
  3327. __pyx_r = __pyx_pf_11pycocotools_5_mask_6decode(__pyx_self, ((PyObject *)__pyx_v_rleObjs));
  3328. /* function exit code */
  3329. __Pyx_RefNannyFinishContext();
  3330. return __pyx_r;
  3331. }
  3332. static PyObject *__pyx_pf_11pycocotools_5_mask_6decode(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs) {
  3333. struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_Rs = 0;
  3334. siz __pyx_v_h;
  3335. siz __pyx_v_w;
  3336. siz __pyx_v_n;
  3337. struct __pyx_obj_11pycocotools_5_mask_Masks *__pyx_v_masks = NULL;
  3338. PyObject *__pyx_r = NULL;
  3339. __Pyx_RefNannyDeclarations
  3340. PyObject *__pyx_t_1 = NULL;
  3341. PyObject *__pyx_t_2 = NULL;
  3342. PyObject *__pyx_t_3 = NULL;
  3343. siz __pyx_t_4;
  3344. siz __pyx_t_5;
  3345. siz __pyx_t_6;
  3346. PyObject *__pyx_t_7 = NULL;
  3347. __Pyx_RefNannySetupContext("decode", 0);
  3348. /* "pycocotools/_mask.pyx":138
  3349. * # decode mask from compressed list of RLE string or RLEs object
  3350. * def decode(rleObjs):
  3351. * cdef RLEs Rs = _frString(rleObjs) # <<<<<<<<<<<<<<
  3352. * h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n
  3353. * masks = Masks(h, w, n)
  3354. */
  3355. __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_frString); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
  3356. __Pyx_GOTREF(__pyx_t_2);
  3357. __pyx_t_3 = NULL;
  3358. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  3359. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  3360. if (likely(__pyx_t_3)) {
  3361. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  3362. __Pyx_INCREF(__pyx_t_3);
  3363. __Pyx_INCREF(function);
  3364. __Pyx_DECREF_SET(__pyx_t_2, function);
  3365. }
  3366. }
  3367. __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_rleObjs) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_rleObjs);
  3368. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3369. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error)
  3370. __Pyx_GOTREF(__pyx_t_1);
  3371. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3372. if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_11pycocotools_5_mask_RLEs))))) __PYX_ERR(0, 138, __pyx_L1_error)
  3373. __pyx_v_Rs = ((struct __pyx_obj_11pycocotools_5_mask_RLEs *)__pyx_t_1);
  3374. __pyx_t_1 = 0;
  3375. /* "pycocotools/_mask.pyx":139
  3376. * def decode(rleObjs):
  3377. * cdef RLEs Rs = _frString(rleObjs)
  3378. * h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n # <<<<<<<<<<<<<<
  3379. * masks = Masks(h, w, n)
  3380. * rleDecode( <RLE*>Rs._R, masks._mask, n );
  3381. */
  3382. __pyx_t_4 = (__pyx_v_Rs->_R[0]).h;
  3383. __pyx_t_5 = (__pyx_v_Rs->_R[0]).w;
  3384. __pyx_t_6 = __pyx_v_Rs->_n;
  3385. __pyx_v_h = __pyx_t_4;
  3386. __pyx_v_w = __pyx_t_5;
  3387. __pyx_v_n = __pyx_t_6;
  3388. /* "pycocotools/_mask.pyx":140
  3389. * cdef RLEs Rs = _frString(rleObjs)
  3390. * h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n
  3391. * masks = Masks(h, w, n) # <<<<<<<<<<<<<<
  3392. * rleDecode( <RLE*>Rs._R, masks._mask, n );
  3393. * return np.array(masks)
  3394. */
  3395. __pyx_t_1 = __Pyx_PyInt_From_siz(__pyx_v_h); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
  3396. __Pyx_GOTREF(__pyx_t_1);
  3397. __pyx_t_2 = __Pyx_PyInt_From_siz(__pyx_v_w); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
  3398. __Pyx_GOTREF(__pyx_t_2);
  3399. __pyx_t_3 = __Pyx_PyInt_From_siz(__pyx_v_n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error)
  3400. __Pyx_GOTREF(__pyx_t_3);
  3401. __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 140, __pyx_L1_error)
  3402. __Pyx_GOTREF(__pyx_t_7);
  3403. __Pyx_GIVEREF(__pyx_t_1);
  3404. PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
  3405. __Pyx_GIVEREF(__pyx_t_2);
  3406. PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
  3407. __Pyx_GIVEREF(__pyx_t_3);
  3408. PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_3);
  3409. __pyx_t_1 = 0;
  3410. __pyx_t_2 = 0;
  3411. __pyx_t_3 = 0;
  3412. __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11pycocotools_5_mask_Masks), __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error)
  3413. __Pyx_GOTREF(__pyx_t_3);
  3414. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3415. __pyx_v_masks = ((struct __pyx_obj_11pycocotools_5_mask_Masks *)__pyx_t_3);
  3416. __pyx_t_3 = 0;
  3417. /* "pycocotools/_mask.pyx":141
  3418. * h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n
  3419. * masks = Masks(h, w, n)
  3420. * rleDecode( <RLE*>Rs._R, masks._mask, n ); # <<<<<<<<<<<<<<
  3421. * return np.array(masks)
  3422. *
  3423. */
  3424. rleDecode(((RLE *)__pyx_v_Rs->_R), __pyx_v_masks->_mask, __pyx_v_n);
  3425. /* "pycocotools/_mask.pyx":142
  3426. * masks = Masks(h, w, n)
  3427. * rleDecode( <RLE*>Rs._R, masks._mask, n );
  3428. * return np.array(masks) # <<<<<<<<<<<<<<
  3429. *
  3430. * def merge(rleObjs, bint intersect=0):
  3431. */
  3432. __Pyx_XDECREF(__pyx_r);
  3433. __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 142, __pyx_L1_error)
  3434. __Pyx_GOTREF(__pyx_t_7);
  3435. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error)
  3436. __Pyx_GOTREF(__pyx_t_2);
  3437. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3438. __pyx_t_7 = NULL;
  3439. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  3440. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
  3441. if (likely(__pyx_t_7)) {
  3442. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  3443. __Pyx_INCREF(__pyx_t_7);
  3444. __Pyx_INCREF(function);
  3445. __Pyx_DECREF_SET(__pyx_t_2, function);
  3446. }
  3447. }
  3448. __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_7, ((PyObject *)__pyx_v_masks)) : __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_masks));
  3449. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3450. if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 142, __pyx_L1_error)
  3451. __Pyx_GOTREF(__pyx_t_3);
  3452. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3453. __pyx_r = __pyx_t_3;
  3454. __pyx_t_3 = 0;
  3455. goto __pyx_L0;
  3456. /* "pycocotools/_mask.pyx":137
  3457. *
  3458. * # decode mask from compressed list of RLE string or RLEs object
  3459. * def decode(rleObjs): # <<<<<<<<<<<<<<
  3460. * cdef RLEs Rs = _frString(rleObjs)
  3461. * h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n
  3462. */
  3463. /* function exit code */
  3464. __pyx_L1_error:;
  3465. __Pyx_XDECREF(__pyx_t_1);
  3466. __Pyx_XDECREF(__pyx_t_2);
  3467. __Pyx_XDECREF(__pyx_t_3);
  3468. __Pyx_XDECREF(__pyx_t_7);
  3469. __Pyx_AddTraceback("pycocotools._mask.decode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3470. __pyx_r = NULL;
  3471. __pyx_L0:;
  3472. __Pyx_XDECREF((PyObject *)__pyx_v_Rs);
  3473. __Pyx_XDECREF((PyObject *)__pyx_v_masks);
  3474. __Pyx_XGIVEREF(__pyx_r);
  3475. __Pyx_RefNannyFinishContext();
  3476. return __pyx_r;
  3477. }
  3478. /* "pycocotools/_mask.pyx":144
  3479. * return np.array(masks)
  3480. *
  3481. * def merge(rleObjs, bint intersect=0): # <<<<<<<<<<<<<<
  3482. * cdef RLEs Rs = _frString(rleObjs)
  3483. * cdef RLEs R = RLEs(1)
  3484. */
  3485. /* Python wrapper */
  3486. static PyObject *__pyx_pw_11pycocotools_5_mask_9merge(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  3487. static PyMethodDef __pyx_mdef_11pycocotools_5_mask_9merge = {"merge", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pycocotools_5_mask_9merge, METH_VARARGS|METH_KEYWORDS, 0};
  3488. static PyObject *__pyx_pw_11pycocotools_5_mask_9merge(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  3489. PyObject *__pyx_v_rleObjs = 0;
  3490. int __pyx_v_intersect;
  3491. PyObject *__pyx_r = 0;
  3492. __Pyx_RefNannyDeclarations
  3493. __Pyx_RefNannySetupContext("merge (wrapper)", 0);
  3494. {
  3495. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_rleObjs,&__pyx_n_s_intersect,0};
  3496. PyObject* values[2] = {0,0};
  3497. if (unlikely(__pyx_kwds)) {
  3498. Py_ssize_t kw_args;
  3499. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  3500. switch (pos_args) {
  3501. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  3502. CYTHON_FALLTHROUGH;
  3503. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  3504. CYTHON_FALLTHROUGH;
  3505. case 0: break;
  3506. default: goto __pyx_L5_argtuple_error;
  3507. }
  3508. kw_args = PyDict_Size(__pyx_kwds);
  3509. switch (pos_args) {
  3510. case 0:
  3511. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rleObjs)) != 0)) kw_args--;
  3512. else goto __pyx_L5_argtuple_error;
  3513. CYTHON_FALLTHROUGH;
  3514. case 1:
  3515. if (kw_args > 0) {
  3516. PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_intersect);
  3517. if (value) { values[1] = value; kw_args--; }
  3518. }
  3519. }
  3520. if (unlikely(kw_args > 0)) {
  3521. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "merge") < 0)) __PYX_ERR(0, 144, __pyx_L3_error)
  3522. }
  3523. } else {
  3524. switch (PyTuple_GET_SIZE(__pyx_args)) {
  3525. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  3526. CYTHON_FALLTHROUGH;
  3527. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  3528. break;
  3529. default: goto __pyx_L5_argtuple_error;
  3530. }
  3531. }
  3532. __pyx_v_rleObjs = values[0];
  3533. if (values[1]) {
  3534. __pyx_v_intersect = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_intersect == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 144, __pyx_L3_error)
  3535. } else {
  3536. __pyx_v_intersect = ((int)0);
  3537. }
  3538. }
  3539. goto __pyx_L4_argument_unpacking_done;
  3540. __pyx_L5_argtuple_error:;
  3541. __Pyx_RaiseArgtupleInvalid("merge", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 144, __pyx_L3_error)
  3542. __pyx_L3_error:;
  3543. __Pyx_AddTraceback("pycocotools._mask.merge", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3544. __Pyx_RefNannyFinishContext();
  3545. return NULL;
  3546. __pyx_L4_argument_unpacking_done:;
  3547. __pyx_r = __pyx_pf_11pycocotools_5_mask_8merge(__pyx_self, __pyx_v_rleObjs, __pyx_v_intersect);
  3548. /* function exit code */
  3549. __Pyx_RefNannyFinishContext();
  3550. return __pyx_r;
  3551. }
  3552. static PyObject *__pyx_pf_11pycocotools_5_mask_8merge(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs, int __pyx_v_intersect) {
  3553. struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_Rs = 0;
  3554. struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_R = 0;
  3555. PyObject *__pyx_v_obj = NULL;
  3556. PyObject *__pyx_r = NULL;
  3557. __Pyx_RefNannyDeclarations
  3558. PyObject *__pyx_t_1 = NULL;
  3559. PyObject *__pyx_t_2 = NULL;
  3560. PyObject *__pyx_t_3 = NULL;
  3561. __Pyx_RefNannySetupContext("merge", 0);
  3562. /* "pycocotools/_mask.pyx":145
  3563. *
  3564. * def merge(rleObjs, bint intersect=0):
  3565. * cdef RLEs Rs = _frString(rleObjs) # <<<<<<<<<<<<<<
  3566. * cdef RLEs R = RLEs(1)
  3567. * rleMerge(<RLE*>Rs._R, <RLE*> R._R, <siz> Rs._n, intersect)
  3568. */
  3569. __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_frString); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error)
  3570. __Pyx_GOTREF(__pyx_t_2);
  3571. __pyx_t_3 = NULL;
  3572. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  3573. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  3574. if (likely(__pyx_t_3)) {
  3575. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  3576. __Pyx_INCREF(__pyx_t_3);
  3577. __Pyx_INCREF(function);
  3578. __Pyx_DECREF_SET(__pyx_t_2, function);
  3579. }
  3580. }
  3581. __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_rleObjs) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_rleObjs);
  3582. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3583. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error)
  3584. __Pyx_GOTREF(__pyx_t_1);
  3585. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3586. if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_11pycocotools_5_mask_RLEs))))) __PYX_ERR(0, 145, __pyx_L1_error)
  3587. __pyx_v_Rs = ((struct __pyx_obj_11pycocotools_5_mask_RLEs *)__pyx_t_1);
  3588. __pyx_t_1 = 0;
  3589. /* "pycocotools/_mask.pyx":146
  3590. * def merge(rleObjs, bint intersect=0):
  3591. * cdef RLEs Rs = _frString(rleObjs)
  3592. * cdef RLEs R = RLEs(1) # <<<<<<<<<<<<<<
  3593. * rleMerge(<RLE*>Rs._R, <RLE*> R._R, <siz> Rs._n, intersect)
  3594. * obj = _toString(R)[0]
  3595. */
  3596. __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11pycocotools_5_mask_RLEs), __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error)
  3597. __Pyx_GOTREF(__pyx_t_1);
  3598. __pyx_v_R = ((struct __pyx_obj_11pycocotools_5_mask_RLEs *)__pyx_t_1);
  3599. __pyx_t_1 = 0;
  3600. /* "pycocotools/_mask.pyx":147
  3601. * cdef RLEs Rs = _frString(rleObjs)
  3602. * cdef RLEs R = RLEs(1)
  3603. * rleMerge(<RLE*>Rs._R, <RLE*> R._R, <siz> Rs._n, intersect) # <<<<<<<<<<<<<<
  3604. * obj = _toString(R)[0]
  3605. * return obj
  3606. */
  3607. rleMerge(((RLE *)__pyx_v_Rs->_R), ((RLE *)__pyx_v_R->_R), ((siz)__pyx_v_Rs->_n), __pyx_v_intersect);
  3608. /* "pycocotools/_mask.pyx":148
  3609. * cdef RLEs R = RLEs(1)
  3610. * rleMerge(<RLE*>Rs._R, <RLE*> R._R, <siz> Rs._n, intersect)
  3611. * obj = _toString(R)[0] # <<<<<<<<<<<<<<
  3612. * return obj
  3613. *
  3614. */
  3615. __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_toString); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error)
  3616. __Pyx_GOTREF(__pyx_t_2);
  3617. __pyx_t_3 = NULL;
  3618. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  3619. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  3620. if (likely(__pyx_t_3)) {
  3621. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  3622. __Pyx_INCREF(__pyx_t_3);
  3623. __Pyx_INCREF(function);
  3624. __Pyx_DECREF_SET(__pyx_t_2, function);
  3625. }
  3626. }
  3627. __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_v_R)) : __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_R));
  3628. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3629. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error)
  3630. __Pyx_GOTREF(__pyx_t_1);
  3631. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3632. __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error)
  3633. __Pyx_GOTREF(__pyx_t_2);
  3634. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3635. __pyx_v_obj = __pyx_t_2;
  3636. __pyx_t_2 = 0;
  3637. /* "pycocotools/_mask.pyx":149
  3638. * rleMerge(<RLE*>Rs._R, <RLE*> R._R, <siz> Rs._n, intersect)
  3639. * obj = _toString(R)[0]
  3640. * return obj # <<<<<<<<<<<<<<
  3641. *
  3642. * def area(rleObjs):
  3643. */
  3644. __Pyx_XDECREF(__pyx_r);
  3645. __Pyx_INCREF(__pyx_v_obj);
  3646. __pyx_r = __pyx_v_obj;
  3647. goto __pyx_L0;
  3648. /* "pycocotools/_mask.pyx":144
  3649. * return np.array(masks)
  3650. *
  3651. * def merge(rleObjs, bint intersect=0): # <<<<<<<<<<<<<<
  3652. * cdef RLEs Rs = _frString(rleObjs)
  3653. * cdef RLEs R = RLEs(1)
  3654. */
  3655. /* function exit code */
  3656. __pyx_L1_error:;
  3657. __Pyx_XDECREF(__pyx_t_1);
  3658. __Pyx_XDECREF(__pyx_t_2);
  3659. __Pyx_XDECREF(__pyx_t_3);
  3660. __Pyx_AddTraceback("pycocotools._mask.merge", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3661. __pyx_r = NULL;
  3662. __pyx_L0:;
  3663. __Pyx_XDECREF((PyObject *)__pyx_v_Rs);
  3664. __Pyx_XDECREF((PyObject *)__pyx_v_R);
  3665. __Pyx_XDECREF(__pyx_v_obj);
  3666. __Pyx_XGIVEREF(__pyx_r);
  3667. __Pyx_RefNannyFinishContext();
  3668. return __pyx_r;
  3669. }
  3670. /* "pycocotools/_mask.pyx":151
  3671. * return obj
  3672. *
  3673. * def area(rleObjs): # <<<<<<<<<<<<<<
  3674. * cdef RLEs Rs = _frString(rleObjs)
  3675. * cdef uint* _a = <uint*> malloc(Rs._n* sizeof(uint))
  3676. */
  3677. /* Python wrapper */
  3678. static PyObject *__pyx_pw_11pycocotools_5_mask_11area(PyObject *__pyx_self, PyObject *__pyx_v_rleObjs); /*proto*/
  3679. static PyMethodDef __pyx_mdef_11pycocotools_5_mask_11area = {"area", (PyCFunction)__pyx_pw_11pycocotools_5_mask_11area, METH_O, 0};
  3680. static PyObject *__pyx_pw_11pycocotools_5_mask_11area(PyObject *__pyx_self, PyObject *__pyx_v_rleObjs) {
  3681. PyObject *__pyx_r = 0;
  3682. __Pyx_RefNannyDeclarations
  3683. __Pyx_RefNannySetupContext("area (wrapper)", 0);
  3684. __pyx_r = __pyx_pf_11pycocotools_5_mask_10area(__pyx_self, ((PyObject *)__pyx_v_rleObjs));
  3685. /* function exit code */
  3686. __Pyx_RefNannyFinishContext();
  3687. return __pyx_r;
  3688. }
  3689. static PyObject *__pyx_pf_11pycocotools_5_mask_10area(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs) {
  3690. struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_Rs = 0;
  3691. uint *__pyx_v__a;
  3692. npy_intp __pyx_v_shape[1];
  3693. PyObject *__pyx_v_a = NULL;
  3694. PyObject *__pyx_r = NULL;
  3695. __Pyx_RefNannyDeclarations
  3696. PyObject *__pyx_t_1 = NULL;
  3697. PyObject *__pyx_t_2 = NULL;
  3698. PyObject *__pyx_t_3 = NULL;
  3699. PyObject *__pyx_t_4 = NULL;
  3700. PyObject *__pyx_t_5 = NULL;
  3701. __Pyx_RefNannySetupContext("area", 0);
  3702. /* "pycocotools/_mask.pyx":152
  3703. *
  3704. * def area(rleObjs):
  3705. * cdef RLEs Rs = _frString(rleObjs) # <<<<<<<<<<<<<<
  3706. * cdef uint* _a = <uint*> malloc(Rs._n* sizeof(uint))
  3707. * rleArea(Rs._R, Rs._n, _a)
  3708. */
  3709. __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_frString); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 152, __pyx_L1_error)
  3710. __Pyx_GOTREF(__pyx_t_2);
  3711. __pyx_t_3 = NULL;
  3712. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  3713. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  3714. if (likely(__pyx_t_3)) {
  3715. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  3716. __Pyx_INCREF(__pyx_t_3);
  3717. __Pyx_INCREF(function);
  3718. __Pyx_DECREF_SET(__pyx_t_2, function);
  3719. }
  3720. }
  3721. __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_rleObjs) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_rleObjs);
  3722. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3723. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error)
  3724. __Pyx_GOTREF(__pyx_t_1);
  3725. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3726. if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_11pycocotools_5_mask_RLEs))))) __PYX_ERR(0, 152, __pyx_L1_error)
  3727. __pyx_v_Rs = ((struct __pyx_obj_11pycocotools_5_mask_RLEs *)__pyx_t_1);
  3728. __pyx_t_1 = 0;
  3729. /* "pycocotools/_mask.pyx":153
  3730. * def area(rleObjs):
  3731. * cdef RLEs Rs = _frString(rleObjs)
  3732. * cdef uint* _a = <uint*> malloc(Rs._n* sizeof(uint)) # <<<<<<<<<<<<<<
  3733. * rleArea(Rs._R, Rs._n, _a)
  3734. * cdef np.npy_intp shape[1]
  3735. */
  3736. __pyx_v__a = ((uint *)malloc((__pyx_v_Rs->_n * (sizeof(unsigned int)))));
  3737. /* "pycocotools/_mask.pyx":154
  3738. * cdef RLEs Rs = _frString(rleObjs)
  3739. * cdef uint* _a = <uint*> malloc(Rs._n* sizeof(uint))
  3740. * rleArea(Rs._R, Rs._n, _a) # <<<<<<<<<<<<<<
  3741. * cdef np.npy_intp shape[1]
  3742. * shape[0] = <np.npy_intp> Rs._n
  3743. */
  3744. rleArea(__pyx_v_Rs->_R, __pyx_v_Rs->_n, __pyx_v__a);
  3745. /* "pycocotools/_mask.pyx":156
  3746. * rleArea(Rs._R, Rs._n, _a)
  3747. * cdef np.npy_intp shape[1]
  3748. * shape[0] = <np.npy_intp> Rs._n # <<<<<<<<<<<<<<
  3749. * a = np.array((Rs._n, ), dtype=np.uint8)
  3750. * a = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT32, _a)
  3751. */
  3752. (__pyx_v_shape[0]) = ((npy_intp)__pyx_v_Rs->_n);
  3753. /* "pycocotools/_mask.pyx":157
  3754. * cdef np.npy_intp shape[1]
  3755. * shape[0] = <np.npy_intp> Rs._n
  3756. * a = np.array((Rs._n, ), dtype=np.uint8) # <<<<<<<<<<<<<<
  3757. * a = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT32, _a)
  3758. * PyArray_ENABLEFLAGS(a, np.NPY_OWNDATA)
  3759. */
  3760. __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error)
  3761. __Pyx_GOTREF(__pyx_t_1);
  3762. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 157, __pyx_L1_error)
  3763. __Pyx_GOTREF(__pyx_t_2);
  3764. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3765. __pyx_t_1 = __Pyx_PyInt_From_siz(__pyx_v_Rs->_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error)
  3766. __Pyx_GOTREF(__pyx_t_1);
  3767. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 157, __pyx_L1_error)
  3768. __Pyx_GOTREF(__pyx_t_3);
  3769. __Pyx_GIVEREF(__pyx_t_1);
  3770. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  3771. __pyx_t_1 = 0;
  3772. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error)
  3773. __Pyx_GOTREF(__pyx_t_1);
  3774. __Pyx_GIVEREF(__pyx_t_3);
  3775. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  3776. __pyx_t_3 = 0;
  3777. __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 157, __pyx_L1_error)
  3778. __Pyx_GOTREF(__pyx_t_3);
  3779. __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 157, __pyx_L1_error)
  3780. __Pyx_GOTREF(__pyx_t_4);
  3781. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 157, __pyx_L1_error)
  3782. __Pyx_GOTREF(__pyx_t_5);
  3783. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3784. if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 157, __pyx_L1_error)
  3785. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3786. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 157, __pyx_L1_error)
  3787. __Pyx_GOTREF(__pyx_t_5);
  3788. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3789. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3790. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3791. __pyx_v_a = __pyx_t_5;
  3792. __pyx_t_5 = 0;
  3793. /* "pycocotools/_mask.pyx":158
  3794. * shape[0] = <np.npy_intp> Rs._n
  3795. * a = np.array((Rs._n, ), dtype=np.uint8)
  3796. * a = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT32, _a) # <<<<<<<<<<<<<<
  3797. * PyArray_ENABLEFLAGS(a, np.NPY_OWNDATA)
  3798. * return a
  3799. */
  3800. __pyx_t_5 = PyArray_SimpleNewFromData(1, __pyx_v_shape, NPY_UINT32, __pyx_v__a); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 158, __pyx_L1_error)
  3801. __Pyx_GOTREF(__pyx_t_5);
  3802. __Pyx_DECREF_SET(__pyx_v_a, __pyx_t_5);
  3803. __pyx_t_5 = 0;
  3804. /* "pycocotools/_mask.pyx":159
  3805. * a = np.array((Rs._n, ), dtype=np.uint8)
  3806. * a = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT32, _a)
  3807. * PyArray_ENABLEFLAGS(a, np.NPY_OWNDATA) # <<<<<<<<<<<<<<
  3808. * return a
  3809. *
  3810. */
  3811. if (!(likely(((__pyx_v_a) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_a, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 159, __pyx_L1_error)
  3812. PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v_a), NPY_OWNDATA);
  3813. /* "pycocotools/_mask.pyx":160
  3814. * a = np.PyArray_SimpleNewFromData(1, shape, np.NPY_UINT32, _a)
  3815. * PyArray_ENABLEFLAGS(a, np.NPY_OWNDATA)
  3816. * return a # <<<<<<<<<<<<<<
  3817. *
  3818. * # iou computation. support function overload (RLEs-RLEs and bbox-bbox).
  3819. */
  3820. __Pyx_XDECREF(__pyx_r);
  3821. __Pyx_INCREF(__pyx_v_a);
  3822. __pyx_r = __pyx_v_a;
  3823. goto __pyx_L0;
  3824. /* "pycocotools/_mask.pyx":151
  3825. * return obj
  3826. *
  3827. * def area(rleObjs): # <<<<<<<<<<<<<<
  3828. * cdef RLEs Rs = _frString(rleObjs)
  3829. * cdef uint* _a = <uint*> malloc(Rs._n* sizeof(uint))
  3830. */
  3831. /* function exit code */
  3832. __pyx_L1_error:;
  3833. __Pyx_XDECREF(__pyx_t_1);
  3834. __Pyx_XDECREF(__pyx_t_2);
  3835. __Pyx_XDECREF(__pyx_t_3);
  3836. __Pyx_XDECREF(__pyx_t_4);
  3837. __Pyx_XDECREF(__pyx_t_5);
  3838. __Pyx_AddTraceback("pycocotools._mask.area", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3839. __pyx_r = NULL;
  3840. __pyx_L0:;
  3841. __Pyx_XDECREF((PyObject *)__pyx_v_Rs);
  3842. __Pyx_XDECREF(__pyx_v_a);
  3843. __Pyx_XGIVEREF(__pyx_r);
  3844. __Pyx_RefNannyFinishContext();
  3845. return __pyx_r;
  3846. }
  3847. /* "pycocotools/_mask.pyx":163
  3848. *
  3849. * # iou computation. support function overload (RLEs-RLEs and bbox-bbox).
  3850. * def iou( dt, gt, pyiscrowd ): # <<<<<<<<<<<<<<
  3851. * def _preproc(objs):
  3852. * if len(objs) == 0:
  3853. */
  3854. /* Python wrapper */
  3855. static PyObject *__pyx_pw_11pycocotools_5_mask_13iou(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  3856. static PyMethodDef __pyx_mdef_11pycocotools_5_mask_13iou = {"iou", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pycocotools_5_mask_13iou, METH_VARARGS|METH_KEYWORDS, 0};
  3857. static PyObject *__pyx_pw_11pycocotools_5_mask_13iou(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  3858. PyObject *__pyx_v_dt = 0;
  3859. PyObject *__pyx_v_gt = 0;
  3860. PyObject *__pyx_v_pyiscrowd = 0;
  3861. PyObject *__pyx_r = 0;
  3862. __Pyx_RefNannyDeclarations
  3863. __Pyx_RefNannySetupContext("iou (wrapper)", 0);
  3864. {
  3865. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dt,&__pyx_n_s_gt,&__pyx_n_s_pyiscrowd,0};
  3866. PyObject* values[3] = {0,0,0};
  3867. if (unlikely(__pyx_kwds)) {
  3868. Py_ssize_t kw_args;
  3869. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  3870. switch (pos_args) {
  3871. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  3872. CYTHON_FALLTHROUGH;
  3873. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  3874. CYTHON_FALLTHROUGH;
  3875. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  3876. CYTHON_FALLTHROUGH;
  3877. case 0: break;
  3878. default: goto __pyx_L5_argtuple_error;
  3879. }
  3880. kw_args = PyDict_Size(__pyx_kwds);
  3881. switch (pos_args) {
  3882. case 0:
  3883. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dt)) != 0)) kw_args--;
  3884. else goto __pyx_L5_argtuple_error;
  3885. CYTHON_FALLTHROUGH;
  3886. case 1:
  3887. if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gt)) != 0)) kw_args--;
  3888. else {
  3889. __Pyx_RaiseArgtupleInvalid("iou", 1, 3, 3, 1); __PYX_ERR(0, 163, __pyx_L3_error)
  3890. }
  3891. CYTHON_FALLTHROUGH;
  3892. case 2:
  3893. if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyiscrowd)) != 0)) kw_args--;
  3894. else {
  3895. __Pyx_RaiseArgtupleInvalid("iou", 1, 3, 3, 2); __PYX_ERR(0, 163, __pyx_L3_error)
  3896. }
  3897. }
  3898. if (unlikely(kw_args > 0)) {
  3899. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "iou") < 0)) __PYX_ERR(0, 163, __pyx_L3_error)
  3900. }
  3901. } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
  3902. goto __pyx_L5_argtuple_error;
  3903. } else {
  3904. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  3905. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  3906. values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  3907. }
  3908. __pyx_v_dt = values[0];
  3909. __pyx_v_gt = values[1];
  3910. __pyx_v_pyiscrowd = values[2];
  3911. }
  3912. goto __pyx_L4_argument_unpacking_done;
  3913. __pyx_L5_argtuple_error:;
  3914. __Pyx_RaiseArgtupleInvalid("iou", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 163, __pyx_L3_error)
  3915. __pyx_L3_error:;
  3916. __Pyx_AddTraceback("pycocotools._mask.iou", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3917. __Pyx_RefNannyFinishContext();
  3918. return NULL;
  3919. __pyx_L4_argument_unpacking_done:;
  3920. __pyx_r = __pyx_pf_11pycocotools_5_mask_12iou(__pyx_self, __pyx_v_dt, __pyx_v_gt, __pyx_v_pyiscrowd);
  3921. /* function exit code */
  3922. __Pyx_RefNannyFinishContext();
  3923. return __pyx_r;
  3924. }
  3925. /* "pycocotools/_mask.pyx":164
  3926. * # iou computation. support function overload (RLEs-RLEs and bbox-bbox).
  3927. * def iou( dt, gt, pyiscrowd ):
  3928. * def _preproc(objs): # <<<<<<<<<<<<<<
  3929. * if len(objs) == 0:
  3930. * return objs
  3931. */
  3932. /* Python wrapper */
  3933. static PyObject *__pyx_pw_11pycocotools_5_mask_3iou_1_preproc(PyObject *__pyx_self, PyObject *__pyx_v_objs); /*proto*/
  3934. static PyMethodDef __pyx_mdef_11pycocotools_5_mask_3iou_1_preproc = {"_preproc", (PyCFunction)__pyx_pw_11pycocotools_5_mask_3iou_1_preproc, METH_O, 0};
  3935. static PyObject *__pyx_pw_11pycocotools_5_mask_3iou_1_preproc(PyObject *__pyx_self, PyObject *__pyx_v_objs) {
  3936. PyObject *__pyx_r = 0;
  3937. __Pyx_RefNannyDeclarations
  3938. __Pyx_RefNannySetupContext("_preproc (wrapper)", 0);
  3939. __pyx_r = __pyx_pf_11pycocotools_5_mask_3iou__preproc(__pyx_self, ((PyObject *)__pyx_v_objs));
  3940. /* function exit code */
  3941. __Pyx_RefNannyFinishContext();
  3942. return __pyx_r;
  3943. }
  3944. static PyObject *__pyx_pf_11pycocotools_5_mask_3iou__preproc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objs) {
  3945. PyObject *__pyx_v_isbox = NULL;
  3946. PyObject *__pyx_v_isrle = NULL;
  3947. PyObject *__pyx_v_obj = NULL;
  3948. PyObject *__pyx_r = NULL;
  3949. __Pyx_RefNannyDeclarations
  3950. Py_ssize_t __pyx_t_1;
  3951. int __pyx_t_2;
  3952. PyObject *__pyx_t_3 = NULL;
  3953. PyObject *__pyx_t_4 = NULL;
  3954. PyObject *__pyx_t_5 = NULL;
  3955. PyObject *__pyx_t_6 = NULL;
  3956. int __pyx_t_7;
  3957. int __pyx_t_8;
  3958. PyObject *__pyx_t_9 = NULL;
  3959. PyObject *__pyx_t_10 = NULL;
  3960. PyObject *(*__pyx_t_11)(PyObject *);
  3961. PyObject *__pyx_t_12 = NULL;
  3962. Py_ssize_t __pyx_t_13;
  3963. PyObject *__pyx_t_14 = NULL;
  3964. __Pyx_RefNannySetupContext("_preproc", 0);
  3965. __Pyx_INCREF(__pyx_v_objs);
  3966. /* "pycocotools/_mask.pyx":165
  3967. * def iou( dt, gt, pyiscrowd ):
  3968. * def _preproc(objs):
  3969. * if len(objs) == 0: # <<<<<<<<<<<<<<
  3970. * return objs
  3971. * if type(objs) == np.ndarray:
  3972. */
  3973. __pyx_t_1 = PyObject_Length(__pyx_v_objs); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 165, __pyx_L1_error)
  3974. __pyx_t_2 = ((__pyx_t_1 == 0) != 0);
  3975. if (__pyx_t_2) {
  3976. /* "pycocotools/_mask.pyx":166
  3977. * def _preproc(objs):
  3978. * if len(objs) == 0:
  3979. * return objs # <<<<<<<<<<<<<<
  3980. * if type(objs) == np.ndarray:
  3981. * if len(objs.shape) == 1:
  3982. */
  3983. __Pyx_XDECREF(__pyx_r);
  3984. __Pyx_INCREF(__pyx_v_objs);
  3985. __pyx_r = __pyx_v_objs;
  3986. goto __pyx_L0;
  3987. /* "pycocotools/_mask.pyx":165
  3988. * def iou( dt, gt, pyiscrowd ):
  3989. * def _preproc(objs):
  3990. * if len(objs) == 0: # <<<<<<<<<<<<<<
  3991. * return objs
  3992. * if type(objs) == np.ndarray:
  3993. */
  3994. }
  3995. /* "pycocotools/_mask.pyx":167
  3996. * if len(objs) == 0:
  3997. * return objs
  3998. * if type(objs) == np.ndarray: # <<<<<<<<<<<<<<
  3999. * if len(objs.shape) == 1:
  4000. * objs = objs.reshape((objs[0], 1))
  4001. */
  4002. __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_objs)), ((PyObject *)__pyx_ptype_5numpy_ndarray), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L1_error)
  4003. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 167, __pyx_L1_error)
  4004. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4005. if (__pyx_t_2) {
  4006. /* "pycocotools/_mask.pyx":168
  4007. * return objs
  4008. * if type(objs) == np.ndarray:
  4009. * if len(objs.shape) == 1: # <<<<<<<<<<<<<<
  4010. * objs = objs.reshape((objs[0], 1))
  4011. * # check if it's Nx4 bbox
  4012. */
  4013. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_objs, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 168, __pyx_L1_error)
  4014. __Pyx_GOTREF(__pyx_t_3);
  4015. __pyx_t_1 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 168, __pyx_L1_error)
  4016. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4017. __pyx_t_2 = ((__pyx_t_1 == 1) != 0);
  4018. if (__pyx_t_2) {
  4019. /* "pycocotools/_mask.pyx":169
  4020. * if type(objs) == np.ndarray:
  4021. * if len(objs.shape) == 1:
  4022. * objs = objs.reshape((objs[0], 1)) # <<<<<<<<<<<<<<
  4023. * # check if it's Nx4 bbox
  4024. * if not len(objs.shape) == 2 or not objs.shape[1] == 4:
  4025. */
  4026. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_objs, __pyx_n_s_reshape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 169, __pyx_L1_error)
  4027. __Pyx_GOTREF(__pyx_t_4);
  4028. __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_objs, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 169, __pyx_L1_error)
  4029. __Pyx_GOTREF(__pyx_t_5);
  4030. __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 169, __pyx_L1_error)
  4031. __Pyx_GOTREF(__pyx_t_6);
  4032. __Pyx_GIVEREF(__pyx_t_5);
  4033. PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
  4034. __Pyx_INCREF(__pyx_int_1);
  4035. __Pyx_GIVEREF(__pyx_int_1);
  4036. PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_1);
  4037. __pyx_t_5 = 0;
  4038. __pyx_t_5 = NULL;
  4039. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  4040. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  4041. if (likely(__pyx_t_5)) {
  4042. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  4043. __Pyx_INCREF(__pyx_t_5);
  4044. __Pyx_INCREF(function);
  4045. __Pyx_DECREF_SET(__pyx_t_4, function);
  4046. }
  4047. }
  4048. __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6);
  4049. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4050. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4051. if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error)
  4052. __Pyx_GOTREF(__pyx_t_3);
  4053. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4054. __Pyx_DECREF_SET(__pyx_v_objs, __pyx_t_3);
  4055. __pyx_t_3 = 0;
  4056. /* "pycocotools/_mask.pyx":168
  4057. * return objs
  4058. * if type(objs) == np.ndarray:
  4059. * if len(objs.shape) == 1: # <<<<<<<<<<<<<<
  4060. * objs = objs.reshape((objs[0], 1))
  4061. * # check if it's Nx4 bbox
  4062. */
  4063. }
  4064. /* "pycocotools/_mask.pyx":171
  4065. * objs = objs.reshape((objs[0], 1))
  4066. * # check if it's Nx4 bbox
  4067. * if not len(objs.shape) == 2 or not objs.shape[1] == 4: # <<<<<<<<<<<<<<
  4068. * raise Exception('numpy ndarray input is only for *bounding boxes* and should have Nx4 dimension')
  4069. * objs = objs.astype(np.double)
  4070. */
  4071. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_objs, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 171, __pyx_L1_error)
  4072. __Pyx_GOTREF(__pyx_t_3);
  4073. __pyx_t_1 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 171, __pyx_L1_error)
  4074. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4075. __pyx_t_7 = ((!((__pyx_t_1 == 2) != 0)) != 0);
  4076. if (!__pyx_t_7) {
  4077. } else {
  4078. __pyx_t_2 = __pyx_t_7;
  4079. goto __pyx_L7_bool_binop_done;
  4080. }
  4081. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_objs, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 171, __pyx_L1_error)
  4082. __Pyx_GOTREF(__pyx_t_3);
  4083. __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 171, __pyx_L1_error)
  4084. __Pyx_GOTREF(__pyx_t_4);
  4085. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4086. __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_4, __pyx_int_4, 4, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 171, __pyx_L1_error)
  4087. __Pyx_GOTREF(__pyx_t_3);
  4088. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4089. __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 171, __pyx_L1_error)
  4090. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4091. __pyx_t_8 = ((!__pyx_t_7) != 0);
  4092. __pyx_t_2 = __pyx_t_8;
  4093. __pyx_L7_bool_binop_done:;
  4094. if (unlikely(__pyx_t_2)) {
  4095. /* "pycocotools/_mask.pyx":172
  4096. * # check if it's Nx4 bbox
  4097. * if not len(objs.shape) == 2 or not objs.shape[1] == 4:
  4098. * raise Exception('numpy ndarray input is only for *bounding boxes* and should have Nx4 dimension') # <<<<<<<<<<<<<<
  4099. * objs = objs.astype(np.double)
  4100. * elif type(objs) == list:
  4101. */
  4102. __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 172, __pyx_L1_error)
  4103. __Pyx_GOTREF(__pyx_t_3);
  4104. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  4105. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4106. __PYX_ERR(0, 172, __pyx_L1_error)
  4107. /* "pycocotools/_mask.pyx":171
  4108. * objs = objs.reshape((objs[0], 1))
  4109. * # check if it's Nx4 bbox
  4110. * if not len(objs.shape) == 2 or not objs.shape[1] == 4: # <<<<<<<<<<<<<<
  4111. * raise Exception('numpy ndarray input is only for *bounding boxes* and should have Nx4 dimension')
  4112. * objs = objs.astype(np.double)
  4113. */
  4114. }
  4115. /* "pycocotools/_mask.pyx":173
  4116. * if not len(objs.shape) == 2 or not objs.shape[1] == 4:
  4117. * raise Exception('numpy ndarray input is only for *bounding boxes* and should have Nx4 dimension')
  4118. * objs = objs.astype(np.double) # <<<<<<<<<<<<<<
  4119. * elif type(objs) == list:
  4120. * # check if list is in box format and convert it to np.ndarray
  4121. */
  4122. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_objs, __pyx_n_s_astype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 173, __pyx_L1_error)
  4123. __Pyx_GOTREF(__pyx_t_4);
  4124. __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 173, __pyx_L1_error)
  4125. __Pyx_GOTREF(__pyx_t_6);
  4126. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_double); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 173, __pyx_L1_error)
  4127. __Pyx_GOTREF(__pyx_t_5);
  4128. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4129. __pyx_t_6 = NULL;
  4130. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  4131. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
  4132. if (likely(__pyx_t_6)) {
  4133. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  4134. __Pyx_INCREF(__pyx_t_6);
  4135. __Pyx_INCREF(function);
  4136. __Pyx_DECREF_SET(__pyx_t_4, function);
  4137. }
  4138. }
  4139. __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5);
  4140. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  4141. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4142. if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 173, __pyx_L1_error)
  4143. __Pyx_GOTREF(__pyx_t_3);
  4144. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4145. __Pyx_DECREF_SET(__pyx_v_objs, __pyx_t_3);
  4146. __pyx_t_3 = 0;
  4147. /* "pycocotools/_mask.pyx":167
  4148. * if len(objs) == 0:
  4149. * return objs
  4150. * if type(objs) == np.ndarray: # <<<<<<<<<<<<<<
  4151. * if len(objs.shape) == 1:
  4152. * objs = objs.reshape((objs[0], 1))
  4153. */
  4154. goto __pyx_L4;
  4155. }
  4156. /* "pycocotools/_mask.pyx":174
  4157. * raise Exception('numpy ndarray input is only for *bounding boxes* and should have Nx4 dimension')
  4158. * objs = objs.astype(np.double)
  4159. * elif type(objs) == list: # <<<<<<<<<<<<<<
  4160. * # check if list is in box format and convert it to np.ndarray
  4161. * isbox = np.all(np.array([(len(obj)==4) and ((type(obj)==list) or (type(obj)==np.ndarray)) for obj in objs]))
  4162. */
  4163. __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_objs)), ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error)
  4164. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 174, __pyx_L1_error)
  4165. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4166. if (likely(__pyx_t_2)) {
  4167. /* "pycocotools/_mask.pyx":176
  4168. * elif type(objs) == list:
  4169. * # check if list is in box format and convert it to np.ndarray
  4170. * isbox = np.all(np.array([(len(obj)==4) and ((type(obj)==list) or (type(obj)==np.ndarray)) for obj in objs])) # <<<<<<<<<<<<<<
  4171. * isrle = np.all(np.array([type(obj) == dict for obj in objs]))
  4172. * if isbox:
  4173. */
  4174. __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 176, __pyx_L1_error)
  4175. __Pyx_GOTREF(__pyx_t_4);
  4176. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_all); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 176, __pyx_L1_error)
  4177. __Pyx_GOTREF(__pyx_t_5);
  4178. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4179. __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 176, __pyx_L1_error)
  4180. __Pyx_GOTREF(__pyx_t_6);
  4181. __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_array); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 176, __pyx_L1_error)
  4182. __Pyx_GOTREF(__pyx_t_9);
  4183. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4184. __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 176, __pyx_L1_error)
  4185. __Pyx_GOTREF(__pyx_t_6);
  4186. if (likely(PyList_CheckExact(__pyx_v_objs)) || PyTuple_CheckExact(__pyx_v_objs)) {
  4187. __pyx_t_10 = __pyx_v_objs; __Pyx_INCREF(__pyx_t_10); __pyx_t_1 = 0;
  4188. __pyx_t_11 = NULL;
  4189. } else {
  4190. __pyx_t_1 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_v_objs); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 176, __pyx_L1_error)
  4191. __Pyx_GOTREF(__pyx_t_10);
  4192. __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 176, __pyx_L1_error)
  4193. }
  4194. for (;;) {
  4195. if (likely(!__pyx_t_11)) {
  4196. if (likely(PyList_CheckExact(__pyx_t_10))) {
  4197. if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_10)) break;
  4198. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4199. __pyx_t_12 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_1); __Pyx_INCREF(__pyx_t_12); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 176, __pyx_L1_error)
  4200. #else
  4201. __pyx_t_12 = PySequence_ITEM(__pyx_t_10, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 176, __pyx_L1_error)
  4202. __Pyx_GOTREF(__pyx_t_12);
  4203. #endif
  4204. } else {
  4205. if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_10)) break;
  4206. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4207. __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_10, __pyx_t_1); __Pyx_INCREF(__pyx_t_12); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 176, __pyx_L1_error)
  4208. #else
  4209. __pyx_t_12 = PySequence_ITEM(__pyx_t_10, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 176, __pyx_L1_error)
  4210. __Pyx_GOTREF(__pyx_t_12);
  4211. #endif
  4212. }
  4213. } else {
  4214. __pyx_t_12 = __pyx_t_11(__pyx_t_10);
  4215. if (unlikely(!__pyx_t_12)) {
  4216. PyObject* exc_type = PyErr_Occurred();
  4217. if (exc_type) {
  4218. if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  4219. else __PYX_ERR(0, 176, __pyx_L1_error)
  4220. }
  4221. break;
  4222. }
  4223. __Pyx_GOTREF(__pyx_t_12);
  4224. }
  4225. __Pyx_XDECREF_SET(__pyx_v_obj, __pyx_t_12);
  4226. __pyx_t_12 = 0;
  4227. __pyx_t_13 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 176, __pyx_L1_error)
  4228. __pyx_t_2 = (__pyx_t_13 == 4);
  4229. if (__pyx_t_2) {
  4230. } else {
  4231. __pyx_t_14 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 176, __pyx_L1_error)
  4232. __Pyx_GOTREF(__pyx_t_14);
  4233. __pyx_t_12 = __pyx_t_14;
  4234. __pyx_t_14 = 0;
  4235. goto __pyx_L11_bool_binop_done;
  4236. }
  4237. __pyx_t_14 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_obj)), ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 176, __pyx_L1_error)
  4238. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 176, __pyx_L1_error)
  4239. if (!__pyx_t_2) {
  4240. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  4241. } else {
  4242. __Pyx_INCREF(__pyx_t_14);
  4243. __pyx_t_12 = __pyx_t_14;
  4244. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  4245. goto __pyx_L11_bool_binop_done;
  4246. }
  4247. __pyx_t_14 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_obj)), ((PyObject *)__pyx_ptype_5numpy_ndarray), Py_EQ); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 176, __pyx_L1_error)
  4248. __Pyx_INCREF(__pyx_t_14);
  4249. __pyx_t_12 = __pyx_t_14;
  4250. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  4251. __pyx_L11_bool_binop_done:;
  4252. if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_12))) __PYX_ERR(0, 176, __pyx_L1_error)
  4253. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4254. }
  4255. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  4256. __pyx_t_10 = NULL;
  4257. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
  4258. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
  4259. if (likely(__pyx_t_10)) {
  4260. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
  4261. __Pyx_INCREF(__pyx_t_10);
  4262. __Pyx_INCREF(function);
  4263. __Pyx_DECREF_SET(__pyx_t_9, function);
  4264. }
  4265. }
  4266. __pyx_t_4 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_6);
  4267. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  4268. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4269. if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 176, __pyx_L1_error)
  4270. __Pyx_GOTREF(__pyx_t_4);
  4271. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4272. __pyx_t_9 = NULL;
  4273. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
  4274. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5);
  4275. if (likely(__pyx_t_9)) {
  4276. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  4277. __Pyx_INCREF(__pyx_t_9);
  4278. __Pyx_INCREF(function);
  4279. __Pyx_DECREF_SET(__pyx_t_5, function);
  4280. }
  4281. }
  4282. __pyx_t_3 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_9, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4);
  4283. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  4284. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4285. if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error)
  4286. __Pyx_GOTREF(__pyx_t_3);
  4287. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4288. __pyx_v_isbox = __pyx_t_3;
  4289. __pyx_t_3 = 0;
  4290. /* "pycocotools/_mask.pyx":177
  4291. * # check if list is in box format and convert it to np.ndarray
  4292. * isbox = np.all(np.array([(len(obj)==4) and ((type(obj)==list) or (type(obj)==np.ndarray)) for obj in objs]))
  4293. * isrle = np.all(np.array([type(obj) == dict for obj in objs])) # <<<<<<<<<<<<<<
  4294. * if isbox:
  4295. * objs = np.array(objs, dtype=np.double)
  4296. */
  4297. __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 177, __pyx_L1_error)
  4298. __Pyx_GOTREF(__pyx_t_5);
  4299. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_all); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 177, __pyx_L1_error)
  4300. __Pyx_GOTREF(__pyx_t_4);
  4301. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4302. __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 177, __pyx_L1_error)
  4303. __Pyx_GOTREF(__pyx_t_9);
  4304. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_array); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 177, __pyx_L1_error)
  4305. __Pyx_GOTREF(__pyx_t_6);
  4306. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4307. __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 177, __pyx_L1_error)
  4308. __Pyx_GOTREF(__pyx_t_9);
  4309. if (likely(PyList_CheckExact(__pyx_v_objs)) || PyTuple_CheckExact(__pyx_v_objs)) {
  4310. __pyx_t_10 = __pyx_v_objs; __Pyx_INCREF(__pyx_t_10); __pyx_t_1 = 0;
  4311. __pyx_t_11 = NULL;
  4312. } else {
  4313. __pyx_t_1 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_v_objs); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 177, __pyx_L1_error)
  4314. __Pyx_GOTREF(__pyx_t_10);
  4315. __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 177, __pyx_L1_error)
  4316. }
  4317. for (;;) {
  4318. if (likely(!__pyx_t_11)) {
  4319. if (likely(PyList_CheckExact(__pyx_t_10))) {
  4320. if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_10)) break;
  4321. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4322. __pyx_t_12 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_1); __Pyx_INCREF(__pyx_t_12); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 177, __pyx_L1_error)
  4323. #else
  4324. __pyx_t_12 = PySequence_ITEM(__pyx_t_10, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 177, __pyx_L1_error)
  4325. __Pyx_GOTREF(__pyx_t_12);
  4326. #endif
  4327. } else {
  4328. if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_10)) break;
  4329. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4330. __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_10, __pyx_t_1); __Pyx_INCREF(__pyx_t_12); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 177, __pyx_L1_error)
  4331. #else
  4332. __pyx_t_12 = PySequence_ITEM(__pyx_t_10, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 177, __pyx_L1_error)
  4333. __Pyx_GOTREF(__pyx_t_12);
  4334. #endif
  4335. }
  4336. } else {
  4337. __pyx_t_12 = __pyx_t_11(__pyx_t_10);
  4338. if (unlikely(!__pyx_t_12)) {
  4339. PyObject* exc_type = PyErr_Occurred();
  4340. if (exc_type) {
  4341. if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  4342. else __PYX_ERR(0, 177, __pyx_L1_error)
  4343. }
  4344. break;
  4345. }
  4346. __Pyx_GOTREF(__pyx_t_12);
  4347. }
  4348. __Pyx_XDECREF_SET(__pyx_v_obj, __pyx_t_12);
  4349. __pyx_t_12 = 0;
  4350. __pyx_t_12 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_obj)), ((PyObject *)(&PyDict_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 177, __pyx_L1_error)
  4351. if (unlikely(__Pyx_ListComp_Append(__pyx_t_9, (PyObject*)__pyx_t_12))) __PYX_ERR(0, 177, __pyx_L1_error)
  4352. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4353. }
  4354. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  4355. __pyx_t_10 = NULL;
  4356. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
  4357. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
  4358. if (likely(__pyx_t_10)) {
  4359. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  4360. __Pyx_INCREF(__pyx_t_10);
  4361. __Pyx_INCREF(function);
  4362. __Pyx_DECREF_SET(__pyx_t_6, function);
  4363. }
  4364. }
  4365. __pyx_t_5 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_10, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_9);
  4366. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  4367. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4368. if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 177, __pyx_L1_error)
  4369. __Pyx_GOTREF(__pyx_t_5);
  4370. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4371. __pyx_t_6 = NULL;
  4372. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  4373. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
  4374. if (likely(__pyx_t_6)) {
  4375. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  4376. __Pyx_INCREF(__pyx_t_6);
  4377. __Pyx_INCREF(function);
  4378. __Pyx_DECREF_SET(__pyx_t_4, function);
  4379. }
  4380. }
  4381. __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5);
  4382. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  4383. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4384. if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error)
  4385. __Pyx_GOTREF(__pyx_t_3);
  4386. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4387. __pyx_v_isrle = __pyx_t_3;
  4388. __pyx_t_3 = 0;
  4389. /* "pycocotools/_mask.pyx":178
  4390. * isbox = np.all(np.array([(len(obj)==4) and ((type(obj)==list) or (type(obj)==np.ndarray)) for obj in objs]))
  4391. * isrle = np.all(np.array([type(obj) == dict for obj in objs]))
  4392. * if isbox: # <<<<<<<<<<<<<<
  4393. * objs = np.array(objs, dtype=np.double)
  4394. * if len(objs.shape) == 1:
  4395. */
  4396. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_isbox); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 178, __pyx_L1_error)
  4397. if (__pyx_t_2) {
  4398. /* "pycocotools/_mask.pyx":179
  4399. * isrle = np.all(np.array([type(obj) == dict for obj in objs]))
  4400. * if isbox:
  4401. * objs = np.array(objs, dtype=np.double) # <<<<<<<<<<<<<<
  4402. * if len(objs.shape) == 1:
  4403. * objs = objs.reshape((1,objs.shape[0]))
  4404. */
  4405. __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error)
  4406. __Pyx_GOTREF(__pyx_t_3);
  4407. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error)
  4408. __Pyx_GOTREF(__pyx_t_4);
  4409. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4410. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error)
  4411. __Pyx_GOTREF(__pyx_t_3);
  4412. __Pyx_INCREF(__pyx_v_objs);
  4413. __Pyx_GIVEREF(__pyx_v_objs);
  4414. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_objs);
  4415. __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 179, __pyx_L1_error)
  4416. __Pyx_GOTREF(__pyx_t_5);
  4417. __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 179, __pyx_L1_error)
  4418. __Pyx_GOTREF(__pyx_t_6);
  4419. __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_double); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 179, __pyx_L1_error)
  4420. __Pyx_GOTREF(__pyx_t_9);
  4421. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4422. if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_9) < 0) __PYX_ERR(0, 179, __pyx_L1_error)
  4423. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4424. __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 179, __pyx_L1_error)
  4425. __Pyx_GOTREF(__pyx_t_9);
  4426. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4427. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4428. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4429. __Pyx_DECREF_SET(__pyx_v_objs, __pyx_t_9);
  4430. __pyx_t_9 = 0;
  4431. /* "pycocotools/_mask.pyx":180
  4432. * if isbox:
  4433. * objs = np.array(objs, dtype=np.double)
  4434. * if len(objs.shape) == 1: # <<<<<<<<<<<<<<
  4435. * objs = objs.reshape((1,objs.shape[0]))
  4436. * elif isrle:
  4437. */
  4438. __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_objs, __pyx_n_s_shape); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 180, __pyx_L1_error)
  4439. __Pyx_GOTREF(__pyx_t_9);
  4440. __pyx_t_1 = PyObject_Length(__pyx_t_9); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 180, __pyx_L1_error)
  4441. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4442. __pyx_t_2 = ((__pyx_t_1 == 1) != 0);
  4443. if (__pyx_t_2) {
  4444. /* "pycocotools/_mask.pyx":181
  4445. * objs = np.array(objs, dtype=np.double)
  4446. * if len(objs.shape) == 1:
  4447. * objs = objs.reshape((1,objs.shape[0])) # <<<<<<<<<<<<<<
  4448. * elif isrle:
  4449. * objs = _frString(objs)
  4450. */
  4451. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_objs, __pyx_n_s_reshape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 181, __pyx_L1_error)
  4452. __Pyx_GOTREF(__pyx_t_5);
  4453. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_objs, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L1_error)
  4454. __Pyx_GOTREF(__pyx_t_3);
  4455. __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error)
  4456. __Pyx_GOTREF(__pyx_t_4);
  4457. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4458. __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L1_error)
  4459. __Pyx_GOTREF(__pyx_t_3);
  4460. __Pyx_INCREF(__pyx_int_1);
  4461. __Pyx_GIVEREF(__pyx_int_1);
  4462. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
  4463. __Pyx_GIVEREF(__pyx_t_4);
  4464. PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  4465. __pyx_t_4 = 0;
  4466. __pyx_t_4 = NULL;
  4467. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
  4468. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
  4469. if (likely(__pyx_t_4)) {
  4470. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  4471. __Pyx_INCREF(__pyx_t_4);
  4472. __Pyx_INCREF(function);
  4473. __Pyx_DECREF_SET(__pyx_t_5, function);
  4474. }
  4475. }
  4476. __pyx_t_9 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3);
  4477. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  4478. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4479. if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 181, __pyx_L1_error)
  4480. __Pyx_GOTREF(__pyx_t_9);
  4481. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4482. __Pyx_DECREF_SET(__pyx_v_objs, __pyx_t_9);
  4483. __pyx_t_9 = 0;
  4484. /* "pycocotools/_mask.pyx":180
  4485. * if isbox:
  4486. * objs = np.array(objs, dtype=np.double)
  4487. * if len(objs.shape) == 1: # <<<<<<<<<<<<<<
  4488. * objs = objs.reshape((1,objs.shape[0]))
  4489. * elif isrle:
  4490. */
  4491. }
  4492. /* "pycocotools/_mask.pyx":178
  4493. * isbox = np.all(np.array([(len(obj)==4) and ((type(obj)==list) or (type(obj)==np.ndarray)) for obj in objs]))
  4494. * isrle = np.all(np.array([type(obj) == dict for obj in objs]))
  4495. * if isbox: # <<<<<<<<<<<<<<
  4496. * objs = np.array(objs, dtype=np.double)
  4497. * if len(objs.shape) == 1:
  4498. */
  4499. goto __pyx_L16;
  4500. }
  4501. /* "pycocotools/_mask.pyx":182
  4502. * if len(objs.shape) == 1:
  4503. * objs = objs.reshape((1,objs.shape[0]))
  4504. * elif isrle: # <<<<<<<<<<<<<<
  4505. * objs = _frString(objs)
  4506. * else:
  4507. */
  4508. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_isrle); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 182, __pyx_L1_error)
  4509. if (likely(__pyx_t_2)) {
  4510. /* "pycocotools/_mask.pyx":183
  4511. * objs = objs.reshape((1,objs.shape[0]))
  4512. * elif isrle:
  4513. * objs = _frString(objs) # <<<<<<<<<<<<<<
  4514. * else:
  4515. * raise Exception('list input can be bounding box (Nx4) or RLEs ([RLE])')
  4516. */
  4517. __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_frString); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 183, __pyx_L1_error)
  4518. __Pyx_GOTREF(__pyx_t_5);
  4519. __pyx_t_3 = NULL;
  4520. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
  4521. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
  4522. if (likely(__pyx_t_3)) {
  4523. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
  4524. __Pyx_INCREF(__pyx_t_3);
  4525. __Pyx_INCREF(function);
  4526. __Pyx_DECREF_SET(__pyx_t_5, function);
  4527. }
  4528. }
  4529. __pyx_t_9 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_3, __pyx_v_objs) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_objs);
  4530. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  4531. if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 183, __pyx_L1_error)
  4532. __Pyx_GOTREF(__pyx_t_9);
  4533. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4534. __Pyx_DECREF_SET(__pyx_v_objs, __pyx_t_9);
  4535. __pyx_t_9 = 0;
  4536. /* "pycocotools/_mask.pyx":182
  4537. * if len(objs.shape) == 1:
  4538. * objs = objs.reshape((1,objs.shape[0]))
  4539. * elif isrle: # <<<<<<<<<<<<<<
  4540. * objs = _frString(objs)
  4541. * else:
  4542. */
  4543. goto __pyx_L16;
  4544. }
  4545. /* "pycocotools/_mask.pyx":185
  4546. * objs = _frString(objs)
  4547. * else:
  4548. * raise Exception('list input can be bounding box (Nx4) or RLEs ([RLE])') # <<<<<<<<<<<<<<
  4549. * else:
  4550. * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.')
  4551. */
  4552. /*else*/ {
  4553. __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 185, __pyx_L1_error)
  4554. __Pyx_GOTREF(__pyx_t_9);
  4555. __Pyx_Raise(__pyx_t_9, 0, 0, 0);
  4556. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4557. __PYX_ERR(0, 185, __pyx_L1_error)
  4558. }
  4559. __pyx_L16:;
  4560. /* "pycocotools/_mask.pyx":174
  4561. * raise Exception('numpy ndarray input is only for *bounding boxes* and should have Nx4 dimension')
  4562. * objs = objs.astype(np.double)
  4563. * elif type(objs) == list: # <<<<<<<<<<<<<<
  4564. * # check if list is in box format and convert it to np.ndarray
  4565. * isbox = np.all(np.array([(len(obj)==4) and ((type(obj)==list) or (type(obj)==np.ndarray)) for obj in objs]))
  4566. */
  4567. goto __pyx_L4;
  4568. }
  4569. /* "pycocotools/_mask.pyx":187
  4570. * raise Exception('list input can be bounding box (Nx4) or RLEs ([RLE])')
  4571. * else:
  4572. * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.') # <<<<<<<<<<<<<<
  4573. * return objs
  4574. * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  4575. */
  4576. /*else*/ {
  4577. __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 187, __pyx_L1_error)
  4578. __Pyx_GOTREF(__pyx_t_9);
  4579. __Pyx_Raise(__pyx_t_9, 0, 0, 0);
  4580. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4581. __PYX_ERR(0, 187, __pyx_L1_error)
  4582. }
  4583. __pyx_L4:;
  4584. /* "pycocotools/_mask.pyx":188
  4585. * else:
  4586. * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.')
  4587. * return objs # <<<<<<<<<<<<<<
  4588. * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  4589. * rleIou( <RLE*> dt._R, <RLE*> gt._R, m, n, <byte*> iscrowd.data, <double*> _iou.data )
  4590. */
  4591. __Pyx_XDECREF(__pyx_r);
  4592. __Pyx_INCREF(__pyx_v_objs);
  4593. __pyx_r = __pyx_v_objs;
  4594. goto __pyx_L0;
  4595. /* "pycocotools/_mask.pyx":164
  4596. * # iou computation. support function overload (RLEs-RLEs and bbox-bbox).
  4597. * def iou( dt, gt, pyiscrowd ):
  4598. * def _preproc(objs): # <<<<<<<<<<<<<<
  4599. * if len(objs) == 0:
  4600. * return objs
  4601. */
  4602. /* function exit code */
  4603. __pyx_L1_error:;
  4604. __Pyx_XDECREF(__pyx_t_3);
  4605. __Pyx_XDECREF(__pyx_t_4);
  4606. __Pyx_XDECREF(__pyx_t_5);
  4607. __Pyx_XDECREF(__pyx_t_6);
  4608. __Pyx_XDECREF(__pyx_t_9);
  4609. __Pyx_XDECREF(__pyx_t_10);
  4610. __Pyx_XDECREF(__pyx_t_12);
  4611. __Pyx_XDECREF(__pyx_t_14);
  4612. __Pyx_AddTraceback("pycocotools._mask.iou._preproc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4613. __pyx_r = NULL;
  4614. __pyx_L0:;
  4615. __Pyx_XDECREF(__pyx_v_isbox);
  4616. __Pyx_XDECREF(__pyx_v_isrle);
  4617. __Pyx_XDECREF(__pyx_v_obj);
  4618. __Pyx_XDECREF(__pyx_v_objs);
  4619. __Pyx_XGIVEREF(__pyx_r);
  4620. __Pyx_RefNannyFinishContext();
  4621. return __pyx_r;
  4622. }
  4623. /* "pycocotools/_mask.pyx":189
  4624. * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.')
  4625. * return objs
  4626. * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): # <<<<<<<<<<<<<<
  4627. * rleIou( <RLE*> dt._R, <RLE*> gt._R, m, n, <byte*> iscrowd.data, <double*> _iou.data )
  4628. * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  4629. */
  4630. /* Python wrapper */
  4631. static PyObject *__pyx_pw_11pycocotools_5_mask_3iou_3_rleIou(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  4632. static PyMethodDef __pyx_mdef_11pycocotools_5_mask_3iou_3_rleIou = {"_rleIou", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pycocotools_5_mask_3iou_3_rleIou, METH_VARARGS|METH_KEYWORDS, 0};
  4633. static PyObject *__pyx_pw_11pycocotools_5_mask_3iou_3_rleIou(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  4634. struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_dt = 0;
  4635. struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_gt = 0;
  4636. PyArrayObject *__pyx_v_iscrowd = 0;
  4637. siz __pyx_v_m;
  4638. siz __pyx_v_n;
  4639. PyArrayObject *__pyx_v__iou = 0;
  4640. PyObject *__pyx_r = 0;
  4641. __Pyx_RefNannyDeclarations
  4642. __Pyx_RefNannySetupContext("_rleIou (wrapper)", 0);
  4643. {
  4644. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dt,&__pyx_n_s_gt,&__pyx_n_s_iscrowd,&__pyx_n_s_m,&__pyx_n_s_n,&__pyx_n_s_iou,0};
  4645. PyObject* values[6] = {0,0,0,0,0,0};
  4646. if (unlikely(__pyx_kwds)) {
  4647. Py_ssize_t kw_args;
  4648. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  4649. switch (pos_args) {
  4650. case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
  4651. CYTHON_FALLTHROUGH;
  4652. case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
  4653. CYTHON_FALLTHROUGH;
  4654. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  4655. CYTHON_FALLTHROUGH;
  4656. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  4657. CYTHON_FALLTHROUGH;
  4658. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  4659. CYTHON_FALLTHROUGH;
  4660. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  4661. CYTHON_FALLTHROUGH;
  4662. case 0: break;
  4663. default: goto __pyx_L5_argtuple_error;
  4664. }
  4665. kw_args = PyDict_Size(__pyx_kwds);
  4666. switch (pos_args) {
  4667. case 0:
  4668. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dt)) != 0)) kw_args--;
  4669. else goto __pyx_L5_argtuple_error;
  4670. CYTHON_FALLTHROUGH;
  4671. case 1:
  4672. if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gt)) != 0)) kw_args--;
  4673. else {
  4674. __Pyx_RaiseArgtupleInvalid("_rleIou", 1, 6, 6, 1); __PYX_ERR(0, 189, __pyx_L3_error)
  4675. }
  4676. CYTHON_FALLTHROUGH;
  4677. case 2:
  4678. if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_iscrowd)) != 0)) kw_args--;
  4679. else {
  4680. __Pyx_RaiseArgtupleInvalid("_rleIou", 1, 6, 6, 2); __PYX_ERR(0, 189, __pyx_L3_error)
  4681. }
  4682. CYTHON_FALLTHROUGH;
  4683. case 3:
  4684. if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--;
  4685. else {
  4686. __Pyx_RaiseArgtupleInvalid("_rleIou", 1, 6, 6, 3); __PYX_ERR(0, 189, __pyx_L3_error)
  4687. }
  4688. CYTHON_FALLTHROUGH;
  4689. case 4:
  4690. if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--;
  4691. else {
  4692. __Pyx_RaiseArgtupleInvalid("_rleIou", 1, 6, 6, 4); __PYX_ERR(0, 189, __pyx_L3_error)
  4693. }
  4694. CYTHON_FALLTHROUGH;
  4695. case 5:
  4696. if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_iou)) != 0)) kw_args--;
  4697. else {
  4698. __Pyx_RaiseArgtupleInvalid("_rleIou", 1, 6, 6, 5); __PYX_ERR(0, 189, __pyx_L3_error)
  4699. }
  4700. }
  4701. if (unlikely(kw_args > 0)) {
  4702. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_rleIou") < 0)) __PYX_ERR(0, 189, __pyx_L3_error)
  4703. }
  4704. } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
  4705. goto __pyx_L5_argtuple_error;
  4706. } else {
  4707. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  4708. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  4709. values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  4710. values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  4711. values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
  4712. values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
  4713. }
  4714. __pyx_v_dt = ((struct __pyx_obj_11pycocotools_5_mask_RLEs *)values[0]);
  4715. __pyx_v_gt = ((struct __pyx_obj_11pycocotools_5_mask_RLEs *)values[1]);
  4716. __pyx_v_iscrowd = ((PyArrayObject *)values[2]);
  4717. __pyx_v_m = __Pyx_PyInt_As_siz(values[3]); if (unlikely((__pyx_v_m == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 189, __pyx_L3_error)
  4718. __pyx_v_n = __Pyx_PyInt_As_siz(values[4]); if (unlikely((__pyx_v_n == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 189, __pyx_L3_error)
  4719. __pyx_v__iou = ((PyArrayObject *)values[5]);
  4720. }
  4721. goto __pyx_L4_argument_unpacking_done;
  4722. __pyx_L5_argtuple_error:;
  4723. __Pyx_RaiseArgtupleInvalid("_rleIou", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 189, __pyx_L3_error)
  4724. __pyx_L3_error:;
  4725. __Pyx_AddTraceback("pycocotools._mask.iou._rleIou", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4726. __Pyx_RefNannyFinishContext();
  4727. return NULL;
  4728. __pyx_L4_argument_unpacking_done:;
  4729. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dt), __pyx_ptype_11pycocotools_5_mask_RLEs, 1, "dt", 0))) __PYX_ERR(0, 189, __pyx_L1_error)
  4730. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_gt), __pyx_ptype_11pycocotools_5_mask_RLEs, 1, "gt", 0))) __PYX_ERR(0, 189, __pyx_L1_error)
  4731. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iscrowd), __pyx_ptype_5numpy_ndarray, 1, "iscrowd", 0))) __PYX_ERR(0, 189, __pyx_L1_error)
  4732. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__iou), __pyx_ptype_5numpy_ndarray, 1, "_iou", 0))) __PYX_ERR(0, 189, __pyx_L1_error)
  4733. __pyx_r = __pyx_pf_11pycocotools_5_mask_3iou_2_rleIou(__pyx_self, __pyx_v_dt, __pyx_v_gt, __pyx_v_iscrowd, __pyx_v_m, __pyx_v_n, __pyx_v__iou);
  4734. /* function exit code */
  4735. goto __pyx_L0;
  4736. __pyx_L1_error:;
  4737. __pyx_r = NULL;
  4738. __pyx_L0:;
  4739. __Pyx_RefNannyFinishContext();
  4740. return __pyx_r;
  4741. }
  4742. static PyObject *__pyx_pf_11pycocotools_5_mask_3iou_2_rleIou(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_dt, struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_gt, PyArrayObject *__pyx_v_iscrowd, siz __pyx_v_m, siz __pyx_v_n, PyArrayObject *__pyx_v__iou) {
  4743. __Pyx_LocalBuf_ND __pyx_pybuffernd__iou;
  4744. __Pyx_Buffer __pyx_pybuffer__iou;
  4745. __Pyx_LocalBuf_ND __pyx_pybuffernd_iscrowd;
  4746. __Pyx_Buffer __pyx_pybuffer_iscrowd;
  4747. PyObject *__pyx_r = NULL;
  4748. __Pyx_RefNannyDeclarations
  4749. __Pyx_RefNannySetupContext("_rleIou", 0);
  4750. __pyx_pybuffer_iscrowd.pybuffer.buf = NULL;
  4751. __pyx_pybuffer_iscrowd.refcount = 0;
  4752. __pyx_pybuffernd_iscrowd.data = NULL;
  4753. __pyx_pybuffernd_iscrowd.rcbuffer = &__pyx_pybuffer_iscrowd;
  4754. __pyx_pybuffer__iou.pybuffer.buf = NULL;
  4755. __pyx_pybuffer__iou.refcount = 0;
  4756. __pyx_pybuffernd__iou.data = NULL;
  4757. __pyx_pybuffernd__iou.rcbuffer = &__pyx_pybuffer__iou;
  4758. {
  4759. __Pyx_BufFmt_StackElem __pyx_stack[1];
  4760. if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer, (PyObject*)__pyx_v_iscrowd, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 189, __pyx_L1_error)
  4761. }
  4762. __pyx_pybuffernd_iscrowd.diminfo[0].strides = __pyx_pybuffernd_iscrowd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_iscrowd.diminfo[0].shape = __pyx_pybuffernd_iscrowd.rcbuffer->pybuffer.shape[0];
  4763. {
  4764. __Pyx_BufFmt_StackElem __pyx_stack[1];
  4765. if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd__iou.rcbuffer->pybuffer, (PyObject*)__pyx_v__iou, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 189, __pyx_L1_error)
  4766. }
  4767. __pyx_pybuffernd__iou.diminfo[0].strides = __pyx_pybuffernd__iou.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd__iou.diminfo[0].shape = __pyx_pybuffernd__iou.rcbuffer->pybuffer.shape[0];
  4768. /* "pycocotools/_mask.pyx":190
  4769. * return objs
  4770. * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  4771. * rleIou( <RLE*> dt._R, <RLE*> gt._R, m, n, <byte*> iscrowd.data, <double*> _iou.data ) # <<<<<<<<<<<<<<
  4772. * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  4773. * bbIou( <BB> dt.data, <BB> gt.data, m, n, <byte*> iscrowd.data, <double*>_iou.data )
  4774. */
  4775. rleIou(((RLE *)__pyx_v_dt->_R), ((RLE *)__pyx_v_gt->_R), __pyx_v_m, __pyx_v_n, ((byte *)__pyx_v_iscrowd->data), ((double *)__pyx_v__iou->data));
  4776. /* "pycocotools/_mask.pyx":189
  4777. * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.')
  4778. * return objs
  4779. * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): # <<<<<<<<<<<<<<
  4780. * rleIou( <RLE*> dt._R, <RLE*> gt._R, m, n, <byte*> iscrowd.data, <double*> _iou.data )
  4781. * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  4782. */
  4783. /* function exit code */
  4784. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4785. goto __pyx_L0;
  4786. __pyx_L1_error:;
  4787. { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
  4788. __Pyx_PyThreadState_declare
  4789. __Pyx_PyThreadState_assign
  4790. __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
  4791. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__iou.rcbuffer->pybuffer);
  4792. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer);
  4793. __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  4794. __Pyx_AddTraceback("pycocotools._mask.iou._rleIou", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4795. __pyx_r = NULL;
  4796. goto __pyx_L2;
  4797. __pyx_L0:;
  4798. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__iou.rcbuffer->pybuffer);
  4799. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer);
  4800. __pyx_L2:;
  4801. __Pyx_XGIVEREF(__pyx_r);
  4802. __Pyx_RefNannyFinishContext();
  4803. return __pyx_r;
  4804. }
  4805. /* "pycocotools/_mask.pyx":191
  4806. * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  4807. * rleIou( <RLE*> dt._R, <RLE*> gt._R, m, n, <byte*> iscrowd.data, <double*> _iou.data )
  4808. * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): # <<<<<<<<<<<<<<
  4809. * bbIou( <BB> dt.data, <BB> gt.data, m, n, <byte*> iscrowd.data, <double*>_iou.data )
  4810. * def _len(obj):
  4811. */
  4812. /* Python wrapper */
  4813. static PyObject *__pyx_pw_11pycocotools_5_mask_3iou_5_bbIou(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  4814. static PyMethodDef __pyx_mdef_11pycocotools_5_mask_3iou_5_bbIou = {"_bbIou", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pycocotools_5_mask_3iou_5_bbIou, METH_VARARGS|METH_KEYWORDS, 0};
  4815. static PyObject *__pyx_pw_11pycocotools_5_mask_3iou_5_bbIou(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  4816. PyArrayObject *__pyx_v_dt = 0;
  4817. PyArrayObject *__pyx_v_gt = 0;
  4818. PyArrayObject *__pyx_v_iscrowd = 0;
  4819. siz __pyx_v_m;
  4820. siz __pyx_v_n;
  4821. PyArrayObject *__pyx_v__iou = 0;
  4822. PyObject *__pyx_r = 0;
  4823. __Pyx_RefNannyDeclarations
  4824. __Pyx_RefNannySetupContext("_bbIou (wrapper)", 0);
  4825. {
  4826. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dt,&__pyx_n_s_gt,&__pyx_n_s_iscrowd,&__pyx_n_s_m,&__pyx_n_s_n,&__pyx_n_s_iou,0};
  4827. PyObject* values[6] = {0,0,0,0,0,0};
  4828. if (unlikely(__pyx_kwds)) {
  4829. Py_ssize_t kw_args;
  4830. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  4831. switch (pos_args) {
  4832. case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
  4833. CYTHON_FALLTHROUGH;
  4834. case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
  4835. CYTHON_FALLTHROUGH;
  4836. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  4837. CYTHON_FALLTHROUGH;
  4838. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  4839. CYTHON_FALLTHROUGH;
  4840. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  4841. CYTHON_FALLTHROUGH;
  4842. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  4843. CYTHON_FALLTHROUGH;
  4844. case 0: break;
  4845. default: goto __pyx_L5_argtuple_error;
  4846. }
  4847. kw_args = PyDict_Size(__pyx_kwds);
  4848. switch (pos_args) {
  4849. case 0:
  4850. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dt)) != 0)) kw_args--;
  4851. else goto __pyx_L5_argtuple_error;
  4852. CYTHON_FALLTHROUGH;
  4853. case 1:
  4854. if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gt)) != 0)) kw_args--;
  4855. else {
  4856. __Pyx_RaiseArgtupleInvalid("_bbIou", 1, 6, 6, 1); __PYX_ERR(0, 191, __pyx_L3_error)
  4857. }
  4858. CYTHON_FALLTHROUGH;
  4859. case 2:
  4860. if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_iscrowd)) != 0)) kw_args--;
  4861. else {
  4862. __Pyx_RaiseArgtupleInvalid("_bbIou", 1, 6, 6, 2); __PYX_ERR(0, 191, __pyx_L3_error)
  4863. }
  4864. CYTHON_FALLTHROUGH;
  4865. case 3:
  4866. if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--;
  4867. else {
  4868. __Pyx_RaiseArgtupleInvalid("_bbIou", 1, 6, 6, 3); __PYX_ERR(0, 191, __pyx_L3_error)
  4869. }
  4870. CYTHON_FALLTHROUGH;
  4871. case 4:
  4872. if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--;
  4873. else {
  4874. __Pyx_RaiseArgtupleInvalid("_bbIou", 1, 6, 6, 4); __PYX_ERR(0, 191, __pyx_L3_error)
  4875. }
  4876. CYTHON_FALLTHROUGH;
  4877. case 5:
  4878. if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_iou)) != 0)) kw_args--;
  4879. else {
  4880. __Pyx_RaiseArgtupleInvalid("_bbIou", 1, 6, 6, 5); __PYX_ERR(0, 191, __pyx_L3_error)
  4881. }
  4882. }
  4883. if (unlikely(kw_args > 0)) {
  4884. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_bbIou") < 0)) __PYX_ERR(0, 191, __pyx_L3_error)
  4885. }
  4886. } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
  4887. goto __pyx_L5_argtuple_error;
  4888. } else {
  4889. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  4890. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  4891. values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  4892. values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  4893. values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
  4894. values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
  4895. }
  4896. __pyx_v_dt = ((PyArrayObject *)values[0]);
  4897. __pyx_v_gt = ((PyArrayObject *)values[1]);
  4898. __pyx_v_iscrowd = ((PyArrayObject *)values[2]);
  4899. __pyx_v_m = __Pyx_PyInt_As_siz(values[3]); if (unlikely((__pyx_v_m == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 191, __pyx_L3_error)
  4900. __pyx_v_n = __Pyx_PyInt_As_siz(values[4]); if (unlikely((__pyx_v_n == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 191, __pyx_L3_error)
  4901. __pyx_v__iou = ((PyArrayObject *)values[5]);
  4902. }
  4903. goto __pyx_L4_argument_unpacking_done;
  4904. __pyx_L5_argtuple_error:;
  4905. __Pyx_RaiseArgtupleInvalid("_bbIou", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 191, __pyx_L3_error)
  4906. __pyx_L3_error:;
  4907. __Pyx_AddTraceback("pycocotools._mask.iou._bbIou", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4908. __Pyx_RefNannyFinishContext();
  4909. return NULL;
  4910. __pyx_L4_argument_unpacking_done:;
  4911. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dt), __pyx_ptype_5numpy_ndarray, 1, "dt", 0))) __PYX_ERR(0, 191, __pyx_L1_error)
  4912. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_gt), __pyx_ptype_5numpy_ndarray, 1, "gt", 0))) __PYX_ERR(0, 191, __pyx_L1_error)
  4913. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iscrowd), __pyx_ptype_5numpy_ndarray, 1, "iscrowd", 0))) __PYX_ERR(0, 191, __pyx_L1_error)
  4914. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v__iou), __pyx_ptype_5numpy_ndarray, 1, "_iou", 0))) __PYX_ERR(0, 191, __pyx_L1_error)
  4915. __pyx_r = __pyx_pf_11pycocotools_5_mask_3iou_4_bbIou(__pyx_self, __pyx_v_dt, __pyx_v_gt, __pyx_v_iscrowd, __pyx_v_m, __pyx_v_n, __pyx_v__iou);
  4916. /* function exit code */
  4917. goto __pyx_L0;
  4918. __pyx_L1_error:;
  4919. __pyx_r = NULL;
  4920. __pyx_L0:;
  4921. __Pyx_RefNannyFinishContext();
  4922. return __pyx_r;
  4923. }
  4924. static PyObject *__pyx_pf_11pycocotools_5_mask_3iou_4_bbIou(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_dt, PyArrayObject *__pyx_v_gt, PyArrayObject *__pyx_v_iscrowd, siz __pyx_v_m, siz __pyx_v_n, PyArrayObject *__pyx_v__iou) {
  4925. __Pyx_LocalBuf_ND __pyx_pybuffernd__iou;
  4926. __Pyx_Buffer __pyx_pybuffer__iou;
  4927. __Pyx_LocalBuf_ND __pyx_pybuffernd_dt;
  4928. __Pyx_Buffer __pyx_pybuffer_dt;
  4929. __Pyx_LocalBuf_ND __pyx_pybuffernd_gt;
  4930. __Pyx_Buffer __pyx_pybuffer_gt;
  4931. __Pyx_LocalBuf_ND __pyx_pybuffernd_iscrowd;
  4932. __Pyx_Buffer __pyx_pybuffer_iscrowd;
  4933. PyObject *__pyx_r = NULL;
  4934. __Pyx_RefNannyDeclarations
  4935. __Pyx_RefNannySetupContext("_bbIou", 0);
  4936. __pyx_pybuffer_dt.pybuffer.buf = NULL;
  4937. __pyx_pybuffer_dt.refcount = 0;
  4938. __pyx_pybuffernd_dt.data = NULL;
  4939. __pyx_pybuffernd_dt.rcbuffer = &__pyx_pybuffer_dt;
  4940. __pyx_pybuffer_gt.pybuffer.buf = NULL;
  4941. __pyx_pybuffer_gt.refcount = 0;
  4942. __pyx_pybuffernd_gt.data = NULL;
  4943. __pyx_pybuffernd_gt.rcbuffer = &__pyx_pybuffer_gt;
  4944. __pyx_pybuffer_iscrowd.pybuffer.buf = NULL;
  4945. __pyx_pybuffer_iscrowd.refcount = 0;
  4946. __pyx_pybuffernd_iscrowd.data = NULL;
  4947. __pyx_pybuffernd_iscrowd.rcbuffer = &__pyx_pybuffer_iscrowd;
  4948. __pyx_pybuffer__iou.pybuffer.buf = NULL;
  4949. __pyx_pybuffer__iou.refcount = 0;
  4950. __pyx_pybuffernd__iou.data = NULL;
  4951. __pyx_pybuffernd__iou.rcbuffer = &__pyx_pybuffer__iou;
  4952. {
  4953. __Pyx_BufFmt_StackElem __pyx_stack[1];
  4954. if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dt.rcbuffer->pybuffer, (PyObject*)__pyx_v_dt, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 191, __pyx_L1_error)
  4955. }
  4956. __pyx_pybuffernd_dt.diminfo[0].strides = __pyx_pybuffernd_dt.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dt.diminfo[0].shape = __pyx_pybuffernd_dt.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dt.diminfo[1].strides = __pyx_pybuffernd_dt.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dt.diminfo[1].shape = __pyx_pybuffernd_dt.rcbuffer->pybuffer.shape[1];
  4957. {
  4958. __Pyx_BufFmt_StackElem __pyx_stack[1];
  4959. if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_gt.rcbuffer->pybuffer, (PyObject*)__pyx_v_gt, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 191, __pyx_L1_error)
  4960. }
  4961. __pyx_pybuffernd_gt.diminfo[0].strides = __pyx_pybuffernd_gt.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_gt.diminfo[0].shape = __pyx_pybuffernd_gt.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_gt.diminfo[1].strides = __pyx_pybuffernd_gt.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_gt.diminfo[1].shape = __pyx_pybuffernd_gt.rcbuffer->pybuffer.shape[1];
  4962. {
  4963. __Pyx_BufFmt_StackElem __pyx_stack[1];
  4964. if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer, (PyObject*)__pyx_v_iscrowd, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 191, __pyx_L1_error)
  4965. }
  4966. __pyx_pybuffernd_iscrowd.diminfo[0].strides = __pyx_pybuffernd_iscrowd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_iscrowd.diminfo[0].shape = __pyx_pybuffernd_iscrowd.rcbuffer->pybuffer.shape[0];
  4967. {
  4968. __Pyx_BufFmt_StackElem __pyx_stack[1];
  4969. if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd__iou.rcbuffer->pybuffer, (PyObject*)__pyx_v__iou, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 191, __pyx_L1_error)
  4970. }
  4971. __pyx_pybuffernd__iou.diminfo[0].strides = __pyx_pybuffernd__iou.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd__iou.diminfo[0].shape = __pyx_pybuffernd__iou.rcbuffer->pybuffer.shape[0];
  4972. /* "pycocotools/_mask.pyx":192
  4973. * rleIou( <RLE*> dt._R, <RLE*> gt._R, m, n, <byte*> iscrowd.data, <double*> _iou.data )
  4974. * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  4975. * bbIou( <BB> dt.data, <BB> gt.data, m, n, <byte*> iscrowd.data, <double*>_iou.data ) # <<<<<<<<<<<<<<
  4976. * def _len(obj):
  4977. * cdef siz N = 0
  4978. */
  4979. bbIou(((BB)__pyx_v_dt->data), ((BB)__pyx_v_gt->data), __pyx_v_m, __pyx_v_n, ((byte *)__pyx_v_iscrowd->data), ((double *)__pyx_v__iou->data));
  4980. /* "pycocotools/_mask.pyx":191
  4981. * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  4982. * rleIou( <RLE*> dt._R, <RLE*> gt._R, m, n, <byte*> iscrowd.data, <double*> _iou.data )
  4983. * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): # <<<<<<<<<<<<<<
  4984. * bbIou( <BB> dt.data, <BB> gt.data, m, n, <byte*> iscrowd.data, <double*>_iou.data )
  4985. * def _len(obj):
  4986. */
  4987. /* function exit code */
  4988. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4989. goto __pyx_L0;
  4990. __pyx_L1_error:;
  4991. { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
  4992. __Pyx_PyThreadState_declare
  4993. __Pyx_PyThreadState_assign
  4994. __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
  4995. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__iou.rcbuffer->pybuffer);
  4996. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dt.rcbuffer->pybuffer);
  4997. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_gt.rcbuffer->pybuffer);
  4998. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer);
  4999. __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  5000. __Pyx_AddTraceback("pycocotools._mask.iou._bbIou", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5001. __pyx_r = NULL;
  5002. goto __pyx_L2;
  5003. __pyx_L0:;
  5004. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__iou.rcbuffer->pybuffer);
  5005. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dt.rcbuffer->pybuffer);
  5006. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_gt.rcbuffer->pybuffer);
  5007. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer);
  5008. __pyx_L2:;
  5009. __Pyx_XGIVEREF(__pyx_r);
  5010. __Pyx_RefNannyFinishContext();
  5011. return __pyx_r;
  5012. }
  5013. /* "pycocotools/_mask.pyx":193
  5014. * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  5015. * bbIou( <BB> dt.data, <BB> gt.data, m, n, <byte*> iscrowd.data, <double*>_iou.data )
  5016. * def _len(obj): # <<<<<<<<<<<<<<
  5017. * cdef siz N = 0
  5018. * if type(obj) == RLEs:
  5019. */
  5020. /* Python wrapper */
  5021. static PyObject *__pyx_pw_11pycocotools_5_mask_3iou_7_len(PyObject *__pyx_self, PyObject *__pyx_v_obj); /*proto*/
  5022. static PyMethodDef __pyx_mdef_11pycocotools_5_mask_3iou_7_len = {"_len", (PyCFunction)__pyx_pw_11pycocotools_5_mask_3iou_7_len, METH_O, 0};
  5023. static PyObject *__pyx_pw_11pycocotools_5_mask_3iou_7_len(PyObject *__pyx_self, PyObject *__pyx_v_obj) {
  5024. PyObject *__pyx_r = 0;
  5025. __Pyx_RefNannyDeclarations
  5026. __Pyx_RefNannySetupContext("_len (wrapper)", 0);
  5027. __pyx_r = __pyx_pf_11pycocotools_5_mask_3iou_6_len(__pyx_self, ((PyObject *)__pyx_v_obj));
  5028. /* function exit code */
  5029. __Pyx_RefNannyFinishContext();
  5030. return __pyx_r;
  5031. }
  5032. static PyObject *__pyx_pf_11pycocotools_5_mask_3iou_6_len(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) {
  5033. siz __pyx_v_N;
  5034. PyObject *__pyx_r = NULL;
  5035. __Pyx_RefNannyDeclarations
  5036. PyObject *__pyx_t_1 = NULL;
  5037. int __pyx_t_2;
  5038. siz __pyx_t_3;
  5039. Py_ssize_t __pyx_t_4;
  5040. PyObject *__pyx_t_5 = NULL;
  5041. __Pyx_RefNannySetupContext("_len", 0);
  5042. /* "pycocotools/_mask.pyx":194
  5043. * bbIou( <BB> dt.data, <BB> gt.data, m, n, <byte*> iscrowd.data, <double*>_iou.data )
  5044. * def _len(obj):
  5045. * cdef siz N = 0 # <<<<<<<<<<<<<<
  5046. * if type(obj) == RLEs:
  5047. * N = obj.n
  5048. */
  5049. __pyx_v_N = 0;
  5050. /* "pycocotools/_mask.pyx":195
  5051. * def _len(obj):
  5052. * cdef siz N = 0
  5053. * if type(obj) == RLEs: # <<<<<<<<<<<<<<
  5054. * N = obj.n
  5055. * elif len(obj)==0:
  5056. */
  5057. __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_obj)), ((PyObject *)__pyx_ptype_11pycocotools_5_mask_RLEs), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error)
  5058. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 195, __pyx_L1_error)
  5059. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5060. if (__pyx_t_2) {
  5061. /* "pycocotools/_mask.pyx":196
  5062. * cdef siz N = 0
  5063. * if type(obj) == RLEs:
  5064. * N = obj.n # <<<<<<<<<<<<<<
  5065. * elif len(obj)==0:
  5066. * pass
  5067. */
  5068. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error)
  5069. __Pyx_GOTREF(__pyx_t_1);
  5070. __pyx_t_3 = __Pyx_PyInt_As_siz(__pyx_t_1); if (unlikely((__pyx_t_3 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 196, __pyx_L1_error)
  5071. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5072. __pyx_v_N = __pyx_t_3;
  5073. /* "pycocotools/_mask.pyx":195
  5074. * def _len(obj):
  5075. * cdef siz N = 0
  5076. * if type(obj) == RLEs: # <<<<<<<<<<<<<<
  5077. * N = obj.n
  5078. * elif len(obj)==0:
  5079. */
  5080. goto __pyx_L3;
  5081. }
  5082. /* "pycocotools/_mask.pyx":197
  5083. * if type(obj) == RLEs:
  5084. * N = obj.n
  5085. * elif len(obj)==0: # <<<<<<<<<<<<<<
  5086. * pass
  5087. * elif type(obj) == np.ndarray:
  5088. */
  5089. __pyx_t_4 = PyObject_Length(__pyx_v_obj); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 197, __pyx_L1_error)
  5090. __pyx_t_2 = ((__pyx_t_4 == 0) != 0);
  5091. if (__pyx_t_2) {
  5092. goto __pyx_L3;
  5093. }
  5094. /* "pycocotools/_mask.pyx":199
  5095. * elif len(obj)==0:
  5096. * pass
  5097. * elif type(obj) == np.ndarray: # <<<<<<<<<<<<<<
  5098. * N = obj.shape[0]
  5099. * return N
  5100. */
  5101. __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_obj)), ((PyObject *)__pyx_ptype_5numpy_ndarray), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error)
  5102. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 199, __pyx_L1_error)
  5103. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5104. if (__pyx_t_2) {
  5105. /* "pycocotools/_mask.pyx":200
  5106. * pass
  5107. * elif type(obj) == np.ndarray:
  5108. * N = obj.shape[0] # <<<<<<<<<<<<<<
  5109. * return N
  5110. * # convert iscrowd to numpy array
  5111. */
  5112. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
  5113. __Pyx_GOTREF(__pyx_t_1);
  5114. __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 200, __pyx_L1_error)
  5115. __Pyx_GOTREF(__pyx_t_5);
  5116. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5117. __pyx_t_3 = __Pyx_PyInt_As_siz(__pyx_t_5); if (unlikely((__pyx_t_3 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 200, __pyx_L1_error)
  5118. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5119. __pyx_v_N = __pyx_t_3;
  5120. /* "pycocotools/_mask.pyx":199
  5121. * elif len(obj)==0:
  5122. * pass
  5123. * elif type(obj) == np.ndarray: # <<<<<<<<<<<<<<
  5124. * N = obj.shape[0]
  5125. * return N
  5126. */
  5127. }
  5128. __pyx_L3:;
  5129. /* "pycocotools/_mask.pyx":201
  5130. * elif type(obj) == np.ndarray:
  5131. * N = obj.shape[0]
  5132. * return N # <<<<<<<<<<<<<<
  5133. * # convert iscrowd to numpy array
  5134. * cdef np.ndarray[np.uint8_t, ndim=1] iscrowd = np.array(pyiscrowd, dtype=np.uint8)
  5135. */
  5136. __Pyx_XDECREF(__pyx_r);
  5137. __pyx_t_5 = __Pyx_PyInt_From_siz(__pyx_v_N); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 201, __pyx_L1_error)
  5138. __Pyx_GOTREF(__pyx_t_5);
  5139. __pyx_r = __pyx_t_5;
  5140. __pyx_t_5 = 0;
  5141. goto __pyx_L0;
  5142. /* "pycocotools/_mask.pyx":193
  5143. * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  5144. * bbIou( <BB> dt.data, <BB> gt.data, m, n, <byte*> iscrowd.data, <double*>_iou.data )
  5145. * def _len(obj): # <<<<<<<<<<<<<<
  5146. * cdef siz N = 0
  5147. * if type(obj) == RLEs:
  5148. */
  5149. /* function exit code */
  5150. __pyx_L1_error:;
  5151. __Pyx_XDECREF(__pyx_t_1);
  5152. __Pyx_XDECREF(__pyx_t_5);
  5153. __Pyx_AddTraceback("pycocotools._mask.iou._len", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5154. __pyx_r = NULL;
  5155. __pyx_L0:;
  5156. __Pyx_XGIVEREF(__pyx_r);
  5157. __Pyx_RefNannyFinishContext();
  5158. return __pyx_r;
  5159. }
  5160. /* "pycocotools/_mask.pyx":163
  5161. *
  5162. * # iou computation. support function overload (RLEs-RLEs and bbox-bbox).
  5163. * def iou( dt, gt, pyiscrowd ): # <<<<<<<<<<<<<<
  5164. * def _preproc(objs):
  5165. * if len(objs) == 0:
  5166. */
  5167. static PyObject *__pyx_pf_11pycocotools_5_mask_12iou(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dt, PyObject *__pyx_v_gt, PyObject *__pyx_v_pyiscrowd) {
  5168. PyObject *__pyx_v__preproc = 0;
  5169. PyObject *__pyx_v__rleIou = 0;
  5170. PyObject *__pyx_v__bbIou = 0;
  5171. PyObject *__pyx_v__len = 0;
  5172. PyArrayObject *__pyx_v_iscrowd = 0;
  5173. siz __pyx_v_m;
  5174. siz __pyx_v_n;
  5175. double *__pyx_v__iou;
  5176. npy_intp __pyx_v_shape[1];
  5177. PyObject *__pyx_v__iouFun = NULL;
  5178. PyObject *__pyx_v_iou = NULL;
  5179. __Pyx_LocalBuf_ND __pyx_pybuffernd_iscrowd;
  5180. __Pyx_Buffer __pyx_pybuffer_iscrowd;
  5181. PyObject *__pyx_r = NULL;
  5182. __Pyx_RefNannyDeclarations
  5183. PyObject *__pyx_t_1 = NULL;
  5184. PyObject *__pyx_t_2 = NULL;
  5185. PyObject *__pyx_t_3 = NULL;
  5186. PyObject *__pyx_t_4 = NULL;
  5187. PyObject *__pyx_t_5 = NULL;
  5188. PyArrayObject *__pyx_t_6 = NULL;
  5189. siz __pyx_t_7;
  5190. int __pyx_t_8;
  5191. int __pyx_t_9;
  5192. int __pyx_t_10;
  5193. PyObject *__pyx_t_11 = NULL;
  5194. __Pyx_RefNannySetupContext("iou", 0);
  5195. __Pyx_INCREF(__pyx_v_dt);
  5196. __Pyx_INCREF(__pyx_v_gt);
  5197. __pyx_pybuffer_iscrowd.pybuffer.buf = NULL;
  5198. __pyx_pybuffer_iscrowd.refcount = 0;
  5199. __pyx_pybuffernd_iscrowd.data = NULL;
  5200. __pyx_pybuffernd_iscrowd.rcbuffer = &__pyx_pybuffer_iscrowd;
  5201. /* "pycocotools/_mask.pyx":164
  5202. * # iou computation. support function overload (RLEs-RLEs and bbox-bbox).
  5203. * def iou( dt, gt, pyiscrowd ):
  5204. * def _preproc(objs): # <<<<<<<<<<<<<<
  5205. * if len(objs) == 0:
  5206. * return objs
  5207. */
  5208. __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_11pycocotools_5_mask_3iou_1_preproc, 0, __pyx_n_s_iou_locals__preproc, NULL, __pyx_n_s_pycocotools__mask, __pyx_d, ((PyObject *)__pyx_codeobj__10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 164, __pyx_L1_error)
  5209. __Pyx_GOTREF(__pyx_t_1);
  5210. __pyx_v__preproc = __pyx_t_1;
  5211. __pyx_t_1 = 0;
  5212. /* "pycocotools/_mask.pyx":189
  5213. * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.')
  5214. * return objs
  5215. * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): # <<<<<<<<<<<<<<
  5216. * rleIou( <RLE*> dt._R, <RLE*> gt._R, m, n, <byte*> iscrowd.data, <double*> _iou.data )
  5217. * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  5218. */
  5219. __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_11pycocotools_5_mask_3iou_3_rleIou, 0, __pyx_n_s_iou_locals__rleIou, NULL, __pyx_n_s_pycocotools__mask, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error)
  5220. __Pyx_GOTREF(__pyx_t_1);
  5221. __pyx_v__rleIou = __pyx_t_1;
  5222. __pyx_t_1 = 0;
  5223. /* "pycocotools/_mask.pyx":191
  5224. * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  5225. * rleIou( <RLE*> dt._R, <RLE*> gt._R, m, n, <byte*> iscrowd.data, <double*> _iou.data )
  5226. * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): # <<<<<<<<<<<<<<
  5227. * bbIou( <BB> dt.data, <BB> gt.data, m, n, <byte*> iscrowd.data, <double*>_iou.data )
  5228. * def _len(obj):
  5229. */
  5230. __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_11pycocotools_5_mask_3iou_5_bbIou, 0, __pyx_n_s_iou_locals__bbIou, NULL, __pyx_n_s_pycocotools__mask, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error)
  5231. __Pyx_GOTREF(__pyx_t_1);
  5232. __pyx_v__bbIou = __pyx_t_1;
  5233. __pyx_t_1 = 0;
  5234. /* "pycocotools/_mask.pyx":193
  5235. * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  5236. * bbIou( <BB> dt.data, <BB> gt.data, m, n, <byte*> iscrowd.data, <double*>_iou.data )
  5237. * def _len(obj): # <<<<<<<<<<<<<<
  5238. * cdef siz N = 0
  5239. * if type(obj) == RLEs:
  5240. */
  5241. __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_11pycocotools_5_mask_3iou_7_len, 0, __pyx_n_s_iou_locals__len, NULL, __pyx_n_s_pycocotools__mask, __pyx_d, ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error)
  5242. __Pyx_GOTREF(__pyx_t_1);
  5243. __pyx_v__len = __pyx_t_1;
  5244. __pyx_t_1 = 0;
  5245. /* "pycocotools/_mask.pyx":203
  5246. * return N
  5247. * # convert iscrowd to numpy array
  5248. * cdef np.ndarray[np.uint8_t, ndim=1] iscrowd = np.array(pyiscrowd, dtype=np.uint8) # <<<<<<<<<<<<<<
  5249. * # simple type checking
  5250. * cdef siz m, n
  5251. */
  5252. __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error)
  5253. __Pyx_GOTREF(__pyx_t_1);
  5254. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L1_error)
  5255. __Pyx_GOTREF(__pyx_t_2);
  5256. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5257. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error)
  5258. __Pyx_GOTREF(__pyx_t_1);
  5259. __Pyx_INCREF(__pyx_v_pyiscrowd);
  5260. __Pyx_GIVEREF(__pyx_v_pyiscrowd);
  5261. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_pyiscrowd);
  5262. __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 203, __pyx_L1_error)
  5263. __Pyx_GOTREF(__pyx_t_3);
  5264. __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 203, __pyx_L1_error)
  5265. __Pyx_GOTREF(__pyx_t_4);
  5266. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 203, __pyx_L1_error)
  5267. __Pyx_GOTREF(__pyx_t_5);
  5268. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5269. if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 203, __pyx_L1_error)
  5270. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5271. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 203, __pyx_L1_error)
  5272. __Pyx_GOTREF(__pyx_t_5);
  5273. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5274. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5275. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5276. if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 203, __pyx_L1_error)
  5277. __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
  5278. {
  5279. __Pyx_BufFmt_StackElem __pyx_stack[1];
  5280. if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
  5281. __pyx_v_iscrowd = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_iscrowd.rcbuffer->pybuffer.buf = NULL;
  5282. __PYX_ERR(0, 203, __pyx_L1_error)
  5283. } else {__pyx_pybuffernd_iscrowd.diminfo[0].strides = __pyx_pybuffernd_iscrowd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_iscrowd.diminfo[0].shape = __pyx_pybuffernd_iscrowd.rcbuffer->pybuffer.shape[0];
  5284. }
  5285. }
  5286. __pyx_t_6 = 0;
  5287. __pyx_v_iscrowd = ((PyArrayObject *)__pyx_t_5);
  5288. __pyx_t_5 = 0;
  5289. /* "pycocotools/_mask.pyx":206
  5290. * # simple type checking
  5291. * cdef siz m, n
  5292. * dt = _preproc(dt) # <<<<<<<<<<<<<<
  5293. * gt = _preproc(gt)
  5294. * m = _len(dt)
  5295. */
  5296. __pyx_t_5 = __pyx_pf_11pycocotools_5_mask_3iou__preproc(__pyx_v__preproc, __pyx_v_dt); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 206, __pyx_L1_error)
  5297. __Pyx_GOTREF(__pyx_t_5);
  5298. __Pyx_DECREF_SET(__pyx_v_dt, __pyx_t_5);
  5299. __pyx_t_5 = 0;
  5300. /* "pycocotools/_mask.pyx":207
  5301. * cdef siz m, n
  5302. * dt = _preproc(dt)
  5303. * gt = _preproc(gt) # <<<<<<<<<<<<<<
  5304. * m = _len(dt)
  5305. * n = _len(gt)
  5306. */
  5307. __pyx_t_5 = __pyx_pf_11pycocotools_5_mask_3iou__preproc(__pyx_v__preproc, __pyx_v_gt); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 207, __pyx_L1_error)
  5308. __Pyx_GOTREF(__pyx_t_5);
  5309. __Pyx_DECREF_SET(__pyx_v_gt, __pyx_t_5);
  5310. __pyx_t_5 = 0;
  5311. /* "pycocotools/_mask.pyx":208
  5312. * dt = _preproc(dt)
  5313. * gt = _preproc(gt)
  5314. * m = _len(dt) # <<<<<<<<<<<<<<
  5315. * n = _len(gt)
  5316. * if m == 0 or n == 0:
  5317. */
  5318. __pyx_t_5 = __pyx_pf_11pycocotools_5_mask_3iou_6_len(__pyx_v__len, __pyx_v_dt); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 208, __pyx_L1_error)
  5319. __Pyx_GOTREF(__pyx_t_5);
  5320. __pyx_t_7 = __Pyx_PyInt_As_siz(__pyx_t_5); if (unlikely((__pyx_t_7 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 208, __pyx_L1_error)
  5321. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5322. __pyx_v_m = __pyx_t_7;
  5323. /* "pycocotools/_mask.pyx":209
  5324. * gt = _preproc(gt)
  5325. * m = _len(dt)
  5326. * n = _len(gt) # <<<<<<<<<<<<<<
  5327. * if m == 0 or n == 0:
  5328. * return []
  5329. */
  5330. __pyx_t_5 = __pyx_pf_11pycocotools_5_mask_3iou_6_len(__pyx_v__len, __pyx_v_gt); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 209, __pyx_L1_error)
  5331. __Pyx_GOTREF(__pyx_t_5);
  5332. __pyx_t_7 = __Pyx_PyInt_As_siz(__pyx_t_5); if (unlikely((__pyx_t_7 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 209, __pyx_L1_error)
  5333. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5334. __pyx_v_n = __pyx_t_7;
  5335. /* "pycocotools/_mask.pyx":210
  5336. * m = _len(dt)
  5337. * n = _len(gt)
  5338. * if m == 0 or n == 0: # <<<<<<<<<<<<<<
  5339. * return []
  5340. * if not type(dt) == type(gt):
  5341. */
  5342. __pyx_t_9 = ((__pyx_v_m == 0) != 0);
  5343. if (!__pyx_t_9) {
  5344. } else {
  5345. __pyx_t_8 = __pyx_t_9;
  5346. goto __pyx_L4_bool_binop_done;
  5347. }
  5348. __pyx_t_9 = ((__pyx_v_n == 0) != 0);
  5349. __pyx_t_8 = __pyx_t_9;
  5350. __pyx_L4_bool_binop_done:;
  5351. if (__pyx_t_8) {
  5352. /* "pycocotools/_mask.pyx":211
  5353. * n = _len(gt)
  5354. * if m == 0 or n == 0:
  5355. * return [] # <<<<<<<<<<<<<<
  5356. * if not type(dt) == type(gt):
  5357. * raise Exception('The dt and gt should have the same data type, either RLEs, list or np.ndarray')
  5358. */
  5359. __Pyx_XDECREF(__pyx_r);
  5360. __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 211, __pyx_L1_error)
  5361. __Pyx_GOTREF(__pyx_t_5);
  5362. __pyx_r = __pyx_t_5;
  5363. __pyx_t_5 = 0;
  5364. goto __pyx_L0;
  5365. /* "pycocotools/_mask.pyx":210
  5366. * m = _len(dt)
  5367. * n = _len(gt)
  5368. * if m == 0 or n == 0: # <<<<<<<<<<<<<<
  5369. * return []
  5370. * if not type(dt) == type(gt):
  5371. */
  5372. }
  5373. /* "pycocotools/_mask.pyx":212
  5374. * if m == 0 or n == 0:
  5375. * return []
  5376. * if not type(dt) == type(gt): # <<<<<<<<<<<<<<
  5377. * raise Exception('The dt and gt should have the same data type, either RLEs, list or np.ndarray')
  5378. *
  5379. */
  5380. __pyx_t_5 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_dt)), ((PyObject *)Py_TYPE(__pyx_v_gt)), Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 212, __pyx_L1_error)
  5381. __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 212, __pyx_L1_error)
  5382. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5383. __pyx_t_9 = ((!__pyx_t_8) != 0);
  5384. if (unlikely(__pyx_t_9)) {
  5385. /* "pycocotools/_mask.pyx":213
  5386. * return []
  5387. * if not type(dt) == type(gt):
  5388. * raise Exception('The dt and gt should have the same data type, either RLEs, list or np.ndarray') # <<<<<<<<<<<<<<
  5389. *
  5390. * # define local variables
  5391. */
  5392. __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 213, __pyx_L1_error)
  5393. __Pyx_GOTREF(__pyx_t_5);
  5394. __Pyx_Raise(__pyx_t_5, 0, 0, 0);
  5395. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5396. __PYX_ERR(0, 213, __pyx_L1_error)
  5397. /* "pycocotools/_mask.pyx":212
  5398. * if m == 0 or n == 0:
  5399. * return []
  5400. * if not type(dt) == type(gt): # <<<<<<<<<<<<<<
  5401. * raise Exception('The dt and gt should have the same data type, either RLEs, list or np.ndarray')
  5402. *
  5403. */
  5404. }
  5405. /* "pycocotools/_mask.pyx":216
  5406. *
  5407. * # define local variables
  5408. * cdef double* _iou = <double*> 0 # <<<<<<<<<<<<<<
  5409. * cdef np.npy_intp shape[1]
  5410. * # check type and assign iou function
  5411. */
  5412. __pyx_v__iou = ((double *)0);
  5413. /* "pycocotools/_mask.pyx":219
  5414. * cdef np.npy_intp shape[1]
  5415. * # check type and assign iou function
  5416. * if type(dt) == RLEs: # <<<<<<<<<<<<<<
  5417. * _iouFun = _rleIou
  5418. * elif type(dt) == np.ndarray:
  5419. */
  5420. __pyx_t_5 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_dt)), ((PyObject *)__pyx_ptype_11pycocotools_5_mask_RLEs), Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 219, __pyx_L1_error)
  5421. __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 219, __pyx_L1_error)
  5422. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5423. if (__pyx_t_9) {
  5424. /* "pycocotools/_mask.pyx":220
  5425. * # check type and assign iou function
  5426. * if type(dt) == RLEs:
  5427. * _iouFun = _rleIou # <<<<<<<<<<<<<<
  5428. * elif type(dt) == np.ndarray:
  5429. * _iouFun = _bbIou
  5430. */
  5431. __Pyx_INCREF(__pyx_v__rleIou);
  5432. __pyx_v__iouFun = __pyx_v__rleIou;
  5433. /* "pycocotools/_mask.pyx":219
  5434. * cdef np.npy_intp shape[1]
  5435. * # check type and assign iou function
  5436. * if type(dt) == RLEs: # <<<<<<<<<<<<<<
  5437. * _iouFun = _rleIou
  5438. * elif type(dt) == np.ndarray:
  5439. */
  5440. goto __pyx_L7;
  5441. }
  5442. /* "pycocotools/_mask.pyx":221
  5443. * if type(dt) == RLEs:
  5444. * _iouFun = _rleIou
  5445. * elif type(dt) == np.ndarray: # <<<<<<<<<<<<<<
  5446. * _iouFun = _bbIou
  5447. * else:
  5448. */
  5449. __pyx_t_5 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_dt)), ((PyObject *)__pyx_ptype_5numpy_ndarray), Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 221, __pyx_L1_error)
  5450. __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 221, __pyx_L1_error)
  5451. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5452. if (likely(__pyx_t_9)) {
  5453. /* "pycocotools/_mask.pyx":222
  5454. * _iouFun = _rleIou
  5455. * elif type(dt) == np.ndarray:
  5456. * _iouFun = _bbIou # <<<<<<<<<<<<<<
  5457. * else:
  5458. * raise Exception('input data type not allowed.')
  5459. */
  5460. __Pyx_INCREF(__pyx_v__bbIou);
  5461. __pyx_v__iouFun = __pyx_v__bbIou;
  5462. /* "pycocotools/_mask.pyx":221
  5463. * if type(dt) == RLEs:
  5464. * _iouFun = _rleIou
  5465. * elif type(dt) == np.ndarray: # <<<<<<<<<<<<<<
  5466. * _iouFun = _bbIou
  5467. * else:
  5468. */
  5469. goto __pyx_L7;
  5470. }
  5471. /* "pycocotools/_mask.pyx":224
  5472. * _iouFun = _bbIou
  5473. * else:
  5474. * raise Exception('input data type not allowed.') # <<<<<<<<<<<<<<
  5475. * _iou = <double*> malloc(m*n* sizeof(double))
  5476. * iou = np.zeros((m*n, ), dtype=np.double)
  5477. */
  5478. /*else*/ {
  5479. __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 224, __pyx_L1_error)
  5480. __Pyx_GOTREF(__pyx_t_5);
  5481. __Pyx_Raise(__pyx_t_5, 0, 0, 0);
  5482. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5483. __PYX_ERR(0, 224, __pyx_L1_error)
  5484. }
  5485. __pyx_L7:;
  5486. /* "pycocotools/_mask.pyx":225
  5487. * else:
  5488. * raise Exception('input data type not allowed.')
  5489. * _iou = <double*> malloc(m*n* sizeof(double)) # <<<<<<<<<<<<<<
  5490. * iou = np.zeros((m*n, ), dtype=np.double)
  5491. * shape[0] = <np.npy_intp> m*n
  5492. */
  5493. __pyx_v__iou = ((double *)malloc(((__pyx_v_m * __pyx_v_n) * (sizeof(double)))));
  5494. /* "pycocotools/_mask.pyx":226
  5495. * raise Exception('input data type not allowed.')
  5496. * _iou = <double*> malloc(m*n* sizeof(double))
  5497. * iou = np.zeros((m*n, ), dtype=np.double) # <<<<<<<<<<<<<<
  5498. * shape[0] = <np.npy_intp> m*n
  5499. * iou = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _iou)
  5500. */
  5501. __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 226, __pyx_L1_error)
  5502. __Pyx_GOTREF(__pyx_t_5);
  5503. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 226, __pyx_L1_error)
  5504. __Pyx_GOTREF(__pyx_t_3);
  5505. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5506. __pyx_t_5 = __Pyx_PyInt_From_siz((__pyx_v_m * __pyx_v_n)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 226, __pyx_L1_error)
  5507. __Pyx_GOTREF(__pyx_t_5);
  5508. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error)
  5509. __Pyx_GOTREF(__pyx_t_1);
  5510. __Pyx_GIVEREF(__pyx_t_5);
  5511. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
  5512. __pyx_t_5 = 0;
  5513. __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 226, __pyx_L1_error)
  5514. __Pyx_GOTREF(__pyx_t_5);
  5515. __Pyx_GIVEREF(__pyx_t_1);
  5516. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  5517. __pyx_t_1 = 0;
  5518. __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error)
  5519. __Pyx_GOTREF(__pyx_t_1);
  5520. __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 226, __pyx_L1_error)
  5521. __Pyx_GOTREF(__pyx_t_2);
  5522. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_double); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 226, __pyx_L1_error)
  5523. __Pyx_GOTREF(__pyx_t_4);
  5524. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5525. if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 226, __pyx_L1_error)
  5526. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5527. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 226, __pyx_L1_error)
  5528. __Pyx_GOTREF(__pyx_t_4);
  5529. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5530. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5531. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5532. __pyx_v_iou = __pyx_t_4;
  5533. __pyx_t_4 = 0;
  5534. /* "pycocotools/_mask.pyx":227
  5535. * _iou = <double*> malloc(m*n* sizeof(double))
  5536. * iou = np.zeros((m*n, ), dtype=np.double)
  5537. * shape[0] = <np.npy_intp> m*n # <<<<<<<<<<<<<<
  5538. * iou = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _iou)
  5539. * PyArray_ENABLEFLAGS(iou, np.NPY_OWNDATA)
  5540. */
  5541. (__pyx_v_shape[0]) = (((npy_intp)__pyx_v_m) * __pyx_v_n);
  5542. /* "pycocotools/_mask.pyx":228
  5543. * iou = np.zeros((m*n, ), dtype=np.double)
  5544. * shape[0] = <np.npy_intp> m*n
  5545. * iou = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _iou) # <<<<<<<<<<<<<<
  5546. * PyArray_ENABLEFLAGS(iou, np.NPY_OWNDATA)
  5547. * _iouFun(dt, gt, iscrowd, m, n, iou)
  5548. */
  5549. __pyx_t_4 = PyArray_SimpleNewFromData(1, __pyx_v_shape, NPY_DOUBLE, __pyx_v__iou); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 228, __pyx_L1_error)
  5550. __Pyx_GOTREF(__pyx_t_4);
  5551. __Pyx_DECREF_SET(__pyx_v_iou, __pyx_t_4);
  5552. __pyx_t_4 = 0;
  5553. /* "pycocotools/_mask.pyx":229
  5554. * shape[0] = <np.npy_intp> m*n
  5555. * iou = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _iou)
  5556. * PyArray_ENABLEFLAGS(iou, np.NPY_OWNDATA) # <<<<<<<<<<<<<<
  5557. * _iouFun(dt, gt, iscrowd, m, n, iou)
  5558. * return iou.reshape((m,n), order='F')
  5559. */
  5560. if (!(likely(((__pyx_v_iou) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_iou, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 229, __pyx_L1_error)
  5561. PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v_iou), NPY_OWNDATA);
  5562. /* "pycocotools/_mask.pyx":230
  5563. * iou = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _iou)
  5564. * PyArray_ENABLEFLAGS(iou, np.NPY_OWNDATA)
  5565. * _iouFun(dt, gt, iscrowd, m, n, iou) # <<<<<<<<<<<<<<
  5566. * return iou.reshape((m,n), order='F')
  5567. *
  5568. */
  5569. __pyx_t_1 = __Pyx_PyInt_From_siz(__pyx_v_m); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L1_error)
  5570. __Pyx_GOTREF(__pyx_t_1);
  5571. __pyx_t_5 = __Pyx_PyInt_From_siz(__pyx_v_n); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 230, __pyx_L1_error)
  5572. __Pyx_GOTREF(__pyx_t_5);
  5573. __Pyx_INCREF(__pyx_v__iouFun);
  5574. __pyx_t_3 = __pyx_v__iouFun; __pyx_t_2 = NULL;
  5575. __pyx_t_10 = 0;
  5576. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  5577. __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
  5578. if (likely(__pyx_t_2)) {
  5579. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  5580. __Pyx_INCREF(__pyx_t_2);
  5581. __Pyx_INCREF(function);
  5582. __Pyx_DECREF_SET(__pyx_t_3, function);
  5583. __pyx_t_10 = 1;
  5584. }
  5585. }
  5586. #if CYTHON_FAST_PYCALL
  5587. if (PyFunction_Check(__pyx_t_3)) {
  5588. PyObject *__pyx_temp[7] = {__pyx_t_2, __pyx_v_dt, __pyx_v_gt, ((PyObject *)__pyx_v_iscrowd), __pyx_t_1, __pyx_t_5, __pyx_v_iou};
  5589. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 6+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 230, __pyx_L1_error)
  5590. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5591. __Pyx_GOTREF(__pyx_t_4);
  5592. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5593. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5594. } else
  5595. #endif
  5596. #if CYTHON_FAST_PYCCALL
  5597. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  5598. PyObject *__pyx_temp[7] = {__pyx_t_2, __pyx_v_dt, __pyx_v_gt, ((PyObject *)__pyx_v_iscrowd), __pyx_t_1, __pyx_t_5, __pyx_v_iou};
  5599. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 6+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 230, __pyx_L1_error)
  5600. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5601. __Pyx_GOTREF(__pyx_t_4);
  5602. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5603. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5604. } else
  5605. #endif
  5606. {
  5607. __pyx_t_11 = PyTuple_New(6+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 230, __pyx_L1_error)
  5608. __Pyx_GOTREF(__pyx_t_11);
  5609. if (__pyx_t_2) {
  5610. __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2); __pyx_t_2 = NULL;
  5611. }
  5612. __Pyx_INCREF(__pyx_v_dt);
  5613. __Pyx_GIVEREF(__pyx_v_dt);
  5614. PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_v_dt);
  5615. __Pyx_INCREF(__pyx_v_gt);
  5616. __Pyx_GIVEREF(__pyx_v_gt);
  5617. PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_v_gt);
  5618. __Pyx_INCREF(((PyObject *)__pyx_v_iscrowd));
  5619. __Pyx_GIVEREF(((PyObject *)__pyx_v_iscrowd));
  5620. PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, ((PyObject *)__pyx_v_iscrowd));
  5621. __Pyx_GIVEREF(__pyx_t_1);
  5622. PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_10, __pyx_t_1);
  5623. __Pyx_GIVEREF(__pyx_t_5);
  5624. PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_10, __pyx_t_5);
  5625. __Pyx_INCREF(__pyx_v_iou);
  5626. __Pyx_GIVEREF(__pyx_v_iou);
  5627. PyTuple_SET_ITEM(__pyx_t_11, 5+__pyx_t_10, __pyx_v_iou);
  5628. __pyx_t_1 = 0;
  5629. __pyx_t_5 = 0;
  5630. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 230, __pyx_L1_error)
  5631. __Pyx_GOTREF(__pyx_t_4);
  5632. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  5633. }
  5634. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5635. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5636. /* "pycocotools/_mask.pyx":231
  5637. * PyArray_ENABLEFLAGS(iou, np.NPY_OWNDATA)
  5638. * _iouFun(dt, gt, iscrowd, m, n, iou)
  5639. * return iou.reshape((m,n), order='F') # <<<<<<<<<<<<<<
  5640. *
  5641. * def toBbox( rleObjs ):
  5642. */
  5643. __Pyx_XDECREF(__pyx_r);
  5644. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_iou, __pyx_n_s_reshape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 231, __pyx_L1_error)
  5645. __Pyx_GOTREF(__pyx_t_4);
  5646. __pyx_t_3 = __Pyx_PyInt_From_siz(__pyx_v_m); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 231, __pyx_L1_error)
  5647. __Pyx_GOTREF(__pyx_t_3);
  5648. __pyx_t_11 = __Pyx_PyInt_From_siz(__pyx_v_n); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 231, __pyx_L1_error)
  5649. __Pyx_GOTREF(__pyx_t_11);
  5650. __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 231, __pyx_L1_error)
  5651. __Pyx_GOTREF(__pyx_t_5);
  5652. __Pyx_GIVEREF(__pyx_t_3);
  5653. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  5654. __Pyx_GIVEREF(__pyx_t_11);
  5655. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_11);
  5656. __pyx_t_3 = 0;
  5657. __pyx_t_11 = 0;
  5658. __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 231, __pyx_L1_error)
  5659. __Pyx_GOTREF(__pyx_t_11);
  5660. __Pyx_GIVEREF(__pyx_t_5);
  5661. PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_5);
  5662. __pyx_t_5 = 0;
  5663. __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 231, __pyx_L1_error)
  5664. __Pyx_GOTREF(__pyx_t_5);
  5665. if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_order, __pyx_n_s_F) < 0) __PYX_ERR(0, 231, __pyx_L1_error)
  5666. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 231, __pyx_L1_error)
  5667. __Pyx_GOTREF(__pyx_t_3);
  5668. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5669. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  5670. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5671. __pyx_r = __pyx_t_3;
  5672. __pyx_t_3 = 0;
  5673. goto __pyx_L0;
  5674. /* "pycocotools/_mask.pyx":163
  5675. *
  5676. * # iou computation. support function overload (RLEs-RLEs and bbox-bbox).
  5677. * def iou( dt, gt, pyiscrowd ): # <<<<<<<<<<<<<<
  5678. * def _preproc(objs):
  5679. * if len(objs) == 0:
  5680. */
  5681. /* function exit code */
  5682. __pyx_L1_error:;
  5683. __Pyx_XDECREF(__pyx_t_1);
  5684. __Pyx_XDECREF(__pyx_t_2);
  5685. __Pyx_XDECREF(__pyx_t_3);
  5686. __Pyx_XDECREF(__pyx_t_4);
  5687. __Pyx_XDECREF(__pyx_t_5);
  5688. __Pyx_XDECREF(__pyx_t_11);
  5689. { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
  5690. __Pyx_PyThreadState_declare
  5691. __Pyx_PyThreadState_assign
  5692. __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
  5693. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer);
  5694. __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  5695. __Pyx_AddTraceback("pycocotools._mask.iou", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5696. __pyx_r = NULL;
  5697. goto __pyx_L2;
  5698. __pyx_L0:;
  5699. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iscrowd.rcbuffer->pybuffer);
  5700. __pyx_L2:;
  5701. __Pyx_XDECREF(__pyx_v__preproc);
  5702. __Pyx_XDECREF(__pyx_v__rleIou);
  5703. __Pyx_XDECREF(__pyx_v__bbIou);
  5704. __Pyx_XDECREF(__pyx_v__len);
  5705. __Pyx_XDECREF((PyObject *)__pyx_v_iscrowd);
  5706. __Pyx_XDECREF(__pyx_v__iouFun);
  5707. __Pyx_XDECREF(__pyx_v_iou);
  5708. __Pyx_XDECREF(__pyx_v_dt);
  5709. __Pyx_XDECREF(__pyx_v_gt);
  5710. __Pyx_XGIVEREF(__pyx_r);
  5711. __Pyx_RefNannyFinishContext();
  5712. return __pyx_r;
  5713. }
  5714. /* "pycocotools/_mask.pyx":233
  5715. * return iou.reshape((m,n), order='F')
  5716. *
  5717. * def toBbox( rleObjs ): # <<<<<<<<<<<<<<
  5718. * cdef RLEs Rs = _frString(rleObjs)
  5719. * cdef siz n = Rs.n
  5720. */
  5721. /* Python wrapper */
  5722. static PyObject *__pyx_pw_11pycocotools_5_mask_15toBbox(PyObject *__pyx_self, PyObject *__pyx_v_rleObjs); /*proto*/
  5723. static PyMethodDef __pyx_mdef_11pycocotools_5_mask_15toBbox = {"toBbox", (PyCFunction)__pyx_pw_11pycocotools_5_mask_15toBbox, METH_O, 0};
  5724. static PyObject *__pyx_pw_11pycocotools_5_mask_15toBbox(PyObject *__pyx_self, PyObject *__pyx_v_rleObjs) {
  5725. PyObject *__pyx_r = 0;
  5726. __Pyx_RefNannyDeclarations
  5727. __Pyx_RefNannySetupContext("toBbox (wrapper)", 0);
  5728. __pyx_r = __pyx_pf_11pycocotools_5_mask_14toBbox(__pyx_self, ((PyObject *)__pyx_v_rleObjs));
  5729. /* function exit code */
  5730. __Pyx_RefNannyFinishContext();
  5731. return __pyx_r;
  5732. }
  5733. static PyObject *__pyx_pf_11pycocotools_5_mask_14toBbox(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rleObjs) {
  5734. struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_Rs = 0;
  5735. siz __pyx_v_n;
  5736. BB __pyx_v__bb;
  5737. npy_intp __pyx_v_shape[1];
  5738. PyObject *__pyx_v_bb = NULL;
  5739. PyObject *__pyx_r = NULL;
  5740. __Pyx_RefNannyDeclarations
  5741. PyObject *__pyx_t_1 = NULL;
  5742. PyObject *__pyx_t_2 = NULL;
  5743. PyObject *__pyx_t_3 = NULL;
  5744. siz __pyx_t_4;
  5745. PyObject *__pyx_t_5 = NULL;
  5746. PyObject *__pyx_t_6 = NULL;
  5747. __Pyx_RefNannySetupContext("toBbox", 0);
  5748. /* "pycocotools/_mask.pyx":234
  5749. *
  5750. * def toBbox( rleObjs ):
  5751. * cdef RLEs Rs = _frString(rleObjs) # <<<<<<<<<<<<<<
  5752. * cdef siz n = Rs.n
  5753. * cdef BB _bb = <BB> malloc(4*n* sizeof(double))
  5754. */
  5755. __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_frString); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 234, __pyx_L1_error)
  5756. __Pyx_GOTREF(__pyx_t_2);
  5757. __pyx_t_3 = NULL;
  5758. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  5759. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  5760. if (likely(__pyx_t_3)) {
  5761. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  5762. __Pyx_INCREF(__pyx_t_3);
  5763. __Pyx_INCREF(function);
  5764. __Pyx_DECREF_SET(__pyx_t_2, function);
  5765. }
  5766. }
  5767. __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_rleObjs) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_rleObjs);
  5768. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5769. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 234, __pyx_L1_error)
  5770. __Pyx_GOTREF(__pyx_t_1);
  5771. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5772. if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_11pycocotools_5_mask_RLEs))))) __PYX_ERR(0, 234, __pyx_L1_error)
  5773. __pyx_v_Rs = ((struct __pyx_obj_11pycocotools_5_mask_RLEs *)__pyx_t_1);
  5774. __pyx_t_1 = 0;
  5775. /* "pycocotools/_mask.pyx":235
  5776. * def toBbox( rleObjs ):
  5777. * cdef RLEs Rs = _frString(rleObjs)
  5778. * cdef siz n = Rs.n # <<<<<<<<<<<<<<
  5779. * cdef BB _bb = <BB> malloc(4*n* sizeof(double))
  5780. * rleToBbox( <const RLE*> Rs._R, _bb, n )
  5781. */
  5782. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_Rs), __pyx_n_s_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 235, __pyx_L1_error)
  5783. __Pyx_GOTREF(__pyx_t_1);
  5784. __pyx_t_4 = __Pyx_PyInt_As_siz(__pyx_t_1); if (unlikely((__pyx_t_4 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 235, __pyx_L1_error)
  5785. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5786. __pyx_v_n = __pyx_t_4;
  5787. /* "pycocotools/_mask.pyx":236
  5788. * cdef RLEs Rs = _frString(rleObjs)
  5789. * cdef siz n = Rs.n
  5790. * cdef BB _bb = <BB> malloc(4*n* sizeof(double)) # <<<<<<<<<<<<<<
  5791. * rleToBbox( <const RLE*> Rs._R, _bb, n )
  5792. * cdef np.npy_intp shape[1]
  5793. */
  5794. __pyx_v__bb = ((BB)malloc(((4 * __pyx_v_n) * (sizeof(double)))));
  5795. /* "pycocotools/_mask.pyx":237
  5796. * cdef siz n = Rs.n
  5797. * cdef BB _bb = <BB> malloc(4*n* sizeof(double))
  5798. * rleToBbox( <const RLE*> Rs._R, _bb, n ) # <<<<<<<<<<<<<<
  5799. * cdef np.npy_intp shape[1]
  5800. * shape[0] = <np.npy_intp> 4*n
  5801. */
  5802. rleToBbox(((RLE const *)__pyx_v_Rs->_R), __pyx_v__bb, __pyx_v_n);
  5803. /* "pycocotools/_mask.pyx":239
  5804. * rleToBbox( <const RLE*> Rs._R, _bb, n )
  5805. * cdef np.npy_intp shape[1]
  5806. * shape[0] = <np.npy_intp> 4*n # <<<<<<<<<<<<<<
  5807. * bb = np.array((1,4*n), dtype=np.double)
  5808. * bb = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _bb).reshape((n, 4))
  5809. */
  5810. (__pyx_v_shape[0]) = (((npy_intp)4) * __pyx_v_n);
  5811. /* "pycocotools/_mask.pyx":240
  5812. * cdef np.npy_intp shape[1]
  5813. * shape[0] = <np.npy_intp> 4*n
  5814. * bb = np.array((1,4*n), dtype=np.double) # <<<<<<<<<<<<<<
  5815. * bb = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _bb).reshape((n, 4))
  5816. * PyArray_ENABLEFLAGS(bb, np.NPY_OWNDATA)
  5817. */
  5818. __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L1_error)
  5819. __Pyx_GOTREF(__pyx_t_1);
  5820. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 240, __pyx_L1_error)
  5821. __Pyx_GOTREF(__pyx_t_2);
  5822. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5823. __pyx_t_1 = __Pyx_PyInt_From_siz((4 * __pyx_v_n)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L1_error)
  5824. __Pyx_GOTREF(__pyx_t_1);
  5825. __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 240, __pyx_L1_error)
  5826. __Pyx_GOTREF(__pyx_t_3);
  5827. __Pyx_INCREF(__pyx_int_1);
  5828. __Pyx_GIVEREF(__pyx_int_1);
  5829. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
  5830. __Pyx_GIVEREF(__pyx_t_1);
  5831. PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  5832. __pyx_t_1 = 0;
  5833. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L1_error)
  5834. __Pyx_GOTREF(__pyx_t_1);
  5835. __Pyx_GIVEREF(__pyx_t_3);
  5836. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  5837. __pyx_t_3 = 0;
  5838. __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 240, __pyx_L1_error)
  5839. __Pyx_GOTREF(__pyx_t_3);
  5840. __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 240, __pyx_L1_error)
  5841. __Pyx_GOTREF(__pyx_t_5);
  5842. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_double); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 240, __pyx_L1_error)
  5843. __Pyx_GOTREF(__pyx_t_6);
  5844. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5845. if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 240, __pyx_L1_error)
  5846. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5847. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 240, __pyx_L1_error)
  5848. __Pyx_GOTREF(__pyx_t_6);
  5849. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5850. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5851. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5852. __pyx_v_bb = __pyx_t_6;
  5853. __pyx_t_6 = 0;
  5854. /* "pycocotools/_mask.pyx":241
  5855. * shape[0] = <np.npy_intp> 4*n
  5856. * bb = np.array((1,4*n), dtype=np.double)
  5857. * bb = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _bb).reshape((n, 4)) # <<<<<<<<<<<<<<
  5858. * PyArray_ENABLEFLAGS(bb, np.NPY_OWNDATA)
  5859. * return bb
  5860. */
  5861. __pyx_t_3 = PyArray_SimpleNewFromData(1, __pyx_v_shape, NPY_DOUBLE, __pyx_v__bb); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 241, __pyx_L1_error)
  5862. __Pyx_GOTREF(__pyx_t_3);
  5863. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_reshape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 241, __pyx_L1_error)
  5864. __Pyx_GOTREF(__pyx_t_1);
  5865. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5866. __pyx_t_3 = __Pyx_PyInt_From_siz(__pyx_v_n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 241, __pyx_L1_error)
  5867. __Pyx_GOTREF(__pyx_t_3);
  5868. __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 241, __pyx_L1_error)
  5869. __Pyx_GOTREF(__pyx_t_2);
  5870. __Pyx_GIVEREF(__pyx_t_3);
  5871. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  5872. __Pyx_INCREF(__pyx_int_4);
  5873. __Pyx_GIVEREF(__pyx_int_4);
  5874. PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_4);
  5875. __pyx_t_3 = 0;
  5876. __pyx_t_3 = NULL;
  5877. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
  5878. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
  5879. if (likely(__pyx_t_3)) {
  5880. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  5881. __Pyx_INCREF(__pyx_t_3);
  5882. __Pyx_INCREF(function);
  5883. __Pyx_DECREF_SET(__pyx_t_1, function);
  5884. }
  5885. }
  5886. __pyx_t_6 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2);
  5887. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5888. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5889. if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 241, __pyx_L1_error)
  5890. __Pyx_GOTREF(__pyx_t_6);
  5891. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5892. __Pyx_DECREF_SET(__pyx_v_bb, __pyx_t_6);
  5893. __pyx_t_6 = 0;
  5894. /* "pycocotools/_mask.pyx":242
  5895. * bb = np.array((1,4*n), dtype=np.double)
  5896. * bb = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _bb).reshape((n, 4))
  5897. * PyArray_ENABLEFLAGS(bb, np.NPY_OWNDATA) # <<<<<<<<<<<<<<
  5898. * return bb
  5899. *
  5900. */
  5901. if (!(likely(((__pyx_v_bb) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_bb, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 242, __pyx_L1_error)
  5902. PyArray_ENABLEFLAGS(((PyArrayObject *)__pyx_v_bb), NPY_OWNDATA);
  5903. /* "pycocotools/_mask.pyx":243
  5904. * bb = np.PyArray_SimpleNewFromData(1, shape, np.NPY_DOUBLE, _bb).reshape((n, 4))
  5905. * PyArray_ENABLEFLAGS(bb, np.NPY_OWNDATA)
  5906. * return bb # <<<<<<<<<<<<<<
  5907. *
  5908. * def frBbox(np.ndarray[np.double_t, ndim=2] bb, siz h, siz w ):
  5909. */
  5910. __Pyx_XDECREF(__pyx_r);
  5911. __Pyx_INCREF(__pyx_v_bb);
  5912. __pyx_r = __pyx_v_bb;
  5913. goto __pyx_L0;
  5914. /* "pycocotools/_mask.pyx":233
  5915. * return iou.reshape((m,n), order='F')
  5916. *
  5917. * def toBbox( rleObjs ): # <<<<<<<<<<<<<<
  5918. * cdef RLEs Rs = _frString(rleObjs)
  5919. * cdef siz n = Rs.n
  5920. */
  5921. /* function exit code */
  5922. __pyx_L1_error:;
  5923. __Pyx_XDECREF(__pyx_t_1);
  5924. __Pyx_XDECREF(__pyx_t_2);
  5925. __Pyx_XDECREF(__pyx_t_3);
  5926. __Pyx_XDECREF(__pyx_t_5);
  5927. __Pyx_XDECREF(__pyx_t_6);
  5928. __Pyx_AddTraceback("pycocotools._mask.toBbox", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5929. __pyx_r = NULL;
  5930. __pyx_L0:;
  5931. __Pyx_XDECREF((PyObject *)__pyx_v_Rs);
  5932. __Pyx_XDECREF(__pyx_v_bb);
  5933. __Pyx_XGIVEREF(__pyx_r);
  5934. __Pyx_RefNannyFinishContext();
  5935. return __pyx_r;
  5936. }
  5937. /* "pycocotools/_mask.pyx":245
  5938. * return bb
  5939. *
  5940. * def frBbox(np.ndarray[np.double_t, ndim=2] bb, siz h, siz w ): # <<<<<<<<<<<<<<
  5941. * cdef siz n = bb.shape[0]
  5942. * Rs = RLEs(n)
  5943. */
  5944. /* Python wrapper */
  5945. static PyObject *__pyx_pw_11pycocotools_5_mask_17frBbox(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5946. static PyMethodDef __pyx_mdef_11pycocotools_5_mask_17frBbox = {"frBbox", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pycocotools_5_mask_17frBbox, METH_VARARGS|METH_KEYWORDS, 0};
  5947. static PyObject *__pyx_pw_11pycocotools_5_mask_17frBbox(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5948. PyArrayObject *__pyx_v_bb = 0;
  5949. siz __pyx_v_h;
  5950. siz __pyx_v_w;
  5951. PyObject *__pyx_r = 0;
  5952. __Pyx_RefNannyDeclarations
  5953. __Pyx_RefNannySetupContext("frBbox (wrapper)", 0);
  5954. {
  5955. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_bb,&__pyx_n_s_h,&__pyx_n_s_w,0};
  5956. PyObject* values[3] = {0,0,0};
  5957. if (unlikely(__pyx_kwds)) {
  5958. Py_ssize_t kw_args;
  5959. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  5960. switch (pos_args) {
  5961. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  5962. CYTHON_FALLTHROUGH;
  5963. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  5964. CYTHON_FALLTHROUGH;
  5965. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5966. CYTHON_FALLTHROUGH;
  5967. case 0: break;
  5968. default: goto __pyx_L5_argtuple_error;
  5969. }
  5970. kw_args = PyDict_Size(__pyx_kwds);
  5971. switch (pos_args) {
  5972. case 0:
  5973. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bb)) != 0)) kw_args--;
  5974. else goto __pyx_L5_argtuple_error;
  5975. CYTHON_FALLTHROUGH;
  5976. case 1:
  5977. if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_h)) != 0)) kw_args--;
  5978. else {
  5979. __Pyx_RaiseArgtupleInvalid("frBbox", 1, 3, 3, 1); __PYX_ERR(0, 245, __pyx_L3_error)
  5980. }
  5981. CYTHON_FALLTHROUGH;
  5982. case 2:
  5983. if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--;
  5984. else {
  5985. __Pyx_RaiseArgtupleInvalid("frBbox", 1, 3, 3, 2); __PYX_ERR(0, 245, __pyx_L3_error)
  5986. }
  5987. }
  5988. if (unlikely(kw_args > 0)) {
  5989. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "frBbox") < 0)) __PYX_ERR(0, 245, __pyx_L3_error)
  5990. }
  5991. } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
  5992. goto __pyx_L5_argtuple_error;
  5993. } else {
  5994. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5995. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  5996. values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  5997. }
  5998. __pyx_v_bb = ((PyArrayObject *)values[0]);
  5999. __pyx_v_h = __Pyx_PyInt_As_siz(values[1]); if (unlikely((__pyx_v_h == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 245, __pyx_L3_error)
  6000. __pyx_v_w = __Pyx_PyInt_As_siz(values[2]); if (unlikely((__pyx_v_w == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 245, __pyx_L3_error)
  6001. }
  6002. goto __pyx_L4_argument_unpacking_done;
  6003. __pyx_L5_argtuple_error:;
  6004. __Pyx_RaiseArgtupleInvalid("frBbox", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 245, __pyx_L3_error)
  6005. __pyx_L3_error:;
  6006. __Pyx_AddTraceback("pycocotools._mask.frBbox", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6007. __Pyx_RefNannyFinishContext();
  6008. return NULL;
  6009. __pyx_L4_argument_unpacking_done:;
  6010. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_bb), __pyx_ptype_5numpy_ndarray, 1, "bb", 0))) __PYX_ERR(0, 245, __pyx_L1_error)
  6011. __pyx_r = __pyx_pf_11pycocotools_5_mask_16frBbox(__pyx_self, __pyx_v_bb, __pyx_v_h, __pyx_v_w);
  6012. /* function exit code */
  6013. goto __pyx_L0;
  6014. __pyx_L1_error:;
  6015. __pyx_r = NULL;
  6016. __pyx_L0:;
  6017. __Pyx_RefNannyFinishContext();
  6018. return __pyx_r;
  6019. }
  6020. static PyObject *__pyx_pf_11pycocotools_5_mask_16frBbox(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_bb, siz __pyx_v_h, siz __pyx_v_w) {
  6021. siz __pyx_v_n;
  6022. struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_Rs = NULL;
  6023. PyObject *__pyx_v_objs = NULL;
  6024. __Pyx_LocalBuf_ND __pyx_pybuffernd_bb;
  6025. __Pyx_Buffer __pyx_pybuffer_bb;
  6026. PyObject *__pyx_r = NULL;
  6027. __Pyx_RefNannyDeclarations
  6028. PyObject *__pyx_t_1 = NULL;
  6029. PyObject *__pyx_t_2 = NULL;
  6030. PyObject *__pyx_t_3 = NULL;
  6031. __Pyx_RefNannySetupContext("frBbox", 0);
  6032. __pyx_pybuffer_bb.pybuffer.buf = NULL;
  6033. __pyx_pybuffer_bb.refcount = 0;
  6034. __pyx_pybuffernd_bb.data = NULL;
  6035. __pyx_pybuffernd_bb.rcbuffer = &__pyx_pybuffer_bb;
  6036. {
  6037. __Pyx_BufFmt_StackElem __pyx_stack[1];
  6038. if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_bb.rcbuffer->pybuffer, (PyObject*)__pyx_v_bb, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 245, __pyx_L1_error)
  6039. }
  6040. __pyx_pybuffernd_bb.diminfo[0].strides = __pyx_pybuffernd_bb.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_bb.diminfo[0].shape = __pyx_pybuffernd_bb.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_bb.diminfo[1].strides = __pyx_pybuffernd_bb.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_bb.diminfo[1].shape = __pyx_pybuffernd_bb.rcbuffer->pybuffer.shape[1];
  6041. /* "pycocotools/_mask.pyx":246
  6042. *
  6043. * def frBbox(np.ndarray[np.double_t, ndim=2] bb, siz h, siz w ):
  6044. * cdef siz n = bb.shape[0] # <<<<<<<<<<<<<<
  6045. * Rs = RLEs(n)
  6046. * rleFrBbox( <RLE*> Rs._R, <const BB> bb.data, h, w, n )
  6047. */
  6048. __pyx_v_n = (__pyx_v_bb->dimensions[0]);
  6049. /* "pycocotools/_mask.pyx":247
  6050. * def frBbox(np.ndarray[np.double_t, ndim=2] bb, siz h, siz w ):
  6051. * cdef siz n = bb.shape[0]
  6052. * Rs = RLEs(n) # <<<<<<<<<<<<<<
  6053. * rleFrBbox( <RLE*> Rs._R, <const BB> bb.data, h, w, n )
  6054. * objs = _toString(Rs)
  6055. */
  6056. __pyx_t_1 = __Pyx_PyInt_From_siz(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 247, __pyx_L1_error)
  6057. __Pyx_GOTREF(__pyx_t_1);
  6058. __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_11pycocotools_5_mask_RLEs), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 247, __pyx_L1_error)
  6059. __Pyx_GOTREF(__pyx_t_2);
  6060. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6061. __pyx_v_Rs = ((struct __pyx_obj_11pycocotools_5_mask_RLEs *)__pyx_t_2);
  6062. __pyx_t_2 = 0;
  6063. /* "pycocotools/_mask.pyx":248
  6064. * cdef siz n = bb.shape[0]
  6065. * Rs = RLEs(n)
  6066. * rleFrBbox( <RLE*> Rs._R, <const BB> bb.data, h, w, n ) # <<<<<<<<<<<<<<
  6067. * objs = _toString(Rs)
  6068. * return objs
  6069. */
  6070. rleFrBbox(((RLE *)__pyx_v_Rs->_R), ((BB const )__pyx_v_bb->data), __pyx_v_h, __pyx_v_w, __pyx_v_n);
  6071. /* "pycocotools/_mask.pyx":249
  6072. * Rs = RLEs(n)
  6073. * rleFrBbox( <RLE*> Rs._R, <const BB> bb.data, h, w, n )
  6074. * objs = _toString(Rs) # <<<<<<<<<<<<<<
  6075. * return objs
  6076. *
  6077. */
  6078. __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_toString); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L1_error)
  6079. __Pyx_GOTREF(__pyx_t_1);
  6080. __pyx_t_3 = NULL;
  6081. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
  6082. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
  6083. if (likely(__pyx_t_3)) {
  6084. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  6085. __Pyx_INCREF(__pyx_t_3);
  6086. __Pyx_INCREF(function);
  6087. __Pyx_DECREF_SET(__pyx_t_1, function);
  6088. }
  6089. }
  6090. __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, ((PyObject *)__pyx_v_Rs)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_Rs));
  6091. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  6092. if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error)
  6093. __Pyx_GOTREF(__pyx_t_2);
  6094. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6095. __pyx_v_objs = __pyx_t_2;
  6096. __pyx_t_2 = 0;
  6097. /* "pycocotools/_mask.pyx":250
  6098. * rleFrBbox( <RLE*> Rs._R, <const BB> bb.data, h, w, n )
  6099. * objs = _toString(Rs)
  6100. * return objs # <<<<<<<<<<<<<<
  6101. *
  6102. * def frPoly( poly, siz h, siz w ):
  6103. */
  6104. __Pyx_XDECREF(__pyx_r);
  6105. __Pyx_INCREF(__pyx_v_objs);
  6106. __pyx_r = __pyx_v_objs;
  6107. goto __pyx_L0;
  6108. /* "pycocotools/_mask.pyx":245
  6109. * return bb
  6110. *
  6111. * def frBbox(np.ndarray[np.double_t, ndim=2] bb, siz h, siz w ): # <<<<<<<<<<<<<<
  6112. * cdef siz n = bb.shape[0]
  6113. * Rs = RLEs(n)
  6114. */
  6115. /* function exit code */
  6116. __pyx_L1_error:;
  6117. __Pyx_XDECREF(__pyx_t_1);
  6118. __Pyx_XDECREF(__pyx_t_2);
  6119. __Pyx_XDECREF(__pyx_t_3);
  6120. { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
  6121. __Pyx_PyThreadState_declare
  6122. __Pyx_PyThreadState_assign
  6123. __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
  6124. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bb.rcbuffer->pybuffer);
  6125. __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  6126. __Pyx_AddTraceback("pycocotools._mask.frBbox", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6127. __pyx_r = NULL;
  6128. goto __pyx_L2;
  6129. __pyx_L0:;
  6130. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bb.rcbuffer->pybuffer);
  6131. __pyx_L2:;
  6132. __Pyx_XDECREF((PyObject *)__pyx_v_Rs);
  6133. __Pyx_XDECREF(__pyx_v_objs);
  6134. __Pyx_XGIVEREF(__pyx_r);
  6135. __Pyx_RefNannyFinishContext();
  6136. return __pyx_r;
  6137. }
  6138. /* "pycocotools/_mask.pyx":252
  6139. * return objs
  6140. *
  6141. * def frPoly( poly, siz h, siz w ): # <<<<<<<<<<<<<<
  6142. * cdef np.ndarray[np.double_t, ndim=1] np_poly
  6143. * n = len(poly)
  6144. */
  6145. /* Python wrapper */
  6146. static PyObject *__pyx_pw_11pycocotools_5_mask_19frPoly(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  6147. static PyMethodDef __pyx_mdef_11pycocotools_5_mask_19frPoly = {"frPoly", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pycocotools_5_mask_19frPoly, METH_VARARGS|METH_KEYWORDS, 0};
  6148. static PyObject *__pyx_pw_11pycocotools_5_mask_19frPoly(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  6149. PyObject *__pyx_v_poly = 0;
  6150. siz __pyx_v_h;
  6151. siz __pyx_v_w;
  6152. PyObject *__pyx_r = 0;
  6153. __Pyx_RefNannyDeclarations
  6154. __Pyx_RefNannySetupContext("frPoly (wrapper)", 0);
  6155. {
  6156. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_poly,&__pyx_n_s_h,&__pyx_n_s_w,0};
  6157. PyObject* values[3] = {0,0,0};
  6158. if (unlikely(__pyx_kwds)) {
  6159. Py_ssize_t kw_args;
  6160. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  6161. switch (pos_args) {
  6162. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6163. CYTHON_FALLTHROUGH;
  6164. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6165. CYTHON_FALLTHROUGH;
  6166. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6167. CYTHON_FALLTHROUGH;
  6168. case 0: break;
  6169. default: goto __pyx_L5_argtuple_error;
  6170. }
  6171. kw_args = PyDict_Size(__pyx_kwds);
  6172. switch (pos_args) {
  6173. case 0:
  6174. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_poly)) != 0)) kw_args--;
  6175. else goto __pyx_L5_argtuple_error;
  6176. CYTHON_FALLTHROUGH;
  6177. case 1:
  6178. if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_h)) != 0)) kw_args--;
  6179. else {
  6180. __Pyx_RaiseArgtupleInvalid("frPoly", 1, 3, 3, 1); __PYX_ERR(0, 252, __pyx_L3_error)
  6181. }
  6182. CYTHON_FALLTHROUGH;
  6183. case 2:
  6184. if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--;
  6185. else {
  6186. __Pyx_RaiseArgtupleInvalid("frPoly", 1, 3, 3, 2); __PYX_ERR(0, 252, __pyx_L3_error)
  6187. }
  6188. }
  6189. if (unlikely(kw_args > 0)) {
  6190. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "frPoly") < 0)) __PYX_ERR(0, 252, __pyx_L3_error)
  6191. }
  6192. } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
  6193. goto __pyx_L5_argtuple_error;
  6194. } else {
  6195. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6196. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6197. values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6198. }
  6199. __pyx_v_poly = values[0];
  6200. __pyx_v_h = __Pyx_PyInt_As_siz(values[1]); if (unlikely((__pyx_v_h == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 252, __pyx_L3_error)
  6201. __pyx_v_w = __Pyx_PyInt_As_siz(values[2]); if (unlikely((__pyx_v_w == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 252, __pyx_L3_error)
  6202. }
  6203. goto __pyx_L4_argument_unpacking_done;
  6204. __pyx_L5_argtuple_error:;
  6205. __Pyx_RaiseArgtupleInvalid("frPoly", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 252, __pyx_L3_error)
  6206. __pyx_L3_error:;
  6207. __Pyx_AddTraceback("pycocotools._mask.frPoly", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6208. __Pyx_RefNannyFinishContext();
  6209. return NULL;
  6210. __pyx_L4_argument_unpacking_done:;
  6211. __pyx_r = __pyx_pf_11pycocotools_5_mask_18frPoly(__pyx_self, __pyx_v_poly, __pyx_v_h, __pyx_v_w);
  6212. /* function exit code */
  6213. __Pyx_RefNannyFinishContext();
  6214. return __pyx_r;
  6215. }
  6216. static PyObject *__pyx_pf_11pycocotools_5_mask_18frPoly(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_poly, siz __pyx_v_h, siz __pyx_v_w) {
  6217. PyArrayObject *__pyx_v_np_poly = 0;
  6218. Py_ssize_t __pyx_v_n;
  6219. struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_Rs = NULL;
  6220. PyObject *__pyx_v_i = NULL;
  6221. PyObject *__pyx_v_p = NULL;
  6222. PyObject *__pyx_v_objs = NULL;
  6223. __Pyx_LocalBuf_ND __pyx_pybuffernd_np_poly;
  6224. __Pyx_Buffer __pyx_pybuffer_np_poly;
  6225. PyObject *__pyx_r = NULL;
  6226. __Pyx_RefNannyDeclarations
  6227. Py_ssize_t __pyx_t_1;
  6228. PyObject *__pyx_t_2 = NULL;
  6229. PyObject *__pyx_t_3 = NULL;
  6230. PyObject *(*__pyx_t_4)(PyObject *);
  6231. PyObject *__pyx_t_5 = NULL;
  6232. PyObject *__pyx_t_6 = NULL;
  6233. PyObject *__pyx_t_7 = NULL;
  6234. PyObject *__pyx_t_8 = NULL;
  6235. PyObject *__pyx_t_9 = NULL;
  6236. PyArrayObject *__pyx_t_10 = NULL;
  6237. int __pyx_t_11;
  6238. PyObject *__pyx_t_12 = NULL;
  6239. PyObject *__pyx_t_13 = NULL;
  6240. PyObject *__pyx_t_14 = NULL;
  6241. Py_ssize_t __pyx_t_15;
  6242. Py_ssize_t __pyx_t_16;
  6243. __Pyx_RefNannySetupContext("frPoly", 0);
  6244. __pyx_pybuffer_np_poly.pybuffer.buf = NULL;
  6245. __pyx_pybuffer_np_poly.refcount = 0;
  6246. __pyx_pybuffernd_np_poly.data = NULL;
  6247. __pyx_pybuffernd_np_poly.rcbuffer = &__pyx_pybuffer_np_poly;
  6248. /* "pycocotools/_mask.pyx":254
  6249. * def frPoly( poly, siz h, siz w ):
  6250. * cdef np.ndarray[np.double_t, ndim=1] np_poly
  6251. * n = len(poly) # <<<<<<<<<<<<<<
  6252. * Rs = RLEs(n)
  6253. * for i, p in enumerate(poly):
  6254. */
  6255. __pyx_t_1 = PyObject_Length(__pyx_v_poly); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 254, __pyx_L1_error)
  6256. __pyx_v_n = __pyx_t_1;
  6257. /* "pycocotools/_mask.pyx":255
  6258. * cdef np.ndarray[np.double_t, ndim=1] np_poly
  6259. * n = len(poly)
  6260. * Rs = RLEs(n) # <<<<<<<<<<<<<<
  6261. * for i, p in enumerate(poly):
  6262. * np_poly = np.array(p, dtype=np.double, order='F')
  6263. */
  6264. __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 255, __pyx_L1_error)
  6265. __Pyx_GOTREF(__pyx_t_2);
  6266. __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_11pycocotools_5_mask_RLEs), __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 255, __pyx_L1_error)
  6267. __Pyx_GOTREF(__pyx_t_3);
  6268. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6269. __pyx_v_Rs = ((struct __pyx_obj_11pycocotools_5_mask_RLEs *)__pyx_t_3);
  6270. __pyx_t_3 = 0;
  6271. /* "pycocotools/_mask.pyx":256
  6272. * n = len(poly)
  6273. * Rs = RLEs(n)
  6274. * for i, p in enumerate(poly): # <<<<<<<<<<<<<<
  6275. * np_poly = np.array(p, dtype=np.double, order='F')
  6276. * rleFrPoly( <RLE*>&Rs._R[i], <const double*> np_poly.data, len(np_poly)/2, h, w )
  6277. */
  6278. __Pyx_INCREF(__pyx_int_0);
  6279. __pyx_t_3 = __pyx_int_0;
  6280. if (likely(PyList_CheckExact(__pyx_v_poly)) || PyTuple_CheckExact(__pyx_v_poly)) {
  6281. __pyx_t_2 = __pyx_v_poly; __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = 0;
  6282. __pyx_t_4 = NULL;
  6283. } else {
  6284. __pyx_t_1 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_poly); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 256, __pyx_L1_error)
  6285. __Pyx_GOTREF(__pyx_t_2);
  6286. __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 256, __pyx_L1_error)
  6287. }
  6288. for (;;) {
  6289. if (likely(!__pyx_t_4)) {
  6290. if (likely(PyList_CheckExact(__pyx_t_2))) {
  6291. if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_2)) break;
  6292. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6293. __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 256, __pyx_L1_error)
  6294. #else
  6295. __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 256, __pyx_L1_error)
  6296. __Pyx_GOTREF(__pyx_t_5);
  6297. #endif
  6298. } else {
  6299. if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
  6300. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6301. __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 256, __pyx_L1_error)
  6302. #else
  6303. __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 256, __pyx_L1_error)
  6304. __Pyx_GOTREF(__pyx_t_5);
  6305. #endif
  6306. }
  6307. } else {
  6308. __pyx_t_5 = __pyx_t_4(__pyx_t_2);
  6309. if (unlikely(!__pyx_t_5)) {
  6310. PyObject* exc_type = PyErr_Occurred();
  6311. if (exc_type) {
  6312. if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  6313. else __PYX_ERR(0, 256, __pyx_L1_error)
  6314. }
  6315. break;
  6316. }
  6317. __Pyx_GOTREF(__pyx_t_5);
  6318. }
  6319. __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_5);
  6320. __pyx_t_5 = 0;
  6321. __Pyx_INCREF(__pyx_t_3);
  6322. __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
  6323. __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 256, __pyx_L1_error)
  6324. __Pyx_GOTREF(__pyx_t_5);
  6325. __Pyx_DECREF(__pyx_t_3);
  6326. __pyx_t_3 = __pyx_t_5;
  6327. __pyx_t_5 = 0;
  6328. /* "pycocotools/_mask.pyx":257
  6329. * Rs = RLEs(n)
  6330. * for i, p in enumerate(poly):
  6331. * np_poly = np.array(p, dtype=np.double, order='F') # <<<<<<<<<<<<<<
  6332. * rleFrPoly( <RLE*>&Rs._R[i], <const double*> np_poly.data, len(np_poly)/2, h, w )
  6333. * objs = _toString(Rs)
  6334. */
  6335. __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 257, __pyx_L1_error)
  6336. __Pyx_GOTREF(__pyx_t_5);
  6337. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_array); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 257, __pyx_L1_error)
  6338. __Pyx_GOTREF(__pyx_t_6);
  6339. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6340. __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 257, __pyx_L1_error)
  6341. __Pyx_GOTREF(__pyx_t_5);
  6342. __Pyx_INCREF(__pyx_v_p);
  6343. __Pyx_GIVEREF(__pyx_v_p);
  6344. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_p);
  6345. __pyx_t_7 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 257, __pyx_L1_error)
  6346. __Pyx_GOTREF(__pyx_t_7);
  6347. __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 257, __pyx_L1_error)
  6348. __Pyx_GOTREF(__pyx_t_8);
  6349. __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_double); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 257, __pyx_L1_error)
  6350. __Pyx_GOTREF(__pyx_t_9);
  6351. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6352. if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_9) < 0) __PYX_ERR(0, 257, __pyx_L1_error)
  6353. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6354. if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_order, __pyx_n_s_F) < 0) __PYX_ERR(0, 257, __pyx_L1_error)
  6355. __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 257, __pyx_L1_error)
  6356. __Pyx_GOTREF(__pyx_t_9);
  6357. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6358. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6359. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6360. if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 257, __pyx_L1_error)
  6361. __pyx_t_10 = ((PyArrayObject *)__pyx_t_9);
  6362. {
  6363. __Pyx_BufFmt_StackElem __pyx_stack[1];
  6364. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_np_poly.rcbuffer->pybuffer);
  6365. __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_np_poly.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
  6366. if (unlikely(__pyx_t_11 < 0)) {
  6367. PyErr_Fetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
  6368. if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_np_poly.rcbuffer->pybuffer, (PyObject*)__pyx_v_np_poly, &__Pyx_TypeInfo_nn___pyx_t_5numpy_double_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
  6369. Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14);
  6370. __Pyx_RaiseBufferFallbackError();
  6371. } else {
  6372. PyErr_Restore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
  6373. }
  6374. __pyx_t_12 = __pyx_t_13 = __pyx_t_14 = 0;
  6375. }
  6376. __pyx_pybuffernd_np_poly.diminfo[0].strides = __pyx_pybuffernd_np_poly.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_np_poly.diminfo[0].shape = __pyx_pybuffernd_np_poly.rcbuffer->pybuffer.shape[0];
  6377. if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 257, __pyx_L1_error)
  6378. }
  6379. __pyx_t_10 = 0;
  6380. __Pyx_XDECREF_SET(__pyx_v_np_poly, ((PyArrayObject *)__pyx_t_9));
  6381. __pyx_t_9 = 0;
  6382. /* "pycocotools/_mask.pyx":258
  6383. * for i, p in enumerate(poly):
  6384. * np_poly = np.array(p, dtype=np.double, order='F')
  6385. * rleFrPoly( <RLE*>&Rs._R[i], <const double*> np_poly.data, len(np_poly)/2, h, w ) # <<<<<<<<<<<<<<
  6386. * objs = _toString(Rs)
  6387. * return objs
  6388. */
  6389. __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 258, __pyx_L1_error)
  6390. __pyx_t_16 = PyObject_Length(((PyObject *)__pyx_v_np_poly)); if (unlikely(__pyx_t_16 == ((Py_ssize_t)-1))) __PYX_ERR(0, 258, __pyx_L1_error)
  6391. rleFrPoly(((RLE *)(&(__pyx_v_Rs->_R[__pyx_t_15]))), ((double const *)__pyx_v_np_poly->data), __Pyx_div_Py_ssize_t(__pyx_t_16, 2), __pyx_v_h, __pyx_v_w);
  6392. /* "pycocotools/_mask.pyx":256
  6393. * n = len(poly)
  6394. * Rs = RLEs(n)
  6395. * for i, p in enumerate(poly): # <<<<<<<<<<<<<<
  6396. * np_poly = np.array(p, dtype=np.double, order='F')
  6397. * rleFrPoly( <RLE*>&Rs._R[i], <const double*> np_poly.data, len(np_poly)/2, h, w )
  6398. */
  6399. }
  6400. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6401. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6402. /* "pycocotools/_mask.pyx":259
  6403. * np_poly = np.array(p, dtype=np.double, order='F')
  6404. * rleFrPoly( <RLE*>&Rs._R[i], <const double*> np_poly.data, len(np_poly)/2, h, w )
  6405. * objs = _toString(Rs) # <<<<<<<<<<<<<<
  6406. * return objs
  6407. *
  6408. */
  6409. __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_toString); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 259, __pyx_L1_error)
  6410. __Pyx_GOTREF(__pyx_t_2);
  6411. __pyx_t_9 = NULL;
  6412. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  6413. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
  6414. if (likely(__pyx_t_9)) {
  6415. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  6416. __Pyx_INCREF(__pyx_t_9);
  6417. __Pyx_INCREF(function);
  6418. __Pyx_DECREF_SET(__pyx_t_2, function);
  6419. }
  6420. }
  6421. __pyx_t_3 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_9, ((PyObject *)__pyx_v_Rs)) : __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_Rs));
  6422. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  6423. if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error)
  6424. __Pyx_GOTREF(__pyx_t_3);
  6425. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6426. __pyx_v_objs = __pyx_t_3;
  6427. __pyx_t_3 = 0;
  6428. /* "pycocotools/_mask.pyx":260
  6429. * rleFrPoly( <RLE*>&Rs._R[i], <const double*> np_poly.data, len(np_poly)/2, h, w )
  6430. * objs = _toString(Rs)
  6431. * return objs # <<<<<<<<<<<<<<
  6432. *
  6433. * def frUncompressedRLE(ucRles, siz h, siz w):
  6434. */
  6435. __Pyx_XDECREF(__pyx_r);
  6436. __Pyx_INCREF(__pyx_v_objs);
  6437. __pyx_r = __pyx_v_objs;
  6438. goto __pyx_L0;
  6439. /* "pycocotools/_mask.pyx":252
  6440. * return objs
  6441. *
  6442. * def frPoly( poly, siz h, siz w ): # <<<<<<<<<<<<<<
  6443. * cdef np.ndarray[np.double_t, ndim=1] np_poly
  6444. * n = len(poly)
  6445. */
  6446. /* function exit code */
  6447. __pyx_L1_error:;
  6448. __Pyx_XDECREF(__pyx_t_2);
  6449. __Pyx_XDECREF(__pyx_t_3);
  6450. __Pyx_XDECREF(__pyx_t_5);
  6451. __Pyx_XDECREF(__pyx_t_6);
  6452. __Pyx_XDECREF(__pyx_t_7);
  6453. __Pyx_XDECREF(__pyx_t_8);
  6454. __Pyx_XDECREF(__pyx_t_9);
  6455. { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
  6456. __Pyx_PyThreadState_declare
  6457. __Pyx_PyThreadState_assign
  6458. __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
  6459. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_np_poly.rcbuffer->pybuffer);
  6460. __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  6461. __Pyx_AddTraceback("pycocotools._mask.frPoly", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6462. __pyx_r = NULL;
  6463. goto __pyx_L2;
  6464. __pyx_L0:;
  6465. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_np_poly.rcbuffer->pybuffer);
  6466. __pyx_L2:;
  6467. __Pyx_XDECREF((PyObject *)__pyx_v_np_poly);
  6468. __Pyx_XDECREF((PyObject *)__pyx_v_Rs);
  6469. __Pyx_XDECREF(__pyx_v_i);
  6470. __Pyx_XDECREF(__pyx_v_p);
  6471. __Pyx_XDECREF(__pyx_v_objs);
  6472. __Pyx_XGIVEREF(__pyx_r);
  6473. __Pyx_RefNannyFinishContext();
  6474. return __pyx_r;
  6475. }
  6476. /* "pycocotools/_mask.pyx":262
  6477. * return objs
  6478. *
  6479. * def frUncompressedRLE(ucRles, siz h, siz w): # <<<<<<<<<<<<<<
  6480. * cdef np.ndarray[np.uint32_t, ndim=1] cnts
  6481. * cdef RLE R
  6482. */
  6483. /* Python wrapper */
  6484. static PyObject *__pyx_pw_11pycocotools_5_mask_21frUncompressedRLE(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  6485. static PyMethodDef __pyx_mdef_11pycocotools_5_mask_21frUncompressedRLE = {"frUncompressedRLE", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pycocotools_5_mask_21frUncompressedRLE, METH_VARARGS|METH_KEYWORDS, 0};
  6486. static PyObject *__pyx_pw_11pycocotools_5_mask_21frUncompressedRLE(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  6487. PyObject *__pyx_v_ucRles = 0;
  6488. CYTHON_UNUSED siz __pyx_v_h;
  6489. CYTHON_UNUSED siz __pyx_v_w;
  6490. PyObject *__pyx_r = 0;
  6491. __Pyx_RefNannyDeclarations
  6492. __Pyx_RefNannySetupContext("frUncompressedRLE (wrapper)", 0);
  6493. {
  6494. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ucRles,&__pyx_n_s_h,&__pyx_n_s_w,0};
  6495. PyObject* values[3] = {0,0,0};
  6496. if (unlikely(__pyx_kwds)) {
  6497. Py_ssize_t kw_args;
  6498. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  6499. switch (pos_args) {
  6500. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6501. CYTHON_FALLTHROUGH;
  6502. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6503. CYTHON_FALLTHROUGH;
  6504. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6505. CYTHON_FALLTHROUGH;
  6506. case 0: break;
  6507. default: goto __pyx_L5_argtuple_error;
  6508. }
  6509. kw_args = PyDict_Size(__pyx_kwds);
  6510. switch (pos_args) {
  6511. case 0:
  6512. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ucRles)) != 0)) kw_args--;
  6513. else goto __pyx_L5_argtuple_error;
  6514. CYTHON_FALLTHROUGH;
  6515. case 1:
  6516. if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_h)) != 0)) kw_args--;
  6517. else {
  6518. __Pyx_RaiseArgtupleInvalid("frUncompressedRLE", 1, 3, 3, 1); __PYX_ERR(0, 262, __pyx_L3_error)
  6519. }
  6520. CYTHON_FALLTHROUGH;
  6521. case 2:
  6522. if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--;
  6523. else {
  6524. __Pyx_RaiseArgtupleInvalid("frUncompressedRLE", 1, 3, 3, 2); __PYX_ERR(0, 262, __pyx_L3_error)
  6525. }
  6526. }
  6527. if (unlikely(kw_args > 0)) {
  6528. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "frUncompressedRLE") < 0)) __PYX_ERR(0, 262, __pyx_L3_error)
  6529. }
  6530. } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
  6531. goto __pyx_L5_argtuple_error;
  6532. } else {
  6533. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6534. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6535. values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6536. }
  6537. __pyx_v_ucRles = values[0];
  6538. __pyx_v_h = __Pyx_PyInt_As_siz(values[1]); if (unlikely((__pyx_v_h == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 262, __pyx_L3_error)
  6539. __pyx_v_w = __Pyx_PyInt_As_siz(values[2]); if (unlikely((__pyx_v_w == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 262, __pyx_L3_error)
  6540. }
  6541. goto __pyx_L4_argument_unpacking_done;
  6542. __pyx_L5_argtuple_error:;
  6543. __Pyx_RaiseArgtupleInvalid("frUncompressedRLE", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 262, __pyx_L3_error)
  6544. __pyx_L3_error:;
  6545. __Pyx_AddTraceback("pycocotools._mask.frUncompressedRLE", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6546. __Pyx_RefNannyFinishContext();
  6547. return NULL;
  6548. __pyx_L4_argument_unpacking_done:;
  6549. __pyx_r = __pyx_pf_11pycocotools_5_mask_20frUncompressedRLE(__pyx_self, __pyx_v_ucRles, __pyx_v_h, __pyx_v_w);
  6550. /* function exit code */
  6551. __Pyx_RefNannyFinishContext();
  6552. return __pyx_r;
  6553. }
  6554. static PyObject *__pyx_pf_11pycocotools_5_mask_20frUncompressedRLE(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ucRles, CYTHON_UNUSED siz __pyx_v_h, CYTHON_UNUSED siz __pyx_v_w) {
  6555. PyArrayObject *__pyx_v_cnts = 0;
  6556. RLE __pyx_v_R;
  6557. uint *__pyx_v_data;
  6558. Py_ssize_t __pyx_v_n;
  6559. PyObject *__pyx_v_objs = NULL;
  6560. Py_ssize_t __pyx_v_i;
  6561. struct __pyx_obj_11pycocotools_5_mask_RLEs *__pyx_v_Rs = NULL;
  6562. Py_ssize_t __pyx_v_j;
  6563. __Pyx_LocalBuf_ND __pyx_pybuffernd_cnts;
  6564. __Pyx_Buffer __pyx_pybuffer_cnts;
  6565. PyObject *__pyx_r = NULL;
  6566. __Pyx_RefNannyDeclarations
  6567. Py_ssize_t __pyx_t_1;
  6568. PyObject *__pyx_t_2 = NULL;
  6569. Py_ssize_t __pyx_t_3;
  6570. Py_ssize_t __pyx_t_4;
  6571. PyObject *__pyx_t_5 = NULL;
  6572. PyObject *__pyx_t_6 = NULL;
  6573. PyObject *__pyx_t_7 = NULL;
  6574. PyObject *__pyx_t_8 = NULL;
  6575. PyArrayObject *__pyx_t_9 = NULL;
  6576. int __pyx_t_10;
  6577. PyObject *__pyx_t_11 = NULL;
  6578. PyObject *__pyx_t_12 = NULL;
  6579. PyObject *__pyx_t_13 = NULL;
  6580. Py_ssize_t __pyx_t_14;
  6581. Py_ssize_t __pyx_t_15;
  6582. Py_ssize_t __pyx_t_16;
  6583. Py_ssize_t __pyx_t_17;
  6584. RLE __pyx_t_18;
  6585. siz __pyx_t_19;
  6586. int __pyx_t_20;
  6587. __Pyx_RefNannySetupContext("frUncompressedRLE", 0);
  6588. __pyx_pybuffer_cnts.pybuffer.buf = NULL;
  6589. __pyx_pybuffer_cnts.refcount = 0;
  6590. __pyx_pybuffernd_cnts.data = NULL;
  6591. __pyx_pybuffernd_cnts.rcbuffer = &__pyx_pybuffer_cnts;
  6592. /* "pycocotools/_mask.pyx":266
  6593. * cdef RLE R
  6594. * cdef uint *data
  6595. * n = len(ucRles) # <<<<<<<<<<<<<<
  6596. * objs = []
  6597. * for i in range(n):
  6598. */
  6599. __pyx_t_1 = PyObject_Length(__pyx_v_ucRles); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 266, __pyx_L1_error)
  6600. __pyx_v_n = __pyx_t_1;
  6601. /* "pycocotools/_mask.pyx":267
  6602. * cdef uint *data
  6603. * n = len(ucRles)
  6604. * objs = [] # <<<<<<<<<<<<<<
  6605. * for i in range(n):
  6606. * Rs = RLEs(1)
  6607. */
  6608. __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 267, __pyx_L1_error)
  6609. __Pyx_GOTREF(__pyx_t_2);
  6610. __pyx_v_objs = ((PyObject*)__pyx_t_2);
  6611. __pyx_t_2 = 0;
  6612. /* "pycocotools/_mask.pyx":268
  6613. * n = len(ucRles)
  6614. * objs = []
  6615. * for i in range(n): # <<<<<<<<<<<<<<
  6616. * Rs = RLEs(1)
  6617. * cnts = np.array(ucRles[i]['counts'], dtype=np.uint32)
  6618. */
  6619. __pyx_t_1 = __pyx_v_n;
  6620. __pyx_t_3 = __pyx_t_1;
  6621. for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
  6622. __pyx_v_i = __pyx_t_4;
  6623. /* "pycocotools/_mask.pyx":269
  6624. * objs = []
  6625. * for i in range(n):
  6626. * Rs = RLEs(1) # <<<<<<<<<<<<<<
  6627. * cnts = np.array(ucRles[i]['counts'], dtype=np.uint32)
  6628. * # time for malloc can be saved here but it's fine
  6629. */
  6630. __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_11pycocotools_5_mask_RLEs), __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error)
  6631. __Pyx_GOTREF(__pyx_t_2);
  6632. __Pyx_XDECREF_SET(__pyx_v_Rs, ((struct __pyx_obj_11pycocotools_5_mask_RLEs *)__pyx_t_2));
  6633. __pyx_t_2 = 0;
  6634. /* "pycocotools/_mask.pyx":270
  6635. * for i in range(n):
  6636. * Rs = RLEs(1)
  6637. * cnts = np.array(ucRles[i]['counts'], dtype=np.uint32) # <<<<<<<<<<<<<<
  6638. * # time for malloc can be saved here but it's fine
  6639. * data = <uint*> malloc(len(cnts)* sizeof(uint))
  6640. */
  6641. __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 270, __pyx_L1_error)
  6642. __Pyx_GOTREF(__pyx_t_2);
  6643. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 270, __pyx_L1_error)
  6644. __Pyx_GOTREF(__pyx_t_5);
  6645. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6646. __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_ucRles, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 270, __pyx_L1_error)
  6647. __Pyx_GOTREF(__pyx_t_2);
  6648. __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_t_2, __pyx_n_s_counts); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 270, __pyx_L1_error)
  6649. __Pyx_GOTREF(__pyx_t_6);
  6650. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6651. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 270, __pyx_L1_error)
  6652. __Pyx_GOTREF(__pyx_t_2);
  6653. __Pyx_GIVEREF(__pyx_t_6);
  6654. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6);
  6655. __pyx_t_6 = 0;
  6656. __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 270, __pyx_L1_error)
  6657. __Pyx_GOTREF(__pyx_t_6);
  6658. __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 270, __pyx_L1_error)
  6659. __Pyx_GOTREF(__pyx_t_7);
  6660. __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_uint32); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 270, __pyx_L1_error)
  6661. __Pyx_GOTREF(__pyx_t_8);
  6662. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6663. if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_8) < 0) __PYX_ERR(0, 270, __pyx_L1_error)
  6664. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6665. __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 270, __pyx_L1_error)
  6666. __Pyx_GOTREF(__pyx_t_8);
  6667. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6668. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6669. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6670. if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 270, __pyx_L1_error)
  6671. __pyx_t_9 = ((PyArrayObject *)__pyx_t_8);
  6672. {
  6673. __Pyx_BufFmt_StackElem __pyx_stack[1];
  6674. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cnts.rcbuffer->pybuffer);
  6675. __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_cnts.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
  6676. if (unlikely(__pyx_t_10 < 0)) {
  6677. PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
  6678. if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_cnts.rcbuffer->pybuffer, (PyObject*)__pyx_v_cnts, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
  6679. Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
  6680. __Pyx_RaiseBufferFallbackError();
  6681. } else {
  6682. PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
  6683. }
  6684. __pyx_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
  6685. }
  6686. __pyx_pybuffernd_cnts.diminfo[0].strides = __pyx_pybuffernd_cnts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_cnts.diminfo[0].shape = __pyx_pybuffernd_cnts.rcbuffer->pybuffer.shape[0];
  6687. if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 270, __pyx_L1_error)
  6688. }
  6689. __pyx_t_9 = 0;
  6690. __Pyx_XDECREF_SET(__pyx_v_cnts, ((PyArrayObject *)__pyx_t_8));
  6691. __pyx_t_8 = 0;
  6692. /* "pycocotools/_mask.pyx":272
  6693. * cnts = np.array(ucRles[i]['counts'], dtype=np.uint32)
  6694. * # time for malloc can be saved here but it's fine
  6695. * data = <uint*> malloc(len(cnts)* sizeof(uint)) # <<<<<<<<<<<<<<
  6696. * for j in range(len(cnts)):
  6697. * data[j] = <uint> cnts[j]
  6698. */
  6699. __pyx_t_14 = PyObject_Length(((PyObject *)__pyx_v_cnts)); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(0, 272, __pyx_L1_error)
  6700. __pyx_v_data = ((uint *)malloc((__pyx_t_14 * (sizeof(unsigned int)))));
  6701. /* "pycocotools/_mask.pyx":273
  6702. * # time for malloc can be saved here but it's fine
  6703. * data = <uint*> malloc(len(cnts)* sizeof(uint))
  6704. * for j in range(len(cnts)): # <<<<<<<<<<<<<<
  6705. * data[j] = <uint> cnts[j]
  6706. * R = RLE(ucRles[i]['size'][0], ucRles[i]['size'][1], len(cnts), <uint*> data)
  6707. */
  6708. __pyx_t_14 = PyObject_Length(((PyObject *)__pyx_v_cnts)); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(0, 273, __pyx_L1_error)
  6709. __pyx_t_15 = __pyx_t_14;
  6710. for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) {
  6711. __pyx_v_j = __pyx_t_16;
  6712. /* "pycocotools/_mask.pyx":274
  6713. * data = <uint*> malloc(len(cnts)* sizeof(uint))
  6714. * for j in range(len(cnts)):
  6715. * data[j] = <uint> cnts[j] # <<<<<<<<<<<<<<
  6716. * R = RLE(ucRles[i]['size'][0], ucRles[i]['size'][1], len(cnts), <uint*> data)
  6717. * Rs._R[0] = R
  6718. */
  6719. __pyx_t_17 = __pyx_v_j;
  6720. __pyx_t_10 = -1;
  6721. if (__pyx_t_17 < 0) {
  6722. __pyx_t_17 += __pyx_pybuffernd_cnts.diminfo[0].shape;
  6723. if (unlikely(__pyx_t_17 < 0)) __pyx_t_10 = 0;
  6724. } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_cnts.diminfo[0].shape)) __pyx_t_10 = 0;
  6725. if (unlikely(__pyx_t_10 != -1)) {
  6726. __Pyx_RaiseBufferIndexError(__pyx_t_10);
  6727. __PYX_ERR(0, 274, __pyx_L1_error)
  6728. }
  6729. (__pyx_v_data[__pyx_v_j]) = ((uint)(*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_uint32_t *, __pyx_pybuffernd_cnts.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_cnts.diminfo[0].strides)));
  6730. }
  6731. /* "pycocotools/_mask.pyx":275
  6732. * for j in range(len(cnts)):
  6733. * data[j] = <uint> cnts[j]
  6734. * R = RLE(ucRles[i]['size'][0], ucRles[i]['size'][1], len(cnts), <uint*> data) # <<<<<<<<<<<<<<
  6735. * Rs._R[0] = R
  6736. * objs.append(_toString(Rs)[0])
  6737. */
  6738. __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_ucRles, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 275, __pyx_L1_error)
  6739. __Pyx_GOTREF(__pyx_t_8);
  6740. __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_t_8, __pyx_n_s_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 275, __pyx_L1_error)
  6741. __Pyx_GOTREF(__pyx_t_6);
  6742. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6743. __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_6, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 275, __pyx_L1_error)
  6744. __Pyx_GOTREF(__pyx_t_8);
  6745. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6746. __pyx_t_19 = __Pyx_PyInt_As_siz(__pyx_t_8); if (unlikely((__pyx_t_19 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 275, __pyx_L1_error)
  6747. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6748. __pyx_t_18.h = __pyx_t_19;
  6749. __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_ucRles, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 275, __pyx_L1_error)
  6750. __Pyx_GOTREF(__pyx_t_8);
  6751. __pyx_t_6 = __Pyx_PyObject_Dict_GetItem(__pyx_t_8, __pyx_n_s_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 275, __pyx_L1_error)
  6752. __Pyx_GOTREF(__pyx_t_6);
  6753. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6754. __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_6, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 275, __pyx_L1_error)
  6755. __Pyx_GOTREF(__pyx_t_8);
  6756. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6757. __pyx_t_19 = __Pyx_PyInt_As_siz(__pyx_t_8); if (unlikely((__pyx_t_19 == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 275, __pyx_L1_error)
  6758. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6759. __pyx_t_18.w = __pyx_t_19;
  6760. __pyx_t_14 = PyObject_Length(((PyObject *)__pyx_v_cnts)); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(0, 275, __pyx_L1_error)
  6761. __pyx_t_18.m = __pyx_t_14;
  6762. __pyx_t_18.cnts = ((uint *)__pyx_v_data);
  6763. __pyx_v_R = __pyx_t_18;
  6764. /* "pycocotools/_mask.pyx":276
  6765. * data[j] = <uint> cnts[j]
  6766. * R = RLE(ucRles[i]['size'][0], ucRles[i]['size'][1], len(cnts), <uint*> data)
  6767. * Rs._R[0] = R # <<<<<<<<<<<<<<
  6768. * objs.append(_toString(Rs)[0])
  6769. * return objs
  6770. */
  6771. (__pyx_v_Rs->_R[0]) = __pyx_v_R;
  6772. /* "pycocotools/_mask.pyx":277
  6773. * R = RLE(ucRles[i]['size'][0], ucRles[i]['size'][1], len(cnts), <uint*> data)
  6774. * Rs._R[0] = R
  6775. * objs.append(_toString(Rs)[0]) # <<<<<<<<<<<<<<
  6776. * return objs
  6777. *
  6778. */
  6779. __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_toString); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 277, __pyx_L1_error)
  6780. __Pyx_GOTREF(__pyx_t_6);
  6781. __pyx_t_2 = NULL;
  6782. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
  6783. __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
  6784. if (likely(__pyx_t_2)) {
  6785. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
  6786. __Pyx_INCREF(__pyx_t_2);
  6787. __Pyx_INCREF(function);
  6788. __Pyx_DECREF_SET(__pyx_t_6, function);
  6789. }
  6790. }
  6791. __pyx_t_8 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_2, ((PyObject *)__pyx_v_Rs)) : __Pyx_PyObject_CallOneArg(__pyx_t_6, ((PyObject *)__pyx_v_Rs));
  6792. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  6793. if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 277, __pyx_L1_error)
  6794. __Pyx_GOTREF(__pyx_t_8);
  6795. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6796. __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 277, __pyx_L1_error)
  6797. __Pyx_GOTREF(__pyx_t_6);
  6798. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6799. __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_objs, __pyx_t_6); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 277, __pyx_L1_error)
  6800. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6801. }
  6802. /* "pycocotools/_mask.pyx":278
  6803. * Rs._R[0] = R
  6804. * objs.append(_toString(Rs)[0])
  6805. * return objs # <<<<<<<<<<<<<<
  6806. *
  6807. * def frPyObjects(pyobj, siz h, w):
  6808. */
  6809. __Pyx_XDECREF(__pyx_r);
  6810. __Pyx_INCREF(__pyx_v_objs);
  6811. __pyx_r = __pyx_v_objs;
  6812. goto __pyx_L0;
  6813. /* "pycocotools/_mask.pyx":262
  6814. * return objs
  6815. *
  6816. * def frUncompressedRLE(ucRles, siz h, siz w): # <<<<<<<<<<<<<<
  6817. * cdef np.ndarray[np.uint32_t, ndim=1] cnts
  6818. * cdef RLE R
  6819. */
  6820. /* function exit code */
  6821. __pyx_L1_error:;
  6822. __Pyx_XDECREF(__pyx_t_2);
  6823. __Pyx_XDECREF(__pyx_t_5);
  6824. __Pyx_XDECREF(__pyx_t_6);
  6825. __Pyx_XDECREF(__pyx_t_7);
  6826. __Pyx_XDECREF(__pyx_t_8);
  6827. { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
  6828. __Pyx_PyThreadState_declare
  6829. __Pyx_PyThreadState_assign
  6830. __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
  6831. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cnts.rcbuffer->pybuffer);
  6832. __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  6833. __Pyx_AddTraceback("pycocotools._mask.frUncompressedRLE", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6834. __pyx_r = NULL;
  6835. goto __pyx_L2;
  6836. __pyx_L0:;
  6837. __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cnts.rcbuffer->pybuffer);
  6838. __pyx_L2:;
  6839. __Pyx_XDECREF((PyObject *)__pyx_v_cnts);
  6840. __Pyx_XDECREF(__pyx_v_objs);
  6841. __Pyx_XDECREF((PyObject *)__pyx_v_Rs);
  6842. __Pyx_XGIVEREF(__pyx_r);
  6843. __Pyx_RefNannyFinishContext();
  6844. return __pyx_r;
  6845. }
  6846. /* "pycocotools/_mask.pyx":280
  6847. * return objs
  6848. *
  6849. * def frPyObjects(pyobj, siz h, w): # <<<<<<<<<<<<<<
  6850. * if type(pyobj) == np.ndarray:
  6851. * objs = frBbox(pyobj, h, w )
  6852. */
  6853. /* Python wrapper */
  6854. static PyObject *__pyx_pw_11pycocotools_5_mask_23frPyObjects(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  6855. static PyMethodDef __pyx_mdef_11pycocotools_5_mask_23frPyObjects = {"frPyObjects", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11pycocotools_5_mask_23frPyObjects, METH_VARARGS|METH_KEYWORDS, 0};
  6856. static PyObject *__pyx_pw_11pycocotools_5_mask_23frPyObjects(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  6857. PyObject *__pyx_v_pyobj = 0;
  6858. siz __pyx_v_h;
  6859. PyObject *__pyx_v_w = 0;
  6860. PyObject *__pyx_r = 0;
  6861. __Pyx_RefNannyDeclarations
  6862. __Pyx_RefNannySetupContext("frPyObjects (wrapper)", 0);
  6863. {
  6864. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyobj,&__pyx_n_s_h,&__pyx_n_s_w,0};
  6865. PyObject* values[3] = {0,0,0};
  6866. if (unlikely(__pyx_kwds)) {
  6867. Py_ssize_t kw_args;
  6868. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  6869. switch (pos_args) {
  6870. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6871. CYTHON_FALLTHROUGH;
  6872. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6873. CYTHON_FALLTHROUGH;
  6874. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6875. CYTHON_FALLTHROUGH;
  6876. case 0: break;
  6877. default: goto __pyx_L5_argtuple_error;
  6878. }
  6879. kw_args = PyDict_Size(__pyx_kwds);
  6880. switch (pos_args) {
  6881. case 0:
  6882. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyobj)) != 0)) kw_args--;
  6883. else goto __pyx_L5_argtuple_error;
  6884. CYTHON_FALLTHROUGH;
  6885. case 1:
  6886. if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_h)) != 0)) kw_args--;
  6887. else {
  6888. __Pyx_RaiseArgtupleInvalid("frPyObjects", 1, 3, 3, 1); __PYX_ERR(0, 280, __pyx_L3_error)
  6889. }
  6890. CYTHON_FALLTHROUGH;
  6891. case 2:
  6892. if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--;
  6893. else {
  6894. __Pyx_RaiseArgtupleInvalid("frPyObjects", 1, 3, 3, 2); __PYX_ERR(0, 280, __pyx_L3_error)
  6895. }
  6896. }
  6897. if (unlikely(kw_args > 0)) {
  6898. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "frPyObjects") < 0)) __PYX_ERR(0, 280, __pyx_L3_error)
  6899. }
  6900. } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
  6901. goto __pyx_L5_argtuple_error;
  6902. } else {
  6903. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6904. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6905. values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  6906. }
  6907. __pyx_v_pyobj = values[0];
  6908. __pyx_v_h = __Pyx_PyInt_As_siz(values[1]); if (unlikely((__pyx_v_h == ((siz)-1)) && PyErr_Occurred())) __PYX_ERR(0, 280, __pyx_L3_error)
  6909. __pyx_v_w = values[2];
  6910. }
  6911. goto __pyx_L4_argument_unpacking_done;
  6912. __pyx_L5_argtuple_error:;
  6913. __Pyx_RaiseArgtupleInvalid("frPyObjects", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 280, __pyx_L3_error)
  6914. __pyx_L3_error:;
  6915. __Pyx_AddTraceback("pycocotools._mask.frPyObjects", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6916. __Pyx_RefNannyFinishContext();
  6917. return NULL;
  6918. __pyx_L4_argument_unpacking_done:;
  6919. __pyx_r = __pyx_pf_11pycocotools_5_mask_22frPyObjects(__pyx_self, __pyx_v_pyobj, __pyx_v_h, __pyx_v_w);
  6920. /* function exit code */
  6921. __Pyx_RefNannyFinishContext();
  6922. return __pyx_r;
  6923. }
  6924. static PyObject *__pyx_pf_11pycocotools_5_mask_22frPyObjects(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_pyobj, siz __pyx_v_h, PyObject *__pyx_v_w) {
  6925. PyObject *__pyx_v_objs = NULL;
  6926. PyObject *__pyx_r = NULL;
  6927. __Pyx_RefNannyDeclarations
  6928. PyObject *__pyx_t_1 = NULL;
  6929. int __pyx_t_2;
  6930. PyObject *__pyx_t_3 = NULL;
  6931. PyObject *__pyx_t_4 = NULL;
  6932. PyObject *__pyx_t_5 = NULL;
  6933. int __pyx_t_6;
  6934. PyObject *__pyx_t_7 = NULL;
  6935. int __pyx_t_8;
  6936. Py_ssize_t __pyx_t_9;
  6937. __Pyx_RefNannySetupContext("frPyObjects", 0);
  6938. /* "pycocotools/_mask.pyx":281
  6939. *
  6940. * def frPyObjects(pyobj, siz h, w):
  6941. * if type(pyobj) == np.ndarray: # <<<<<<<<<<<<<<
  6942. * objs = frBbox(pyobj, h, w )
  6943. * elif type(pyobj) == list and len(pyobj[0]) == 4:
  6944. */
  6945. __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_pyobj)), ((PyObject *)__pyx_ptype_5numpy_ndarray), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error)
  6946. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 281, __pyx_L1_error)
  6947. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6948. if (__pyx_t_2) {
  6949. /* "pycocotools/_mask.pyx":282
  6950. * def frPyObjects(pyobj, siz h, w):
  6951. * if type(pyobj) == np.ndarray:
  6952. * objs = frBbox(pyobj, h, w ) # <<<<<<<<<<<<<<
  6953. * elif type(pyobj) == list and len(pyobj[0]) == 4:
  6954. * objs = frBbox(pyobj, h, w )
  6955. */
  6956. __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_frBbox); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 282, __pyx_L1_error)
  6957. __Pyx_GOTREF(__pyx_t_3);
  6958. __pyx_t_4 = __Pyx_PyInt_From_siz(__pyx_v_h); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 282, __pyx_L1_error)
  6959. __Pyx_GOTREF(__pyx_t_4);
  6960. __pyx_t_5 = NULL;
  6961. __pyx_t_6 = 0;
  6962. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  6963. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
  6964. if (likely(__pyx_t_5)) {
  6965. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  6966. __Pyx_INCREF(__pyx_t_5);
  6967. __Pyx_INCREF(function);
  6968. __Pyx_DECREF_SET(__pyx_t_3, function);
  6969. __pyx_t_6 = 1;
  6970. }
  6971. }
  6972. #if CYTHON_FAST_PYCALL
  6973. if (PyFunction_Check(__pyx_t_3)) {
  6974. PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_pyobj, __pyx_t_4, __pyx_v_w};
  6975. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L1_error)
  6976. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  6977. __Pyx_GOTREF(__pyx_t_1);
  6978. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6979. } else
  6980. #endif
  6981. #if CYTHON_FAST_PYCCALL
  6982. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  6983. PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_pyobj, __pyx_t_4, __pyx_v_w};
  6984. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L1_error)
  6985. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  6986. __Pyx_GOTREF(__pyx_t_1);
  6987. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6988. } else
  6989. #endif
  6990. {
  6991. __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 282, __pyx_L1_error)
  6992. __Pyx_GOTREF(__pyx_t_7);
  6993. if (__pyx_t_5) {
  6994. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
  6995. }
  6996. __Pyx_INCREF(__pyx_v_pyobj);
  6997. __Pyx_GIVEREF(__pyx_v_pyobj);
  6998. PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_pyobj);
  6999. __Pyx_GIVEREF(__pyx_t_4);
  7000. PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
  7001. __Pyx_INCREF(__pyx_v_w);
  7002. __Pyx_GIVEREF(__pyx_v_w);
  7003. PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_w);
  7004. __pyx_t_4 = 0;
  7005. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L1_error)
  7006. __Pyx_GOTREF(__pyx_t_1);
  7007. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7008. }
  7009. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7010. __pyx_v_objs = __pyx_t_1;
  7011. __pyx_t_1 = 0;
  7012. /* "pycocotools/_mask.pyx":281
  7013. *
  7014. * def frPyObjects(pyobj, siz h, w):
  7015. * if type(pyobj) == np.ndarray: # <<<<<<<<<<<<<<
  7016. * objs = frBbox(pyobj, h, w )
  7017. * elif type(pyobj) == list and len(pyobj[0]) == 4:
  7018. */
  7019. goto __pyx_L3;
  7020. }
  7021. /* "pycocotools/_mask.pyx":283
  7022. * if type(pyobj) == np.ndarray:
  7023. * objs = frBbox(pyobj, h, w )
  7024. * elif type(pyobj) == list and len(pyobj[0]) == 4: # <<<<<<<<<<<<<<
  7025. * objs = frBbox(pyobj, h, w )
  7026. * elif type(pyobj) == list and len(pyobj[0]) > 4:
  7027. */
  7028. __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_pyobj)), ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 283, __pyx_L1_error)
  7029. __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 283, __pyx_L1_error)
  7030. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7031. if (__pyx_t_8) {
  7032. } else {
  7033. __pyx_t_2 = __pyx_t_8;
  7034. goto __pyx_L4_bool_binop_done;
  7035. }
  7036. __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_pyobj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 283, __pyx_L1_error)
  7037. __Pyx_GOTREF(__pyx_t_1);
  7038. __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 283, __pyx_L1_error)
  7039. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7040. __pyx_t_8 = ((__pyx_t_9 == 4) != 0);
  7041. __pyx_t_2 = __pyx_t_8;
  7042. __pyx_L4_bool_binop_done:;
  7043. if (__pyx_t_2) {
  7044. /* "pycocotools/_mask.pyx":284
  7045. * objs = frBbox(pyobj, h, w )
  7046. * elif type(pyobj) == list and len(pyobj[0]) == 4:
  7047. * objs = frBbox(pyobj, h, w ) # <<<<<<<<<<<<<<
  7048. * elif type(pyobj) == list and len(pyobj[0]) > 4:
  7049. * objs = frPoly(pyobj, h, w )
  7050. */
  7051. __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_frBbox); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error)
  7052. __Pyx_GOTREF(__pyx_t_3);
  7053. __pyx_t_7 = __Pyx_PyInt_From_siz(__pyx_v_h); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 284, __pyx_L1_error)
  7054. __Pyx_GOTREF(__pyx_t_7);
  7055. __pyx_t_4 = NULL;
  7056. __pyx_t_6 = 0;
  7057. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  7058. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  7059. if (likely(__pyx_t_4)) {
  7060. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  7061. __Pyx_INCREF(__pyx_t_4);
  7062. __Pyx_INCREF(function);
  7063. __Pyx_DECREF_SET(__pyx_t_3, function);
  7064. __pyx_t_6 = 1;
  7065. }
  7066. }
  7067. #if CYTHON_FAST_PYCALL
  7068. if (PyFunction_Check(__pyx_t_3)) {
  7069. PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_pyobj, __pyx_t_7, __pyx_v_w};
  7070. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 284, __pyx_L1_error)
  7071. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7072. __Pyx_GOTREF(__pyx_t_1);
  7073. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7074. } else
  7075. #endif
  7076. #if CYTHON_FAST_PYCCALL
  7077. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  7078. PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_pyobj, __pyx_t_7, __pyx_v_w};
  7079. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 284, __pyx_L1_error)
  7080. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7081. __Pyx_GOTREF(__pyx_t_1);
  7082. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7083. } else
  7084. #endif
  7085. {
  7086. __pyx_t_5 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 284, __pyx_L1_error)
  7087. __Pyx_GOTREF(__pyx_t_5);
  7088. if (__pyx_t_4) {
  7089. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
  7090. }
  7091. __Pyx_INCREF(__pyx_v_pyobj);
  7092. __Pyx_GIVEREF(__pyx_v_pyobj);
  7093. PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_v_pyobj);
  7094. __Pyx_GIVEREF(__pyx_t_7);
  7095. PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_t_7);
  7096. __Pyx_INCREF(__pyx_v_w);
  7097. __Pyx_GIVEREF(__pyx_v_w);
  7098. PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_6, __pyx_v_w);
  7099. __pyx_t_7 = 0;
  7100. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 284, __pyx_L1_error)
  7101. __Pyx_GOTREF(__pyx_t_1);
  7102. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7103. }
  7104. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7105. __pyx_v_objs = __pyx_t_1;
  7106. __pyx_t_1 = 0;
  7107. /* "pycocotools/_mask.pyx":283
  7108. * if type(pyobj) == np.ndarray:
  7109. * objs = frBbox(pyobj, h, w )
  7110. * elif type(pyobj) == list and len(pyobj[0]) == 4: # <<<<<<<<<<<<<<
  7111. * objs = frBbox(pyobj, h, w )
  7112. * elif type(pyobj) == list and len(pyobj[0]) > 4:
  7113. */
  7114. goto __pyx_L3;
  7115. }
  7116. /* "pycocotools/_mask.pyx":285
  7117. * elif type(pyobj) == list and len(pyobj[0]) == 4:
  7118. * objs = frBbox(pyobj, h, w )
  7119. * elif type(pyobj) == list and len(pyobj[0]) > 4: # <<<<<<<<<<<<<<
  7120. * objs = frPoly(pyobj, h, w )
  7121. * elif type(pyobj) == list and type(pyobj[0]) == dict:
  7122. */
  7123. __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_pyobj)), ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error)
  7124. __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 285, __pyx_L1_error)
  7125. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7126. if (__pyx_t_8) {
  7127. } else {
  7128. __pyx_t_2 = __pyx_t_8;
  7129. goto __pyx_L6_bool_binop_done;
  7130. }
  7131. __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_pyobj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error)
  7132. __Pyx_GOTREF(__pyx_t_1);
  7133. __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 285, __pyx_L1_error)
  7134. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7135. __pyx_t_8 = ((__pyx_t_9 > 4) != 0);
  7136. __pyx_t_2 = __pyx_t_8;
  7137. __pyx_L6_bool_binop_done:;
  7138. if (__pyx_t_2) {
  7139. /* "pycocotools/_mask.pyx":286
  7140. * objs = frBbox(pyobj, h, w )
  7141. * elif type(pyobj) == list and len(pyobj[0]) > 4:
  7142. * objs = frPoly(pyobj, h, w ) # <<<<<<<<<<<<<<
  7143. * elif type(pyobj) == list and type(pyobj[0]) == dict:
  7144. * objs = frUncompressedRLE(pyobj, h, w)
  7145. */
  7146. __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_frPoly); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error)
  7147. __Pyx_GOTREF(__pyx_t_3);
  7148. __pyx_t_5 = __Pyx_PyInt_From_siz(__pyx_v_h); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 286, __pyx_L1_error)
  7149. __Pyx_GOTREF(__pyx_t_5);
  7150. __pyx_t_7 = NULL;
  7151. __pyx_t_6 = 0;
  7152. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  7153. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
  7154. if (likely(__pyx_t_7)) {
  7155. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  7156. __Pyx_INCREF(__pyx_t_7);
  7157. __Pyx_INCREF(function);
  7158. __Pyx_DECREF_SET(__pyx_t_3, function);
  7159. __pyx_t_6 = 1;
  7160. }
  7161. }
  7162. #if CYTHON_FAST_PYCALL
  7163. if (PyFunction_Check(__pyx_t_3)) {
  7164. PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_pyobj, __pyx_t_5, __pyx_v_w};
  7165. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error)
  7166. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7167. __Pyx_GOTREF(__pyx_t_1);
  7168. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7169. } else
  7170. #endif
  7171. #if CYTHON_FAST_PYCCALL
  7172. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  7173. PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_pyobj, __pyx_t_5, __pyx_v_w};
  7174. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error)
  7175. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7176. __Pyx_GOTREF(__pyx_t_1);
  7177. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7178. } else
  7179. #endif
  7180. {
  7181. __pyx_t_4 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 286, __pyx_L1_error)
  7182. __Pyx_GOTREF(__pyx_t_4);
  7183. if (__pyx_t_7) {
  7184. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7); __pyx_t_7 = NULL;
  7185. }
  7186. __Pyx_INCREF(__pyx_v_pyobj);
  7187. __Pyx_GIVEREF(__pyx_v_pyobj);
  7188. PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_pyobj);
  7189. __Pyx_GIVEREF(__pyx_t_5);
  7190. PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_t_5);
  7191. __Pyx_INCREF(__pyx_v_w);
  7192. __Pyx_GIVEREF(__pyx_v_w);
  7193. PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_6, __pyx_v_w);
  7194. __pyx_t_5 = 0;
  7195. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error)
  7196. __Pyx_GOTREF(__pyx_t_1);
  7197. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7198. }
  7199. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7200. __pyx_v_objs = __pyx_t_1;
  7201. __pyx_t_1 = 0;
  7202. /* "pycocotools/_mask.pyx":285
  7203. * elif type(pyobj) == list and len(pyobj[0]) == 4:
  7204. * objs = frBbox(pyobj, h, w )
  7205. * elif type(pyobj) == list and len(pyobj[0]) > 4: # <<<<<<<<<<<<<<
  7206. * objs = frPoly(pyobj, h, w )
  7207. * elif type(pyobj) == list and type(pyobj[0]) == dict:
  7208. */
  7209. goto __pyx_L3;
  7210. }
  7211. /* "pycocotools/_mask.pyx":287
  7212. * elif type(pyobj) == list and len(pyobj[0]) > 4:
  7213. * objs = frPoly(pyobj, h, w )
  7214. * elif type(pyobj) == list and type(pyobj[0]) == dict: # <<<<<<<<<<<<<<
  7215. * objs = frUncompressedRLE(pyobj, h, w)
  7216. * else:
  7217. */
  7218. __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_pyobj)), ((PyObject *)(&PyList_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
  7219. __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 287, __pyx_L1_error)
  7220. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7221. if (__pyx_t_8) {
  7222. } else {
  7223. __pyx_t_2 = __pyx_t_8;
  7224. goto __pyx_L8_bool_binop_done;
  7225. }
  7226. __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_pyobj, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
  7227. __Pyx_GOTREF(__pyx_t_1);
  7228. __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_t_1)), ((PyObject *)(&PyDict_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __pyx_L1_error)
  7229. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7230. __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 287, __pyx_L1_error)
  7231. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7232. __pyx_t_2 = __pyx_t_8;
  7233. __pyx_L8_bool_binop_done:;
  7234. if (likely(__pyx_t_2)) {
  7235. /* "pycocotools/_mask.pyx":288
  7236. * objs = frPoly(pyobj, h, w )
  7237. * elif type(pyobj) == list and type(pyobj[0]) == dict:
  7238. * objs = frUncompressedRLE(pyobj, h, w) # <<<<<<<<<<<<<<
  7239. * else:
  7240. * raise Exception('input type is not supported.')
  7241. */
  7242. __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_frUncompressedRLE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 288, __pyx_L1_error)
  7243. __Pyx_GOTREF(__pyx_t_1);
  7244. __pyx_t_4 = __Pyx_PyInt_From_siz(__pyx_v_h); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 288, __pyx_L1_error)
  7245. __Pyx_GOTREF(__pyx_t_4);
  7246. __pyx_t_5 = NULL;
  7247. __pyx_t_6 = 0;
  7248. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
  7249. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
  7250. if (likely(__pyx_t_5)) {
  7251. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  7252. __Pyx_INCREF(__pyx_t_5);
  7253. __Pyx_INCREF(function);
  7254. __Pyx_DECREF_SET(__pyx_t_1, function);
  7255. __pyx_t_6 = 1;
  7256. }
  7257. }
  7258. #if CYTHON_FAST_PYCALL
  7259. if (PyFunction_Check(__pyx_t_1)) {
  7260. PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_pyobj, __pyx_t_4, __pyx_v_w};
  7261. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error)
  7262. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7263. __Pyx_GOTREF(__pyx_t_3);
  7264. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7265. } else
  7266. #endif
  7267. #if CYTHON_FAST_PYCCALL
  7268. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  7269. PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_pyobj, __pyx_t_4, __pyx_v_w};
  7270. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error)
  7271. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7272. __Pyx_GOTREF(__pyx_t_3);
  7273. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7274. } else
  7275. #endif
  7276. {
  7277. __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 288, __pyx_L1_error)
  7278. __Pyx_GOTREF(__pyx_t_7);
  7279. if (__pyx_t_5) {
  7280. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
  7281. }
  7282. __Pyx_INCREF(__pyx_v_pyobj);
  7283. __Pyx_GIVEREF(__pyx_v_pyobj);
  7284. PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_pyobj);
  7285. __Pyx_GIVEREF(__pyx_t_4);
  7286. PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
  7287. __Pyx_INCREF(__pyx_v_w);
  7288. __Pyx_GIVEREF(__pyx_v_w);
  7289. PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_w);
  7290. __pyx_t_4 = 0;
  7291. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error)
  7292. __Pyx_GOTREF(__pyx_t_3);
  7293. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7294. }
  7295. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7296. __pyx_v_objs = __pyx_t_3;
  7297. __pyx_t_3 = 0;
  7298. /* "pycocotools/_mask.pyx":287
  7299. * elif type(pyobj) == list and len(pyobj[0]) > 4:
  7300. * objs = frPoly(pyobj, h, w )
  7301. * elif type(pyobj) == list and type(pyobj[0]) == dict: # <<<<<<<<<<<<<<
  7302. * objs = frUncompressedRLE(pyobj, h, w)
  7303. * else:
  7304. */
  7305. goto __pyx_L3;
  7306. }
  7307. /* "pycocotools/_mask.pyx":290
  7308. * objs = frUncompressedRLE(pyobj, h, w)
  7309. * else:
  7310. * raise Exception('input type is not supported.') # <<<<<<<<<<<<<<
  7311. * return objs
  7312. */
  7313. /*else*/ {
  7314. __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 290, __pyx_L1_error)
  7315. __Pyx_GOTREF(__pyx_t_3);
  7316. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  7317. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7318. __PYX_ERR(0, 290, __pyx_L1_error)
  7319. }
  7320. __pyx_L3:;
  7321. /* "pycocotools/_mask.pyx":291
  7322. * else:
  7323. * raise Exception('input type is not supported.')
  7324. * return objs # <<<<<<<<<<<<<<
  7325. */
  7326. __Pyx_XDECREF(__pyx_r);
  7327. __Pyx_INCREF(__pyx_v_objs);
  7328. __pyx_r = __pyx_v_objs;
  7329. goto __pyx_L0;
  7330. /* "pycocotools/_mask.pyx":280
  7331. * return objs
  7332. *
  7333. * def frPyObjects(pyobj, siz h, w): # <<<<<<<<<<<<<<
  7334. * if type(pyobj) == np.ndarray:
  7335. * objs = frBbox(pyobj, h, w )
  7336. */
  7337. /* function exit code */
  7338. __pyx_L1_error:;
  7339. __Pyx_XDECREF(__pyx_t_1);
  7340. __Pyx_XDECREF(__pyx_t_3);
  7341. __Pyx_XDECREF(__pyx_t_4);
  7342. __Pyx_XDECREF(__pyx_t_5);
  7343. __Pyx_XDECREF(__pyx_t_7);
  7344. __Pyx_AddTraceback("pycocotools._mask.frPyObjects", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7345. __pyx_r = NULL;
  7346. __pyx_L0:;
  7347. __Pyx_XDECREF(__pyx_v_objs);
  7348. __Pyx_XGIVEREF(__pyx_r);
  7349. __Pyx_RefNannyFinishContext();
  7350. return __pyx_r;
  7351. }
  7352. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":258
  7353. * # experimental exception made for __getbuffer__ and __releasebuffer__
  7354. * # -- the details of this may change.
  7355. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<<
  7356. * # This implementation of getbuffer is geared towards Cython
  7357. * # requirements, and does not yet fulfill the PEP.
  7358. */
  7359. /* Python wrapper */
  7360. static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
  7361. static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  7362. int __pyx_r;
  7363. __Pyx_RefNannyDeclarations
  7364. __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
  7365. __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));
  7366. /* function exit code */
  7367. __Pyx_RefNannyFinishContext();
  7368. return __pyx_r;
  7369. }
  7370. static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  7371. int __pyx_v_i;
  7372. int __pyx_v_ndim;
  7373. int __pyx_v_endian_detector;
  7374. int __pyx_v_little_endian;
  7375. int __pyx_v_t;
  7376. char *__pyx_v_f;
  7377. PyArray_Descr *__pyx_v_descr = 0;
  7378. int __pyx_v_offset;
  7379. int __pyx_r;
  7380. __Pyx_RefNannyDeclarations
  7381. int __pyx_t_1;
  7382. int __pyx_t_2;
  7383. PyObject *__pyx_t_3 = NULL;
  7384. int __pyx_t_4;
  7385. int __pyx_t_5;
  7386. int __pyx_t_6;
  7387. PyArray_Descr *__pyx_t_7;
  7388. PyObject *__pyx_t_8 = NULL;
  7389. char *__pyx_t_9;
  7390. if (__pyx_v_info == NULL) {
  7391. PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
  7392. return -1;
  7393. }
  7394. __Pyx_RefNannySetupContext("__getbuffer__", 0);
  7395. __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
  7396. __Pyx_GIVEREF(__pyx_v_info->obj);
  7397. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":265
  7398. *
  7399. * cdef int i, ndim
  7400. * cdef int endian_detector = 1 # <<<<<<<<<<<<<<
  7401. * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
  7402. *
  7403. */
  7404. __pyx_v_endian_detector = 1;
  7405. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":266
  7406. * cdef int i, ndim
  7407. * cdef int endian_detector = 1
  7408. * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) # <<<<<<<<<<<<<<
  7409. *
  7410. * ndim = PyArray_NDIM(self)
  7411. */
  7412. __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);
  7413. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":268
  7414. * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
  7415. *
  7416. * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<<
  7417. *
  7418. * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
  7419. */
  7420. __pyx_v_ndim = PyArray_NDIM(__pyx_v_self);
  7421. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":270
  7422. * ndim = PyArray_NDIM(self)
  7423. *
  7424. * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<<
  7425. * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)):
  7426. * raise ValueError(u"ndarray is not C contiguous")
  7427. */
  7428. __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0);
  7429. if (__pyx_t_2) {
  7430. } else {
  7431. __pyx_t_1 = __pyx_t_2;
  7432. goto __pyx_L4_bool_binop_done;
  7433. }
  7434. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":271
  7435. *
  7436. * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
  7437. * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): # <<<<<<<<<<<<<<
  7438. * raise ValueError(u"ndarray is not C contiguous")
  7439. *
  7440. */
  7441. __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_ARRAY_C_CONTIGUOUS) != 0)) != 0);
  7442. __pyx_t_1 = __pyx_t_2;
  7443. __pyx_L4_bool_binop_done:;
  7444. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":270
  7445. * ndim = PyArray_NDIM(self)
  7446. *
  7447. * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<<
  7448. * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)):
  7449. * raise ValueError(u"ndarray is not C contiguous")
  7450. */
  7451. if (unlikely(__pyx_t_1)) {
  7452. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":272
  7453. * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
  7454. * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)):
  7455. * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<<
  7456. *
  7457. * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
  7458. */
  7459. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 272, __pyx_L1_error)
  7460. __Pyx_GOTREF(__pyx_t_3);
  7461. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  7462. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7463. __PYX_ERR(2, 272, __pyx_L1_error)
  7464. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":270
  7465. * ndim = PyArray_NDIM(self)
  7466. *
  7467. * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<<
  7468. * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)):
  7469. * raise ValueError(u"ndarray is not C contiguous")
  7470. */
  7471. }
  7472. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":274
  7473. * raise ValueError(u"ndarray is not C contiguous")
  7474. *
  7475. * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<<
  7476. * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)):
  7477. * raise ValueError(u"ndarray is not Fortran contiguous")
  7478. */
  7479. __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0);
  7480. if (__pyx_t_2) {
  7481. } else {
  7482. __pyx_t_1 = __pyx_t_2;
  7483. goto __pyx_L7_bool_binop_done;
  7484. }
  7485. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":275
  7486. *
  7487. * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
  7488. * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): # <<<<<<<<<<<<<<
  7489. * raise ValueError(u"ndarray is not Fortran contiguous")
  7490. *
  7491. */
  7492. __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_ARRAY_F_CONTIGUOUS) != 0)) != 0);
  7493. __pyx_t_1 = __pyx_t_2;
  7494. __pyx_L7_bool_binop_done:;
  7495. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":274
  7496. * raise ValueError(u"ndarray is not C contiguous")
  7497. *
  7498. * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<<
  7499. * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)):
  7500. * raise ValueError(u"ndarray is not Fortran contiguous")
  7501. */
  7502. if (unlikely(__pyx_t_1)) {
  7503. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":276
  7504. * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
  7505. * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)):
  7506. * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<<
  7507. *
  7508. * info.buf = PyArray_DATA(self)
  7509. */
  7510. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 276, __pyx_L1_error)
  7511. __Pyx_GOTREF(__pyx_t_3);
  7512. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  7513. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7514. __PYX_ERR(2, 276, __pyx_L1_error)
  7515. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":274
  7516. * raise ValueError(u"ndarray is not C contiguous")
  7517. *
  7518. * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<<
  7519. * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)):
  7520. * raise ValueError(u"ndarray is not Fortran contiguous")
  7521. */
  7522. }
  7523. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":278
  7524. * raise ValueError(u"ndarray is not Fortran contiguous")
  7525. *
  7526. * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<<
  7527. * info.ndim = ndim
  7528. * if sizeof(npy_intp) != sizeof(Py_ssize_t):
  7529. */
  7530. __pyx_v_info->buf = PyArray_DATA(__pyx_v_self);
  7531. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":279
  7532. *
  7533. * info.buf = PyArray_DATA(self)
  7534. * info.ndim = ndim # <<<<<<<<<<<<<<
  7535. * if sizeof(npy_intp) != sizeof(Py_ssize_t):
  7536. * # Allocate new buffer for strides and shape info.
  7537. */
  7538. __pyx_v_info->ndim = __pyx_v_ndim;
  7539. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":280
  7540. * info.buf = PyArray_DATA(self)
  7541. * info.ndim = ndim
  7542. * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<<
  7543. * # Allocate new buffer for strides and shape info.
  7544. * # This is allocated as one block, strides first.
  7545. */
  7546. __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
  7547. if (__pyx_t_1) {
  7548. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":283
  7549. * # Allocate new buffer for strides and shape info.
  7550. * # This is allocated as one block, strides first.
  7551. * info.strides = <Py_ssize_t*>PyObject_Malloc(sizeof(Py_ssize_t) * 2 * <size_t>ndim) # <<<<<<<<<<<<<<
  7552. * info.shape = info.strides + ndim
  7553. * for i in range(ndim):
  7554. */
  7555. __pyx_v_info->strides = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * 2) * ((size_t)__pyx_v_ndim))));
  7556. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":284
  7557. * # This is allocated as one block, strides first.
  7558. * info.strides = <Py_ssize_t*>PyObject_Malloc(sizeof(Py_ssize_t) * 2 * <size_t>ndim)
  7559. * info.shape = info.strides + ndim # <<<<<<<<<<<<<<
  7560. * for i in range(ndim):
  7561. * info.strides[i] = PyArray_STRIDES(self)[i]
  7562. */
  7563. __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim);
  7564. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":285
  7565. * info.strides = <Py_ssize_t*>PyObject_Malloc(sizeof(Py_ssize_t) * 2 * <size_t>ndim)
  7566. * info.shape = info.strides + ndim
  7567. * for i in range(ndim): # <<<<<<<<<<<<<<
  7568. * info.strides[i] = PyArray_STRIDES(self)[i]
  7569. * info.shape[i] = PyArray_DIMS(self)[i]
  7570. */
  7571. __pyx_t_4 = __pyx_v_ndim;
  7572. __pyx_t_5 = __pyx_t_4;
  7573. for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
  7574. __pyx_v_i = __pyx_t_6;
  7575. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":286
  7576. * info.shape = info.strides + ndim
  7577. * for i in range(ndim):
  7578. * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<<
  7579. * info.shape[i] = PyArray_DIMS(self)[i]
  7580. * else:
  7581. */
  7582. (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]);
  7583. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":287
  7584. * for i in range(ndim):
  7585. * info.strides[i] = PyArray_STRIDES(self)[i]
  7586. * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<<
  7587. * else:
  7588. * info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
  7589. */
  7590. (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]);
  7591. }
  7592. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":280
  7593. * info.buf = PyArray_DATA(self)
  7594. * info.ndim = ndim
  7595. * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<<
  7596. * # Allocate new buffer for strides and shape info.
  7597. * # This is allocated as one block, strides first.
  7598. */
  7599. goto __pyx_L9;
  7600. }
  7601. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":289
  7602. * info.shape[i] = PyArray_DIMS(self)[i]
  7603. * else:
  7604. * info.strides = <Py_ssize_t*>PyArray_STRIDES(self) # <<<<<<<<<<<<<<
  7605. * info.shape = <Py_ssize_t*>PyArray_DIMS(self)
  7606. * info.suboffsets = NULL
  7607. */
  7608. /*else*/ {
  7609. __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self));
  7610. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":290
  7611. * else:
  7612. * info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
  7613. * info.shape = <Py_ssize_t*>PyArray_DIMS(self) # <<<<<<<<<<<<<<
  7614. * info.suboffsets = NULL
  7615. * info.itemsize = PyArray_ITEMSIZE(self)
  7616. */
  7617. __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self));
  7618. }
  7619. __pyx_L9:;
  7620. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":291
  7621. * info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
  7622. * info.shape = <Py_ssize_t*>PyArray_DIMS(self)
  7623. * info.suboffsets = NULL # <<<<<<<<<<<<<<
  7624. * info.itemsize = PyArray_ITEMSIZE(self)
  7625. * info.readonly = not PyArray_ISWRITEABLE(self)
  7626. */
  7627. __pyx_v_info->suboffsets = NULL;
  7628. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":292
  7629. * info.shape = <Py_ssize_t*>PyArray_DIMS(self)
  7630. * info.suboffsets = NULL
  7631. * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<<
  7632. * info.readonly = not PyArray_ISWRITEABLE(self)
  7633. *
  7634. */
  7635. __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self);
  7636. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":293
  7637. * info.suboffsets = NULL
  7638. * info.itemsize = PyArray_ITEMSIZE(self)
  7639. * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<<
  7640. *
  7641. * cdef int t
  7642. */
  7643. __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0));
  7644. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":296
  7645. *
  7646. * cdef int t
  7647. * cdef char* f = NULL # <<<<<<<<<<<<<<
  7648. * cdef dtype descr = <dtype>PyArray_DESCR(self)
  7649. * cdef int offset
  7650. */
  7651. __pyx_v_f = NULL;
  7652. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":297
  7653. * cdef int t
  7654. * cdef char* f = NULL
  7655. * cdef dtype descr = <dtype>PyArray_DESCR(self) # <<<<<<<<<<<<<<
  7656. * cdef int offset
  7657. *
  7658. */
  7659. __pyx_t_7 = PyArray_DESCR(__pyx_v_self);
  7660. __pyx_t_3 = ((PyObject *)__pyx_t_7);
  7661. __Pyx_INCREF(__pyx_t_3);
  7662. __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3);
  7663. __pyx_t_3 = 0;
  7664. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":300
  7665. * cdef int offset
  7666. *
  7667. * info.obj = self # <<<<<<<<<<<<<<
  7668. *
  7669. * if not PyDataType_HASFIELDS(descr):
  7670. */
  7671. __Pyx_INCREF(((PyObject *)__pyx_v_self));
  7672. __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  7673. __Pyx_GOTREF(__pyx_v_info->obj);
  7674. __Pyx_DECREF(__pyx_v_info->obj);
  7675. __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
  7676. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":302
  7677. * info.obj = self
  7678. *
  7679. * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<<
  7680. * t = descr.type_num
  7681. * if ((descr.byteorder == c'>' and little_endian) or
  7682. */
  7683. __pyx_t_1 = ((!(PyDataType_HASFIELDS(__pyx_v_descr) != 0)) != 0);
  7684. if (__pyx_t_1) {
  7685. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":303
  7686. *
  7687. * if not PyDataType_HASFIELDS(descr):
  7688. * t = descr.type_num # <<<<<<<<<<<<<<
  7689. * if ((descr.byteorder == c'>' and little_endian) or
  7690. * (descr.byteorder == c'<' and not little_endian)):
  7691. */
  7692. __pyx_t_4 = __pyx_v_descr->type_num;
  7693. __pyx_v_t = __pyx_t_4;
  7694. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":304
  7695. * if not PyDataType_HASFIELDS(descr):
  7696. * t = descr.type_num
  7697. * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
  7698. * (descr.byteorder == c'<' and not little_endian)):
  7699. * raise ValueError(u"Non-native byte order not supported")
  7700. */
  7701. __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0);
  7702. if (!__pyx_t_2) {
  7703. goto __pyx_L15_next_or;
  7704. } else {
  7705. }
  7706. __pyx_t_2 = (__pyx_v_little_endian != 0);
  7707. if (!__pyx_t_2) {
  7708. } else {
  7709. __pyx_t_1 = __pyx_t_2;
  7710. goto __pyx_L14_bool_binop_done;
  7711. }
  7712. __pyx_L15_next_or:;
  7713. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":305
  7714. * t = descr.type_num
  7715. * if ((descr.byteorder == c'>' and little_endian) or
  7716. * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<<
  7717. * raise ValueError(u"Non-native byte order not supported")
  7718. * if t == NPY_BYTE: f = "b"
  7719. */
  7720. __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0);
  7721. if (__pyx_t_2) {
  7722. } else {
  7723. __pyx_t_1 = __pyx_t_2;
  7724. goto __pyx_L14_bool_binop_done;
  7725. }
  7726. __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0);
  7727. __pyx_t_1 = __pyx_t_2;
  7728. __pyx_L14_bool_binop_done:;
  7729. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":304
  7730. * if not PyDataType_HASFIELDS(descr):
  7731. * t = descr.type_num
  7732. * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
  7733. * (descr.byteorder == c'<' and not little_endian)):
  7734. * raise ValueError(u"Non-native byte order not supported")
  7735. */
  7736. if (unlikely(__pyx_t_1)) {
  7737. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":306
  7738. * if ((descr.byteorder == c'>' and little_endian) or
  7739. * (descr.byteorder == c'<' and not little_endian)):
  7740. * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<<
  7741. * if t == NPY_BYTE: f = "b"
  7742. * elif t == NPY_UBYTE: f = "B"
  7743. */
  7744. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 306, __pyx_L1_error)
  7745. __Pyx_GOTREF(__pyx_t_3);
  7746. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  7747. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7748. __PYX_ERR(2, 306, __pyx_L1_error)
  7749. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":304
  7750. * if not PyDataType_HASFIELDS(descr):
  7751. * t = descr.type_num
  7752. * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
  7753. * (descr.byteorder == c'<' and not little_endian)):
  7754. * raise ValueError(u"Non-native byte order not supported")
  7755. */
  7756. }
  7757. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":307
  7758. * (descr.byteorder == c'<' and not little_endian)):
  7759. * raise ValueError(u"Non-native byte order not supported")
  7760. * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<<
  7761. * elif t == NPY_UBYTE: f = "B"
  7762. * elif t == NPY_SHORT: f = "h"
  7763. */
  7764. switch (__pyx_v_t) {
  7765. case NPY_BYTE:
  7766. __pyx_v_f = ((char *)"b");
  7767. break;
  7768. case NPY_UBYTE:
  7769. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":308
  7770. * raise ValueError(u"Non-native byte order not supported")
  7771. * if t == NPY_BYTE: f = "b"
  7772. * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<<
  7773. * elif t == NPY_SHORT: f = "h"
  7774. * elif t == NPY_USHORT: f = "H"
  7775. */
  7776. __pyx_v_f = ((char *)"B");
  7777. break;
  7778. case NPY_SHORT:
  7779. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":309
  7780. * if t == NPY_BYTE: f = "b"
  7781. * elif t == NPY_UBYTE: f = "B"
  7782. * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<<
  7783. * elif t == NPY_USHORT: f = "H"
  7784. * elif t == NPY_INT: f = "i"
  7785. */
  7786. __pyx_v_f = ((char *)"h");
  7787. break;
  7788. case NPY_USHORT:
  7789. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":310
  7790. * elif t == NPY_UBYTE: f = "B"
  7791. * elif t == NPY_SHORT: f = "h"
  7792. * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<<
  7793. * elif t == NPY_INT: f = "i"
  7794. * elif t == NPY_UINT: f = "I"
  7795. */
  7796. __pyx_v_f = ((char *)"H");
  7797. break;
  7798. case NPY_INT:
  7799. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":311
  7800. * elif t == NPY_SHORT: f = "h"
  7801. * elif t == NPY_USHORT: f = "H"
  7802. * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<<
  7803. * elif t == NPY_UINT: f = "I"
  7804. * elif t == NPY_LONG: f = "l"
  7805. */
  7806. __pyx_v_f = ((char *)"i");
  7807. break;
  7808. case NPY_UINT:
  7809. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":312
  7810. * elif t == NPY_USHORT: f = "H"
  7811. * elif t == NPY_INT: f = "i"
  7812. * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<<
  7813. * elif t == NPY_LONG: f = "l"
  7814. * elif t == NPY_ULONG: f = "L"
  7815. */
  7816. __pyx_v_f = ((char *)"I");
  7817. break;
  7818. case NPY_LONG:
  7819. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":313
  7820. * elif t == NPY_INT: f = "i"
  7821. * elif t == NPY_UINT: f = "I"
  7822. * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<<
  7823. * elif t == NPY_ULONG: f = "L"
  7824. * elif t == NPY_LONGLONG: f = "q"
  7825. */
  7826. __pyx_v_f = ((char *)"l");
  7827. break;
  7828. case NPY_ULONG:
  7829. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":314
  7830. * elif t == NPY_UINT: f = "I"
  7831. * elif t == NPY_LONG: f = "l"
  7832. * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<<
  7833. * elif t == NPY_LONGLONG: f = "q"
  7834. * elif t == NPY_ULONGLONG: f = "Q"
  7835. */
  7836. __pyx_v_f = ((char *)"L");
  7837. break;
  7838. case NPY_LONGLONG:
  7839. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":315
  7840. * elif t == NPY_LONG: f = "l"
  7841. * elif t == NPY_ULONG: f = "L"
  7842. * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<<
  7843. * elif t == NPY_ULONGLONG: f = "Q"
  7844. * elif t == NPY_FLOAT: f = "f"
  7845. */
  7846. __pyx_v_f = ((char *)"q");
  7847. break;
  7848. case NPY_ULONGLONG:
  7849. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":316
  7850. * elif t == NPY_ULONG: f = "L"
  7851. * elif t == NPY_LONGLONG: f = "q"
  7852. * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<<
  7853. * elif t == NPY_FLOAT: f = "f"
  7854. * elif t == NPY_DOUBLE: f = "d"
  7855. */
  7856. __pyx_v_f = ((char *)"Q");
  7857. break;
  7858. case NPY_FLOAT:
  7859. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":317
  7860. * elif t == NPY_LONGLONG: f = "q"
  7861. * elif t == NPY_ULONGLONG: f = "Q"
  7862. * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<<
  7863. * elif t == NPY_DOUBLE: f = "d"
  7864. * elif t == NPY_LONGDOUBLE: f = "g"
  7865. */
  7866. __pyx_v_f = ((char *)"f");
  7867. break;
  7868. case NPY_DOUBLE:
  7869. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":318
  7870. * elif t == NPY_ULONGLONG: f = "Q"
  7871. * elif t == NPY_FLOAT: f = "f"
  7872. * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<<
  7873. * elif t == NPY_LONGDOUBLE: f = "g"
  7874. * elif t == NPY_CFLOAT: f = "Zf"
  7875. */
  7876. __pyx_v_f = ((char *)"d");
  7877. break;
  7878. case NPY_LONGDOUBLE:
  7879. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":319
  7880. * elif t == NPY_FLOAT: f = "f"
  7881. * elif t == NPY_DOUBLE: f = "d"
  7882. * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<<
  7883. * elif t == NPY_CFLOAT: f = "Zf"
  7884. * elif t == NPY_CDOUBLE: f = "Zd"
  7885. */
  7886. __pyx_v_f = ((char *)"g");
  7887. break;
  7888. case NPY_CFLOAT:
  7889. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":320
  7890. * elif t == NPY_DOUBLE: f = "d"
  7891. * elif t == NPY_LONGDOUBLE: f = "g"
  7892. * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<<
  7893. * elif t == NPY_CDOUBLE: f = "Zd"
  7894. * elif t == NPY_CLONGDOUBLE: f = "Zg"
  7895. */
  7896. __pyx_v_f = ((char *)"Zf");
  7897. break;
  7898. case NPY_CDOUBLE:
  7899. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":321
  7900. * elif t == NPY_LONGDOUBLE: f = "g"
  7901. * elif t == NPY_CFLOAT: f = "Zf"
  7902. * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<<
  7903. * elif t == NPY_CLONGDOUBLE: f = "Zg"
  7904. * elif t == NPY_OBJECT: f = "O"
  7905. */
  7906. __pyx_v_f = ((char *)"Zd");
  7907. break;
  7908. case NPY_CLONGDOUBLE:
  7909. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":322
  7910. * elif t == NPY_CFLOAT: f = "Zf"
  7911. * elif t == NPY_CDOUBLE: f = "Zd"
  7912. * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<<
  7913. * elif t == NPY_OBJECT: f = "O"
  7914. * else:
  7915. */
  7916. __pyx_v_f = ((char *)"Zg");
  7917. break;
  7918. case NPY_OBJECT:
  7919. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":323
  7920. * elif t == NPY_CDOUBLE: f = "Zd"
  7921. * elif t == NPY_CLONGDOUBLE: f = "Zg"
  7922. * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<<
  7923. * else:
  7924. * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
  7925. */
  7926. __pyx_v_f = ((char *)"O");
  7927. break;
  7928. default:
  7929. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":325
  7930. * elif t == NPY_OBJECT: f = "O"
  7931. * else:
  7932. * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<<
  7933. * info.format = f
  7934. * return
  7935. */
  7936. __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 325, __pyx_L1_error)
  7937. __Pyx_GOTREF(__pyx_t_3);
  7938. __pyx_t_8 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 325, __pyx_L1_error)
  7939. __Pyx_GOTREF(__pyx_t_8);
  7940. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7941. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 325, __pyx_L1_error)
  7942. __Pyx_GOTREF(__pyx_t_3);
  7943. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7944. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  7945. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7946. __PYX_ERR(2, 325, __pyx_L1_error)
  7947. break;
  7948. }
  7949. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":326
  7950. * else:
  7951. * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
  7952. * info.format = f # <<<<<<<<<<<<<<
  7953. * return
  7954. * else:
  7955. */
  7956. __pyx_v_info->format = __pyx_v_f;
  7957. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":327
  7958. * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
  7959. * info.format = f
  7960. * return # <<<<<<<<<<<<<<
  7961. * else:
  7962. * info.format = <char*>PyObject_Malloc(_buffer_format_string_len)
  7963. */
  7964. __pyx_r = 0;
  7965. goto __pyx_L0;
  7966. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":302
  7967. * info.obj = self
  7968. *
  7969. * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<<
  7970. * t = descr.type_num
  7971. * if ((descr.byteorder == c'>' and little_endian) or
  7972. */
  7973. }
  7974. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":329
  7975. * return
  7976. * else:
  7977. * info.format = <char*>PyObject_Malloc(_buffer_format_string_len) # <<<<<<<<<<<<<<
  7978. * info.format[0] = c'^' # Native data types, manual alignment
  7979. * offset = 0
  7980. */
  7981. /*else*/ {
  7982. __pyx_v_info->format = ((char *)PyObject_Malloc(0xFF));
  7983. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":330
  7984. * else:
  7985. * info.format = <char*>PyObject_Malloc(_buffer_format_string_len)
  7986. * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<<
  7987. * offset = 0
  7988. * f = _util_dtypestring(descr, info.format + 1,
  7989. */
  7990. (__pyx_v_info->format[0]) = '^';
  7991. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":331
  7992. * info.format = <char*>PyObject_Malloc(_buffer_format_string_len)
  7993. * info.format[0] = c'^' # Native data types, manual alignment
  7994. * offset = 0 # <<<<<<<<<<<<<<
  7995. * f = _util_dtypestring(descr, info.format + 1,
  7996. * info.format + _buffer_format_string_len,
  7997. */
  7998. __pyx_v_offset = 0;
  7999. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":332
  8000. * info.format[0] = c'^' # Native data types, manual alignment
  8001. * offset = 0
  8002. * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<<
  8003. * info.format + _buffer_format_string_len,
  8004. * &offset)
  8005. */
  8006. __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(2, 332, __pyx_L1_error)
  8007. __pyx_v_f = __pyx_t_9;
  8008. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":335
  8009. * info.format + _buffer_format_string_len,
  8010. * &offset)
  8011. * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<<
  8012. *
  8013. * def __releasebuffer__(ndarray self, Py_buffer* info):
  8014. */
  8015. (__pyx_v_f[0]) = '\x00';
  8016. }
  8017. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":258
  8018. * # experimental exception made for __getbuffer__ and __releasebuffer__
  8019. * # -- the details of this may change.
  8020. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<<
  8021. * # This implementation of getbuffer is geared towards Cython
  8022. * # requirements, and does not yet fulfill the PEP.
  8023. */
  8024. /* function exit code */
  8025. __pyx_r = 0;
  8026. goto __pyx_L0;
  8027. __pyx_L1_error:;
  8028. __Pyx_XDECREF(__pyx_t_3);
  8029. __Pyx_XDECREF(__pyx_t_8);
  8030. __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8031. __pyx_r = -1;
  8032. if (__pyx_v_info->obj != NULL) {
  8033. __Pyx_GOTREF(__pyx_v_info->obj);
  8034. __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
  8035. }
  8036. goto __pyx_L2;
  8037. __pyx_L0:;
  8038. if (__pyx_v_info->obj == Py_None) {
  8039. __Pyx_GOTREF(__pyx_v_info->obj);
  8040. __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
  8041. }
  8042. __pyx_L2:;
  8043. __Pyx_XDECREF((PyObject *)__pyx_v_descr);
  8044. __Pyx_RefNannyFinishContext();
  8045. return __pyx_r;
  8046. }
  8047. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":337
  8048. * f[0] = c'\0' # Terminate format string
  8049. *
  8050. * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<<
  8051. * if PyArray_HASFIELDS(self):
  8052. * PyObject_Free(info.format)
  8053. */
  8054. /* Python wrapper */
  8055. static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
  8056. static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  8057. __Pyx_RefNannyDeclarations
  8058. __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0);
  8059. __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info));
  8060. /* function exit code */
  8061. __Pyx_RefNannyFinishContext();
  8062. }
  8063. static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  8064. __Pyx_RefNannyDeclarations
  8065. int __pyx_t_1;
  8066. __Pyx_RefNannySetupContext("__releasebuffer__", 0);
  8067. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":338
  8068. *
  8069. * def __releasebuffer__(ndarray self, Py_buffer* info):
  8070. * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<<
  8071. * PyObject_Free(info.format)
  8072. * if sizeof(npy_intp) != sizeof(Py_ssize_t):
  8073. */
  8074. __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0);
  8075. if (__pyx_t_1) {
  8076. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":339
  8077. * def __releasebuffer__(ndarray self, Py_buffer* info):
  8078. * if PyArray_HASFIELDS(self):
  8079. * PyObject_Free(info.format) # <<<<<<<<<<<<<<
  8080. * if sizeof(npy_intp) != sizeof(Py_ssize_t):
  8081. * PyObject_Free(info.strides)
  8082. */
  8083. PyObject_Free(__pyx_v_info->format);
  8084. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":338
  8085. *
  8086. * def __releasebuffer__(ndarray self, Py_buffer* info):
  8087. * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<<
  8088. * PyObject_Free(info.format)
  8089. * if sizeof(npy_intp) != sizeof(Py_ssize_t):
  8090. */
  8091. }
  8092. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":340
  8093. * if PyArray_HASFIELDS(self):
  8094. * PyObject_Free(info.format)
  8095. * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<<
  8096. * PyObject_Free(info.strides)
  8097. * # info.shape was stored after info.strides in the same block
  8098. */
  8099. __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
  8100. if (__pyx_t_1) {
  8101. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":341
  8102. * PyObject_Free(info.format)
  8103. * if sizeof(npy_intp) != sizeof(Py_ssize_t):
  8104. * PyObject_Free(info.strides) # <<<<<<<<<<<<<<
  8105. * # info.shape was stored after info.strides in the same block
  8106. *
  8107. */
  8108. PyObject_Free(__pyx_v_info->strides);
  8109. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":340
  8110. * if PyArray_HASFIELDS(self):
  8111. * PyObject_Free(info.format)
  8112. * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<<
  8113. * PyObject_Free(info.strides)
  8114. * # info.shape was stored after info.strides in the same block
  8115. */
  8116. }
  8117. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":337
  8118. * f[0] = c'\0' # Terminate format string
  8119. *
  8120. * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<<
  8121. * if PyArray_HASFIELDS(self):
  8122. * PyObject_Free(info.format)
  8123. */
  8124. /* function exit code */
  8125. __Pyx_RefNannyFinishContext();
  8126. }
  8127. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":821
  8128. * ctypedef npy_cdouble complex_t
  8129. *
  8130. * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<<
  8131. * return PyArray_MultiIterNew(1, <void*>a)
  8132. *
  8133. */
  8134. static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
  8135. PyObject *__pyx_r = NULL;
  8136. __Pyx_RefNannyDeclarations
  8137. PyObject *__pyx_t_1 = NULL;
  8138. __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);
  8139. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":822
  8140. *
  8141. * cdef inline object PyArray_MultiIterNew1(a):
  8142. * return PyArray_MultiIterNew(1, <void*>a) # <<<<<<<<<<<<<<
  8143. *
  8144. * cdef inline object PyArray_MultiIterNew2(a, b):
  8145. */
  8146. __Pyx_XDECREF(__pyx_r);
  8147. __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 822, __pyx_L1_error)
  8148. __Pyx_GOTREF(__pyx_t_1);
  8149. __pyx_r = __pyx_t_1;
  8150. __pyx_t_1 = 0;
  8151. goto __pyx_L0;
  8152. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":821
  8153. * ctypedef npy_cdouble complex_t
  8154. *
  8155. * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<<
  8156. * return PyArray_MultiIterNew(1, <void*>a)
  8157. *
  8158. */
  8159. /* function exit code */
  8160. __pyx_L1_error:;
  8161. __Pyx_XDECREF(__pyx_t_1);
  8162. __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8163. __pyx_r = 0;
  8164. __pyx_L0:;
  8165. __Pyx_XGIVEREF(__pyx_r);
  8166. __Pyx_RefNannyFinishContext();
  8167. return __pyx_r;
  8168. }
  8169. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":824
  8170. * return PyArray_MultiIterNew(1, <void*>a)
  8171. *
  8172. * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<<
  8173. * return PyArray_MultiIterNew(2, <void*>a, <void*>b)
  8174. *
  8175. */
  8176. static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
  8177. PyObject *__pyx_r = NULL;
  8178. __Pyx_RefNannyDeclarations
  8179. PyObject *__pyx_t_1 = NULL;
  8180. __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);
  8181. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":825
  8182. *
  8183. * cdef inline object PyArray_MultiIterNew2(a, b):
  8184. * return PyArray_MultiIterNew(2, <void*>a, <void*>b) # <<<<<<<<<<<<<<
  8185. *
  8186. * cdef inline object PyArray_MultiIterNew3(a, b, c):
  8187. */
  8188. __Pyx_XDECREF(__pyx_r);
  8189. __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 825, __pyx_L1_error)
  8190. __Pyx_GOTREF(__pyx_t_1);
  8191. __pyx_r = __pyx_t_1;
  8192. __pyx_t_1 = 0;
  8193. goto __pyx_L0;
  8194. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":824
  8195. * return PyArray_MultiIterNew(1, <void*>a)
  8196. *
  8197. * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<<
  8198. * return PyArray_MultiIterNew(2, <void*>a, <void*>b)
  8199. *
  8200. */
  8201. /* function exit code */
  8202. __pyx_L1_error:;
  8203. __Pyx_XDECREF(__pyx_t_1);
  8204. __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8205. __pyx_r = 0;
  8206. __pyx_L0:;
  8207. __Pyx_XGIVEREF(__pyx_r);
  8208. __Pyx_RefNannyFinishContext();
  8209. return __pyx_r;
  8210. }
  8211. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":827
  8212. * return PyArray_MultiIterNew(2, <void*>a, <void*>b)
  8213. *
  8214. * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<<
  8215. * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
  8216. *
  8217. */
  8218. static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
  8219. PyObject *__pyx_r = NULL;
  8220. __Pyx_RefNannyDeclarations
  8221. PyObject *__pyx_t_1 = NULL;
  8222. __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);
  8223. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":828
  8224. *
  8225. * cdef inline object PyArray_MultiIterNew3(a, b, c):
  8226. * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c) # <<<<<<<<<<<<<<
  8227. *
  8228. * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
  8229. */
  8230. __Pyx_XDECREF(__pyx_r);
  8231. __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 828, __pyx_L1_error)
  8232. __Pyx_GOTREF(__pyx_t_1);
  8233. __pyx_r = __pyx_t_1;
  8234. __pyx_t_1 = 0;
  8235. goto __pyx_L0;
  8236. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":827
  8237. * return PyArray_MultiIterNew(2, <void*>a, <void*>b)
  8238. *
  8239. * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<<
  8240. * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
  8241. *
  8242. */
  8243. /* function exit code */
  8244. __pyx_L1_error:;
  8245. __Pyx_XDECREF(__pyx_t_1);
  8246. __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8247. __pyx_r = 0;
  8248. __pyx_L0:;
  8249. __Pyx_XGIVEREF(__pyx_r);
  8250. __Pyx_RefNannyFinishContext();
  8251. return __pyx_r;
  8252. }
  8253. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":830
  8254. * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
  8255. *
  8256. * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<<
  8257. * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
  8258. *
  8259. */
  8260. static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) {
  8261. PyObject *__pyx_r = NULL;
  8262. __Pyx_RefNannyDeclarations
  8263. PyObject *__pyx_t_1 = NULL;
  8264. __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);
  8265. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":831
  8266. *
  8267. * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
  8268. * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d) # <<<<<<<<<<<<<<
  8269. *
  8270. * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
  8271. */
  8272. __Pyx_XDECREF(__pyx_r);
  8273. __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 831, __pyx_L1_error)
  8274. __Pyx_GOTREF(__pyx_t_1);
  8275. __pyx_r = __pyx_t_1;
  8276. __pyx_t_1 = 0;
  8277. goto __pyx_L0;
  8278. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":830
  8279. * return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
  8280. *
  8281. * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<<
  8282. * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
  8283. *
  8284. */
  8285. /* function exit code */
  8286. __pyx_L1_error:;
  8287. __Pyx_XDECREF(__pyx_t_1);
  8288. __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8289. __pyx_r = 0;
  8290. __pyx_L0:;
  8291. __Pyx_XGIVEREF(__pyx_r);
  8292. __Pyx_RefNannyFinishContext();
  8293. return __pyx_r;
  8294. }
  8295. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":833
  8296. * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
  8297. *
  8298. * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<<
  8299. * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
  8300. *
  8301. */
  8302. static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) {
  8303. PyObject *__pyx_r = NULL;
  8304. __Pyx_RefNannyDeclarations
  8305. PyObject *__pyx_t_1 = NULL;
  8306. __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);
  8307. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":834
  8308. *
  8309. * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
  8310. * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e) # <<<<<<<<<<<<<<
  8311. *
  8312. * cdef inline tuple PyDataType_SHAPE(dtype d):
  8313. */
  8314. __Pyx_XDECREF(__pyx_r);
  8315. __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 834, __pyx_L1_error)
  8316. __Pyx_GOTREF(__pyx_t_1);
  8317. __pyx_r = __pyx_t_1;
  8318. __pyx_t_1 = 0;
  8319. goto __pyx_L0;
  8320. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":833
  8321. * return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
  8322. *
  8323. * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<<
  8324. * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
  8325. *
  8326. */
  8327. /* function exit code */
  8328. __pyx_L1_error:;
  8329. __Pyx_XDECREF(__pyx_t_1);
  8330. __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8331. __pyx_r = 0;
  8332. __pyx_L0:;
  8333. __Pyx_XGIVEREF(__pyx_r);
  8334. __Pyx_RefNannyFinishContext();
  8335. return __pyx_r;
  8336. }
  8337. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":836
  8338. * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
  8339. *
  8340. * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<<
  8341. * if PyDataType_HASSUBARRAY(d):
  8342. * return <tuple>d.subarray.shape
  8343. */
  8344. static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) {
  8345. PyObject *__pyx_r = NULL;
  8346. __Pyx_RefNannyDeclarations
  8347. int __pyx_t_1;
  8348. __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0);
  8349. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":837
  8350. *
  8351. * cdef inline tuple PyDataType_SHAPE(dtype d):
  8352. * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<<
  8353. * return <tuple>d.subarray.shape
  8354. * else:
  8355. */
  8356. __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0);
  8357. if (__pyx_t_1) {
  8358. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":838
  8359. * cdef inline tuple PyDataType_SHAPE(dtype d):
  8360. * if PyDataType_HASSUBARRAY(d):
  8361. * return <tuple>d.subarray.shape # <<<<<<<<<<<<<<
  8362. * else:
  8363. * return ()
  8364. */
  8365. __Pyx_XDECREF(__pyx_r);
  8366. __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
  8367. __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
  8368. goto __pyx_L0;
  8369. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":837
  8370. *
  8371. * cdef inline tuple PyDataType_SHAPE(dtype d):
  8372. * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<<
  8373. * return <tuple>d.subarray.shape
  8374. * else:
  8375. */
  8376. }
  8377. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":840
  8378. * return <tuple>d.subarray.shape
  8379. * else:
  8380. * return () # <<<<<<<<<<<<<<
  8381. *
  8382. * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:
  8383. */
  8384. /*else*/ {
  8385. __Pyx_XDECREF(__pyx_r);
  8386. __Pyx_INCREF(__pyx_empty_tuple);
  8387. __pyx_r = __pyx_empty_tuple;
  8388. goto __pyx_L0;
  8389. }
  8390. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":836
  8391. * return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
  8392. *
  8393. * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<<
  8394. * if PyDataType_HASSUBARRAY(d):
  8395. * return <tuple>d.subarray.shape
  8396. */
  8397. /* function exit code */
  8398. __pyx_L0:;
  8399. __Pyx_XGIVEREF(__pyx_r);
  8400. __Pyx_RefNannyFinishContext();
  8401. return __pyx_r;
  8402. }
  8403. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":842
  8404. * return ()
  8405. *
  8406. * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<<
  8407. * # Recursive utility function used in __getbuffer__ to get format
  8408. * # string. The new location in the format string is returned.
  8409. */
  8410. static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) {
  8411. PyArray_Descr *__pyx_v_child = 0;
  8412. int __pyx_v_endian_detector;
  8413. int __pyx_v_little_endian;
  8414. PyObject *__pyx_v_fields = 0;
  8415. PyObject *__pyx_v_childname = NULL;
  8416. PyObject *__pyx_v_new_offset = NULL;
  8417. PyObject *__pyx_v_t = NULL;
  8418. char *__pyx_r;
  8419. __Pyx_RefNannyDeclarations
  8420. PyObject *__pyx_t_1 = NULL;
  8421. Py_ssize_t __pyx_t_2;
  8422. PyObject *__pyx_t_3 = NULL;
  8423. PyObject *__pyx_t_4 = NULL;
  8424. int __pyx_t_5;
  8425. int __pyx_t_6;
  8426. int __pyx_t_7;
  8427. long __pyx_t_8;
  8428. char *__pyx_t_9;
  8429. __Pyx_RefNannySetupContext("_util_dtypestring", 0);
  8430. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":847
  8431. *
  8432. * cdef dtype child
  8433. * cdef int endian_detector = 1 # <<<<<<<<<<<<<<
  8434. * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
  8435. * cdef tuple fields
  8436. */
  8437. __pyx_v_endian_detector = 1;
  8438. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":848
  8439. * cdef dtype child
  8440. * cdef int endian_detector = 1
  8441. * cdef bint little_endian = ((<char*>&endian_detector)[0] != 0) # <<<<<<<<<<<<<<
  8442. * cdef tuple fields
  8443. *
  8444. */
  8445. __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);
  8446. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":851
  8447. * cdef tuple fields
  8448. *
  8449. * for childname in descr.names: # <<<<<<<<<<<<<<
  8450. * fields = descr.fields[childname]
  8451. * child, new_offset = fields
  8452. */
  8453. if (unlikely(__pyx_v_descr->names == Py_None)) {
  8454. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
  8455. __PYX_ERR(2, 851, __pyx_L1_error)
  8456. }
  8457. __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  8458. for (;;) {
  8459. if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
  8460. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  8461. __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(2, 851, __pyx_L1_error)
  8462. #else
  8463. __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 851, __pyx_L1_error)
  8464. __Pyx_GOTREF(__pyx_t_3);
  8465. #endif
  8466. __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3);
  8467. __pyx_t_3 = 0;
  8468. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":852
  8469. *
  8470. * for childname in descr.names:
  8471. * fields = descr.fields[childname] # <<<<<<<<<<<<<<
  8472. * child, new_offset = fields
  8473. *
  8474. */
  8475. if (unlikely(__pyx_v_descr->fields == Py_None)) {
  8476. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
  8477. __PYX_ERR(2, 852, __pyx_L1_error)
  8478. }
  8479. __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 852, __pyx_L1_error)
  8480. __Pyx_GOTREF(__pyx_t_3);
  8481. if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(2, 852, __pyx_L1_error)
  8482. __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3));
  8483. __pyx_t_3 = 0;
  8484. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":853
  8485. * for childname in descr.names:
  8486. * fields = descr.fields[childname]
  8487. * child, new_offset = fields # <<<<<<<<<<<<<<
  8488. *
  8489. * if (end - f) - <int>(new_offset - offset[0]) < 15:
  8490. */
  8491. if (likely(__pyx_v_fields != Py_None)) {
  8492. PyObject* sequence = __pyx_v_fields;
  8493. Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
  8494. if (unlikely(size != 2)) {
  8495. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  8496. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  8497. __PYX_ERR(2, 853, __pyx_L1_error)
  8498. }
  8499. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  8500. __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
  8501. __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
  8502. __Pyx_INCREF(__pyx_t_3);
  8503. __Pyx_INCREF(__pyx_t_4);
  8504. #else
  8505. __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 853, __pyx_L1_error)
  8506. __Pyx_GOTREF(__pyx_t_3);
  8507. __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 853, __pyx_L1_error)
  8508. __Pyx_GOTREF(__pyx_t_4);
  8509. #endif
  8510. } else {
  8511. __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(2, 853, __pyx_L1_error)
  8512. }
  8513. if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(2, 853, __pyx_L1_error)
  8514. __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3));
  8515. __pyx_t_3 = 0;
  8516. __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4);
  8517. __pyx_t_4 = 0;
  8518. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":855
  8519. * child, new_offset = fields
  8520. *
  8521. * if (end - f) - <int>(new_offset - offset[0]) < 15: # <<<<<<<<<<<<<<
  8522. * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
  8523. *
  8524. */
  8525. __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 855, __pyx_L1_error)
  8526. __Pyx_GOTREF(__pyx_t_4);
  8527. __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 855, __pyx_L1_error)
  8528. __Pyx_GOTREF(__pyx_t_3);
  8529. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8530. __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 855, __pyx_L1_error)
  8531. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8532. __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0);
  8533. if (unlikely(__pyx_t_6)) {
  8534. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":856
  8535. *
  8536. * if (end - f) - <int>(new_offset - offset[0]) < 15:
  8537. * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<<
  8538. *
  8539. * if ((child.byteorder == c'>' and little_endian) or
  8540. */
  8541. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 856, __pyx_L1_error)
  8542. __Pyx_GOTREF(__pyx_t_3);
  8543. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  8544. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8545. __PYX_ERR(2, 856, __pyx_L1_error)
  8546. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":855
  8547. * child, new_offset = fields
  8548. *
  8549. * if (end - f) - <int>(new_offset - offset[0]) < 15: # <<<<<<<<<<<<<<
  8550. * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
  8551. *
  8552. */
  8553. }
  8554. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":858
  8555. * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
  8556. *
  8557. * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
  8558. * (child.byteorder == c'<' and not little_endian)):
  8559. * raise ValueError(u"Non-native byte order not supported")
  8560. */
  8561. __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0);
  8562. if (!__pyx_t_7) {
  8563. goto __pyx_L8_next_or;
  8564. } else {
  8565. }
  8566. __pyx_t_7 = (__pyx_v_little_endian != 0);
  8567. if (!__pyx_t_7) {
  8568. } else {
  8569. __pyx_t_6 = __pyx_t_7;
  8570. goto __pyx_L7_bool_binop_done;
  8571. }
  8572. __pyx_L8_next_or:;
  8573. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":859
  8574. *
  8575. * if ((child.byteorder == c'>' and little_endian) or
  8576. * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<<
  8577. * raise ValueError(u"Non-native byte order not supported")
  8578. * # One could encode it in the format string and have Cython
  8579. */
  8580. __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0);
  8581. if (__pyx_t_7) {
  8582. } else {
  8583. __pyx_t_6 = __pyx_t_7;
  8584. goto __pyx_L7_bool_binop_done;
  8585. }
  8586. __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0);
  8587. __pyx_t_6 = __pyx_t_7;
  8588. __pyx_L7_bool_binop_done:;
  8589. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":858
  8590. * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
  8591. *
  8592. * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
  8593. * (child.byteorder == c'<' and not little_endian)):
  8594. * raise ValueError(u"Non-native byte order not supported")
  8595. */
  8596. if (unlikely(__pyx_t_6)) {
  8597. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":860
  8598. * if ((child.byteorder == c'>' and little_endian) or
  8599. * (child.byteorder == c'<' and not little_endian)):
  8600. * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<<
  8601. * # One could encode it in the format string and have Cython
  8602. * # complain instead, BUT: < and > in format strings also imply
  8603. */
  8604. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 860, __pyx_L1_error)
  8605. __Pyx_GOTREF(__pyx_t_3);
  8606. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  8607. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8608. __PYX_ERR(2, 860, __pyx_L1_error)
  8609. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":858
  8610. * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
  8611. *
  8612. * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<<
  8613. * (child.byteorder == c'<' and not little_endian)):
  8614. * raise ValueError(u"Non-native byte order not supported")
  8615. */
  8616. }
  8617. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":870
  8618. *
  8619. * # Output padding bytes
  8620. * while offset[0] < new_offset: # <<<<<<<<<<<<<<
  8621. * f[0] = 120 # "x"; pad byte
  8622. * f += 1
  8623. */
  8624. while (1) {
  8625. __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 870, __pyx_L1_error)
  8626. __Pyx_GOTREF(__pyx_t_3);
  8627. __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 870, __pyx_L1_error)
  8628. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8629. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 870, __pyx_L1_error)
  8630. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8631. if (!__pyx_t_6) break;
  8632. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":871
  8633. * # Output padding bytes
  8634. * while offset[0] < new_offset:
  8635. * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<<
  8636. * f += 1
  8637. * offset[0] += 1
  8638. */
  8639. (__pyx_v_f[0]) = 0x78;
  8640. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":872
  8641. * while offset[0] < new_offset:
  8642. * f[0] = 120 # "x"; pad byte
  8643. * f += 1 # <<<<<<<<<<<<<<
  8644. * offset[0] += 1
  8645. *
  8646. */
  8647. __pyx_v_f = (__pyx_v_f + 1);
  8648. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":873
  8649. * f[0] = 120 # "x"; pad byte
  8650. * f += 1
  8651. * offset[0] += 1 # <<<<<<<<<<<<<<
  8652. *
  8653. * offset[0] += child.itemsize
  8654. */
  8655. __pyx_t_8 = 0;
  8656. (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1);
  8657. }
  8658. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":875
  8659. * offset[0] += 1
  8660. *
  8661. * offset[0] += child.itemsize # <<<<<<<<<<<<<<
  8662. *
  8663. * if not PyDataType_HASFIELDS(child):
  8664. */
  8665. __pyx_t_8 = 0;
  8666. (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize);
  8667. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":877
  8668. * offset[0] += child.itemsize
  8669. *
  8670. * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<<
  8671. * t = child.type_num
  8672. * if end - f < 5:
  8673. */
  8674. __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0);
  8675. if (__pyx_t_6) {
  8676. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":878
  8677. *
  8678. * if not PyDataType_HASFIELDS(child):
  8679. * t = child.type_num # <<<<<<<<<<<<<<
  8680. * if end - f < 5:
  8681. * raise RuntimeError(u"Format string allocated too short.")
  8682. */
  8683. __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 878, __pyx_L1_error)
  8684. __Pyx_GOTREF(__pyx_t_4);
  8685. __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4);
  8686. __pyx_t_4 = 0;
  8687. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":879
  8688. * if not PyDataType_HASFIELDS(child):
  8689. * t = child.type_num
  8690. * if end - f < 5: # <<<<<<<<<<<<<<
  8691. * raise RuntimeError(u"Format string allocated too short.")
  8692. *
  8693. */
  8694. __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0);
  8695. if (unlikely(__pyx_t_6)) {
  8696. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":880
  8697. * t = child.type_num
  8698. * if end - f < 5:
  8699. * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<<
  8700. *
  8701. * # Until ticket #99 is fixed, use integers to avoid warnings
  8702. */
  8703. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 880, __pyx_L1_error)
  8704. __Pyx_GOTREF(__pyx_t_4);
  8705. __Pyx_Raise(__pyx_t_4, 0, 0, 0);
  8706. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8707. __PYX_ERR(2, 880, __pyx_L1_error)
  8708. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":879
  8709. * if not PyDataType_HASFIELDS(child):
  8710. * t = child.type_num
  8711. * if end - f < 5: # <<<<<<<<<<<<<<
  8712. * raise RuntimeError(u"Format string allocated too short.")
  8713. *
  8714. */
  8715. }
  8716. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":883
  8717. *
  8718. * # Until ticket #99 is fixed, use integers to avoid warnings
  8719. * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<<
  8720. * elif t == NPY_UBYTE: f[0] = 66 #"B"
  8721. * elif t == NPY_SHORT: f[0] = 104 #"h"
  8722. */
  8723. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 883, __pyx_L1_error)
  8724. __Pyx_GOTREF(__pyx_t_4);
  8725. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 883, __pyx_L1_error)
  8726. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8727. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 883, __pyx_L1_error)
  8728. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8729. if (__pyx_t_6) {
  8730. (__pyx_v_f[0]) = 98;
  8731. goto __pyx_L15;
  8732. }
  8733. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":884
  8734. * # Until ticket #99 is fixed, use integers to avoid warnings
  8735. * if t == NPY_BYTE: f[0] = 98 #"b"
  8736. * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<<
  8737. * elif t == NPY_SHORT: f[0] = 104 #"h"
  8738. * elif t == NPY_USHORT: f[0] = 72 #"H"
  8739. */
  8740. __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 884, __pyx_L1_error)
  8741. __Pyx_GOTREF(__pyx_t_3);
  8742. __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 884, __pyx_L1_error)
  8743. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8744. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 884, __pyx_L1_error)
  8745. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8746. if (__pyx_t_6) {
  8747. (__pyx_v_f[0]) = 66;
  8748. goto __pyx_L15;
  8749. }
  8750. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":885
  8751. * if t == NPY_BYTE: f[0] = 98 #"b"
  8752. * elif t == NPY_UBYTE: f[0] = 66 #"B"
  8753. * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<<
  8754. * elif t == NPY_USHORT: f[0] = 72 #"H"
  8755. * elif t == NPY_INT: f[0] = 105 #"i"
  8756. */
  8757. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 885, __pyx_L1_error)
  8758. __Pyx_GOTREF(__pyx_t_4);
  8759. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 885, __pyx_L1_error)
  8760. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8761. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 885, __pyx_L1_error)
  8762. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8763. if (__pyx_t_6) {
  8764. (__pyx_v_f[0]) = 0x68;
  8765. goto __pyx_L15;
  8766. }
  8767. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":886
  8768. * elif t == NPY_UBYTE: f[0] = 66 #"B"
  8769. * elif t == NPY_SHORT: f[0] = 104 #"h"
  8770. * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<<
  8771. * elif t == NPY_INT: f[0] = 105 #"i"
  8772. * elif t == NPY_UINT: f[0] = 73 #"I"
  8773. */
  8774. __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 886, __pyx_L1_error)
  8775. __Pyx_GOTREF(__pyx_t_3);
  8776. __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 886, __pyx_L1_error)
  8777. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8778. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 886, __pyx_L1_error)
  8779. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8780. if (__pyx_t_6) {
  8781. (__pyx_v_f[0]) = 72;
  8782. goto __pyx_L15;
  8783. }
  8784. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":887
  8785. * elif t == NPY_SHORT: f[0] = 104 #"h"
  8786. * elif t == NPY_USHORT: f[0] = 72 #"H"
  8787. * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<<
  8788. * elif t == NPY_UINT: f[0] = 73 #"I"
  8789. * elif t == NPY_LONG: f[0] = 108 #"l"
  8790. */
  8791. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 887, __pyx_L1_error)
  8792. __Pyx_GOTREF(__pyx_t_4);
  8793. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 887, __pyx_L1_error)
  8794. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8795. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 887, __pyx_L1_error)
  8796. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8797. if (__pyx_t_6) {
  8798. (__pyx_v_f[0]) = 0x69;
  8799. goto __pyx_L15;
  8800. }
  8801. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":888
  8802. * elif t == NPY_USHORT: f[0] = 72 #"H"
  8803. * elif t == NPY_INT: f[0] = 105 #"i"
  8804. * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<<
  8805. * elif t == NPY_LONG: f[0] = 108 #"l"
  8806. * elif t == NPY_ULONG: f[0] = 76 #"L"
  8807. */
  8808. __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 888, __pyx_L1_error)
  8809. __Pyx_GOTREF(__pyx_t_3);
  8810. __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 888, __pyx_L1_error)
  8811. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8812. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 888, __pyx_L1_error)
  8813. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8814. if (__pyx_t_6) {
  8815. (__pyx_v_f[0]) = 73;
  8816. goto __pyx_L15;
  8817. }
  8818. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":889
  8819. * elif t == NPY_INT: f[0] = 105 #"i"
  8820. * elif t == NPY_UINT: f[0] = 73 #"I"
  8821. * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<<
  8822. * elif t == NPY_ULONG: f[0] = 76 #"L"
  8823. * elif t == NPY_LONGLONG: f[0] = 113 #"q"
  8824. */
  8825. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 889, __pyx_L1_error)
  8826. __Pyx_GOTREF(__pyx_t_4);
  8827. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 889, __pyx_L1_error)
  8828. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8829. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 889, __pyx_L1_error)
  8830. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8831. if (__pyx_t_6) {
  8832. (__pyx_v_f[0]) = 0x6C;
  8833. goto __pyx_L15;
  8834. }
  8835. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":890
  8836. * elif t == NPY_UINT: f[0] = 73 #"I"
  8837. * elif t == NPY_LONG: f[0] = 108 #"l"
  8838. * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<<
  8839. * elif t == NPY_LONGLONG: f[0] = 113 #"q"
  8840. * elif t == NPY_ULONGLONG: f[0] = 81 #"Q"
  8841. */
  8842. __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 890, __pyx_L1_error)
  8843. __Pyx_GOTREF(__pyx_t_3);
  8844. __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 890, __pyx_L1_error)
  8845. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8846. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 890, __pyx_L1_error)
  8847. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8848. if (__pyx_t_6) {
  8849. (__pyx_v_f[0]) = 76;
  8850. goto __pyx_L15;
  8851. }
  8852. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":891
  8853. * elif t == NPY_LONG: f[0] = 108 #"l"
  8854. * elif t == NPY_ULONG: f[0] = 76 #"L"
  8855. * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<<
  8856. * elif t == NPY_ULONGLONG: f[0] = 81 #"Q"
  8857. * elif t == NPY_FLOAT: f[0] = 102 #"f"
  8858. */
  8859. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 891, __pyx_L1_error)
  8860. __Pyx_GOTREF(__pyx_t_4);
  8861. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 891, __pyx_L1_error)
  8862. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8863. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 891, __pyx_L1_error)
  8864. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8865. if (__pyx_t_6) {
  8866. (__pyx_v_f[0]) = 0x71;
  8867. goto __pyx_L15;
  8868. }
  8869. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":892
  8870. * elif t == NPY_ULONG: f[0] = 76 #"L"
  8871. * elif t == NPY_LONGLONG: f[0] = 113 #"q"
  8872. * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<<
  8873. * elif t == NPY_FLOAT: f[0] = 102 #"f"
  8874. * elif t == NPY_DOUBLE: f[0] = 100 #"d"
  8875. */
  8876. __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 892, __pyx_L1_error)
  8877. __Pyx_GOTREF(__pyx_t_3);
  8878. __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 892, __pyx_L1_error)
  8879. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8880. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 892, __pyx_L1_error)
  8881. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8882. if (__pyx_t_6) {
  8883. (__pyx_v_f[0]) = 81;
  8884. goto __pyx_L15;
  8885. }
  8886. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":893
  8887. * elif t == NPY_LONGLONG: f[0] = 113 #"q"
  8888. * elif t == NPY_ULONGLONG: f[0] = 81 #"Q"
  8889. * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<<
  8890. * elif t == NPY_DOUBLE: f[0] = 100 #"d"
  8891. * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g"
  8892. */
  8893. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 893, __pyx_L1_error)
  8894. __Pyx_GOTREF(__pyx_t_4);
  8895. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 893, __pyx_L1_error)
  8896. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8897. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 893, __pyx_L1_error)
  8898. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8899. if (__pyx_t_6) {
  8900. (__pyx_v_f[0]) = 0x66;
  8901. goto __pyx_L15;
  8902. }
  8903. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":894
  8904. * elif t == NPY_ULONGLONG: f[0] = 81 #"Q"
  8905. * elif t == NPY_FLOAT: f[0] = 102 #"f"
  8906. * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<<
  8907. * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g"
  8908. * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf
  8909. */
  8910. __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 894, __pyx_L1_error)
  8911. __Pyx_GOTREF(__pyx_t_3);
  8912. __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 894, __pyx_L1_error)
  8913. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8914. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 894, __pyx_L1_error)
  8915. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8916. if (__pyx_t_6) {
  8917. (__pyx_v_f[0]) = 0x64;
  8918. goto __pyx_L15;
  8919. }
  8920. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":895
  8921. * elif t == NPY_FLOAT: f[0] = 102 #"f"
  8922. * elif t == NPY_DOUBLE: f[0] = 100 #"d"
  8923. * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<<
  8924. * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf
  8925. * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd
  8926. */
  8927. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 895, __pyx_L1_error)
  8928. __Pyx_GOTREF(__pyx_t_4);
  8929. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 895, __pyx_L1_error)
  8930. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8931. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 895, __pyx_L1_error)
  8932. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8933. if (__pyx_t_6) {
  8934. (__pyx_v_f[0]) = 0x67;
  8935. goto __pyx_L15;
  8936. }
  8937. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":896
  8938. * elif t == NPY_DOUBLE: f[0] = 100 #"d"
  8939. * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g"
  8940. * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<<
  8941. * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd
  8942. * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
  8943. */
  8944. __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 896, __pyx_L1_error)
  8945. __Pyx_GOTREF(__pyx_t_3);
  8946. __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 896, __pyx_L1_error)
  8947. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8948. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 896, __pyx_L1_error)
  8949. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8950. if (__pyx_t_6) {
  8951. (__pyx_v_f[0]) = 90;
  8952. (__pyx_v_f[1]) = 0x66;
  8953. __pyx_v_f = (__pyx_v_f + 1);
  8954. goto __pyx_L15;
  8955. }
  8956. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":897
  8957. * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g"
  8958. * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf
  8959. * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<<
  8960. * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
  8961. * elif t == NPY_OBJECT: f[0] = 79 #"O"
  8962. */
  8963. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 897, __pyx_L1_error)
  8964. __Pyx_GOTREF(__pyx_t_4);
  8965. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 897, __pyx_L1_error)
  8966. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8967. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 897, __pyx_L1_error)
  8968. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8969. if (__pyx_t_6) {
  8970. (__pyx_v_f[0]) = 90;
  8971. (__pyx_v_f[1]) = 0x64;
  8972. __pyx_v_f = (__pyx_v_f + 1);
  8973. goto __pyx_L15;
  8974. }
  8975. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":898
  8976. * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf
  8977. * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd
  8978. * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<<
  8979. * elif t == NPY_OBJECT: f[0] = 79 #"O"
  8980. * else:
  8981. */
  8982. __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 898, __pyx_L1_error)
  8983. __Pyx_GOTREF(__pyx_t_3);
  8984. __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 898, __pyx_L1_error)
  8985. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8986. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 898, __pyx_L1_error)
  8987. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8988. if (__pyx_t_6) {
  8989. (__pyx_v_f[0]) = 90;
  8990. (__pyx_v_f[1]) = 0x67;
  8991. __pyx_v_f = (__pyx_v_f + 1);
  8992. goto __pyx_L15;
  8993. }
  8994. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":899
  8995. * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd
  8996. * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
  8997. * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<<
  8998. * else:
  8999. * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
  9000. */
  9001. __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 899, __pyx_L1_error)
  9002. __Pyx_GOTREF(__pyx_t_4);
  9003. __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 899, __pyx_L1_error)
  9004. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9005. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 899, __pyx_L1_error)
  9006. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9007. if (likely(__pyx_t_6)) {
  9008. (__pyx_v_f[0]) = 79;
  9009. goto __pyx_L15;
  9010. }
  9011. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":901
  9012. * elif t == NPY_OBJECT: f[0] = 79 #"O"
  9013. * else:
  9014. * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<<
  9015. * f += 1
  9016. * else:
  9017. */
  9018. /*else*/ {
  9019. __pyx_t_3 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 901, __pyx_L1_error)
  9020. __Pyx_GOTREF(__pyx_t_3);
  9021. __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 901, __pyx_L1_error)
  9022. __Pyx_GOTREF(__pyx_t_4);
  9023. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9024. __Pyx_Raise(__pyx_t_4, 0, 0, 0);
  9025. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9026. __PYX_ERR(2, 901, __pyx_L1_error)
  9027. }
  9028. __pyx_L15:;
  9029. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":902
  9030. * else:
  9031. * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
  9032. * f += 1 # <<<<<<<<<<<<<<
  9033. * else:
  9034. * # Cython ignores struct boundary information ("T{...}"),
  9035. */
  9036. __pyx_v_f = (__pyx_v_f + 1);
  9037. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":877
  9038. * offset[0] += child.itemsize
  9039. *
  9040. * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<<
  9041. * t = child.type_num
  9042. * if end - f < 5:
  9043. */
  9044. goto __pyx_L13;
  9045. }
  9046. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":906
  9047. * # Cython ignores struct boundary information ("T{...}"),
  9048. * # so don't output it
  9049. * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<<
  9050. * return f
  9051. *
  9052. */
  9053. /*else*/ {
  9054. __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(2, 906, __pyx_L1_error)
  9055. __pyx_v_f = __pyx_t_9;
  9056. }
  9057. __pyx_L13:;
  9058. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":851
  9059. * cdef tuple fields
  9060. *
  9061. * for childname in descr.names: # <<<<<<<<<<<<<<
  9062. * fields = descr.fields[childname]
  9063. * child, new_offset = fields
  9064. */
  9065. }
  9066. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9067. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":907
  9068. * # so don't output it
  9069. * f = _util_dtypestring(child, f, end, offset)
  9070. * return f # <<<<<<<<<<<<<<
  9071. *
  9072. *
  9073. */
  9074. __pyx_r = __pyx_v_f;
  9075. goto __pyx_L0;
  9076. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":842
  9077. * return ()
  9078. *
  9079. * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<<
  9080. * # Recursive utility function used in __getbuffer__ to get format
  9081. * # string. The new location in the format string is returned.
  9082. */
  9083. /* function exit code */
  9084. __pyx_L1_error:;
  9085. __Pyx_XDECREF(__pyx_t_1);
  9086. __Pyx_XDECREF(__pyx_t_3);
  9087. __Pyx_XDECREF(__pyx_t_4);
  9088. __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9089. __pyx_r = NULL;
  9090. __pyx_L0:;
  9091. __Pyx_XDECREF((PyObject *)__pyx_v_child);
  9092. __Pyx_XDECREF(__pyx_v_fields);
  9093. __Pyx_XDECREF(__pyx_v_childname);
  9094. __Pyx_XDECREF(__pyx_v_new_offset);
  9095. __Pyx_XDECREF(__pyx_v_t);
  9096. __Pyx_RefNannyFinishContext();
  9097. return __pyx_r;
  9098. }
  9099. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1022
  9100. * int _import_umath() except -1
  9101. *
  9102. * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<<
  9103. * Py_INCREF(base) # important to do this before stealing the reference below!
  9104. * PyArray_SetBaseObject(arr, base)
  9105. */
  9106. static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
  9107. __Pyx_RefNannyDeclarations
  9108. __Pyx_RefNannySetupContext("set_array_base", 0);
  9109. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1023
  9110. *
  9111. * cdef inline void set_array_base(ndarray arr, object base):
  9112. * Py_INCREF(base) # important to do this before stealing the reference below! # <<<<<<<<<<<<<<
  9113. * PyArray_SetBaseObject(arr, base)
  9114. *
  9115. */
  9116. Py_INCREF(__pyx_v_base);
  9117. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1024
  9118. * cdef inline void set_array_base(ndarray arr, object base):
  9119. * Py_INCREF(base) # important to do this before stealing the reference below!
  9120. * PyArray_SetBaseObject(arr, base) # <<<<<<<<<<<<<<
  9121. *
  9122. * cdef inline object get_array_base(ndarray arr):
  9123. */
  9124. (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base));
  9125. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1022
  9126. * int _import_umath() except -1
  9127. *
  9128. * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<<
  9129. * Py_INCREF(base) # important to do this before stealing the reference below!
  9130. * PyArray_SetBaseObject(arr, base)
  9131. */
  9132. /* function exit code */
  9133. __Pyx_RefNannyFinishContext();
  9134. }
  9135. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1026
  9136. * PyArray_SetBaseObject(arr, base)
  9137. *
  9138. * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<<
  9139. * base = PyArray_BASE(arr)
  9140. * if base is NULL:
  9141. */
  9142. static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
  9143. PyObject *__pyx_v_base;
  9144. PyObject *__pyx_r = NULL;
  9145. __Pyx_RefNannyDeclarations
  9146. int __pyx_t_1;
  9147. __Pyx_RefNannySetupContext("get_array_base", 0);
  9148. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1027
  9149. *
  9150. * cdef inline object get_array_base(ndarray arr):
  9151. * base = PyArray_BASE(arr) # <<<<<<<<<<<<<<
  9152. * if base is NULL:
  9153. * return None
  9154. */
  9155. __pyx_v_base = PyArray_BASE(__pyx_v_arr);
  9156. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1028
  9157. * cdef inline object get_array_base(ndarray arr):
  9158. * base = PyArray_BASE(arr)
  9159. * if base is NULL: # <<<<<<<<<<<<<<
  9160. * return None
  9161. * return <object>base
  9162. */
  9163. __pyx_t_1 = ((__pyx_v_base == NULL) != 0);
  9164. if (__pyx_t_1) {
  9165. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1029
  9166. * base = PyArray_BASE(arr)
  9167. * if base is NULL:
  9168. * return None # <<<<<<<<<<<<<<
  9169. * return <object>base
  9170. *
  9171. */
  9172. __Pyx_XDECREF(__pyx_r);
  9173. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  9174. goto __pyx_L0;
  9175. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1028
  9176. * cdef inline object get_array_base(ndarray arr):
  9177. * base = PyArray_BASE(arr)
  9178. * if base is NULL: # <<<<<<<<<<<<<<
  9179. * return None
  9180. * return <object>base
  9181. */
  9182. }
  9183. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1030
  9184. * if base is NULL:
  9185. * return None
  9186. * return <object>base # <<<<<<<<<<<<<<
  9187. *
  9188. * # Versions of the import_* functions which are more suitable for
  9189. */
  9190. __Pyx_XDECREF(__pyx_r);
  9191. __Pyx_INCREF(((PyObject *)__pyx_v_base));
  9192. __pyx_r = ((PyObject *)__pyx_v_base);
  9193. goto __pyx_L0;
  9194. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1026
  9195. * PyArray_SetBaseObject(arr, base)
  9196. *
  9197. * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<<
  9198. * base = PyArray_BASE(arr)
  9199. * if base is NULL:
  9200. */
  9201. /* function exit code */
  9202. __pyx_L0:;
  9203. __Pyx_XGIVEREF(__pyx_r);
  9204. __Pyx_RefNannyFinishContext();
  9205. return __pyx_r;
  9206. }
  9207. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1034
  9208. * # Versions of the import_* functions which are more suitable for
  9209. * # Cython code.
  9210. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<<
  9211. * try:
  9212. * _import_array()
  9213. */
  9214. static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) {
  9215. int __pyx_r;
  9216. __Pyx_RefNannyDeclarations
  9217. PyObject *__pyx_t_1 = NULL;
  9218. PyObject *__pyx_t_2 = NULL;
  9219. PyObject *__pyx_t_3 = NULL;
  9220. int __pyx_t_4;
  9221. PyObject *__pyx_t_5 = NULL;
  9222. PyObject *__pyx_t_6 = NULL;
  9223. PyObject *__pyx_t_7 = NULL;
  9224. PyObject *__pyx_t_8 = NULL;
  9225. __Pyx_RefNannySetupContext("import_array", 0);
  9226. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1035
  9227. * # Cython code.
  9228. * cdef inline int import_array() except -1:
  9229. * try: # <<<<<<<<<<<<<<
  9230. * _import_array()
  9231. * except Exception:
  9232. */
  9233. {
  9234. __Pyx_PyThreadState_declare
  9235. __Pyx_PyThreadState_assign
  9236. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  9237. __Pyx_XGOTREF(__pyx_t_1);
  9238. __Pyx_XGOTREF(__pyx_t_2);
  9239. __Pyx_XGOTREF(__pyx_t_3);
  9240. /*try:*/ {
  9241. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1036
  9242. * cdef inline int import_array() except -1:
  9243. * try:
  9244. * _import_array() # <<<<<<<<<<<<<<
  9245. * except Exception:
  9246. * raise ImportError("numpy.core.multiarray failed to import")
  9247. */
  9248. __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 1036, __pyx_L3_error)
  9249. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1035
  9250. * # Cython code.
  9251. * cdef inline int import_array() except -1:
  9252. * try: # <<<<<<<<<<<<<<
  9253. * _import_array()
  9254. * except Exception:
  9255. */
  9256. }
  9257. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  9258. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  9259. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  9260. goto __pyx_L8_try_end;
  9261. __pyx_L3_error:;
  9262. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1037
  9263. * try:
  9264. * _import_array()
  9265. * except Exception: # <<<<<<<<<<<<<<
  9266. * raise ImportError("numpy.core.multiarray failed to import")
  9267. *
  9268. */
  9269. __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  9270. if (__pyx_t_4) {
  9271. __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9272. if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 1037, __pyx_L5_except_error)
  9273. __Pyx_GOTREF(__pyx_t_5);
  9274. __Pyx_GOTREF(__pyx_t_6);
  9275. __Pyx_GOTREF(__pyx_t_7);
  9276. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1038
  9277. * _import_array()
  9278. * except Exception:
  9279. * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<<
  9280. *
  9281. * cdef inline int import_umath() except -1:
  9282. */
  9283. __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 1038, __pyx_L5_except_error)
  9284. __Pyx_GOTREF(__pyx_t_8);
  9285. __Pyx_Raise(__pyx_t_8, 0, 0, 0);
  9286. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  9287. __PYX_ERR(2, 1038, __pyx_L5_except_error)
  9288. }
  9289. goto __pyx_L5_except_error;
  9290. __pyx_L5_except_error:;
  9291. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1035
  9292. * # Cython code.
  9293. * cdef inline int import_array() except -1:
  9294. * try: # <<<<<<<<<<<<<<
  9295. * _import_array()
  9296. * except Exception:
  9297. */
  9298. __Pyx_XGIVEREF(__pyx_t_1);
  9299. __Pyx_XGIVEREF(__pyx_t_2);
  9300. __Pyx_XGIVEREF(__pyx_t_3);
  9301. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  9302. goto __pyx_L1_error;
  9303. __pyx_L8_try_end:;
  9304. }
  9305. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1034
  9306. * # Versions of the import_* functions which are more suitable for
  9307. * # Cython code.
  9308. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<<
  9309. * try:
  9310. * _import_array()
  9311. */
  9312. /* function exit code */
  9313. __pyx_r = 0;
  9314. goto __pyx_L0;
  9315. __pyx_L1_error:;
  9316. __Pyx_XDECREF(__pyx_t_5);
  9317. __Pyx_XDECREF(__pyx_t_6);
  9318. __Pyx_XDECREF(__pyx_t_7);
  9319. __Pyx_XDECREF(__pyx_t_8);
  9320. __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9321. __pyx_r = -1;
  9322. __pyx_L0:;
  9323. __Pyx_RefNannyFinishContext();
  9324. return __pyx_r;
  9325. }
  9326. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1040
  9327. * raise ImportError("numpy.core.multiarray failed to import")
  9328. *
  9329. * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<<
  9330. * try:
  9331. * _import_umath()
  9332. */
  9333. static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) {
  9334. int __pyx_r;
  9335. __Pyx_RefNannyDeclarations
  9336. PyObject *__pyx_t_1 = NULL;
  9337. PyObject *__pyx_t_2 = NULL;
  9338. PyObject *__pyx_t_3 = NULL;
  9339. int __pyx_t_4;
  9340. PyObject *__pyx_t_5 = NULL;
  9341. PyObject *__pyx_t_6 = NULL;
  9342. PyObject *__pyx_t_7 = NULL;
  9343. PyObject *__pyx_t_8 = NULL;
  9344. __Pyx_RefNannySetupContext("import_umath", 0);
  9345. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1041
  9346. *
  9347. * cdef inline int import_umath() except -1:
  9348. * try: # <<<<<<<<<<<<<<
  9349. * _import_umath()
  9350. * except Exception:
  9351. */
  9352. {
  9353. __Pyx_PyThreadState_declare
  9354. __Pyx_PyThreadState_assign
  9355. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  9356. __Pyx_XGOTREF(__pyx_t_1);
  9357. __Pyx_XGOTREF(__pyx_t_2);
  9358. __Pyx_XGOTREF(__pyx_t_3);
  9359. /*try:*/ {
  9360. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1042
  9361. * cdef inline int import_umath() except -1:
  9362. * try:
  9363. * _import_umath() # <<<<<<<<<<<<<<
  9364. * except Exception:
  9365. * raise ImportError("numpy.core.umath failed to import")
  9366. */
  9367. __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 1042, __pyx_L3_error)
  9368. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1041
  9369. *
  9370. * cdef inline int import_umath() except -1:
  9371. * try: # <<<<<<<<<<<<<<
  9372. * _import_umath()
  9373. * except Exception:
  9374. */
  9375. }
  9376. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  9377. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  9378. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  9379. goto __pyx_L8_try_end;
  9380. __pyx_L3_error:;
  9381. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1043
  9382. * try:
  9383. * _import_umath()
  9384. * except Exception: # <<<<<<<<<<<<<<
  9385. * raise ImportError("numpy.core.umath failed to import")
  9386. *
  9387. */
  9388. __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  9389. if (__pyx_t_4) {
  9390. __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9391. if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 1043, __pyx_L5_except_error)
  9392. __Pyx_GOTREF(__pyx_t_5);
  9393. __Pyx_GOTREF(__pyx_t_6);
  9394. __Pyx_GOTREF(__pyx_t_7);
  9395. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1044
  9396. * _import_umath()
  9397. * except Exception:
  9398. * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<<
  9399. *
  9400. * cdef inline int import_ufunc() except -1:
  9401. */
  9402. __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 1044, __pyx_L5_except_error)
  9403. __Pyx_GOTREF(__pyx_t_8);
  9404. __Pyx_Raise(__pyx_t_8, 0, 0, 0);
  9405. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  9406. __PYX_ERR(2, 1044, __pyx_L5_except_error)
  9407. }
  9408. goto __pyx_L5_except_error;
  9409. __pyx_L5_except_error:;
  9410. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1041
  9411. *
  9412. * cdef inline int import_umath() except -1:
  9413. * try: # <<<<<<<<<<<<<<
  9414. * _import_umath()
  9415. * except Exception:
  9416. */
  9417. __Pyx_XGIVEREF(__pyx_t_1);
  9418. __Pyx_XGIVEREF(__pyx_t_2);
  9419. __Pyx_XGIVEREF(__pyx_t_3);
  9420. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  9421. goto __pyx_L1_error;
  9422. __pyx_L8_try_end:;
  9423. }
  9424. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1040
  9425. * raise ImportError("numpy.core.multiarray failed to import")
  9426. *
  9427. * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<<
  9428. * try:
  9429. * _import_umath()
  9430. */
  9431. /* function exit code */
  9432. __pyx_r = 0;
  9433. goto __pyx_L0;
  9434. __pyx_L1_error:;
  9435. __Pyx_XDECREF(__pyx_t_5);
  9436. __Pyx_XDECREF(__pyx_t_6);
  9437. __Pyx_XDECREF(__pyx_t_7);
  9438. __Pyx_XDECREF(__pyx_t_8);
  9439. __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9440. __pyx_r = -1;
  9441. __pyx_L0:;
  9442. __Pyx_RefNannyFinishContext();
  9443. return __pyx_r;
  9444. }
  9445. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1046
  9446. * raise ImportError("numpy.core.umath failed to import")
  9447. *
  9448. * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<<
  9449. * try:
  9450. * _import_umath()
  9451. */
  9452. static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) {
  9453. int __pyx_r;
  9454. __Pyx_RefNannyDeclarations
  9455. PyObject *__pyx_t_1 = NULL;
  9456. PyObject *__pyx_t_2 = NULL;
  9457. PyObject *__pyx_t_3 = NULL;
  9458. int __pyx_t_4;
  9459. PyObject *__pyx_t_5 = NULL;
  9460. PyObject *__pyx_t_6 = NULL;
  9461. PyObject *__pyx_t_7 = NULL;
  9462. PyObject *__pyx_t_8 = NULL;
  9463. __Pyx_RefNannySetupContext("import_ufunc", 0);
  9464. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1047
  9465. *
  9466. * cdef inline int import_ufunc() except -1:
  9467. * try: # <<<<<<<<<<<<<<
  9468. * _import_umath()
  9469. * except Exception:
  9470. */
  9471. {
  9472. __Pyx_PyThreadState_declare
  9473. __Pyx_PyThreadState_assign
  9474. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  9475. __Pyx_XGOTREF(__pyx_t_1);
  9476. __Pyx_XGOTREF(__pyx_t_2);
  9477. __Pyx_XGOTREF(__pyx_t_3);
  9478. /*try:*/ {
  9479. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1048
  9480. * cdef inline int import_ufunc() except -1:
  9481. * try:
  9482. * _import_umath() # <<<<<<<<<<<<<<
  9483. * except Exception:
  9484. * raise ImportError("numpy.core.umath failed to import")
  9485. */
  9486. __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 1048, __pyx_L3_error)
  9487. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1047
  9488. *
  9489. * cdef inline int import_ufunc() except -1:
  9490. * try: # <<<<<<<<<<<<<<
  9491. * _import_umath()
  9492. * except Exception:
  9493. */
  9494. }
  9495. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  9496. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  9497. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  9498. goto __pyx_L8_try_end;
  9499. __pyx_L3_error:;
  9500. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1049
  9501. * try:
  9502. * _import_umath()
  9503. * except Exception: # <<<<<<<<<<<<<<
  9504. * raise ImportError("numpy.core.umath failed to import")
  9505. */
  9506. __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
  9507. if (__pyx_t_4) {
  9508. __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9509. if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 1049, __pyx_L5_except_error)
  9510. __Pyx_GOTREF(__pyx_t_5);
  9511. __Pyx_GOTREF(__pyx_t_6);
  9512. __Pyx_GOTREF(__pyx_t_7);
  9513. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1050
  9514. * _import_umath()
  9515. * except Exception:
  9516. * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<<
  9517. */
  9518. __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 1050, __pyx_L5_except_error)
  9519. __Pyx_GOTREF(__pyx_t_8);
  9520. __Pyx_Raise(__pyx_t_8, 0, 0, 0);
  9521. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  9522. __PYX_ERR(2, 1050, __pyx_L5_except_error)
  9523. }
  9524. goto __pyx_L5_except_error;
  9525. __pyx_L5_except_error:;
  9526. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1047
  9527. *
  9528. * cdef inline int import_ufunc() except -1:
  9529. * try: # <<<<<<<<<<<<<<
  9530. * _import_umath()
  9531. * except Exception:
  9532. */
  9533. __Pyx_XGIVEREF(__pyx_t_1);
  9534. __Pyx_XGIVEREF(__pyx_t_2);
  9535. __Pyx_XGIVEREF(__pyx_t_3);
  9536. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  9537. goto __pyx_L1_error;
  9538. __pyx_L8_try_end:;
  9539. }
  9540. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1046
  9541. * raise ImportError("numpy.core.umath failed to import")
  9542. *
  9543. * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<<
  9544. * try:
  9545. * _import_umath()
  9546. */
  9547. /* function exit code */
  9548. __pyx_r = 0;
  9549. goto __pyx_L0;
  9550. __pyx_L1_error:;
  9551. __Pyx_XDECREF(__pyx_t_5);
  9552. __Pyx_XDECREF(__pyx_t_6);
  9553. __Pyx_XDECREF(__pyx_t_7);
  9554. __Pyx_XDECREF(__pyx_t_8);
  9555. __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9556. __pyx_r = -1;
  9557. __pyx_L0:;
  9558. __Pyx_RefNannyFinishContext();
  9559. return __pyx_r;
  9560. }
  9561. static PyObject *__pyx_tp_new_11pycocotools_5_mask_RLEs(PyTypeObject *t, PyObject *a, PyObject *k) {
  9562. PyObject *o;
  9563. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  9564. o = (*t->tp_alloc)(t, 0);
  9565. } else {
  9566. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  9567. }
  9568. if (unlikely(!o)) return 0;
  9569. if (unlikely(__pyx_pw_11pycocotools_5_mask_4RLEs_1__cinit__(o, a, k) < 0)) goto bad;
  9570. return o;
  9571. bad:
  9572. Py_DECREF(o); o = 0;
  9573. return NULL;
  9574. }
  9575. static void __pyx_tp_dealloc_11pycocotools_5_mask_RLEs(PyObject *o) {
  9576. #if CYTHON_USE_TP_FINALIZE
  9577. if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
  9578. if (PyObject_CallFinalizerFromDealloc(o)) return;
  9579. }
  9580. #endif
  9581. {
  9582. PyObject *etype, *eval, *etb;
  9583. PyErr_Fetch(&etype, &eval, &etb);
  9584. ++Py_REFCNT(o);
  9585. __pyx_pw_11pycocotools_5_mask_4RLEs_3__dealloc__(o);
  9586. --Py_REFCNT(o);
  9587. PyErr_Restore(etype, eval, etb);
  9588. }
  9589. (*Py_TYPE(o)->tp_free)(o);
  9590. }
  9591. static PyObject *__pyx_tp_getattro_11pycocotools_5_mask_RLEs(PyObject *o, PyObject *n) {
  9592. PyObject *v = __Pyx_PyObject_GenericGetAttr(o, n);
  9593. if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  9594. PyErr_Clear();
  9595. v = __pyx_pw_11pycocotools_5_mask_4RLEs_5__getattr__(o, n);
  9596. }
  9597. return v;
  9598. }
  9599. static PyMethodDef __pyx_methods_11pycocotools_5_mask_RLEs[] = {
  9600. {"__getattr__", (PyCFunction)__pyx_pw_11pycocotools_5_mask_4RLEs_5__getattr__, METH_O|METH_COEXIST, 0},
  9601. {"__reduce_cython__", (PyCFunction)__pyx_pw_11pycocotools_5_mask_4RLEs_7__reduce_cython__, METH_NOARGS, 0},
  9602. {"__setstate_cython__", (PyCFunction)__pyx_pw_11pycocotools_5_mask_4RLEs_9__setstate_cython__, METH_O, 0},
  9603. {0, 0, 0, 0}
  9604. };
  9605. static PyTypeObject __pyx_type_11pycocotools_5_mask_RLEs = {
  9606. PyVarObject_HEAD_INIT(0, 0)
  9607. "pycocotools._mask.RLEs", /*tp_name*/
  9608. sizeof(struct __pyx_obj_11pycocotools_5_mask_RLEs), /*tp_basicsize*/
  9609. 0, /*tp_itemsize*/
  9610. __pyx_tp_dealloc_11pycocotools_5_mask_RLEs, /*tp_dealloc*/
  9611. 0, /*tp_print*/
  9612. 0, /*tp_getattr*/
  9613. 0, /*tp_setattr*/
  9614. #if PY_MAJOR_VERSION < 3
  9615. 0, /*tp_compare*/
  9616. #endif
  9617. #if PY_MAJOR_VERSION >= 3
  9618. 0, /*tp_as_async*/
  9619. #endif
  9620. 0, /*tp_repr*/
  9621. 0, /*tp_as_number*/
  9622. 0, /*tp_as_sequence*/
  9623. 0, /*tp_as_mapping*/
  9624. 0, /*tp_hash*/
  9625. 0, /*tp_call*/
  9626. 0, /*tp_str*/
  9627. __pyx_tp_getattro_11pycocotools_5_mask_RLEs, /*tp_getattro*/
  9628. 0, /*tp_setattro*/
  9629. 0, /*tp_as_buffer*/
  9630. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  9631. 0, /*tp_doc*/
  9632. 0, /*tp_traverse*/
  9633. 0, /*tp_clear*/
  9634. 0, /*tp_richcompare*/
  9635. 0, /*tp_weaklistoffset*/
  9636. 0, /*tp_iter*/
  9637. 0, /*tp_iternext*/
  9638. __pyx_methods_11pycocotools_5_mask_RLEs, /*tp_methods*/
  9639. 0, /*tp_members*/
  9640. 0, /*tp_getset*/
  9641. 0, /*tp_base*/
  9642. 0, /*tp_dict*/
  9643. 0, /*tp_descr_get*/
  9644. 0, /*tp_descr_set*/
  9645. 0, /*tp_dictoffset*/
  9646. 0, /*tp_init*/
  9647. 0, /*tp_alloc*/
  9648. __pyx_tp_new_11pycocotools_5_mask_RLEs, /*tp_new*/
  9649. 0, /*tp_free*/
  9650. 0, /*tp_is_gc*/
  9651. 0, /*tp_bases*/
  9652. 0, /*tp_mro*/
  9653. 0, /*tp_cache*/
  9654. 0, /*tp_subclasses*/
  9655. 0, /*tp_weaklist*/
  9656. 0, /*tp_del*/
  9657. 0, /*tp_version_tag*/
  9658. #if PY_VERSION_HEX >= 0x030400a1
  9659. 0, /*tp_finalize*/
  9660. #endif
  9661. };
  9662. static PyObject *__pyx_tp_new_11pycocotools_5_mask_Masks(PyTypeObject *t, PyObject *a, PyObject *k) {
  9663. PyObject *o;
  9664. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  9665. o = (*t->tp_alloc)(t, 0);
  9666. } else {
  9667. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  9668. }
  9669. if (unlikely(!o)) return 0;
  9670. if (unlikely(__pyx_pw_11pycocotools_5_mask_5Masks_1__cinit__(o, a, k) < 0)) goto bad;
  9671. return o;
  9672. bad:
  9673. Py_DECREF(o); o = 0;
  9674. return NULL;
  9675. }
  9676. static void __pyx_tp_dealloc_11pycocotools_5_mask_Masks(PyObject *o) {
  9677. #if CYTHON_USE_TP_FINALIZE
  9678. if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
  9679. if (PyObject_CallFinalizerFromDealloc(o)) return;
  9680. }
  9681. #endif
  9682. (*Py_TYPE(o)->tp_free)(o);
  9683. }
  9684. static PyMethodDef __pyx_methods_11pycocotools_5_mask_Masks[] = {
  9685. {"__array__", (PyCFunction)__pyx_pw_11pycocotools_5_mask_5Masks_3__array__, METH_NOARGS, 0},
  9686. {"__reduce_cython__", (PyCFunction)__pyx_pw_11pycocotools_5_mask_5Masks_5__reduce_cython__, METH_NOARGS, 0},
  9687. {"__setstate_cython__", (PyCFunction)__pyx_pw_11pycocotools_5_mask_5Masks_7__setstate_cython__, METH_O, 0},
  9688. {0, 0, 0, 0}
  9689. };
  9690. static PyTypeObject __pyx_type_11pycocotools_5_mask_Masks = {
  9691. PyVarObject_HEAD_INIT(0, 0)
  9692. "pycocotools._mask.Masks", /*tp_name*/
  9693. sizeof(struct __pyx_obj_11pycocotools_5_mask_Masks), /*tp_basicsize*/
  9694. 0, /*tp_itemsize*/
  9695. __pyx_tp_dealloc_11pycocotools_5_mask_Masks, /*tp_dealloc*/
  9696. 0, /*tp_print*/
  9697. 0, /*tp_getattr*/
  9698. 0, /*tp_setattr*/
  9699. #if PY_MAJOR_VERSION < 3
  9700. 0, /*tp_compare*/
  9701. #endif
  9702. #if PY_MAJOR_VERSION >= 3
  9703. 0, /*tp_as_async*/
  9704. #endif
  9705. 0, /*tp_repr*/
  9706. 0, /*tp_as_number*/
  9707. 0, /*tp_as_sequence*/
  9708. 0, /*tp_as_mapping*/
  9709. 0, /*tp_hash*/
  9710. 0, /*tp_call*/
  9711. 0, /*tp_str*/
  9712. 0, /*tp_getattro*/
  9713. 0, /*tp_setattro*/
  9714. 0, /*tp_as_buffer*/
  9715. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  9716. 0, /*tp_doc*/
  9717. 0, /*tp_traverse*/
  9718. 0, /*tp_clear*/
  9719. 0, /*tp_richcompare*/
  9720. 0, /*tp_weaklistoffset*/
  9721. 0, /*tp_iter*/
  9722. 0, /*tp_iternext*/
  9723. __pyx_methods_11pycocotools_5_mask_Masks, /*tp_methods*/
  9724. 0, /*tp_members*/
  9725. 0, /*tp_getset*/
  9726. 0, /*tp_base*/
  9727. 0, /*tp_dict*/
  9728. 0, /*tp_descr_get*/
  9729. 0, /*tp_descr_set*/
  9730. 0, /*tp_dictoffset*/
  9731. 0, /*tp_init*/
  9732. 0, /*tp_alloc*/
  9733. __pyx_tp_new_11pycocotools_5_mask_Masks, /*tp_new*/
  9734. 0, /*tp_free*/
  9735. 0, /*tp_is_gc*/
  9736. 0, /*tp_bases*/
  9737. 0, /*tp_mro*/
  9738. 0, /*tp_cache*/
  9739. 0, /*tp_subclasses*/
  9740. 0, /*tp_weaklist*/
  9741. 0, /*tp_del*/
  9742. 0, /*tp_version_tag*/
  9743. #if PY_VERSION_HEX >= 0x030400a1
  9744. 0, /*tp_finalize*/
  9745. #endif
  9746. };
  9747. static PyMethodDef __pyx_methods[] = {
  9748. {0, 0, 0, 0}
  9749. };
  9750. #if PY_MAJOR_VERSION >= 3
  9751. #if CYTHON_PEP489_MULTI_PHASE_INIT
  9752. static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
  9753. static int __pyx_pymod_exec__mask(PyObject* module); /*proto*/
  9754. static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  9755. {Py_mod_create, (void*)__pyx_pymod_create},
  9756. {Py_mod_exec, (void*)__pyx_pymod_exec__mask},
  9757. {0, NULL}
  9758. };
  9759. #endif
  9760. static struct PyModuleDef __pyx_moduledef = {
  9761. PyModuleDef_HEAD_INIT,
  9762. "_mask",
  9763. 0, /* m_doc */
  9764. #if CYTHON_PEP489_MULTI_PHASE_INIT
  9765. 0, /* m_size */
  9766. #else
  9767. -1, /* m_size */
  9768. #endif
  9769. __pyx_methods /* m_methods */,
  9770. #if CYTHON_PEP489_MULTI_PHASE_INIT
  9771. __pyx_moduledef_slots, /* m_slots */
  9772. #else
  9773. NULL, /* m_reload */
  9774. #endif
  9775. NULL, /* m_traverse */
  9776. NULL, /* m_clear */
  9777. NULL /* m_free */
  9778. };
  9779. #endif
  9780. #ifndef CYTHON_SMALL_CODE
  9781. #if defined(__clang__)
  9782. #define CYTHON_SMALL_CODE
  9783. #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
  9784. #define CYTHON_SMALL_CODE __attribute__((cold))
  9785. #else
  9786. #define CYTHON_SMALL_CODE
  9787. #endif
  9788. #endif
  9789. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  9790. {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
  9791. {&__pyx_n_s_F, __pyx_k_F, sizeof(__pyx_k_F), 0, 0, 1, 1},
  9792. {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0},
  9793. {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0},
  9794. {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
  9795. {&__pyx_n_s_Masks, __pyx_k_Masks, sizeof(__pyx_k_Masks), 0, 0, 1, 1},
  9796. {&__pyx_n_s_N, __pyx_k_N, sizeof(__pyx_k_N), 0, 0, 1, 1},
  9797. {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0},
  9798. {&__pyx_n_s_R, __pyx_k_R, sizeof(__pyx_k_R), 0, 0, 1, 1},
  9799. {&__pyx_n_s_RLEs, __pyx_k_RLEs, sizeof(__pyx_k_RLEs), 0, 0, 1, 1},
  9800. {&__pyx_n_s_Rs, __pyx_k_Rs, sizeof(__pyx_k_Rs), 0, 0, 1, 1},
  9801. {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  9802. {&__pyx_kp_s_The_dt_and_gt_should_have_the_sa, __pyx_k_The_dt_and_gt_should_have_the_sa, sizeof(__pyx_k_The_dt_and_gt_should_have_the_sa), 0, 0, 1, 0},
  9803. {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  9804. {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  9805. {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
  9806. {&__pyx_n_s_a_2, __pyx_k_a_2, sizeof(__pyx_k_a_2), 0, 0, 1, 1},
  9807. {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
  9808. {&__pyx_n_s_area, __pyx_k_area, sizeof(__pyx_k_area), 0, 0, 1, 1},
  9809. {&__pyx_n_s_array, __pyx_k_array, sizeof(__pyx_k_array), 0, 0, 1, 1},
  9810. {&__pyx_n_s_astype, __pyx_k_astype, sizeof(__pyx_k_astype), 0, 0, 1, 1},
  9811. {&__pyx_n_s_author, __pyx_k_author, sizeof(__pyx_k_author), 0, 0, 1, 1},
  9812. {&__pyx_n_s_bb, __pyx_k_bb, sizeof(__pyx_k_bb), 0, 0, 1, 1},
  9813. {&__pyx_n_s_bbIou, __pyx_k_bbIou, sizeof(__pyx_k_bbIou), 0, 0, 1, 1},
  9814. {&__pyx_n_s_bb_2, __pyx_k_bb_2, sizeof(__pyx_k_bb_2), 0, 0, 1, 1},
  9815. {&__pyx_n_s_c_string, __pyx_k_c_string, sizeof(__pyx_k_c_string), 0, 0, 1, 1},
  9816. {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  9817. {&__pyx_n_s_cnts, __pyx_k_cnts, sizeof(__pyx_k_cnts), 0, 0, 1, 1},
  9818. {&__pyx_n_s_counts, __pyx_k_counts, sizeof(__pyx_k_counts), 0, 0, 1, 1},
  9819. {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
  9820. {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1},
  9821. {&__pyx_n_s_double, __pyx_k_double, sizeof(__pyx_k_double), 0, 0, 1, 1},
  9822. {&__pyx_n_s_dt, __pyx_k_dt, sizeof(__pyx_k_dt), 0, 0, 1, 1},
  9823. {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
  9824. {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  9825. {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  9826. {&__pyx_n_s_frBbox, __pyx_k_frBbox, sizeof(__pyx_k_frBbox), 0, 0, 1, 1},
  9827. {&__pyx_n_s_frPoly, __pyx_k_frPoly, sizeof(__pyx_k_frPoly), 0, 0, 1, 1},
  9828. {&__pyx_n_s_frPyObjects, __pyx_k_frPyObjects, sizeof(__pyx_k_frPyObjects), 0, 0, 1, 1},
  9829. {&__pyx_n_s_frString, __pyx_k_frString, sizeof(__pyx_k_frString), 0, 0, 1, 1},
  9830. {&__pyx_n_s_frUncompressedRLE, __pyx_k_frUncompressedRLE, sizeof(__pyx_k_frUncompressedRLE), 0, 0, 1, 1},
  9831. {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  9832. {&__pyx_n_s_gt, __pyx_k_gt, sizeof(__pyx_k_gt), 0, 0, 1, 1},
  9833. {&__pyx_n_s_h, __pyx_k_h, sizeof(__pyx_k_h), 0, 0, 1, 1},
  9834. {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  9835. {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  9836. {&__pyx_kp_s_input_data_type_not_allowed, __pyx_k_input_data_type_not_allowed, sizeof(__pyx_k_input_data_type_not_allowed), 0, 0, 1, 0},
  9837. {&__pyx_kp_s_input_type_is_not_supported, __pyx_k_input_type_is_not_supported, sizeof(__pyx_k_input_type_is_not_supported), 0, 0, 1, 0},
  9838. {&__pyx_n_s_intersect, __pyx_k_intersect, sizeof(__pyx_k_intersect), 0, 0, 1, 1},
  9839. {&__pyx_n_s_iou, __pyx_k_iou, sizeof(__pyx_k_iou), 0, 0, 1, 1},
  9840. {&__pyx_n_s_iouFun, __pyx_k_iouFun, sizeof(__pyx_k_iouFun), 0, 0, 1, 1},
  9841. {&__pyx_n_s_iou_2, __pyx_k_iou_2, sizeof(__pyx_k_iou_2), 0, 0, 1, 1},
  9842. {&__pyx_n_s_iou_locals__bbIou, __pyx_k_iou_locals__bbIou, sizeof(__pyx_k_iou_locals__bbIou), 0, 0, 1, 1},
  9843. {&__pyx_n_s_iou_locals__len, __pyx_k_iou_locals__len, sizeof(__pyx_k_iou_locals__len), 0, 0, 1, 1},
  9844. {&__pyx_n_s_iou_locals__preproc, __pyx_k_iou_locals__preproc, sizeof(__pyx_k_iou_locals__preproc), 0, 0, 1, 1},
  9845. {&__pyx_n_s_iou_locals__rleIou, __pyx_k_iou_locals__rleIou, sizeof(__pyx_k_iou_locals__rleIou), 0, 0, 1, 1},
  9846. {&__pyx_n_s_isbox, __pyx_k_isbox, sizeof(__pyx_k_isbox), 0, 0, 1, 1},
  9847. {&__pyx_n_s_iscrowd, __pyx_k_iscrowd, sizeof(__pyx_k_iscrowd), 0, 0, 1, 1},
  9848. {&__pyx_n_s_isrle, __pyx_k_isrle, sizeof(__pyx_k_isrle), 0, 0, 1, 1},
  9849. {&__pyx_n_s_j, __pyx_k_j, sizeof(__pyx_k_j), 0, 0, 1, 1},
  9850. {&__pyx_n_s_len, __pyx_k_len, sizeof(__pyx_k_len), 0, 0, 1, 1},
  9851. {&__pyx_kp_s_list_input_can_be_bounding_box_N, __pyx_k_list_input_can_be_bounding_box_N, sizeof(__pyx_k_list_input_can_be_bounding_box_N), 0, 0, 1, 0},
  9852. {&__pyx_n_s_m, __pyx_k_m, sizeof(__pyx_k_m), 0, 0, 1, 1},
  9853. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  9854. {&__pyx_n_s_mask, __pyx_k_mask, sizeof(__pyx_k_mask), 0, 0, 1, 1},
  9855. {&__pyx_n_s_masks, __pyx_k_masks, sizeof(__pyx_k_masks), 0, 0, 1, 1},
  9856. {&__pyx_n_s_merge, __pyx_k_merge, sizeof(__pyx_k_merge), 0, 0, 1, 1},
  9857. {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1},
  9858. {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  9859. {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0},
  9860. {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0},
  9861. {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0},
  9862. {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
  9863. {&__pyx_n_s_np_poly, __pyx_k_np_poly, sizeof(__pyx_k_np_poly), 0, 0, 1, 1},
  9864. {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  9865. {&__pyx_kp_s_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 0, 1, 0},
  9866. {&__pyx_kp_s_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 0, 1, 0},
  9867. {&__pyx_kp_s_numpy_ndarray_input_is_only_for, __pyx_k_numpy_ndarray_input_is_only_for, sizeof(__pyx_k_numpy_ndarray_input_is_only_for), 0, 0, 1, 0},
  9868. {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
  9869. {&__pyx_n_s_objs, __pyx_k_objs, sizeof(__pyx_k_objs), 0, 0, 1, 1},
  9870. {&__pyx_n_s_order, __pyx_k_order, sizeof(__pyx_k_order), 0, 0, 1, 1},
  9871. {&__pyx_n_s_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 0, 1, 1},
  9872. {&__pyx_n_s_poly, __pyx_k_poly, sizeof(__pyx_k_poly), 0, 0, 1, 1},
  9873. {&__pyx_n_s_preproc, __pyx_k_preproc, sizeof(__pyx_k_preproc), 0, 0, 1, 1},
  9874. {&__pyx_n_s_py_string, __pyx_k_py_string, sizeof(__pyx_k_py_string), 0, 0, 1, 1},
  9875. {&__pyx_n_s_pycocotools__mask, __pyx_k_pycocotools__mask, sizeof(__pyx_k_pycocotools__mask), 0, 0, 1, 1},
  9876. {&__pyx_kp_s_pycocotools__mask_pyx, __pyx_k_pycocotools__mask_pyx, sizeof(__pyx_k_pycocotools__mask_pyx), 0, 0, 1, 0},
  9877. {&__pyx_n_s_pyiscrowd, __pyx_k_pyiscrowd, sizeof(__pyx_k_pyiscrowd), 0, 0, 1, 1},
  9878. {&__pyx_n_s_pyobj, __pyx_k_pyobj, sizeof(__pyx_k_pyobj), 0, 0, 1, 1},
  9879. {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  9880. {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  9881. {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  9882. {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  9883. {&__pyx_n_s_reshape, __pyx_k_reshape, sizeof(__pyx_k_reshape), 0, 0, 1, 1},
  9884. {&__pyx_n_s_rleIou, __pyx_k_rleIou, sizeof(__pyx_k_rleIou), 0, 0, 1, 1},
  9885. {&__pyx_n_s_rleObjs, __pyx_k_rleObjs, sizeof(__pyx_k_rleObjs), 0, 0, 1, 1},
  9886. {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  9887. {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  9888. {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
  9889. {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
  9890. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  9891. {&__pyx_n_s_toBbox, __pyx_k_toBbox, sizeof(__pyx_k_toBbox), 0, 0, 1, 1},
  9892. {&__pyx_n_s_toString, __pyx_k_toString, sizeof(__pyx_k_toString), 0, 0, 1, 1},
  9893. {&__pyx_n_s_tsungyi, __pyx_k_tsungyi, sizeof(__pyx_k_tsungyi), 0, 0, 1, 1},
  9894. {&__pyx_n_s_ucRles, __pyx_k_ucRles, sizeof(__pyx_k_ucRles), 0, 0, 1, 1},
  9895. {&__pyx_n_s_uint32, __pyx_k_uint32, sizeof(__pyx_k_uint32), 0, 0, 1, 1},
  9896. {&__pyx_n_s_uint8, __pyx_k_uint8, sizeof(__pyx_k_uint8), 0, 0, 1, 1},
  9897. {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0},
  9898. {&__pyx_kp_s_unrecognized_type_The_following, __pyx_k_unrecognized_type_The_following, sizeof(__pyx_k_unrecognized_type_The_following), 0, 0, 1, 0},
  9899. {&__pyx_n_s_w, __pyx_k_w, sizeof(__pyx_k_w), 0, 0, 1, 1},
  9900. {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1},
  9901. {0, 0, 0, 0, 0, 0, 0}
  9902. };
  9903. static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  9904. __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 64, __pyx_L1_error)
  9905. __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 70, __pyx_L1_error)
  9906. __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error)
  9907. __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 121, __pyx_L1_error)
  9908. __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(2, 272, __pyx_L1_error)
  9909. __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(2, 856, __pyx_L1_error)
  9910. __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(2, 1038, __pyx_L1_error)
  9911. return 0;
  9912. __pyx_L1_error:;
  9913. return -1;
  9914. }
  9915. static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  9916. __Pyx_RefNannyDeclarations
  9917. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  9918. /* "(tree fragment)":2
  9919. * def __reduce_cython__(self):
  9920. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  9921. * def __setstate_cython__(self, __pyx_state):
  9922. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  9923. */
  9924. __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 2, __pyx_L1_error)
  9925. __Pyx_GOTREF(__pyx_tuple_);
  9926. __Pyx_GIVEREF(__pyx_tuple_);
  9927. /* "(tree fragment)":4
  9928. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  9929. * def __setstate_cython__(self, __pyx_state):
  9930. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  9931. */
  9932. __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 4, __pyx_L1_error)
  9933. __Pyx_GOTREF(__pyx_tuple__2);
  9934. __Pyx_GIVEREF(__pyx_tuple__2);
  9935. /* "(tree fragment)":2
  9936. * def __reduce_cython__(self):
  9937. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  9938. * def __setstate_cython__(self, __pyx_state):
  9939. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  9940. */
  9941. __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 2, __pyx_L1_error)
  9942. __Pyx_GOTREF(__pyx_tuple__3);
  9943. __Pyx_GIVEREF(__pyx_tuple__3);
  9944. /* "(tree fragment)":4
  9945. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  9946. * def __setstate_cython__(self, __pyx_state):
  9947. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  9948. */
  9949. __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 4, __pyx_L1_error)
  9950. __Pyx_GOTREF(__pyx_tuple__4);
  9951. __Pyx_GIVEREF(__pyx_tuple__4);
  9952. /* "pycocotools/_mask.pyx":146
  9953. * def merge(rleObjs, bint intersect=0):
  9954. * cdef RLEs Rs = _frString(rleObjs)
  9955. * cdef RLEs R = RLEs(1) # <<<<<<<<<<<<<<
  9956. * rleMerge(<RLE*>Rs._R, <RLE*> R._R, <siz> Rs._n, intersect)
  9957. * obj = _toString(R)[0]
  9958. */
  9959. __pyx_tuple__5 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 146, __pyx_L1_error)
  9960. __Pyx_GOTREF(__pyx_tuple__5);
  9961. __Pyx_GIVEREF(__pyx_tuple__5);
  9962. /* "pycocotools/_mask.pyx":172
  9963. * # check if it's Nx4 bbox
  9964. * if not len(objs.shape) == 2 or not objs.shape[1] == 4:
  9965. * raise Exception('numpy ndarray input is only for *bounding boxes* and should have Nx4 dimension') # <<<<<<<<<<<<<<
  9966. * objs = objs.astype(np.double)
  9967. * elif type(objs) == list:
  9968. */
  9969. __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_numpy_ndarray_input_is_only_for); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 172, __pyx_L1_error)
  9970. __Pyx_GOTREF(__pyx_tuple__6);
  9971. __Pyx_GIVEREF(__pyx_tuple__6);
  9972. /* "pycocotools/_mask.pyx":185
  9973. * objs = _frString(objs)
  9974. * else:
  9975. * raise Exception('list input can be bounding box (Nx4) or RLEs ([RLE])') # <<<<<<<<<<<<<<
  9976. * else:
  9977. * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.')
  9978. */
  9979. __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_list_input_can_be_bounding_box_N); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 185, __pyx_L1_error)
  9980. __Pyx_GOTREF(__pyx_tuple__7);
  9981. __Pyx_GIVEREF(__pyx_tuple__7);
  9982. /* "pycocotools/_mask.pyx":187
  9983. * raise Exception('list input can be bounding box (Nx4) or RLEs ([RLE])')
  9984. * else:
  9985. * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.') # <<<<<<<<<<<<<<
  9986. * return objs
  9987. * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  9988. */
  9989. __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_unrecognized_type_The_following); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 187, __pyx_L1_error)
  9990. __Pyx_GOTREF(__pyx_tuple__8);
  9991. __Pyx_GIVEREF(__pyx_tuple__8);
  9992. /* "pycocotools/_mask.pyx":164
  9993. * # iou computation. support function overload (RLEs-RLEs and bbox-bbox).
  9994. * def iou( dt, gt, pyiscrowd ):
  9995. * def _preproc(objs): # <<<<<<<<<<<<<<
  9996. * if len(objs) == 0:
  9997. * return objs
  9998. */
  9999. __pyx_tuple__9 = PyTuple_Pack(4, __pyx_n_s_objs, __pyx_n_s_isbox, __pyx_n_s_isrle, __pyx_n_s_obj); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 164, __pyx_L1_error)
  10000. __Pyx_GOTREF(__pyx_tuple__9);
  10001. __Pyx_GIVEREF(__pyx_tuple__9);
  10002. __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pycocotools__mask_pyx, __pyx_n_s_preproc, 164, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 164, __pyx_L1_error)
  10003. /* "pycocotools/_mask.pyx":189
  10004. * raise Exception('unrecognized type. The following type: RLEs (rle), np.ndarray (box), and list (box) are supported.')
  10005. * return objs
  10006. * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): # <<<<<<<<<<<<<<
  10007. * rleIou( <RLE*> dt._R, <RLE*> gt._R, m, n, <byte*> iscrowd.data, <double*> _iou.data )
  10008. * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  10009. */
  10010. __pyx_tuple__11 = PyTuple_Pack(6, __pyx_n_s_dt, __pyx_n_s_gt, __pyx_n_s_iscrowd, __pyx_n_s_m, __pyx_n_s_n, __pyx_n_s_iou); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 189, __pyx_L1_error)
  10011. __Pyx_GOTREF(__pyx_tuple__11);
  10012. __Pyx_GIVEREF(__pyx_tuple__11);
  10013. __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(6, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pycocotools__mask_pyx, __pyx_n_s_rleIou, 189, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 189, __pyx_L1_error)
  10014. /* "pycocotools/_mask.pyx":191
  10015. * def _rleIou(RLEs dt, RLEs gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  10016. * rleIou( <RLE*> dt._R, <RLE*> gt._R, m, n, <byte*> iscrowd.data, <double*> _iou.data )
  10017. * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou): # <<<<<<<<<<<<<<
  10018. * bbIou( <BB> dt.data, <BB> gt.data, m, n, <byte*> iscrowd.data, <double*>_iou.data )
  10019. * def _len(obj):
  10020. */
  10021. __pyx_tuple__13 = PyTuple_Pack(6, __pyx_n_s_dt, __pyx_n_s_gt, __pyx_n_s_iscrowd, __pyx_n_s_m, __pyx_n_s_n, __pyx_n_s_iou); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 191, __pyx_L1_error)
  10022. __Pyx_GOTREF(__pyx_tuple__13);
  10023. __Pyx_GIVEREF(__pyx_tuple__13);
  10024. __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(6, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pycocotools__mask_pyx, __pyx_n_s_bbIou, 191, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 191, __pyx_L1_error)
  10025. /* "pycocotools/_mask.pyx":193
  10026. * def _bbIou(np.ndarray[np.double_t, ndim=2] dt, np.ndarray[np.double_t, ndim=2] gt, np.ndarray[np.uint8_t, ndim=1] iscrowd, siz m, siz n, np.ndarray[np.double_t, ndim=1] _iou):
  10027. * bbIou( <BB> dt.data, <BB> gt.data, m, n, <byte*> iscrowd.data, <double*>_iou.data )
  10028. * def _len(obj): # <<<<<<<<<<<<<<
  10029. * cdef siz N = 0
  10030. * if type(obj) == RLEs:
  10031. */
  10032. __pyx_tuple__15 = PyTuple_Pack(2, __pyx_n_s_obj, __pyx_n_s_N); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 193, __pyx_L1_error)
  10033. __Pyx_GOTREF(__pyx_tuple__15);
  10034. __Pyx_GIVEREF(__pyx_tuple__15);
  10035. __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pycocotools__mask_pyx, __pyx_n_s_len, 193, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 193, __pyx_L1_error)
  10036. /* "pycocotools/_mask.pyx":213
  10037. * return []
  10038. * if not type(dt) == type(gt):
  10039. * raise Exception('The dt and gt should have the same data type, either RLEs, list or np.ndarray') # <<<<<<<<<<<<<<
  10040. *
  10041. * # define local variables
  10042. */
  10043. __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_The_dt_and_gt_should_have_the_sa); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 213, __pyx_L1_error)
  10044. __Pyx_GOTREF(__pyx_tuple__17);
  10045. __Pyx_GIVEREF(__pyx_tuple__17);
  10046. /* "pycocotools/_mask.pyx":224
  10047. * _iouFun = _bbIou
  10048. * else:
  10049. * raise Exception('input data type not allowed.') # <<<<<<<<<<<<<<
  10050. * _iou = <double*> malloc(m*n* sizeof(double))
  10051. * iou = np.zeros((m*n, ), dtype=np.double)
  10052. */
  10053. __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_input_data_type_not_allowed); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 224, __pyx_L1_error)
  10054. __Pyx_GOTREF(__pyx_tuple__18);
  10055. __Pyx_GIVEREF(__pyx_tuple__18);
  10056. /* "pycocotools/_mask.pyx":290
  10057. * objs = frUncompressedRLE(pyobj, h, w)
  10058. * else:
  10059. * raise Exception('input type is not supported.') # <<<<<<<<<<<<<<
  10060. * return objs
  10061. */
  10062. __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_input_type_is_not_supported); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 290, __pyx_L1_error)
  10063. __Pyx_GOTREF(__pyx_tuple__19);
  10064. __Pyx_GIVEREF(__pyx_tuple__19);
  10065. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":272
  10066. * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
  10067. * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)):
  10068. * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<<
  10069. *
  10070. * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
  10071. */
  10072. __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(2, 272, __pyx_L1_error)
  10073. __Pyx_GOTREF(__pyx_tuple__20);
  10074. __Pyx_GIVEREF(__pyx_tuple__20);
  10075. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":276
  10076. * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
  10077. * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)):
  10078. * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<<
  10079. *
  10080. * info.buf = PyArray_DATA(self)
  10081. */
  10082. __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(2, 276, __pyx_L1_error)
  10083. __Pyx_GOTREF(__pyx_tuple__21);
  10084. __Pyx_GIVEREF(__pyx_tuple__21);
  10085. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":306
  10086. * if ((descr.byteorder == c'>' and little_endian) or
  10087. * (descr.byteorder == c'<' and not little_endian)):
  10088. * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<<
  10089. * if t == NPY_BYTE: f = "b"
  10090. * elif t == NPY_UBYTE: f = "B"
  10091. */
  10092. __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(2, 306, __pyx_L1_error)
  10093. __Pyx_GOTREF(__pyx_tuple__22);
  10094. __Pyx_GIVEREF(__pyx_tuple__22);
  10095. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":856
  10096. *
  10097. * if (end - f) - <int>(new_offset - offset[0]) < 15:
  10098. * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<<
  10099. *
  10100. * if ((child.byteorder == c'>' and little_endian) or
  10101. */
  10102. __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(2, 856, __pyx_L1_error)
  10103. __Pyx_GOTREF(__pyx_tuple__23);
  10104. __Pyx_GIVEREF(__pyx_tuple__23);
  10105. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":880
  10106. * t = child.type_num
  10107. * if end - f < 5:
  10108. * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<<
  10109. *
  10110. * # Until ticket #99 is fixed, use integers to avoid warnings
  10111. */
  10112. __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(2, 880, __pyx_L1_error)
  10113. __Pyx_GOTREF(__pyx_tuple__24);
  10114. __Pyx_GIVEREF(__pyx_tuple__24);
  10115. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1038
  10116. * _import_array()
  10117. * except Exception:
  10118. * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<<
  10119. *
  10120. * cdef inline int import_umath() except -1:
  10121. */
  10122. __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(2, 1038, __pyx_L1_error)
  10123. __Pyx_GOTREF(__pyx_tuple__25);
  10124. __Pyx_GIVEREF(__pyx_tuple__25);
  10125. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1044
  10126. * _import_umath()
  10127. * except Exception:
  10128. * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<<
  10129. *
  10130. * cdef inline int import_ufunc() except -1:
  10131. */
  10132. __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(2, 1044, __pyx_L1_error)
  10133. __Pyx_GOTREF(__pyx_tuple__26);
  10134. __Pyx_GIVEREF(__pyx_tuple__26);
  10135. /* "pycocotools/_mask.pyx":100
  10136. *
  10137. * # internal conversion from Python RLEs object to compressed RLE format
  10138. * def _toString(RLEs Rs): # <<<<<<<<<<<<<<
  10139. * cdef siz n = Rs.n
  10140. * cdef bytes py_string
  10141. */
  10142. __pyx_tuple__27 = PyTuple_Pack(6, __pyx_n_s_Rs, __pyx_n_s_n, __pyx_n_s_py_string, __pyx_n_s_c_string, __pyx_n_s_objs, __pyx_n_s_i); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 100, __pyx_L1_error)
  10143. __Pyx_GOTREF(__pyx_tuple__27);
  10144. __Pyx_GIVEREF(__pyx_tuple__27);
  10145. __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pycocotools__mask_pyx, __pyx_n_s_toString, 100, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 100, __pyx_L1_error)
  10146. /* "pycocotools/_mask.pyx":116
  10147. *
  10148. * # internal conversion from compressed RLE format to Python RLEs object
  10149. * def _frString(rleObjs): # <<<<<<<<<<<<<<
  10150. * cdef siz n = len(rleObjs)
  10151. * Rs = RLEs(n)
  10152. */
  10153. __pyx_tuple__29 = PyTuple_Pack(7, __pyx_n_s_rleObjs, __pyx_n_s_n, __pyx_n_s_Rs, __pyx_n_s_py_string, __pyx_n_s_c_string, __pyx_n_s_i, __pyx_n_s_obj); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 116, __pyx_L1_error)
  10154. __Pyx_GOTREF(__pyx_tuple__29);
  10155. __Pyx_GIVEREF(__pyx_tuple__29);
  10156. __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(1, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pycocotools__mask_pyx, __pyx_n_s_frString, 116, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 116, __pyx_L1_error)
  10157. /* "pycocotools/_mask.pyx":129
  10158. * # encode mask to RLEs objects
  10159. * # list of RLE string can be generated by RLEs member function
  10160. * def encode(np.ndarray[np.uint8_t, ndim=3, mode='fortran'] mask): # <<<<<<<<<<<<<<
  10161. * h, w, n = mask.shape[0], mask.shape[1], mask.shape[2]
  10162. * cdef RLEs Rs = RLEs(n)
  10163. */
  10164. __pyx_tuple__31 = PyTuple_Pack(6, __pyx_n_s_mask, __pyx_n_s_h, __pyx_n_s_w, __pyx_n_s_n, __pyx_n_s_Rs, __pyx_n_s_objs); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 129, __pyx_L1_error)
  10165. __Pyx_GOTREF(__pyx_tuple__31);
  10166. __Pyx_GIVEREF(__pyx_tuple__31);
  10167. __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pycocotools__mask_pyx, __pyx_n_s_encode, 129, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 129, __pyx_L1_error)
  10168. /* "pycocotools/_mask.pyx":137
  10169. *
  10170. * # decode mask from compressed list of RLE string or RLEs object
  10171. * def decode(rleObjs): # <<<<<<<<<<<<<<
  10172. * cdef RLEs Rs = _frString(rleObjs)
  10173. * h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n
  10174. */
  10175. __pyx_tuple__33 = PyTuple_Pack(6, __pyx_n_s_rleObjs, __pyx_n_s_Rs, __pyx_n_s_h, __pyx_n_s_w, __pyx_n_s_n, __pyx_n_s_masks); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 137, __pyx_L1_error)
  10176. __Pyx_GOTREF(__pyx_tuple__33);
  10177. __Pyx_GIVEREF(__pyx_tuple__33);
  10178. __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pycocotools__mask_pyx, __pyx_n_s_decode, 137, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 137, __pyx_L1_error)
  10179. /* "pycocotools/_mask.pyx":144
  10180. * return np.array(masks)
  10181. *
  10182. * def merge(rleObjs, bint intersect=0): # <<<<<<<<<<<<<<
  10183. * cdef RLEs Rs = _frString(rleObjs)
  10184. * cdef RLEs R = RLEs(1)
  10185. */
  10186. __pyx_tuple__35 = PyTuple_Pack(5, __pyx_n_s_rleObjs, __pyx_n_s_intersect, __pyx_n_s_Rs, __pyx_n_s_R, __pyx_n_s_obj); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 144, __pyx_L1_error)
  10187. __Pyx_GOTREF(__pyx_tuple__35);
  10188. __Pyx_GIVEREF(__pyx_tuple__35);
  10189. __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pycocotools__mask_pyx, __pyx_n_s_merge, 144, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 144, __pyx_L1_error)
  10190. /* "pycocotools/_mask.pyx":151
  10191. * return obj
  10192. *
  10193. * def area(rleObjs): # <<<<<<<<<<<<<<
  10194. * cdef RLEs Rs = _frString(rleObjs)
  10195. * cdef uint* _a = <uint*> malloc(Rs._n* sizeof(uint))
  10196. */
  10197. __pyx_tuple__37 = PyTuple_Pack(5, __pyx_n_s_rleObjs, __pyx_n_s_Rs, __pyx_n_s_a, __pyx_n_s_shape, __pyx_n_s_a_2); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 151, __pyx_L1_error)
  10198. __Pyx_GOTREF(__pyx_tuple__37);
  10199. __Pyx_GIVEREF(__pyx_tuple__37);
  10200. __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pycocotools__mask_pyx, __pyx_n_s_area, 151, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 151, __pyx_L1_error)
  10201. /* "pycocotools/_mask.pyx":163
  10202. *
  10203. * # iou computation. support function overload (RLEs-RLEs and bbox-bbox).
  10204. * def iou( dt, gt, pyiscrowd ): # <<<<<<<<<<<<<<
  10205. * def _preproc(objs):
  10206. * if len(objs) == 0:
  10207. */
  10208. __pyx_tuple__39 = PyTuple_Pack(18, __pyx_n_s_dt, __pyx_n_s_gt, __pyx_n_s_pyiscrowd, __pyx_n_s_preproc, __pyx_n_s_preproc, __pyx_n_s_rleIou, __pyx_n_s_rleIou, __pyx_n_s_bbIou, __pyx_n_s_bbIou, __pyx_n_s_len, __pyx_n_s_len, __pyx_n_s_iscrowd, __pyx_n_s_m, __pyx_n_s_n, __pyx_n_s_iou, __pyx_n_s_shape, __pyx_n_s_iouFun, __pyx_n_s_iou_2); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 163, __pyx_L1_error)
  10209. __Pyx_GOTREF(__pyx_tuple__39);
  10210. __Pyx_GIVEREF(__pyx_tuple__39);
  10211. __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(3, 0, 18, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pycocotools__mask_pyx, __pyx_n_s_iou_2, 163, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 163, __pyx_L1_error)
  10212. /* "pycocotools/_mask.pyx":233
  10213. * return iou.reshape((m,n), order='F')
  10214. *
  10215. * def toBbox( rleObjs ): # <<<<<<<<<<<<<<
  10216. * cdef RLEs Rs = _frString(rleObjs)
  10217. * cdef siz n = Rs.n
  10218. */
  10219. __pyx_tuple__41 = PyTuple_Pack(6, __pyx_n_s_rleObjs, __pyx_n_s_Rs, __pyx_n_s_n, __pyx_n_s_bb_2, __pyx_n_s_shape, __pyx_n_s_bb); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 233, __pyx_L1_error)
  10220. __Pyx_GOTREF(__pyx_tuple__41);
  10221. __Pyx_GIVEREF(__pyx_tuple__41);
  10222. __pyx_codeobj__42 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__41, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pycocotools__mask_pyx, __pyx_n_s_toBbox, 233, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__42)) __PYX_ERR(0, 233, __pyx_L1_error)
  10223. /* "pycocotools/_mask.pyx":245
  10224. * return bb
  10225. *
  10226. * def frBbox(np.ndarray[np.double_t, ndim=2] bb, siz h, siz w ): # <<<<<<<<<<<<<<
  10227. * cdef siz n = bb.shape[0]
  10228. * Rs = RLEs(n)
  10229. */
  10230. __pyx_tuple__43 = PyTuple_Pack(6, __pyx_n_s_bb, __pyx_n_s_h, __pyx_n_s_w, __pyx_n_s_n, __pyx_n_s_Rs, __pyx_n_s_objs); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 245, __pyx_L1_error)
  10231. __Pyx_GOTREF(__pyx_tuple__43);
  10232. __Pyx_GIVEREF(__pyx_tuple__43);
  10233. __pyx_codeobj__44 = (PyObject*)__Pyx_PyCode_New(3, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__43, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pycocotools__mask_pyx, __pyx_n_s_frBbox, 245, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__44)) __PYX_ERR(0, 245, __pyx_L1_error)
  10234. /* "pycocotools/_mask.pyx":252
  10235. * return objs
  10236. *
  10237. * def frPoly( poly, siz h, siz w ): # <<<<<<<<<<<<<<
  10238. * cdef np.ndarray[np.double_t, ndim=1] np_poly
  10239. * n = len(poly)
  10240. */
  10241. __pyx_tuple__45 = PyTuple_Pack(9, __pyx_n_s_poly, __pyx_n_s_h, __pyx_n_s_w, __pyx_n_s_np_poly, __pyx_n_s_n, __pyx_n_s_Rs, __pyx_n_s_i, __pyx_n_s_p, __pyx_n_s_objs); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 252, __pyx_L1_error)
  10242. __Pyx_GOTREF(__pyx_tuple__45);
  10243. __Pyx_GIVEREF(__pyx_tuple__45);
  10244. __pyx_codeobj__46 = (PyObject*)__Pyx_PyCode_New(3, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__45, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pycocotools__mask_pyx, __pyx_n_s_frPoly, 252, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__46)) __PYX_ERR(0, 252, __pyx_L1_error)
  10245. /* "pycocotools/_mask.pyx":262
  10246. * return objs
  10247. *
  10248. * def frUncompressedRLE(ucRles, siz h, siz w): # <<<<<<<<<<<<<<
  10249. * cdef np.ndarray[np.uint32_t, ndim=1] cnts
  10250. * cdef RLE R
  10251. */
  10252. __pyx_tuple__47 = PyTuple_Pack(11, __pyx_n_s_ucRles, __pyx_n_s_h, __pyx_n_s_w, __pyx_n_s_cnts, __pyx_n_s_R, __pyx_n_s_data, __pyx_n_s_n, __pyx_n_s_objs, __pyx_n_s_i, __pyx_n_s_Rs, __pyx_n_s_j); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 262, __pyx_L1_error)
  10253. __Pyx_GOTREF(__pyx_tuple__47);
  10254. __Pyx_GIVEREF(__pyx_tuple__47);
  10255. __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(3, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pycocotools__mask_pyx, __pyx_n_s_frUncompressedRLE, 262, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) __PYX_ERR(0, 262, __pyx_L1_error)
  10256. /* "pycocotools/_mask.pyx":280
  10257. * return objs
  10258. *
  10259. * def frPyObjects(pyobj, siz h, w): # <<<<<<<<<<<<<<
  10260. * if type(pyobj) == np.ndarray:
  10261. * objs = frBbox(pyobj, h, w )
  10262. */
  10263. __pyx_tuple__49 = PyTuple_Pack(4, __pyx_n_s_pyobj, __pyx_n_s_h, __pyx_n_s_w, __pyx_n_s_objs); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 280, __pyx_L1_error)
  10264. __Pyx_GOTREF(__pyx_tuple__49);
  10265. __Pyx_GIVEREF(__pyx_tuple__49);
  10266. __pyx_codeobj__50 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pycocotools__mask_pyx, __pyx_n_s_frPyObjects, 280, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__50)) __PYX_ERR(0, 280, __pyx_L1_error)
  10267. __Pyx_RefNannyFinishContext();
  10268. return 0;
  10269. __pyx_L1_error:;
  10270. __Pyx_RefNannyFinishContext();
  10271. return -1;
  10272. }
  10273. static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  10274. if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  10275. __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  10276. __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  10277. __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  10278. return 0;
  10279. __pyx_L1_error:;
  10280. return -1;
  10281. }
  10282. static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
  10283. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
  10284. static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
  10285. static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
  10286. static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
  10287. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
  10288. static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
  10289. static int __Pyx_modinit_global_init_code(void) {
  10290. __Pyx_RefNannyDeclarations
  10291. __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  10292. /*--- Global init code ---*/
  10293. __Pyx_RefNannyFinishContext();
  10294. return 0;
  10295. }
  10296. static int __Pyx_modinit_variable_export_code(void) {
  10297. __Pyx_RefNannyDeclarations
  10298. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  10299. /*--- Variable export code ---*/
  10300. __Pyx_RefNannyFinishContext();
  10301. return 0;
  10302. }
  10303. static int __Pyx_modinit_function_export_code(void) {
  10304. __Pyx_RefNannyDeclarations
  10305. __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  10306. /*--- Function export code ---*/
  10307. __Pyx_RefNannyFinishContext();
  10308. return 0;
  10309. }
  10310. static int __Pyx_modinit_type_init_code(void) {
  10311. __Pyx_RefNannyDeclarations
  10312. __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  10313. /*--- Type init code ---*/
  10314. if (PyType_Ready(&__pyx_type_11pycocotools_5_mask_RLEs) < 0) __PYX_ERR(0, 53, __pyx_L1_error)
  10315. __pyx_type_11pycocotools_5_mask_RLEs.tp_print = 0;
  10316. if (PyObject_SetAttr(__pyx_m, __pyx_n_s_RLEs, (PyObject *)&__pyx_type_11pycocotools_5_mask_RLEs) < 0) __PYX_ERR(0, 53, __pyx_L1_error)
  10317. if (__Pyx_setup_reduce((PyObject*)&__pyx_type_11pycocotools_5_mask_RLEs) < 0) __PYX_ERR(0, 53, __pyx_L1_error)
  10318. __pyx_ptype_11pycocotools_5_mask_RLEs = &__pyx_type_11pycocotools_5_mask_RLEs;
  10319. if (PyType_Ready(&__pyx_type_11pycocotools_5_mask_Masks) < 0) __PYX_ERR(0, 74, __pyx_L1_error)
  10320. __pyx_type_11pycocotools_5_mask_Masks.tp_print = 0;
  10321. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_11pycocotools_5_mask_Masks.tp_dictoffset && __pyx_type_11pycocotools_5_mask_Masks.tp_getattro == PyObject_GenericGetAttr)) {
  10322. __pyx_type_11pycocotools_5_mask_Masks.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  10323. }
  10324. if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Masks, (PyObject *)&__pyx_type_11pycocotools_5_mask_Masks) < 0) __PYX_ERR(0, 74, __pyx_L1_error)
  10325. if (__Pyx_setup_reduce((PyObject*)&__pyx_type_11pycocotools_5_mask_Masks) < 0) __PYX_ERR(0, 74, __pyx_L1_error)
  10326. __pyx_ptype_11pycocotools_5_mask_Masks = &__pyx_type_11pycocotools_5_mask_Masks;
  10327. __Pyx_RefNannyFinishContext();
  10328. return 0;
  10329. __pyx_L1_error:;
  10330. __Pyx_RefNannyFinishContext();
  10331. return -1;
  10332. }
  10333. static int __Pyx_modinit_type_import_code(void) {
  10334. __Pyx_RefNannyDeclarations
  10335. PyObject *__pyx_t_1 = NULL;
  10336. __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  10337. /*--- Type import code ---*/
  10338. __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 9, __pyx_L1_error)
  10339. __Pyx_GOTREF(__pyx_t_1);
  10340. __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
  10341. #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
  10342. sizeof(PyTypeObject),
  10343. #else
  10344. sizeof(PyHeapTypeObject),
  10345. #endif
  10346. __Pyx_ImportType_CheckSize_Warn);
  10347. if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(3, 9, __pyx_L1_error)
  10348. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10349. __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 206, __pyx_L1_error)
  10350. __Pyx_GOTREF(__pyx_t_1);
  10351. __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore);
  10352. if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(2, 206, __pyx_L1_error)
  10353. __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Warn);
  10354. if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(2, 229, __pyx_L1_error)
  10355. __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Warn);
  10356. if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(2, 233, __pyx_L1_error)
  10357. __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore);
  10358. if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(2, 242, __pyx_L1_error)
  10359. __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Warn);
  10360. if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(2, 918, __pyx_L1_error)
  10361. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10362. __Pyx_RefNannyFinishContext();
  10363. return 0;
  10364. __pyx_L1_error:;
  10365. __Pyx_XDECREF(__pyx_t_1);
  10366. __Pyx_RefNannyFinishContext();
  10367. return -1;
  10368. }
  10369. static int __Pyx_modinit_variable_import_code(void) {
  10370. __Pyx_RefNannyDeclarations
  10371. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  10372. /*--- Variable import code ---*/
  10373. __Pyx_RefNannyFinishContext();
  10374. return 0;
  10375. }
  10376. static int __Pyx_modinit_function_import_code(void) {
  10377. __Pyx_RefNannyDeclarations
  10378. __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  10379. /*--- Function import code ---*/
  10380. __Pyx_RefNannyFinishContext();
  10381. return 0;
  10382. }
  10383. #if PY_MAJOR_VERSION < 3
  10384. #ifdef CYTHON_NO_PYINIT_EXPORT
  10385. #define __Pyx_PyMODINIT_FUNC void
  10386. #else
  10387. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  10388. #endif
  10389. #else
  10390. #ifdef CYTHON_NO_PYINIT_EXPORT
  10391. #define __Pyx_PyMODINIT_FUNC PyObject *
  10392. #else
  10393. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  10394. #endif
  10395. #endif
  10396. #if PY_MAJOR_VERSION < 3
  10397. __Pyx_PyMODINIT_FUNC init_mask(void) CYTHON_SMALL_CODE; /*proto*/
  10398. __Pyx_PyMODINIT_FUNC init_mask(void)
  10399. #else
  10400. __Pyx_PyMODINIT_FUNC PyInit__mask(void) CYTHON_SMALL_CODE; /*proto*/
  10401. __Pyx_PyMODINIT_FUNC PyInit__mask(void)
  10402. #if CYTHON_PEP489_MULTI_PHASE_INIT
  10403. {
  10404. return PyModuleDef_Init(&__pyx_moduledef);
  10405. }
  10406. static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
  10407. #if PY_VERSION_HEX >= 0x030700A1
  10408. static PY_INT64_T main_interpreter_id = -1;
  10409. PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
  10410. if (main_interpreter_id == -1) {
  10411. main_interpreter_id = current_id;
  10412. return (unlikely(current_id == -1)) ? -1 : 0;
  10413. } else if (unlikely(main_interpreter_id != current_id))
  10414. #else
  10415. static PyInterpreterState *main_interpreter = NULL;
  10416. PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
  10417. if (!main_interpreter) {
  10418. main_interpreter = current_interpreter;
  10419. } else if (unlikely(main_interpreter != current_interpreter))
  10420. #endif
  10421. {
  10422. PyErr_SetString(
  10423. PyExc_ImportError,
  10424. "Interpreter change detected - this module can only be loaded into one interpreter per process.");
  10425. return -1;
  10426. }
  10427. return 0;
  10428. }
  10429. static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
  10430. PyObject *value = PyObject_GetAttrString(spec, from_name);
  10431. int result = 0;
  10432. if (likely(value)) {
  10433. if (allow_none || value != Py_None) {
  10434. result = PyDict_SetItemString(moddict, to_name, value);
  10435. }
  10436. Py_DECREF(value);
  10437. } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
  10438. PyErr_Clear();
  10439. } else {
  10440. result = -1;
  10441. }
  10442. return result;
  10443. }
  10444. static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
  10445. PyObject *module = NULL, *moddict, *modname;
  10446. if (__Pyx_check_single_interpreter())
  10447. return NULL;
  10448. if (__pyx_m)
  10449. return __Pyx_NewRef(__pyx_m);
  10450. modname = PyObject_GetAttrString(spec, "name");
  10451. if (unlikely(!modname)) goto bad;
  10452. module = PyModule_NewObject(modname);
  10453. Py_DECREF(modname);
  10454. if (unlikely(!module)) goto bad;
  10455. moddict = PyModule_GetDict(module);
  10456. if (unlikely(!moddict)) goto bad;
  10457. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
  10458. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
  10459. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
  10460. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
  10461. return module;
  10462. bad:
  10463. Py_XDECREF(module);
  10464. return NULL;
  10465. }
  10466. static CYTHON_SMALL_CODE int __pyx_pymod_exec__mask(PyObject *__pyx_pyinit_module)
  10467. #endif
  10468. #endif
  10469. {
  10470. PyObject *__pyx_t_1 = NULL;
  10471. int __pyx_t_2;
  10472. __Pyx_RefNannyDeclarations
  10473. #if CYTHON_PEP489_MULTI_PHASE_INIT
  10474. if (__pyx_m) {
  10475. if (__pyx_m == __pyx_pyinit_module) return 0;
  10476. PyErr_SetString(PyExc_RuntimeError, "Module '_mask' has already been imported. Re-initialisation is not supported.");
  10477. return -1;
  10478. }
  10479. #elif PY_MAJOR_VERSION >= 3
  10480. if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  10481. #endif
  10482. #if CYTHON_REFNANNY
  10483. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  10484. if (!__Pyx_RefNanny) {
  10485. PyErr_Clear();
  10486. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  10487. if (!__Pyx_RefNanny)
  10488. Py_FatalError("failed to import 'refnanny' module");
  10489. }
  10490. #endif
  10491. __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__mask(void)", 0);
  10492. if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  10493. #ifdef __Pxy_PyFrame_Initialize_Offsets
  10494. __Pxy_PyFrame_Initialize_Offsets();
  10495. #endif
  10496. __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  10497. __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  10498. __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  10499. #ifdef __Pyx_CyFunction_USED
  10500. if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  10501. #endif
  10502. #ifdef __Pyx_FusedFunction_USED
  10503. if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  10504. #endif
  10505. #ifdef __Pyx_Coroutine_USED
  10506. if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  10507. #endif
  10508. #ifdef __Pyx_Generator_USED
  10509. if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  10510. #endif
  10511. #ifdef __Pyx_AsyncGen_USED
  10512. if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  10513. #endif
  10514. #ifdef __Pyx_StopAsyncIteration_USED
  10515. if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  10516. #endif
  10517. /*--- Library function declarations ---*/
  10518. /*--- Threads initialization code ---*/
  10519. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  10520. #ifdef WITH_THREAD /* Python build with threading support? */
  10521. PyEval_InitThreads();
  10522. #endif
  10523. #endif
  10524. /*--- Module creation code ---*/
  10525. #if CYTHON_PEP489_MULTI_PHASE_INIT
  10526. __pyx_m = __pyx_pyinit_module;
  10527. Py_INCREF(__pyx_m);
  10528. #else
  10529. #if PY_MAJOR_VERSION < 3
  10530. __pyx_m = Py_InitModule4("_mask", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  10531. #else
  10532. __pyx_m = PyModule_Create(&__pyx_moduledef);
  10533. #endif
  10534. if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  10535. #endif
  10536. __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  10537. Py_INCREF(__pyx_d);
  10538. __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  10539. __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  10540. #if CYTHON_COMPILING_IN_PYPY
  10541. Py_INCREF(__pyx_b);
  10542. #endif
  10543. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  10544. /*--- Initialize various global constants etc. ---*/
  10545. if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  10546. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  10547. if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  10548. #endif
  10549. if (__pyx_module_is_main_pycocotools___mask) {
  10550. if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  10551. }
  10552. #if PY_MAJOR_VERSION >= 3
  10553. {
  10554. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
  10555. if (!PyDict_GetItemString(modules, "pycocotools._mask")) {
  10556. if (unlikely(PyDict_SetItemString(modules, "pycocotools._mask", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  10557. }
  10558. }
  10559. #endif
  10560. /*--- Builtin init code ---*/
  10561. if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  10562. /*--- Constants init code ---*/
  10563. if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  10564. /*--- Global type/function init code ---*/
  10565. (void)__Pyx_modinit_global_init_code();
  10566. (void)__Pyx_modinit_variable_export_code();
  10567. (void)__Pyx_modinit_function_export_code();
  10568. if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
  10569. if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
  10570. (void)__Pyx_modinit_variable_import_code();
  10571. (void)__Pyx_modinit_function_import_code();
  10572. /*--- Execution code ---*/
  10573. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  10574. if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  10575. #endif
  10576. /* "pycocotools/_mask.pyx":11
  10577. * #**************************************************************************
  10578. *
  10579. * __author__ = 'tsungyi' # <<<<<<<<<<<<<<
  10580. *
  10581. * # import both Python-level and C-level symbols of Numpy
  10582. */
  10583. if (PyDict_SetItem(__pyx_d, __pyx_n_s_author, __pyx_n_s_tsungyi) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
  10584. /* "pycocotools/_mask.pyx":15
  10585. * # import both Python-level and C-level symbols of Numpy
  10586. * # the API uses Numpy to interface C and Python
  10587. * import numpy as np # <<<<<<<<<<<<<<
  10588. * cimport numpy as np
  10589. * from libc.stdlib cimport malloc, free
  10590. */
  10591. __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
  10592. __Pyx_GOTREF(__pyx_t_1);
  10593. if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
  10594. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10595. /* "pycocotools/_mask.pyx":20
  10596. *
  10597. * # intialized Numpy. must do.
  10598. * np.import_array() # <<<<<<<<<<<<<<
  10599. *
  10600. * # import numpy C function
  10601. */
  10602. __pyx_t_2 = __pyx_f_5numpy_import_array(); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 20, __pyx_L1_error)
  10603. /* "pycocotools/_mask.pyx":100
  10604. *
  10605. * # internal conversion from Python RLEs object to compressed RLE format
  10606. * def _toString(RLEs Rs): # <<<<<<<<<<<<<<
  10607. * cdef siz n = Rs.n
  10608. * cdef bytes py_string
  10609. */
  10610. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11pycocotools_5_mask_1_toString, NULL, __pyx_n_s_pycocotools__mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error)
  10611. __Pyx_GOTREF(__pyx_t_1);
  10612. if (PyDict_SetItem(__pyx_d, __pyx_n_s_toString, __pyx_t_1) < 0) __PYX_ERR(0, 100, __pyx_L1_error)
  10613. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10614. /* "pycocotools/_mask.pyx":116
  10615. *
  10616. * # internal conversion from compressed RLE format to Python RLEs object
  10617. * def _frString(rleObjs): # <<<<<<<<<<<<<<
  10618. * cdef siz n = len(rleObjs)
  10619. * Rs = RLEs(n)
  10620. */
  10621. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11pycocotools_5_mask_3_frString, NULL, __pyx_n_s_pycocotools__mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error)
  10622. __Pyx_GOTREF(__pyx_t_1);
  10623. if (PyDict_SetItem(__pyx_d, __pyx_n_s_frString, __pyx_t_1) < 0) __PYX_ERR(0, 116, __pyx_L1_error)
  10624. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10625. /* "pycocotools/_mask.pyx":129
  10626. * # encode mask to RLEs objects
  10627. * # list of RLE string can be generated by RLEs member function
  10628. * def encode(np.ndarray[np.uint8_t, ndim=3, mode='fortran'] mask): # <<<<<<<<<<<<<<
  10629. * h, w, n = mask.shape[0], mask.shape[1], mask.shape[2]
  10630. * cdef RLEs Rs = RLEs(n)
  10631. */
  10632. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11pycocotools_5_mask_5encode, NULL, __pyx_n_s_pycocotools__mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error)
  10633. __Pyx_GOTREF(__pyx_t_1);
  10634. if (PyDict_SetItem(__pyx_d, __pyx_n_s_encode, __pyx_t_1) < 0) __PYX_ERR(0, 129, __pyx_L1_error)
  10635. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10636. /* "pycocotools/_mask.pyx":137
  10637. *
  10638. * # decode mask from compressed list of RLE string or RLEs object
  10639. * def decode(rleObjs): # <<<<<<<<<<<<<<
  10640. * cdef RLEs Rs = _frString(rleObjs)
  10641. * h, w, n = Rs._R[0].h, Rs._R[0].w, Rs._n
  10642. */
  10643. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11pycocotools_5_mask_7decode, NULL, __pyx_n_s_pycocotools__mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error)
  10644. __Pyx_GOTREF(__pyx_t_1);
  10645. if (PyDict_SetItem(__pyx_d, __pyx_n_s_decode, __pyx_t_1) < 0) __PYX_ERR(0, 137, __pyx_L1_error)
  10646. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10647. /* "pycocotools/_mask.pyx":144
  10648. * return np.array(masks)
  10649. *
  10650. * def merge(rleObjs, bint intersect=0): # <<<<<<<<<<<<<<
  10651. * cdef RLEs Rs = _frString(rleObjs)
  10652. * cdef RLEs R = RLEs(1)
  10653. */
  10654. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11pycocotools_5_mask_9merge, NULL, __pyx_n_s_pycocotools__mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error)
  10655. __Pyx_GOTREF(__pyx_t_1);
  10656. if (PyDict_SetItem(__pyx_d, __pyx_n_s_merge, __pyx_t_1) < 0) __PYX_ERR(0, 144, __pyx_L1_error)
  10657. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10658. /* "pycocotools/_mask.pyx":151
  10659. * return obj
  10660. *
  10661. * def area(rleObjs): # <<<<<<<<<<<<<<
  10662. * cdef RLEs Rs = _frString(rleObjs)
  10663. * cdef uint* _a = <uint*> malloc(Rs._n* sizeof(uint))
  10664. */
  10665. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11pycocotools_5_mask_11area, NULL, __pyx_n_s_pycocotools__mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error)
  10666. __Pyx_GOTREF(__pyx_t_1);
  10667. if (PyDict_SetItem(__pyx_d, __pyx_n_s_area, __pyx_t_1) < 0) __PYX_ERR(0, 151, __pyx_L1_error)
  10668. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10669. /* "pycocotools/_mask.pyx":163
  10670. *
  10671. * # iou computation. support function overload (RLEs-RLEs and bbox-bbox).
  10672. * def iou( dt, gt, pyiscrowd ): # <<<<<<<<<<<<<<
  10673. * def _preproc(objs):
  10674. * if len(objs) == 0:
  10675. */
  10676. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11pycocotools_5_mask_13iou, NULL, __pyx_n_s_pycocotools__mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
  10677. __Pyx_GOTREF(__pyx_t_1);
  10678. if (PyDict_SetItem(__pyx_d, __pyx_n_s_iou_2, __pyx_t_1) < 0) __PYX_ERR(0, 163, __pyx_L1_error)
  10679. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10680. /* "pycocotools/_mask.pyx":233
  10681. * return iou.reshape((m,n), order='F')
  10682. *
  10683. * def toBbox( rleObjs ): # <<<<<<<<<<<<<<
  10684. * cdef RLEs Rs = _frString(rleObjs)
  10685. * cdef siz n = Rs.n
  10686. */
  10687. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11pycocotools_5_mask_15toBbox, NULL, __pyx_n_s_pycocotools__mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 233, __pyx_L1_error)
  10688. __Pyx_GOTREF(__pyx_t_1);
  10689. if (PyDict_SetItem(__pyx_d, __pyx_n_s_toBbox, __pyx_t_1) < 0) __PYX_ERR(0, 233, __pyx_L1_error)
  10690. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10691. /* "pycocotools/_mask.pyx":245
  10692. * return bb
  10693. *
  10694. * def frBbox(np.ndarray[np.double_t, ndim=2] bb, siz h, siz w ): # <<<<<<<<<<<<<<
  10695. * cdef siz n = bb.shape[0]
  10696. * Rs = RLEs(n)
  10697. */
  10698. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11pycocotools_5_mask_17frBbox, NULL, __pyx_n_s_pycocotools__mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 245, __pyx_L1_error)
  10699. __Pyx_GOTREF(__pyx_t_1);
  10700. if (PyDict_SetItem(__pyx_d, __pyx_n_s_frBbox, __pyx_t_1) < 0) __PYX_ERR(0, 245, __pyx_L1_error)
  10701. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10702. /* "pycocotools/_mask.pyx":252
  10703. * return objs
  10704. *
  10705. * def frPoly( poly, siz h, siz w ): # <<<<<<<<<<<<<<
  10706. * cdef np.ndarray[np.double_t, ndim=1] np_poly
  10707. * n = len(poly)
  10708. */
  10709. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11pycocotools_5_mask_19frPoly, NULL, __pyx_n_s_pycocotools__mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error)
  10710. __Pyx_GOTREF(__pyx_t_1);
  10711. if (PyDict_SetItem(__pyx_d, __pyx_n_s_frPoly, __pyx_t_1) < 0) __PYX_ERR(0, 252, __pyx_L1_error)
  10712. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10713. /* "pycocotools/_mask.pyx":262
  10714. * return objs
  10715. *
  10716. * def frUncompressedRLE(ucRles, siz h, siz w): # <<<<<<<<<<<<<<
  10717. * cdef np.ndarray[np.uint32_t, ndim=1] cnts
  10718. * cdef RLE R
  10719. */
  10720. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11pycocotools_5_mask_21frUncompressedRLE, NULL, __pyx_n_s_pycocotools__mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error)
  10721. __Pyx_GOTREF(__pyx_t_1);
  10722. if (PyDict_SetItem(__pyx_d, __pyx_n_s_frUncompressedRLE, __pyx_t_1) < 0) __PYX_ERR(0, 262, __pyx_L1_error)
  10723. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10724. /* "pycocotools/_mask.pyx":280
  10725. * return objs
  10726. *
  10727. * def frPyObjects(pyobj, siz h, w): # <<<<<<<<<<<<<<
  10728. * if type(pyobj) == np.ndarray:
  10729. * objs = frBbox(pyobj, h, w )
  10730. */
  10731. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_11pycocotools_5_mask_23frPyObjects, NULL, __pyx_n_s_pycocotools__mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error)
  10732. __Pyx_GOTREF(__pyx_t_1);
  10733. if (PyDict_SetItem(__pyx_d, __pyx_n_s_frPyObjects, __pyx_t_1) < 0) __PYX_ERR(0, 280, __pyx_L1_error)
  10734. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10735. /* "pycocotools/_mask.pyx":1
  10736. * # distutils: language = c # <<<<<<<<<<<<<<
  10737. * # distutils: sources = ../MatlabAPI/private/maskApi.c
  10738. *
  10739. */
  10740. __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  10741. __Pyx_GOTREF(__pyx_t_1);
  10742. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  10743. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  10744. /* "../../Anaconda2/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1046
  10745. * raise ImportError("numpy.core.umath failed to import")
  10746. *
  10747. * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<<
  10748. * try:
  10749. * _import_umath()
  10750. */
  10751. /*--- Wrapped vars code ---*/
  10752. goto __pyx_L0;
  10753. __pyx_L1_error:;
  10754. __Pyx_XDECREF(__pyx_t_1);
  10755. if (__pyx_m) {
  10756. if (__pyx_d) {
  10757. __Pyx_AddTraceback("init pycocotools._mask", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10758. }
  10759. Py_CLEAR(__pyx_m);
  10760. } else if (!PyErr_Occurred()) {
  10761. PyErr_SetString(PyExc_ImportError, "init pycocotools._mask");
  10762. }
  10763. __pyx_L0:;
  10764. __Pyx_RefNannyFinishContext();
  10765. #if CYTHON_PEP489_MULTI_PHASE_INIT
  10766. return (__pyx_m != NULL) ? 0 : -1;
  10767. #elif PY_MAJOR_VERSION >= 3
  10768. return __pyx_m;
  10769. #else
  10770. return;
  10771. #endif
  10772. }
  10773. /* --- Runtime support code --- */
  10774. /* Refnanny */
  10775. #if CYTHON_REFNANNY
  10776. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  10777. PyObject *m = NULL, *p = NULL;
  10778. void *r = NULL;
  10779. m = PyImport_ImportModule(modname);
  10780. if (!m) goto end;
  10781. p = PyObject_GetAttrString(m, "RefNannyAPI");
  10782. if (!p) goto end;
  10783. r = PyLong_AsVoidPtr(p);
  10784. end:
  10785. Py_XDECREF(p);
  10786. Py_XDECREF(m);
  10787. return (__Pyx_RefNannyAPIStruct *)r;
  10788. }
  10789. #endif
  10790. /* PyObjectGetAttrStr */
  10791. #if CYTHON_USE_TYPE_SLOTS
  10792. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  10793. PyTypeObject* tp = Py_TYPE(obj);
  10794. if (likely(tp->tp_getattro))
  10795. return tp->tp_getattro(obj, attr_name);
  10796. #if PY_MAJOR_VERSION < 3
  10797. if (likely(tp->tp_getattr))
  10798. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  10799. #endif
  10800. return PyObject_GetAttr(obj, attr_name);
  10801. }
  10802. #endif
  10803. /* GetBuiltinName */
  10804. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  10805. PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
  10806. if (unlikely(!result)) {
  10807. PyErr_Format(PyExc_NameError,
  10808. #if PY_MAJOR_VERSION >= 3
  10809. "name '%U' is not defined", name);
  10810. #else
  10811. "name '%.200s' is not defined", PyString_AS_STRING(name));
  10812. #endif
  10813. }
  10814. return result;
  10815. }
  10816. /* RaiseDoubleKeywords */
  10817. static void __Pyx_RaiseDoubleKeywordsError(
  10818. const char* func_name,
  10819. PyObject* kw_name)
  10820. {
  10821. PyErr_Format(PyExc_TypeError,
  10822. #if PY_MAJOR_VERSION >= 3
  10823. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  10824. #else
  10825. "%s() got multiple values for keyword argument '%s'", func_name,
  10826. PyString_AsString(kw_name));
  10827. #endif
  10828. }
  10829. /* ParseKeywords */
  10830. static int __Pyx_ParseOptionalKeywords(
  10831. PyObject *kwds,
  10832. PyObject **argnames[],
  10833. PyObject *kwds2,
  10834. PyObject *values[],
  10835. Py_ssize_t num_pos_args,
  10836. const char* function_name)
  10837. {
  10838. PyObject *key = 0, *value = 0;
  10839. Py_ssize_t pos = 0;
  10840. PyObject*** name;
  10841. PyObject*** first_kw_arg = argnames + num_pos_args;
  10842. while (PyDict_Next(kwds, &pos, &key, &value)) {
  10843. name = first_kw_arg;
  10844. while (*name && (**name != key)) name++;
  10845. if (*name) {
  10846. values[name-argnames] = value;
  10847. continue;
  10848. }
  10849. name = first_kw_arg;
  10850. #if PY_MAJOR_VERSION < 3
  10851. if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
  10852. while (*name) {
  10853. if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
  10854. && _PyString_Eq(**name, key)) {
  10855. values[name-argnames] = value;
  10856. break;
  10857. }
  10858. name++;
  10859. }
  10860. if (*name) continue;
  10861. else {
  10862. PyObject*** argname = argnames;
  10863. while (argname != first_kw_arg) {
  10864. if ((**argname == key) || (
  10865. (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
  10866. && _PyString_Eq(**argname, key))) {
  10867. goto arg_passed_twice;
  10868. }
  10869. argname++;
  10870. }
  10871. }
  10872. } else
  10873. #endif
  10874. if (likely(PyUnicode_Check(key))) {
  10875. while (*name) {
  10876. int cmp = (**name == key) ? 0 :
  10877. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  10878. (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
  10879. #endif
  10880. PyUnicode_Compare(**name, key);
  10881. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  10882. if (cmp == 0) {
  10883. values[name-argnames] = value;
  10884. break;
  10885. }
  10886. name++;
  10887. }
  10888. if (*name) continue;
  10889. else {
  10890. PyObject*** argname = argnames;
  10891. while (argname != first_kw_arg) {
  10892. int cmp = (**argname == key) ? 0 :
  10893. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  10894. (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
  10895. #endif
  10896. PyUnicode_Compare(**argname, key);
  10897. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  10898. if (cmp == 0) goto arg_passed_twice;
  10899. argname++;
  10900. }
  10901. }
  10902. } else
  10903. goto invalid_keyword_type;
  10904. if (kwds2) {
  10905. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  10906. } else {
  10907. goto invalid_keyword;
  10908. }
  10909. }
  10910. return 0;
  10911. arg_passed_twice:
  10912. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  10913. goto bad;
  10914. invalid_keyword_type:
  10915. PyErr_Format(PyExc_TypeError,
  10916. "%.200s() keywords must be strings", function_name);
  10917. goto bad;
  10918. invalid_keyword:
  10919. PyErr_Format(PyExc_TypeError,
  10920. #if PY_MAJOR_VERSION < 3
  10921. "%.200s() got an unexpected keyword argument '%.200s'",
  10922. function_name, PyString_AsString(key));
  10923. #else
  10924. "%s() got an unexpected keyword argument '%U'",
  10925. function_name, key);
  10926. #endif
  10927. bad:
  10928. return -1;
  10929. }
  10930. /* RaiseArgTupleInvalid */
  10931. static void __Pyx_RaiseArgtupleInvalid(
  10932. const char* func_name,
  10933. int exact,
  10934. Py_ssize_t num_min,
  10935. Py_ssize_t num_max,
  10936. Py_ssize_t num_found)
  10937. {
  10938. Py_ssize_t num_expected;
  10939. const char *more_or_less;
  10940. if (num_found < num_min) {
  10941. num_expected = num_min;
  10942. more_or_less = "at least";
  10943. } else {
  10944. num_expected = num_max;
  10945. more_or_less = "at most";
  10946. }
  10947. if (exact) {
  10948. more_or_less = "exactly";
  10949. }
  10950. PyErr_Format(PyExc_TypeError,
  10951. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  10952. func_name, more_or_less, num_expected,
  10953. (num_expected == 1) ? "" : "s", num_found);
  10954. }
  10955. /* BytesEquals */
  10956. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
  10957. #if CYTHON_COMPILING_IN_PYPY
  10958. return PyObject_RichCompareBool(s1, s2, equals);
  10959. #else
  10960. if (s1 == s2) {
  10961. return (equals == Py_EQ);
  10962. } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
  10963. const char *ps1, *ps2;
  10964. Py_ssize_t length = PyBytes_GET_SIZE(s1);
  10965. if (length != PyBytes_GET_SIZE(s2))
  10966. return (equals == Py_NE);
  10967. ps1 = PyBytes_AS_STRING(s1);
  10968. ps2 = PyBytes_AS_STRING(s2);
  10969. if (ps1[0] != ps2[0]) {
  10970. return (equals == Py_NE);
  10971. } else if (length == 1) {
  10972. return (equals == Py_EQ);
  10973. } else {
  10974. int result;
  10975. #if CYTHON_USE_UNICODE_INTERNALS
  10976. Py_hash_t hash1, hash2;
  10977. hash1 = ((PyBytesObject*)s1)->ob_shash;
  10978. hash2 = ((PyBytesObject*)s2)->ob_shash;
  10979. if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
  10980. return (equals == Py_NE);
  10981. }
  10982. #endif
  10983. result = memcmp(ps1, ps2, (size_t)length);
  10984. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  10985. }
  10986. } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
  10987. return (equals == Py_NE);
  10988. } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
  10989. return (equals == Py_NE);
  10990. } else {
  10991. int result;
  10992. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  10993. if (!py_result)
  10994. return -1;
  10995. result = __Pyx_PyObject_IsTrue(py_result);
  10996. Py_DECREF(py_result);
  10997. return result;
  10998. }
  10999. #endif
  11000. }
  11001. /* UnicodeEquals */
  11002. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
  11003. #if CYTHON_COMPILING_IN_PYPY
  11004. return PyObject_RichCompareBool(s1, s2, equals);
  11005. #else
  11006. #if PY_MAJOR_VERSION < 3
  11007. PyObject* owned_ref = NULL;
  11008. #endif
  11009. int s1_is_unicode, s2_is_unicode;
  11010. if (s1 == s2) {
  11011. goto return_eq;
  11012. }
  11013. s1_is_unicode = PyUnicode_CheckExact(s1);
  11014. s2_is_unicode = PyUnicode_CheckExact(s2);
  11015. #if PY_MAJOR_VERSION < 3
  11016. if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
  11017. owned_ref = PyUnicode_FromObject(s2);
  11018. if (unlikely(!owned_ref))
  11019. return -1;
  11020. s2 = owned_ref;
  11021. s2_is_unicode = 1;
  11022. } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
  11023. owned_ref = PyUnicode_FromObject(s1);
  11024. if (unlikely(!owned_ref))
  11025. return -1;
  11026. s1 = owned_ref;
  11027. s1_is_unicode = 1;
  11028. } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
  11029. return __Pyx_PyBytes_Equals(s1, s2, equals);
  11030. }
  11031. #endif
  11032. if (s1_is_unicode & s2_is_unicode) {
  11033. Py_ssize_t length;
  11034. int kind;
  11035. void *data1, *data2;
  11036. if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
  11037. return -1;
  11038. length = __Pyx_PyUnicode_GET_LENGTH(s1);
  11039. if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
  11040. goto return_ne;
  11041. }
  11042. #if CYTHON_USE_UNICODE_INTERNALS
  11043. {
  11044. Py_hash_t hash1, hash2;
  11045. #if CYTHON_PEP393_ENABLED
  11046. hash1 = ((PyASCIIObject*)s1)->hash;
  11047. hash2 = ((PyASCIIObject*)s2)->hash;
  11048. #else
  11049. hash1 = ((PyUnicodeObject*)s1)->hash;
  11050. hash2 = ((PyUnicodeObject*)s2)->hash;
  11051. #endif
  11052. if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
  11053. goto return_ne;
  11054. }
  11055. }
  11056. #endif
  11057. kind = __Pyx_PyUnicode_KIND(s1);
  11058. if (kind != __Pyx_PyUnicode_KIND(s2)) {
  11059. goto return_ne;
  11060. }
  11061. data1 = __Pyx_PyUnicode_DATA(s1);
  11062. data2 = __Pyx_PyUnicode_DATA(s2);
  11063. if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
  11064. goto return_ne;
  11065. } else if (length == 1) {
  11066. goto return_eq;
  11067. } else {
  11068. int result = memcmp(data1, data2, (size_t)(length * kind));
  11069. #if PY_MAJOR_VERSION < 3
  11070. Py_XDECREF(owned_ref);
  11071. #endif
  11072. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  11073. }
  11074. } else if ((s1 == Py_None) & s2_is_unicode) {
  11075. goto return_ne;
  11076. } else if ((s2 == Py_None) & s1_is_unicode) {
  11077. goto return_ne;
  11078. } else {
  11079. int result;
  11080. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  11081. #if PY_MAJOR_VERSION < 3
  11082. Py_XDECREF(owned_ref);
  11083. #endif
  11084. if (!py_result)
  11085. return -1;
  11086. result = __Pyx_PyObject_IsTrue(py_result);
  11087. Py_DECREF(py_result);
  11088. return result;
  11089. }
  11090. return_eq:
  11091. #if PY_MAJOR_VERSION < 3
  11092. Py_XDECREF(owned_ref);
  11093. #endif
  11094. return (equals == Py_EQ);
  11095. return_ne:
  11096. #if PY_MAJOR_VERSION < 3
  11097. Py_XDECREF(owned_ref);
  11098. #endif
  11099. return (equals == Py_NE);
  11100. #endif
  11101. }
  11102. /* PyCFunctionFastCall */
  11103. #if CYTHON_FAST_PYCCALL
  11104. static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
  11105. PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
  11106. PyCFunction meth = PyCFunction_GET_FUNCTION(func);
  11107. PyObject *self = PyCFunction_GET_SELF(func);
  11108. int flags = PyCFunction_GET_FLAGS(func);
  11109. assert(PyCFunction_Check(func));
  11110. assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
  11111. assert(nargs >= 0);
  11112. assert(nargs == 0 || args != NULL);
  11113. /* _PyCFunction_FastCallDict() must not be called with an exception set,
  11114. because it may clear it (directly or indirectly) and so the
  11115. caller loses its exception */
  11116. assert(!PyErr_Occurred());
  11117. if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
  11118. return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
  11119. } else {
  11120. return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
  11121. }
  11122. }
  11123. #endif
  11124. /* PyFunctionFastCall */
  11125. #if CYTHON_FAST_PYCALL
  11126. static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
  11127. PyObject *globals) {
  11128. PyFrameObject *f;
  11129. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  11130. PyObject **fastlocals;
  11131. Py_ssize_t i;
  11132. PyObject *result;
  11133. assert(globals != NULL);
  11134. /* XXX Perhaps we should create a specialized
  11135. PyFrame_New() that doesn't take locals, but does
  11136. take builtins without sanity checking them.
  11137. */
  11138. assert(tstate != NULL);
  11139. f = PyFrame_New(tstate, co, globals, NULL);
  11140. if (f == NULL) {
  11141. return NULL;
  11142. }
  11143. fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
  11144. for (i = 0; i < na; i++) {
  11145. Py_INCREF(*args);
  11146. fastlocals[i] = *args++;
  11147. }
  11148. result = PyEval_EvalFrameEx(f,0);
  11149. ++tstate->recursion_depth;
  11150. Py_DECREF(f);
  11151. --tstate->recursion_depth;
  11152. return result;
  11153. }
  11154. #if 1 || PY_VERSION_HEX < 0x030600B1
  11155. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
  11156. PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
  11157. PyObject *globals = PyFunction_GET_GLOBALS(func);
  11158. PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
  11159. PyObject *closure;
  11160. #if PY_MAJOR_VERSION >= 3
  11161. PyObject *kwdefs;
  11162. #endif
  11163. PyObject *kwtuple, **k;
  11164. PyObject **d;
  11165. Py_ssize_t nd;
  11166. Py_ssize_t nk;
  11167. PyObject *result;
  11168. assert(kwargs == NULL || PyDict_Check(kwargs));
  11169. nk = kwargs ? PyDict_Size(kwargs) : 0;
  11170. if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
  11171. return NULL;
  11172. }
  11173. if (
  11174. #if PY_MAJOR_VERSION >= 3
  11175. co->co_kwonlyargcount == 0 &&
  11176. #endif
  11177. likely(kwargs == NULL || nk == 0) &&
  11178. co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
  11179. if (argdefs == NULL && co->co_argcount == nargs) {
  11180. result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
  11181. goto done;
  11182. }
  11183. else if (nargs == 0 && argdefs != NULL
  11184. && co->co_argcount == Py_SIZE(argdefs)) {
  11185. /* function called with no arguments, but all parameters have
  11186. a default value: use default values as arguments .*/
  11187. args = &PyTuple_GET_ITEM(argdefs, 0);
  11188. result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
  11189. goto done;
  11190. }
  11191. }
  11192. if (kwargs != NULL) {
  11193. Py_ssize_t pos, i;
  11194. kwtuple = PyTuple_New(2 * nk);
  11195. if (kwtuple == NULL) {
  11196. result = NULL;
  11197. goto done;
  11198. }
  11199. k = &PyTuple_GET_ITEM(kwtuple, 0);
  11200. pos = i = 0;
  11201. while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
  11202. Py_INCREF(k[i]);
  11203. Py_INCREF(k[i+1]);
  11204. i += 2;
  11205. }
  11206. nk = i / 2;
  11207. }
  11208. else {
  11209. kwtuple = NULL;
  11210. k = NULL;
  11211. }
  11212. closure = PyFunction_GET_CLOSURE(func);
  11213. #if PY_MAJOR_VERSION >= 3
  11214. kwdefs = PyFunction_GET_KW_DEFAULTS(func);
  11215. #endif
  11216. if (argdefs != NULL) {
  11217. d = &PyTuple_GET_ITEM(argdefs, 0);
  11218. nd = Py_SIZE(argdefs);
  11219. }
  11220. else {
  11221. d = NULL;
  11222. nd = 0;
  11223. }
  11224. #if PY_MAJOR_VERSION >= 3
  11225. result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
  11226. args, nargs,
  11227. k, (int)nk,
  11228. d, (int)nd, kwdefs, closure);
  11229. #else
  11230. result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
  11231. args, nargs,
  11232. k, (int)nk,
  11233. d, (int)nd, closure);
  11234. #endif
  11235. Py_XDECREF(kwtuple);
  11236. done:
  11237. Py_LeaveRecursiveCall();
  11238. return result;
  11239. }
  11240. #endif
  11241. #endif
  11242. /* PyObjectCall */
  11243. #if CYTHON_COMPILING_IN_CPYTHON
  11244. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  11245. PyObject *result;
  11246. ternaryfunc call = func->ob_type->tp_call;
  11247. if (unlikely(!call))
  11248. return PyObject_Call(func, arg, kw);
  11249. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  11250. return NULL;
  11251. result = (*call)(func, arg, kw);
  11252. Py_LeaveRecursiveCall();
  11253. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  11254. PyErr_SetString(
  11255. PyExc_SystemError,
  11256. "NULL result without error in PyObject_Call");
  11257. }
  11258. return result;
  11259. }
  11260. #endif
  11261. /* PyObjectCallMethO */
  11262. #if CYTHON_COMPILING_IN_CPYTHON
  11263. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
  11264. PyObject *self, *result;
  11265. PyCFunction cfunc;
  11266. cfunc = PyCFunction_GET_FUNCTION(func);
  11267. self = PyCFunction_GET_SELF(func);
  11268. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  11269. return NULL;
  11270. result = cfunc(self, arg);
  11271. Py_LeaveRecursiveCall();
  11272. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  11273. PyErr_SetString(
  11274. PyExc_SystemError,
  11275. "NULL result without error in PyObject_Call");
  11276. }
  11277. return result;
  11278. }
  11279. #endif
  11280. /* PyObjectCallOneArg */
  11281. #if CYTHON_COMPILING_IN_CPYTHON
  11282. static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  11283. PyObject *result;
  11284. PyObject *args = PyTuple_New(1);
  11285. if (unlikely(!args)) return NULL;
  11286. Py_INCREF(arg);
  11287. PyTuple_SET_ITEM(args, 0, arg);
  11288. result = __Pyx_PyObject_Call(func, args, NULL);
  11289. Py_DECREF(args);
  11290. return result;
  11291. }
  11292. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  11293. #if CYTHON_FAST_PYCALL
  11294. if (PyFunction_Check(func)) {
  11295. return __Pyx_PyFunction_FastCall(func, &arg, 1);
  11296. }
  11297. #endif
  11298. if (likely(PyCFunction_Check(func))) {
  11299. if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
  11300. return __Pyx_PyObject_CallMethO(func, arg);
  11301. #if CYTHON_FAST_PYCCALL
  11302. } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
  11303. return __Pyx_PyCFunction_FastCall(func, &arg, 1);
  11304. #endif
  11305. }
  11306. }
  11307. return __Pyx__PyObject_CallOneArg(func, arg);
  11308. }
  11309. #else
  11310. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  11311. PyObject *result;
  11312. PyObject *args = PyTuple_Pack(1, arg);
  11313. if (unlikely(!args)) return NULL;
  11314. result = __Pyx_PyObject_Call(func, args, NULL);
  11315. Py_DECREF(args);
  11316. return result;
  11317. }
  11318. #endif
  11319. /* PyErrFetchRestore */
  11320. #if CYTHON_FAST_THREAD_STATE
  11321. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  11322. PyObject *tmp_type, *tmp_value, *tmp_tb;
  11323. tmp_type = tstate->curexc_type;
  11324. tmp_value = tstate->curexc_value;
  11325. tmp_tb = tstate->curexc_traceback;
  11326. tstate->curexc_type = type;
  11327. tstate->curexc_value = value;
  11328. tstate->curexc_traceback = tb;
  11329. Py_XDECREF(tmp_type);
  11330. Py_XDECREF(tmp_value);
  11331. Py_XDECREF(tmp_tb);
  11332. }
  11333. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  11334. *type = tstate->curexc_type;
  11335. *value = tstate->curexc_value;
  11336. *tb = tstate->curexc_traceback;
  11337. tstate->curexc_type = 0;
  11338. tstate->curexc_value = 0;
  11339. tstate->curexc_traceback = 0;
  11340. }
  11341. #endif
  11342. /* RaiseException */
  11343. #if PY_MAJOR_VERSION < 3
  11344. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
  11345. CYTHON_UNUSED PyObject *cause) {
  11346. __Pyx_PyThreadState_declare
  11347. Py_XINCREF(type);
  11348. if (!value || value == Py_None)
  11349. value = NULL;
  11350. else
  11351. Py_INCREF(value);
  11352. if (!tb || tb == Py_None)
  11353. tb = NULL;
  11354. else {
  11355. Py_INCREF(tb);
  11356. if (!PyTraceBack_Check(tb)) {
  11357. PyErr_SetString(PyExc_TypeError,
  11358. "raise: arg 3 must be a traceback or None");
  11359. goto raise_error;
  11360. }
  11361. }
  11362. if (PyType_Check(type)) {
  11363. #if CYTHON_COMPILING_IN_PYPY
  11364. if (!value) {
  11365. Py_INCREF(Py_None);
  11366. value = Py_None;
  11367. }
  11368. #endif
  11369. PyErr_NormalizeException(&type, &value, &tb);
  11370. } else {
  11371. if (value) {
  11372. PyErr_SetString(PyExc_TypeError,
  11373. "instance exception may not have a separate value");
  11374. goto raise_error;
  11375. }
  11376. value = type;
  11377. type = (PyObject*) Py_TYPE(type);
  11378. Py_INCREF(type);
  11379. if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
  11380. PyErr_SetString(PyExc_TypeError,
  11381. "raise: exception class must be a subclass of BaseException");
  11382. goto raise_error;
  11383. }
  11384. }
  11385. __Pyx_PyThreadState_assign
  11386. __Pyx_ErrRestore(type, value, tb);
  11387. return;
  11388. raise_error:
  11389. Py_XDECREF(value);
  11390. Py_XDECREF(type);
  11391. Py_XDECREF(tb);
  11392. return;
  11393. }
  11394. #else
  11395. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
  11396. PyObject* owned_instance = NULL;
  11397. if (tb == Py_None) {
  11398. tb = 0;
  11399. } else if (tb && !PyTraceBack_Check(tb)) {
  11400. PyErr_SetString(PyExc_TypeError,
  11401. "raise: arg 3 must be a traceback or None");
  11402. goto bad;
  11403. }
  11404. if (value == Py_None)
  11405. value = 0;
  11406. if (PyExceptionInstance_Check(type)) {
  11407. if (value) {
  11408. PyErr_SetString(PyExc_TypeError,
  11409. "instance exception may not have a separate value");
  11410. goto bad;
  11411. }
  11412. value = type;
  11413. type = (PyObject*) Py_TYPE(value);
  11414. } else if (PyExceptionClass_Check(type)) {
  11415. PyObject *instance_class = NULL;
  11416. if (value && PyExceptionInstance_Check(value)) {
  11417. instance_class = (PyObject*) Py_TYPE(value);
  11418. if (instance_class != type) {
  11419. int is_subclass = PyObject_IsSubclass(instance_class, type);
  11420. if (!is_subclass) {
  11421. instance_class = NULL;
  11422. } else if (unlikely(is_subclass == -1)) {
  11423. goto bad;
  11424. } else {
  11425. type = instance_class;
  11426. }
  11427. }
  11428. }
  11429. if (!instance_class) {
  11430. PyObject *args;
  11431. if (!value)
  11432. args = PyTuple_New(0);
  11433. else if (PyTuple_Check(value)) {
  11434. Py_INCREF(value);
  11435. args = value;
  11436. } else
  11437. args = PyTuple_Pack(1, value);
  11438. if (!args)
  11439. goto bad;
  11440. owned_instance = PyObject_Call(type, args, NULL);
  11441. Py_DECREF(args);
  11442. if (!owned_instance)
  11443. goto bad;
  11444. value = owned_instance;
  11445. if (!PyExceptionInstance_Check(value)) {
  11446. PyErr_Format(PyExc_TypeError,
  11447. "calling %R should have returned an instance of "
  11448. "BaseException, not %R",
  11449. type, Py_TYPE(value));
  11450. goto bad;
  11451. }
  11452. }
  11453. } else {
  11454. PyErr_SetString(PyExc_TypeError,
  11455. "raise: exception class must be a subclass of BaseException");
  11456. goto bad;
  11457. }
  11458. if (cause) {
  11459. PyObject *fixed_cause;
  11460. if (cause == Py_None) {
  11461. fixed_cause = NULL;
  11462. } else if (PyExceptionClass_Check(cause)) {
  11463. fixed_cause = PyObject_CallObject(cause, NULL);
  11464. if (fixed_cause == NULL)
  11465. goto bad;
  11466. } else if (PyExceptionInstance_Check(cause)) {
  11467. fixed_cause = cause;
  11468. Py_INCREF(fixed_cause);
  11469. } else {
  11470. PyErr_SetString(PyExc_TypeError,
  11471. "exception causes must derive from "
  11472. "BaseException");
  11473. goto bad;
  11474. }
  11475. PyException_SetCause(value, fixed_cause);
  11476. }
  11477. PyErr_SetObject(type, value);
  11478. if (tb) {
  11479. #if CYTHON_COMPILING_IN_PYPY
  11480. PyObject *tmp_type, *tmp_value, *tmp_tb;
  11481. PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
  11482. Py_INCREF(tb);
  11483. PyErr_Restore(tmp_type, tmp_value, tb);
  11484. Py_XDECREF(tmp_tb);
  11485. #else
  11486. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  11487. PyObject* tmp_tb = tstate->curexc_traceback;
  11488. if (tb != tmp_tb) {
  11489. Py_INCREF(tb);
  11490. tstate->curexc_traceback = tb;
  11491. Py_XDECREF(tmp_tb);
  11492. }
  11493. #endif
  11494. }
  11495. bad:
  11496. Py_XDECREF(owned_instance);
  11497. return;
  11498. }
  11499. #endif
  11500. /* ExtTypeTest */
  11501. static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
  11502. if (unlikely(!type)) {
  11503. PyErr_SetString(PyExc_SystemError, "Missing type object");
  11504. return 0;
  11505. }
  11506. if (likely(__Pyx_TypeCheck(obj, type)))
  11507. return 1;
  11508. PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
  11509. Py_TYPE(obj)->tp_name, type->tp_name);
  11510. return 0;
  11511. }
  11512. /* ArgTypeTest */
  11513. static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
  11514. {
  11515. if (unlikely(!type)) {
  11516. PyErr_SetString(PyExc_SystemError, "Missing type object");
  11517. return 0;
  11518. }
  11519. else if (exact) {
  11520. #if PY_MAJOR_VERSION == 2
  11521. if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
  11522. #endif
  11523. }
  11524. else {
  11525. if (likely(__Pyx_TypeCheck(obj, type))) return 1;
  11526. }
  11527. PyErr_Format(PyExc_TypeError,
  11528. "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
  11529. name, type->tp_name, Py_TYPE(obj)->tp_name);
  11530. return 0;
  11531. }
  11532. /* PyIntBinop */
  11533. #if !CYTHON_COMPILING_IN_PYPY
  11534. static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
  11535. (void)inplace;
  11536. (void)zerodivision_check;
  11537. #if PY_MAJOR_VERSION < 3
  11538. if (likely(PyInt_CheckExact(op1))) {
  11539. const long b = intval;
  11540. long x;
  11541. long a = PyInt_AS_LONG(op1);
  11542. x = (long)((unsigned long)a + b);
  11543. if (likely((x^a) >= 0 || (x^b) >= 0))
  11544. return PyInt_FromLong(x);
  11545. return PyLong_Type.tp_as_number->nb_add(op1, op2);
  11546. }
  11547. #endif
  11548. #if CYTHON_USE_PYLONG_INTERNALS
  11549. if (likely(PyLong_CheckExact(op1))) {
  11550. const long b = intval;
  11551. long a, x;
  11552. #ifdef HAVE_LONG_LONG
  11553. const PY_LONG_LONG llb = intval;
  11554. PY_LONG_LONG lla, llx;
  11555. #endif
  11556. const digit* digits = ((PyLongObject*)op1)->ob_digit;
  11557. const Py_ssize_t size = Py_SIZE(op1);
  11558. if (likely(__Pyx_sst_abs(size) <= 1)) {
  11559. a = likely(size) ? digits[0] : 0;
  11560. if (size == -1) a = -a;
  11561. } else {
  11562. switch (size) {
  11563. case -2:
  11564. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  11565. a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  11566. break;
  11567. #ifdef HAVE_LONG_LONG
  11568. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
  11569. lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  11570. goto long_long;
  11571. #endif
  11572. }
  11573. CYTHON_FALLTHROUGH;
  11574. case 2:
  11575. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  11576. a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  11577. break;
  11578. #ifdef HAVE_LONG_LONG
  11579. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
  11580. lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  11581. goto long_long;
  11582. #endif
  11583. }
  11584. CYTHON_FALLTHROUGH;
  11585. case -3:
  11586. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  11587. a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  11588. break;
  11589. #ifdef HAVE_LONG_LONG
  11590. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
  11591. lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  11592. goto long_long;
  11593. #endif
  11594. }
  11595. CYTHON_FALLTHROUGH;
  11596. case 3:
  11597. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  11598. a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  11599. break;
  11600. #ifdef HAVE_LONG_LONG
  11601. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
  11602. lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  11603. goto long_long;
  11604. #endif
  11605. }
  11606. CYTHON_FALLTHROUGH;
  11607. case -4:
  11608. if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  11609. a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  11610. break;
  11611. #ifdef HAVE_LONG_LONG
  11612. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
  11613. lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  11614. goto long_long;
  11615. #endif
  11616. }
  11617. CYTHON_FALLTHROUGH;
  11618. case 4:
  11619. if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  11620. a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  11621. break;
  11622. #ifdef HAVE_LONG_LONG
  11623. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
  11624. lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  11625. goto long_long;
  11626. #endif
  11627. }
  11628. CYTHON_FALLTHROUGH;
  11629. default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
  11630. }
  11631. }
  11632. x = a + b;
  11633. return PyLong_FromLong(x);
  11634. #ifdef HAVE_LONG_LONG
  11635. long_long:
  11636. llx = lla + llb;
  11637. return PyLong_FromLongLong(llx);
  11638. #endif
  11639. }
  11640. #endif
  11641. if (PyFloat_CheckExact(op1)) {
  11642. const long b = intval;
  11643. double a = PyFloat_AS_DOUBLE(op1);
  11644. double result;
  11645. PyFPE_START_PROTECT("add", return NULL)
  11646. result = ((double)a) + (double)b;
  11647. PyFPE_END_PROTECT(result)
  11648. return PyFloat_FromDouble(result);
  11649. }
  11650. return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
  11651. }
  11652. #endif
  11653. /* DictGetItem */
  11654. #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
  11655. static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
  11656. PyObject *value;
  11657. value = PyDict_GetItemWithError(d, key);
  11658. if (unlikely(!value)) {
  11659. if (!PyErr_Occurred()) {
  11660. if (unlikely(PyTuple_Check(key))) {
  11661. PyObject* args = PyTuple_Pack(1, key);
  11662. if (likely(args)) {
  11663. PyErr_SetObject(PyExc_KeyError, args);
  11664. Py_DECREF(args);
  11665. }
  11666. } else {
  11667. PyErr_SetObject(PyExc_KeyError, key);
  11668. }
  11669. }
  11670. return NULL;
  11671. }
  11672. Py_INCREF(value);
  11673. return value;
  11674. }
  11675. #endif
  11676. /* GetItemInt */
  11677. static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
  11678. PyObject *r;
  11679. if (!j) return NULL;
  11680. r = PyObject_GetItem(o, j);
  11681. Py_DECREF(j);
  11682. return r;
  11683. }
  11684. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  11685. CYTHON_NCP_UNUSED int wraparound,
  11686. CYTHON_NCP_UNUSED int boundscheck) {
  11687. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  11688. Py_ssize_t wrapped_i = i;
  11689. if (wraparound & unlikely(i < 0)) {
  11690. wrapped_i += PyList_GET_SIZE(o);
  11691. }
  11692. if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
  11693. PyObject *r = PyList_GET_ITEM(o, wrapped_i);
  11694. Py_INCREF(r);
  11695. return r;
  11696. }
  11697. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  11698. #else
  11699. return PySequence_GetItem(o, i);
  11700. #endif
  11701. }
  11702. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  11703. CYTHON_NCP_UNUSED int wraparound,
  11704. CYTHON_NCP_UNUSED int boundscheck) {
  11705. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  11706. Py_ssize_t wrapped_i = i;
  11707. if (wraparound & unlikely(i < 0)) {
  11708. wrapped_i += PyTuple_GET_SIZE(o);
  11709. }
  11710. if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
  11711. PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
  11712. Py_INCREF(r);
  11713. return r;
  11714. }
  11715. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  11716. #else
  11717. return PySequence_GetItem(o, i);
  11718. #endif
  11719. }
  11720. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
  11721. CYTHON_NCP_UNUSED int wraparound,
  11722. CYTHON_NCP_UNUSED int boundscheck) {
  11723. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
  11724. if (is_list || PyList_CheckExact(o)) {
  11725. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
  11726. if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
  11727. PyObject *r = PyList_GET_ITEM(o, n);
  11728. Py_INCREF(r);
  11729. return r;
  11730. }
  11731. }
  11732. else if (PyTuple_CheckExact(o)) {
  11733. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
  11734. if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
  11735. PyObject *r = PyTuple_GET_ITEM(o, n);
  11736. Py_INCREF(r);
  11737. return r;
  11738. }
  11739. } else {
  11740. PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
  11741. if (likely(m && m->sq_item)) {
  11742. if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
  11743. Py_ssize_t l = m->sq_length(o);
  11744. if (likely(l >= 0)) {
  11745. i += l;
  11746. } else {
  11747. if (!PyErr_ExceptionMatches(PyExc_OverflowError))
  11748. return NULL;
  11749. PyErr_Clear();
  11750. }
  11751. }
  11752. return m->sq_item(o, i);
  11753. }
  11754. }
  11755. #else
  11756. if (is_list || PySequence_Check(o)) {
  11757. return PySequence_GetItem(o, i);
  11758. }
  11759. #endif
  11760. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  11761. }
  11762. /* IsLittleEndian */
  11763. static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
  11764. {
  11765. union {
  11766. uint32_t u32;
  11767. uint8_t u8[4];
  11768. } S;
  11769. S.u32 = 0x01020304;
  11770. return S.u8[0] == 4;
  11771. }
  11772. /* BufferFormatCheck */
  11773. static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
  11774. __Pyx_BufFmt_StackElem* stack,
  11775. __Pyx_TypeInfo* type) {
  11776. stack[0].field = &ctx->root;
  11777. stack[0].parent_offset = 0;
  11778. ctx->root.type = type;
  11779. ctx->root.name = "buffer dtype";
  11780. ctx->root.offset = 0;
  11781. ctx->head = stack;
  11782. ctx->head->field = &ctx->root;
  11783. ctx->fmt_offset = 0;
  11784. ctx->head->parent_offset = 0;
  11785. ctx->new_packmode = '@';
  11786. ctx->enc_packmode = '@';
  11787. ctx->new_count = 1;
  11788. ctx->enc_count = 0;
  11789. ctx->enc_type = 0;
  11790. ctx->is_complex = 0;
  11791. ctx->is_valid_array = 0;
  11792. ctx->struct_alignment = 0;
  11793. while (type->typegroup == 'S') {
  11794. ++ctx->head;
  11795. ctx->head->field = type->fields;
  11796. ctx->head->parent_offset = 0;
  11797. type = type->fields->type;
  11798. }
  11799. }
  11800. static int __Pyx_BufFmt_ParseNumber(const char** ts) {
  11801. int count;
  11802. const char* t = *ts;
  11803. if (*t < '0' || *t > '9') {
  11804. return -1;
  11805. } else {
  11806. count = *t++ - '0';
  11807. while (*t >= '0' && *t <= '9') {
  11808. count *= 10;
  11809. count += *t++ - '0';
  11810. }
  11811. }
  11812. *ts = t;
  11813. return count;
  11814. }
  11815. static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
  11816. int number = __Pyx_BufFmt_ParseNumber(ts);
  11817. if (number == -1)
  11818. PyErr_Format(PyExc_ValueError,\
  11819. "Does not understand character buffer dtype format string ('%c')", **ts);
  11820. return number;
  11821. }
  11822. static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
  11823. PyErr_Format(PyExc_ValueError,
  11824. "Unexpected format string character: '%c'", ch);
  11825. }
  11826. static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
  11827. switch (ch) {
  11828. case 'c': return "'char'";
  11829. case 'b': return "'signed char'";
  11830. case 'B': return "'unsigned char'";
  11831. case 'h': return "'short'";
  11832. case 'H': return "'unsigned short'";
  11833. case 'i': return "'int'";
  11834. case 'I': return "'unsigned int'";
  11835. case 'l': return "'long'";
  11836. case 'L': return "'unsigned long'";
  11837. case 'q': return "'long long'";
  11838. case 'Q': return "'unsigned long long'";
  11839. case 'f': return (is_complex ? "'complex float'" : "'float'");
  11840. case 'd': return (is_complex ? "'complex double'" : "'double'");
  11841. case 'g': return (is_complex ? "'complex long double'" : "'long double'");
  11842. case 'T': return "a struct";
  11843. case 'O': return "Python object";
  11844. case 'P': return "a pointer";
  11845. case 's': case 'p': return "a string";
  11846. case 0: return "end";
  11847. default: return "unparseable format string";
  11848. }
  11849. }
  11850. static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
  11851. switch (ch) {
  11852. case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
  11853. case 'h': case 'H': return 2;
  11854. case 'i': case 'I': case 'l': case 'L': return 4;
  11855. case 'q': case 'Q': return 8;
  11856. case 'f': return (is_complex ? 8 : 4);
  11857. case 'd': return (is_complex ? 16 : 8);
  11858. case 'g': {
  11859. PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
  11860. return 0;
  11861. }
  11862. case 'O': case 'P': return sizeof(void*);
  11863. default:
  11864. __Pyx_BufFmt_RaiseUnexpectedChar(ch);
  11865. return 0;
  11866. }
  11867. }
  11868. static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
  11869. switch (ch) {
  11870. case 'c': case 'b': case 'B': case 's': case 'p': return 1;
  11871. case 'h': case 'H': return sizeof(short);
  11872. case 'i': case 'I': return sizeof(int);
  11873. case 'l': case 'L': return sizeof(long);
  11874. #ifdef HAVE_LONG_LONG
  11875. case 'q': case 'Q': return sizeof(PY_LONG_LONG);
  11876. #endif
  11877. case 'f': return sizeof(float) * (is_complex ? 2 : 1);
  11878. case 'd': return sizeof(double) * (is_complex ? 2 : 1);
  11879. case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
  11880. case 'O': case 'P': return sizeof(void*);
  11881. default: {
  11882. __Pyx_BufFmt_RaiseUnexpectedChar(ch);
  11883. return 0;
  11884. }
  11885. }
  11886. }
  11887. typedef struct { char c; short x; } __Pyx_st_short;
  11888. typedef struct { char c; int x; } __Pyx_st_int;
  11889. typedef struct { char c; long x; } __Pyx_st_long;
  11890. typedef struct { char c; float x; } __Pyx_st_float;
  11891. typedef struct { char c; double x; } __Pyx_st_double;
  11892. typedef struct { char c; long double x; } __Pyx_st_longdouble;
  11893. typedef struct { char c; void *x; } __Pyx_st_void_p;
  11894. #ifdef HAVE_LONG_LONG
  11895. typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
  11896. #endif
  11897. static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
  11898. switch (ch) {
  11899. case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
  11900. case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
  11901. case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
  11902. case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
  11903. #ifdef HAVE_LONG_LONG
  11904. case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
  11905. #endif
  11906. case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
  11907. case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
  11908. case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
  11909. case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
  11910. default:
  11911. __Pyx_BufFmt_RaiseUnexpectedChar(ch);
  11912. return 0;
  11913. }
  11914. }
  11915. /* These are for computing the padding at the end of the struct to align
  11916. on the first member of the struct. This will probably the same as above,
  11917. but we don't have any guarantees.
  11918. */
  11919. typedef struct { short x; char c; } __Pyx_pad_short;
  11920. typedef struct { int x; char c; } __Pyx_pad_int;
  11921. typedef struct { long x; char c; } __Pyx_pad_long;
  11922. typedef struct { float x; char c; } __Pyx_pad_float;
  11923. typedef struct { double x; char c; } __Pyx_pad_double;
  11924. typedef struct { long double x; char c; } __Pyx_pad_longdouble;
  11925. typedef struct { void *x; char c; } __Pyx_pad_void_p;
  11926. #ifdef HAVE_LONG_LONG
  11927. typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
  11928. #endif
  11929. static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
  11930. switch (ch) {
  11931. case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
  11932. case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
  11933. case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
  11934. case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
  11935. #ifdef HAVE_LONG_LONG
  11936. case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
  11937. #endif
  11938. case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
  11939. case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
  11940. case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
  11941. case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
  11942. default:
  11943. __Pyx_BufFmt_RaiseUnexpectedChar(ch);
  11944. return 0;
  11945. }
  11946. }
  11947. static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
  11948. switch (ch) {
  11949. case 'c':
  11950. return 'H';
  11951. case 'b': case 'h': case 'i':
  11952. case 'l': case 'q': case 's': case 'p':
  11953. return 'I';
  11954. case 'B': case 'H': case 'I': case 'L': case 'Q':
  11955. return 'U';
  11956. case 'f': case 'd': case 'g':
  11957. return (is_complex ? 'C' : 'R');
  11958. case 'O':
  11959. return 'O';
  11960. case 'P':
  11961. return 'P';
  11962. default: {
  11963. __Pyx_BufFmt_RaiseUnexpectedChar(ch);
  11964. return 0;
  11965. }
  11966. }
  11967. }
  11968. static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
  11969. if (ctx->head == NULL || ctx->head->field == &ctx->root) {
  11970. const char* expected;
  11971. const char* quote;
  11972. if (ctx->head == NULL) {
  11973. expected = "end";
  11974. quote = "";
  11975. } else {
  11976. expected = ctx->head->field->type->name;
  11977. quote = "'";
  11978. }
  11979. PyErr_Format(PyExc_ValueError,
  11980. "Buffer dtype mismatch, expected %s%s%s but got %s",
  11981. quote, expected, quote,
  11982. __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
  11983. } else {
  11984. __Pyx_StructField* field = ctx->head->field;
  11985. __Pyx_StructField* parent = (ctx->head - 1)->field;
  11986. PyErr_Format(PyExc_ValueError,
  11987. "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
  11988. field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
  11989. parent->type->name, field->name);
  11990. }
  11991. }
  11992. static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
  11993. char group;
  11994. size_t size, offset, arraysize = 1;
  11995. if (ctx->enc_type == 0) return 0;
  11996. if (ctx->head->field->type->arraysize[0]) {
  11997. int i, ndim = 0;
  11998. if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
  11999. ctx->is_valid_array = ctx->head->field->type->ndim == 1;
  12000. ndim = 1;
  12001. if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
  12002. PyErr_Format(PyExc_ValueError,
  12003. "Expected a dimension of size %zu, got %zu",
  12004. ctx->head->field->type->arraysize[0], ctx->enc_count);
  12005. return -1;
  12006. }
  12007. }
  12008. if (!ctx->is_valid_array) {
  12009. PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
  12010. ctx->head->field->type->ndim, ndim);
  12011. return -1;
  12012. }
  12013. for (i = 0; i < ctx->head->field->type->ndim; i++) {
  12014. arraysize *= ctx->head->field->type->arraysize[i];
  12015. }
  12016. ctx->is_valid_array = 0;
  12017. ctx->enc_count = 1;
  12018. }
  12019. group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
  12020. do {
  12021. __Pyx_StructField* field = ctx->head->field;
  12022. __Pyx_TypeInfo* type = field->type;
  12023. if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
  12024. size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
  12025. } else {
  12026. size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
  12027. }
  12028. if (ctx->enc_packmode == '@') {
  12029. size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
  12030. size_t align_mod_offset;
  12031. if (align_at == 0) return -1;
  12032. align_mod_offset = ctx->fmt_offset % align_at;
  12033. if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
  12034. if (ctx->struct_alignment == 0)
  12035. ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
  12036. ctx->is_complex);
  12037. }
  12038. if (type->size != size || type->typegroup != group) {
  12039. if (type->typegroup == 'C' && type->fields != NULL) {
  12040. size_t parent_offset = ctx->head->parent_offset + field->offset;
  12041. ++ctx->head;
  12042. ctx->head->field = type->fields;
  12043. ctx->head->parent_offset = parent_offset;
  12044. continue;
  12045. }
  12046. if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
  12047. } else {
  12048. __Pyx_BufFmt_RaiseExpected(ctx);
  12049. return -1;
  12050. }
  12051. }
  12052. offset = ctx->head->parent_offset + field->offset;
  12053. if (ctx->fmt_offset != offset) {
  12054. PyErr_Format(PyExc_ValueError,
  12055. "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
  12056. (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
  12057. return -1;
  12058. }
  12059. ctx->fmt_offset += size;
  12060. if (arraysize)
  12061. ctx->fmt_offset += (arraysize - 1) * size;
  12062. --ctx->enc_count;
  12063. while (1) {
  12064. if (field == &ctx->root) {
  12065. ctx->head = NULL;
  12066. if (ctx->enc_count != 0) {
  12067. __Pyx_BufFmt_RaiseExpected(ctx);
  12068. return -1;
  12069. }
  12070. break;
  12071. }
  12072. ctx->head->field = ++field;
  12073. if (field->type == NULL) {
  12074. --ctx->head;
  12075. field = ctx->head->field;
  12076. continue;
  12077. } else if (field->type->typegroup == 'S') {
  12078. size_t parent_offset = ctx->head->parent_offset + field->offset;
  12079. if (field->type->fields->type == NULL) continue;
  12080. field = field->type->fields;
  12081. ++ctx->head;
  12082. ctx->head->field = field;
  12083. ctx->head->parent_offset = parent_offset;
  12084. break;
  12085. } else {
  12086. break;
  12087. }
  12088. }
  12089. } while (ctx->enc_count);
  12090. ctx->enc_type = 0;
  12091. ctx->is_complex = 0;
  12092. return 0;
  12093. }
  12094. static PyObject *
  12095. __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
  12096. {
  12097. const char *ts = *tsp;
  12098. int i = 0, number;
  12099. int ndim = ctx->head->field->type->ndim;
  12100. ;
  12101. ++ts;
  12102. if (ctx->new_count != 1) {
  12103. PyErr_SetString(PyExc_ValueError,
  12104. "Cannot handle repeated arrays in format string");
  12105. return NULL;
  12106. }
  12107. if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
  12108. while (*ts && *ts != ')') {
  12109. switch (*ts) {
  12110. case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue;
  12111. default: break;
  12112. }
  12113. number = __Pyx_BufFmt_ExpectNumber(&ts);
  12114. if (number == -1) return NULL;
  12115. if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
  12116. return PyErr_Format(PyExc_ValueError,
  12117. "Expected a dimension of size %zu, got %d",
  12118. ctx->head->field->type->arraysize[i], number);
  12119. if (*ts != ',' && *ts != ')')
  12120. return PyErr_Format(PyExc_ValueError,
  12121. "Expected a comma in format string, got '%c'", *ts);
  12122. if (*ts == ',') ts++;
  12123. i++;
  12124. }
  12125. if (i != ndim)
  12126. return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
  12127. ctx->head->field->type->ndim, i);
  12128. if (!*ts) {
  12129. PyErr_SetString(PyExc_ValueError,
  12130. "Unexpected end of format string, expected ')'");
  12131. return NULL;
  12132. }
  12133. ctx->is_valid_array = 1;
  12134. ctx->new_count = 1;
  12135. *tsp = ++ts;
  12136. return Py_None;
  12137. }
  12138. static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
  12139. int got_Z = 0;
  12140. while (1) {
  12141. switch(*ts) {
  12142. case 0:
  12143. if (ctx->enc_type != 0 && ctx->head == NULL) {
  12144. __Pyx_BufFmt_RaiseExpected(ctx);
  12145. return NULL;
  12146. }
  12147. if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
  12148. if (ctx->head != NULL) {
  12149. __Pyx_BufFmt_RaiseExpected(ctx);
  12150. return NULL;
  12151. }
  12152. return ts;
  12153. case ' ':
  12154. case '\r':
  12155. case '\n':
  12156. ++ts;
  12157. break;
  12158. case '<':
  12159. if (!__Pyx_Is_Little_Endian()) {
  12160. PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
  12161. return NULL;
  12162. }
  12163. ctx->new_packmode = '=';
  12164. ++ts;
  12165. break;
  12166. case '>':
  12167. case '!':
  12168. if (__Pyx_Is_Little_Endian()) {
  12169. PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
  12170. return NULL;
  12171. }
  12172. ctx->new_packmode = '=';
  12173. ++ts;
  12174. break;
  12175. case '=':
  12176. case '@':
  12177. case '^':
  12178. ctx->new_packmode = *ts++;
  12179. break;
  12180. case 'T':
  12181. {
  12182. const char* ts_after_sub;
  12183. size_t i, struct_count = ctx->new_count;
  12184. size_t struct_alignment = ctx->struct_alignment;
  12185. ctx->new_count = 1;
  12186. ++ts;
  12187. if (*ts != '{') {
  12188. PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
  12189. return NULL;
  12190. }
  12191. if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
  12192. ctx->enc_type = 0;
  12193. ctx->enc_count = 0;
  12194. ctx->struct_alignment = 0;
  12195. ++ts;
  12196. ts_after_sub = ts;
  12197. for (i = 0; i != struct_count; ++i) {
  12198. ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
  12199. if (!ts_after_sub) return NULL;
  12200. }
  12201. ts = ts_after_sub;
  12202. if (struct_alignment) ctx->struct_alignment = struct_alignment;
  12203. }
  12204. break;
  12205. case '}':
  12206. {
  12207. size_t alignment = ctx->struct_alignment;
  12208. ++ts;
  12209. if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
  12210. ctx->enc_type = 0;
  12211. if (alignment && ctx->fmt_offset % alignment) {
  12212. ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
  12213. }
  12214. }
  12215. return ts;
  12216. case 'x':
  12217. if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
  12218. ctx->fmt_offset += ctx->new_count;
  12219. ctx->new_count = 1;
  12220. ctx->enc_count = 0;
  12221. ctx->enc_type = 0;
  12222. ctx->enc_packmode = ctx->new_packmode;
  12223. ++ts;
  12224. break;
  12225. case 'Z':
  12226. got_Z = 1;
  12227. ++ts;
  12228. if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
  12229. __Pyx_BufFmt_RaiseUnexpectedChar('Z');
  12230. return NULL;
  12231. }
  12232. CYTHON_FALLTHROUGH;
  12233. case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
  12234. case 'l': case 'L': case 'q': case 'Q':
  12235. case 'f': case 'd': case 'g':
  12236. case 'O': case 'p':
  12237. if (ctx->enc_type == *ts && got_Z == ctx->is_complex &&
  12238. ctx->enc_packmode == ctx->new_packmode) {
  12239. ctx->enc_count += ctx->new_count;
  12240. ctx->new_count = 1;
  12241. got_Z = 0;
  12242. ++ts;
  12243. break;
  12244. }
  12245. CYTHON_FALLTHROUGH;
  12246. case 's':
  12247. if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
  12248. ctx->enc_count = ctx->new_count;
  12249. ctx->enc_packmode = ctx->new_packmode;
  12250. ctx->enc_type = *ts;
  12251. ctx->is_complex = got_Z;
  12252. ++ts;
  12253. ctx->new_count = 1;
  12254. got_Z = 0;
  12255. break;
  12256. case ':':
  12257. ++ts;
  12258. while(*ts != ':') ++ts;
  12259. ++ts;
  12260. break;
  12261. case '(':
  12262. if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
  12263. break;
  12264. default:
  12265. {
  12266. int number = __Pyx_BufFmt_ExpectNumber(&ts);
  12267. if (number == -1) return NULL;
  12268. ctx->new_count = (size_t)number;
  12269. }
  12270. }
  12271. }
  12272. }
  12273. /* BufferGetAndValidate */
  12274. static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
  12275. if (unlikely(info->buf == NULL)) return;
  12276. if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
  12277. __Pyx_ReleaseBuffer(info);
  12278. }
  12279. static void __Pyx_ZeroBuffer(Py_buffer* buf) {
  12280. buf->buf = NULL;
  12281. buf->obj = NULL;
  12282. buf->strides = __Pyx_zeros;
  12283. buf->shape = __Pyx_zeros;
  12284. buf->suboffsets = __Pyx_minusones;
  12285. }
  12286. static int __Pyx__GetBufferAndValidate(
  12287. Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags,
  12288. int nd, int cast, __Pyx_BufFmt_StackElem* stack)
  12289. {
  12290. buf->buf = NULL;
  12291. if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) {
  12292. __Pyx_ZeroBuffer(buf);
  12293. return -1;
  12294. }
  12295. if (unlikely(buf->ndim != nd)) {
  12296. PyErr_Format(PyExc_ValueError,
  12297. "Buffer has wrong number of dimensions (expected %d, got %d)",
  12298. nd, buf->ndim);
  12299. goto fail;
  12300. }
  12301. if (!cast) {
  12302. __Pyx_BufFmt_Context ctx;
  12303. __Pyx_BufFmt_Init(&ctx, stack, dtype);
  12304. if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
  12305. }
  12306. if (unlikely((size_t)buf->itemsize != dtype->size)) {
  12307. PyErr_Format(PyExc_ValueError,
  12308. "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)",
  12309. buf->itemsize, (buf->itemsize > 1) ? "s" : "",
  12310. dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
  12311. goto fail;
  12312. }
  12313. if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
  12314. return 0;
  12315. fail:;
  12316. __Pyx_SafeReleaseBuffer(buf);
  12317. return -1;
  12318. }
  12319. /* PyDictVersioning */
  12320. #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
  12321. static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
  12322. PyObject *dict = Py_TYPE(obj)->tp_dict;
  12323. return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
  12324. }
  12325. static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
  12326. PyObject **dictptr = NULL;
  12327. Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
  12328. if (offset) {
  12329. #if CYTHON_COMPILING_IN_CPYTHON
  12330. dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
  12331. #else
  12332. dictptr = _PyObject_GetDictPtr(obj);
  12333. #endif
  12334. }
  12335. return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
  12336. }
  12337. static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
  12338. PyObject *dict = Py_TYPE(obj)->tp_dict;
  12339. if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
  12340. return 0;
  12341. return obj_dict_version == __Pyx_get_object_dict_version(obj);
  12342. }
  12343. #endif
  12344. /* GetModuleGlobalName */
  12345. #if CYTHON_USE_DICT_VERSIONS
  12346. static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
  12347. #else
  12348. static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
  12349. #endif
  12350. {
  12351. PyObject *result;
  12352. #if !CYTHON_AVOID_BORROWED_REFS
  12353. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
  12354. result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
  12355. __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
  12356. if (likely(result)) {
  12357. return __Pyx_NewRef(result);
  12358. } else if (unlikely(PyErr_Occurred())) {
  12359. return NULL;
  12360. }
  12361. #else
  12362. result = PyDict_GetItem(__pyx_d, name);
  12363. __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
  12364. if (likely(result)) {
  12365. return __Pyx_NewRef(result);
  12366. }
  12367. #endif
  12368. #else
  12369. result = PyObject_GetItem(__pyx_d, name);
  12370. __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
  12371. if (likely(result)) {
  12372. return __Pyx_NewRef(result);
  12373. }
  12374. PyErr_Clear();
  12375. #endif
  12376. return __Pyx_GetBuiltinName(name);
  12377. }
  12378. /* PyObjectCall2Args */
  12379. static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
  12380. PyObject *args, *result = NULL;
  12381. #if CYTHON_FAST_PYCALL
  12382. if (PyFunction_Check(function)) {
  12383. PyObject *args[2] = {arg1, arg2};
  12384. return __Pyx_PyFunction_FastCall(function, args, 2);
  12385. }
  12386. #endif
  12387. #if CYTHON_FAST_PYCCALL
  12388. if (__Pyx_PyFastCFunction_Check(function)) {
  12389. PyObject *args[2] = {arg1, arg2};
  12390. return __Pyx_PyCFunction_FastCall(function, args, 2);
  12391. }
  12392. #endif
  12393. args = PyTuple_New(2);
  12394. if (unlikely(!args)) goto done;
  12395. Py_INCREF(arg1);
  12396. PyTuple_SET_ITEM(args, 0, arg1);
  12397. Py_INCREF(arg2);
  12398. PyTuple_SET_ITEM(args, 1, arg2);
  12399. Py_INCREF(function);
  12400. result = __Pyx_PyObject_Call(function, args, NULL);
  12401. Py_DECREF(args);
  12402. Py_DECREF(function);
  12403. done:
  12404. return result;
  12405. }
  12406. /* PyIntCompare */
  12407. static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
  12408. if (op1 == op2) {
  12409. Py_RETURN_TRUE;
  12410. }
  12411. #if PY_MAJOR_VERSION < 3
  12412. if (likely(PyInt_CheckExact(op1))) {
  12413. const long b = intval;
  12414. long a = PyInt_AS_LONG(op1);
  12415. if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
  12416. }
  12417. #endif
  12418. #if CYTHON_USE_PYLONG_INTERNALS
  12419. if (likely(PyLong_CheckExact(op1))) {
  12420. int unequal;
  12421. unsigned long uintval;
  12422. Py_ssize_t size = Py_SIZE(op1);
  12423. const digit* digits = ((PyLongObject*)op1)->ob_digit;
  12424. if (intval == 0) {
  12425. if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
  12426. } else if (intval < 0) {
  12427. if (size >= 0)
  12428. Py_RETURN_FALSE;
  12429. intval = -intval;
  12430. size = -size;
  12431. } else {
  12432. if (size <= 0)
  12433. Py_RETURN_FALSE;
  12434. }
  12435. uintval = (unsigned long) intval;
  12436. #if PyLong_SHIFT * 4 < SIZEOF_LONG*8
  12437. if (uintval >> (PyLong_SHIFT * 4)) {
  12438. unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
  12439. | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
  12440. } else
  12441. #endif
  12442. #if PyLong_SHIFT * 3 < SIZEOF_LONG*8
  12443. if (uintval >> (PyLong_SHIFT * 3)) {
  12444. unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
  12445. | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
  12446. } else
  12447. #endif
  12448. #if PyLong_SHIFT * 2 < SIZEOF_LONG*8
  12449. if (uintval >> (PyLong_SHIFT * 2)) {
  12450. unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
  12451. | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
  12452. } else
  12453. #endif
  12454. #if PyLong_SHIFT * 1 < SIZEOF_LONG*8
  12455. if (uintval >> (PyLong_SHIFT * 1)) {
  12456. unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
  12457. | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
  12458. } else
  12459. #endif
  12460. unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
  12461. if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
  12462. }
  12463. #endif
  12464. if (PyFloat_CheckExact(op1)) {
  12465. const long b = intval;
  12466. double a = PyFloat_AS_DOUBLE(op1);
  12467. if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
  12468. }
  12469. return (
  12470. PyObject_RichCompare(op1, op2, Py_EQ));
  12471. }
  12472. /* FetchCommonType */
  12473. static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
  12474. PyObject* fake_module;
  12475. PyTypeObject* cached_type = NULL;
  12476. fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
  12477. if (!fake_module) return NULL;
  12478. Py_INCREF(fake_module);
  12479. cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
  12480. if (cached_type) {
  12481. if (!PyType_Check((PyObject*)cached_type)) {
  12482. PyErr_Format(PyExc_TypeError,
  12483. "Shared Cython type %.200s is not a type object",
  12484. type->tp_name);
  12485. goto bad;
  12486. }
  12487. if (cached_type->tp_basicsize != type->tp_basicsize) {
  12488. PyErr_Format(PyExc_TypeError,
  12489. "Shared Cython type %.200s has the wrong size, try recompiling",
  12490. type->tp_name);
  12491. goto bad;
  12492. }
  12493. } else {
  12494. if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
  12495. PyErr_Clear();
  12496. if (PyType_Ready(type) < 0) goto bad;
  12497. if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
  12498. goto bad;
  12499. Py_INCREF(type);
  12500. cached_type = type;
  12501. }
  12502. done:
  12503. Py_DECREF(fake_module);
  12504. return cached_type;
  12505. bad:
  12506. Py_XDECREF(cached_type);
  12507. cached_type = NULL;
  12508. goto done;
  12509. }
  12510. /* CythonFunction */
  12511. #include <structmember.h>
  12512. static PyObject *
  12513. __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
  12514. {
  12515. if (unlikely(op->func_doc == NULL)) {
  12516. if (op->func.m_ml->ml_doc) {
  12517. #if PY_MAJOR_VERSION >= 3
  12518. op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
  12519. #else
  12520. op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
  12521. #endif
  12522. if (unlikely(op->func_doc == NULL))
  12523. return NULL;
  12524. } else {
  12525. Py_INCREF(Py_None);
  12526. return Py_None;
  12527. }
  12528. }
  12529. Py_INCREF(op->func_doc);
  12530. return op->func_doc;
  12531. }
  12532. static int
  12533. __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
  12534. {
  12535. PyObject *tmp = op->func_doc;
  12536. if (value == NULL) {
  12537. value = Py_None;
  12538. }
  12539. Py_INCREF(value);
  12540. op->func_doc = value;
  12541. Py_XDECREF(tmp);
  12542. return 0;
  12543. }
  12544. static PyObject *
  12545. __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
  12546. {
  12547. if (unlikely(op->func_name == NULL)) {
  12548. #if PY_MAJOR_VERSION >= 3
  12549. op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
  12550. #else
  12551. op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
  12552. #endif
  12553. if (unlikely(op->func_name == NULL))
  12554. return NULL;
  12555. }
  12556. Py_INCREF(op->func_name);
  12557. return op->func_name;
  12558. }
  12559. static int
  12560. __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
  12561. {
  12562. PyObject *tmp;
  12563. #if PY_MAJOR_VERSION >= 3
  12564. if (unlikely(value == NULL || !PyUnicode_Check(value)))
  12565. #else
  12566. if (unlikely(value == NULL || !PyString_Check(value)))
  12567. #endif
  12568. {
  12569. PyErr_SetString(PyExc_TypeError,
  12570. "__name__ must be set to a string object");
  12571. return -1;
  12572. }
  12573. tmp = op->func_name;
  12574. Py_INCREF(value);
  12575. op->func_name = value;
  12576. Py_XDECREF(tmp);
  12577. return 0;
  12578. }
  12579. static PyObject *
  12580. __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
  12581. {
  12582. Py_INCREF(op->func_qualname);
  12583. return op->func_qualname;
  12584. }
  12585. static int
  12586. __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
  12587. {
  12588. PyObject *tmp;
  12589. #if PY_MAJOR_VERSION >= 3
  12590. if (unlikely(value == NULL || !PyUnicode_Check(value)))
  12591. #else
  12592. if (unlikely(value == NULL || !PyString_Check(value)))
  12593. #endif
  12594. {
  12595. PyErr_SetString(PyExc_TypeError,
  12596. "__qualname__ must be set to a string object");
  12597. return -1;
  12598. }
  12599. tmp = op->func_qualname;
  12600. Py_INCREF(value);
  12601. op->func_qualname = value;
  12602. Py_XDECREF(tmp);
  12603. return 0;
  12604. }
  12605. static PyObject *
  12606. __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
  12607. {
  12608. PyObject *self;
  12609. self = m->func_closure;
  12610. if (self == NULL)
  12611. self = Py_None;
  12612. Py_INCREF(self);
  12613. return self;
  12614. }
  12615. static PyObject *
  12616. __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
  12617. {
  12618. if (unlikely(op->func_dict == NULL)) {
  12619. op->func_dict = PyDict_New();
  12620. if (unlikely(op->func_dict == NULL))
  12621. return NULL;
  12622. }
  12623. Py_INCREF(op->func_dict);
  12624. return op->func_dict;
  12625. }
  12626. static int
  12627. __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
  12628. {
  12629. PyObject *tmp;
  12630. if (unlikely(value == NULL)) {
  12631. PyErr_SetString(PyExc_TypeError,
  12632. "function's dictionary may not be deleted");
  12633. return -1;
  12634. }
  12635. if (unlikely(!PyDict_Check(value))) {
  12636. PyErr_SetString(PyExc_TypeError,
  12637. "setting function's dictionary to a non-dict");
  12638. return -1;
  12639. }
  12640. tmp = op->func_dict;
  12641. Py_INCREF(value);
  12642. op->func_dict = value;
  12643. Py_XDECREF(tmp);
  12644. return 0;
  12645. }
  12646. static PyObject *
  12647. __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
  12648. {
  12649. Py_INCREF(op->func_globals);
  12650. return op->func_globals;
  12651. }
  12652. static PyObject *
  12653. __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
  12654. {
  12655. Py_INCREF(Py_None);
  12656. return Py_None;
  12657. }
  12658. static PyObject *
  12659. __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
  12660. {
  12661. PyObject* result = (op->func_code) ? op->func_code : Py_None;
  12662. Py_INCREF(result);
  12663. return result;
  12664. }
  12665. static int
  12666. __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
  12667. int result = 0;
  12668. PyObject *res = op->defaults_getter((PyObject *) op);
  12669. if (unlikely(!res))
  12670. return -1;
  12671. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  12672. op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
  12673. Py_INCREF(op->defaults_tuple);
  12674. op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
  12675. Py_INCREF(op->defaults_kwdict);
  12676. #else
  12677. op->defaults_tuple = PySequence_ITEM(res, 0);
  12678. if (unlikely(!op->defaults_tuple)) result = -1;
  12679. else {
  12680. op->defaults_kwdict = PySequence_ITEM(res, 1);
  12681. if (unlikely(!op->defaults_kwdict)) result = -1;
  12682. }
  12683. #endif
  12684. Py_DECREF(res);
  12685. return result;
  12686. }
  12687. static int
  12688. __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
  12689. PyObject* tmp;
  12690. if (!value) {
  12691. value = Py_None;
  12692. } else if (value != Py_None && !PyTuple_Check(value)) {
  12693. PyErr_SetString(PyExc_TypeError,
  12694. "__defaults__ must be set to a tuple object");
  12695. return -1;
  12696. }
  12697. Py_INCREF(value);
  12698. tmp = op->defaults_tuple;
  12699. op->defaults_tuple = value;
  12700. Py_XDECREF(tmp);
  12701. return 0;
  12702. }
  12703. static PyObject *
  12704. __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
  12705. PyObject* result = op->defaults_tuple;
  12706. if (unlikely(!result)) {
  12707. if (op->defaults_getter) {
  12708. if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
  12709. result = op->defaults_tuple;
  12710. } else {
  12711. result = Py_None;
  12712. }
  12713. }
  12714. Py_INCREF(result);
  12715. return result;
  12716. }
  12717. static int
  12718. __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
  12719. PyObject* tmp;
  12720. if (!value) {
  12721. value = Py_None;
  12722. } else if (value != Py_None && !PyDict_Check(value)) {
  12723. PyErr_SetString(PyExc_TypeError,
  12724. "__kwdefaults__ must be set to a dict object");
  12725. return -1;
  12726. }
  12727. Py_INCREF(value);
  12728. tmp = op->defaults_kwdict;
  12729. op->defaults_kwdict = value;
  12730. Py_XDECREF(tmp);
  12731. return 0;
  12732. }
  12733. static PyObject *
  12734. __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
  12735. PyObject* result = op->defaults_kwdict;
  12736. if (unlikely(!result)) {
  12737. if (op->defaults_getter) {
  12738. if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
  12739. result = op->defaults_kwdict;
  12740. } else {
  12741. result = Py_None;
  12742. }
  12743. }
  12744. Py_INCREF(result);
  12745. return result;
  12746. }
  12747. static int
  12748. __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
  12749. PyObject* tmp;
  12750. if (!value || value == Py_None) {
  12751. value = NULL;
  12752. } else if (!PyDict_Check(value)) {
  12753. PyErr_SetString(PyExc_TypeError,
  12754. "__annotations__ must be set to a dict object");
  12755. return -1;
  12756. }
  12757. Py_XINCREF(value);
  12758. tmp = op->func_annotations;
  12759. op->func_annotations = value;
  12760. Py_XDECREF(tmp);
  12761. return 0;
  12762. }
  12763. static PyObject *
  12764. __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
  12765. PyObject* result = op->func_annotations;
  12766. if (unlikely(!result)) {
  12767. result = PyDict_New();
  12768. if (unlikely(!result)) return NULL;
  12769. op->func_annotations = result;
  12770. }
  12771. Py_INCREF(result);
  12772. return result;
  12773. }
  12774. static PyGetSetDef __pyx_CyFunction_getsets[] = {
  12775. {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  12776. {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  12777. {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  12778. {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  12779. {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
  12780. {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
  12781. {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
  12782. {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
  12783. {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  12784. {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  12785. {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  12786. {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  12787. {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  12788. {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  12789. {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  12790. {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  12791. {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
  12792. {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
  12793. {0, 0, 0, 0, 0}
  12794. };
  12795. static PyMemberDef __pyx_CyFunction_members[] = {
  12796. {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
  12797. {0, 0, 0, 0, 0}
  12798. };
  12799. static PyObject *
  12800. __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
  12801. {
  12802. #if PY_MAJOR_VERSION >= 3
  12803. return PyUnicode_FromString(m->func.m_ml->ml_name);
  12804. #else
  12805. return PyString_FromString(m->func.m_ml->ml_name);
  12806. #endif
  12807. }
  12808. static PyMethodDef __pyx_CyFunction_methods[] = {
  12809. {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
  12810. {0, 0, 0, 0}
  12811. };
  12812. #if PY_VERSION_HEX < 0x030500A0
  12813. #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
  12814. #else
  12815. #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
  12816. #endif
  12817. static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
  12818. PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
  12819. __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
  12820. if (op == NULL)
  12821. return NULL;
  12822. op->flags = flags;
  12823. __Pyx_CyFunction_weakreflist(op) = NULL;
  12824. op->func.m_ml = ml;
  12825. op->func.m_self = (PyObject *) op;
  12826. Py_XINCREF(closure);
  12827. op->func_closure = closure;
  12828. Py_XINCREF(module);
  12829. op->func.m_module = module;
  12830. op->func_dict = NULL;
  12831. op->func_name = NULL;
  12832. Py_INCREF(qualname);
  12833. op->func_qualname = qualname;
  12834. op->func_doc = NULL;
  12835. op->func_classobj = NULL;
  12836. op->func_globals = globals;
  12837. Py_INCREF(op->func_globals);
  12838. Py_XINCREF(code);
  12839. op->func_code = code;
  12840. op->defaults_pyobjects = 0;
  12841. op->defaults = NULL;
  12842. op->defaults_tuple = NULL;
  12843. op->defaults_kwdict = NULL;
  12844. op->defaults_getter = NULL;
  12845. op->func_annotations = NULL;
  12846. PyObject_GC_Track(op);
  12847. return (PyObject *) op;
  12848. }
  12849. static int
  12850. __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
  12851. {
  12852. Py_CLEAR(m->func_closure);
  12853. Py_CLEAR(m->func.m_module);
  12854. Py_CLEAR(m->func_dict);
  12855. Py_CLEAR(m->func_name);
  12856. Py_CLEAR(m->func_qualname);
  12857. Py_CLEAR(m->func_doc);
  12858. Py_CLEAR(m->func_globals);
  12859. Py_CLEAR(m->func_code);
  12860. Py_CLEAR(m->func_classobj);
  12861. Py_CLEAR(m->defaults_tuple);
  12862. Py_CLEAR(m->defaults_kwdict);
  12863. Py_CLEAR(m->func_annotations);
  12864. if (m->defaults) {
  12865. PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
  12866. int i;
  12867. for (i = 0; i < m->defaults_pyobjects; i++)
  12868. Py_XDECREF(pydefaults[i]);
  12869. PyObject_Free(m->defaults);
  12870. m->defaults = NULL;
  12871. }
  12872. return 0;
  12873. }
  12874. static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
  12875. {
  12876. if (__Pyx_CyFunction_weakreflist(m) != NULL)
  12877. PyObject_ClearWeakRefs((PyObject *) m);
  12878. __Pyx_CyFunction_clear(m);
  12879. PyObject_GC_Del(m);
  12880. }
  12881. static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
  12882. {
  12883. PyObject_GC_UnTrack(m);
  12884. __Pyx__CyFunction_dealloc(m);
  12885. }
  12886. static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
  12887. {
  12888. Py_VISIT(m->func_closure);
  12889. Py_VISIT(m->func.m_module);
  12890. Py_VISIT(m->func_dict);
  12891. Py_VISIT(m->func_name);
  12892. Py_VISIT(m->func_qualname);
  12893. Py_VISIT(m->func_doc);
  12894. Py_VISIT(m->func_globals);
  12895. Py_VISIT(m->func_code);
  12896. Py_VISIT(m->func_classobj);
  12897. Py_VISIT(m->defaults_tuple);
  12898. Py_VISIT(m->defaults_kwdict);
  12899. if (m->defaults) {
  12900. PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
  12901. int i;
  12902. for (i = 0; i < m->defaults_pyobjects; i++)
  12903. Py_VISIT(pydefaults[i]);
  12904. }
  12905. return 0;
  12906. }
  12907. static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
  12908. {
  12909. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  12910. if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
  12911. Py_INCREF(func);
  12912. return func;
  12913. }
  12914. if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
  12915. if (type == NULL)
  12916. type = (PyObject *)(Py_TYPE(obj));
  12917. return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
  12918. }
  12919. if (obj == Py_None)
  12920. obj = NULL;
  12921. return __Pyx_PyMethod_New(func, obj, type);
  12922. }
  12923. static PyObject*
  12924. __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
  12925. {
  12926. #if PY_MAJOR_VERSION >= 3
  12927. return PyUnicode_FromFormat("<cyfunction %U at %p>",
  12928. op->func_qualname, (void *)op);
  12929. #else
  12930. return PyString_FromFormat("<cyfunction %s at %p>",
  12931. PyString_AsString(op->func_qualname), (void *)op);
  12932. #endif
  12933. }
  12934. static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
  12935. PyCFunctionObject* f = (PyCFunctionObject*)func;
  12936. PyCFunction meth = f->m_ml->ml_meth;
  12937. Py_ssize_t size;
  12938. switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
  12939. case METH_VARARGS:
  12940. if (likely(kw == NULL || PyDict_Size(kw) == 0))
  12941. return (*meth)(self, arg);
  12942. break;
  12943. case METH_VARARGS | METH_KEYWORDS:
  12944. return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw);
  12945. case METH_NOARGS:
  12946. if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
  12947. size = PyTuple_GET_SIZE(arg);
  12948. if (likely(size == 0))
  12949. return (*meth)(self, NULL);
  12950. PyErr_Format(PyExc_TypeError,
  12951. "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
  12952. f->m_ml->ml_name, size);
  12953. return NULL;
  12954. }
  12955. break;
  12956. case METH_O:
  12957. if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
  12958. size = PyTuple_GET_SIZE(arg);
  12959. if (likely(size == 1)) {
  12960. PyObject *result, *arg0;
  12961. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  12962. arg0 = PyTuple_GET_ITEM(arg, 0);
  12963. #else
  12964. arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
  12965. #endif
  12966. result = (*meth)(self, arg0);
  12967. #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
  12968. Py_DECREF(arg0);
  12969. #endif
  12970. return result;
  12971. }
  12972. PyErr_Format(PyExc_TypeError,
  12973. "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
  12974. f->m_ml->ml_name, size);
  12975. return NULL;
  12976. }
  12977. break;
  12978. default:
  12979. PyErr_SetString(PyExc_SystemError, "Bad call flags in "
  12980. "__Pyx_CyFunction_Call. METH_OLDARGS is no "
  12981. "longer supported!");
  12982. return NULL;
  12983. }
  12984. PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
  12985. f->m_ml->ml_name);
  12986. return NULL;
  12987. }
  12988. static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  12989. return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
  12990. }
  12991. static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
  12992. PyObject *result;
  12993. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
  12994. if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
  12995. Py_ssize_t argc;
  12996. PyObject *new_args;
  12997. PyObject *self;
  12998. argc = PyTuple_GET_SIZE(args);
  12999. new_args = PyTuple_GetSlice(args, 1, argc);
  13000. if (unlikely(!new_args))
  13001. return NULL;
  13002. self = PyTuple_GetItem(args, 0);
  13003. if (unlikely(!self)) {
  13004. Py_DECREF(new_args);
  13005. return NULL;
  13006. }
  13007. result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
  13008. Py_DECREF(new_args);
  13009. } else {
  13010. result = __Pyx_CyFunction_Call(func, args, kw);
  13011. }
  13012. return result;
  13013. }
  13014. static PyTypeObject __pyx_CyFunctionType_type = {
  13015. PyVarObject_HEAD_INIT(0, 0)
  13016. "cython_function_or_method",
  13017. sizeof(__pyx_CyFunctionObject),
  13018. 0,
  13019. (destructor) __Pyx_CyFunction_dealloc,
  13020. 0,
  13021. 0,
  13022. 0,
  13023. #if PY_MAJOR_VERSION < 3
  13024. 0,
  13025. #else
  13026. 0,
  13027. #endif
  13028. (reprfunc) __Pyx_CyFunction_repr,
  13029. 0,
  13030. 0,
  13031. 0,
  13032. 0,
  13033. __Pyx_CyFunction_CallAsMethod,
  13034. 0,
  13035. 0,
  13036. 0,
  13037. 0,
  13038. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
  13039. 0,
  13040. (traverseproc) __Pyx_CyFunction_traverse,
  13041. (inquiry) __Pyx_CyFunction_clear,
  13042. 0,
  13043. #if PY_VERSION_HEX < 0x030500A0
  13044. offsetof(__pyx_CyFunctionObject, func_weakreflist),
  13045. #else
  13046. offsetof(PyCFunctionObject, m_weakreflist),
  13047. #endif
  13048. 0,
  13049. 0,
  13050. __pyx_CyFunction_methods,
  13051. __pyx_CyFunction_members,
  13052. __pyx_CyFunction_getsets,
  13053. 0,
  13054. 0,
  13055. __Pyx_CyFunction_descr_get,
  13056. 0,
  13057. offsetof(__pyx_CyFunctionObject, func_dict),
  13058. 0,
  13059. 0,
  13060. 0,
  13061. 0,
  13062. 0,
  13063. 0,
  13064. 0,
  13065. 0,
  13066. 0,
  13067. 0,
  13068. 0,
  13069. 0,
  13070. #if PY_VERSION_HEX >= 0x030400a1
  13071. 0,
  13072. #endif
  13073. };
  13074. static int __pyx_CyFunction_init(void) {
  13075. __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
  13076. if (unlikely(__pyx_CyFunctionType == NULL)) {
  13077. return -1;
  13078. }
  13079. return 0;
  13080. }
  13081. static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
  13082. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  13083. m->defaults = PyObject_Malloc(size);
  13084. if (unlikely(!m->defaults))
  13085. return PyErr_NoMemory();
  13086. memset(m->defaults, 0, size);
  13087. m->defaults_pyobjects = pyobjects;
  13088. return m->defaults;
  13089. }
  13090. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
  13091. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  13092. m->defaults_tuple = tuple;
  13093. Py_INCREF(tuple);
  13094. }
  13095. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
  13096. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  13097. m->defaults_kwdict = dict;
  13098. Py_INCREF(dict);
  13099. }
  13100. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
  13101. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  13102. m->func_annotations = dict;
  13103. Py_INCREF(dict);
  13104. }
  13105. /* BufferFallbackError */
  13106. static void __Pyx_RaiseBufferFallbackError(void) {
  13107. PyErr_SetString(PyExc_ValueError,
  13108. "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
  13109. }
  13110. /* None */
  13111. static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
  13112. Py_ssize_t q = a / b;
  13113. Py_ssize_t r = a - q*b;
  13114. q -= ((r != 0) & ((r ^ b) < 0));
  13115. return q;
  13116. }
  13117. /* BufferIndexError */
  13118. static void __Pyx_RaiseBufferIndexError(int axis) {
  13119. PyErr_Format(PyExc_IndexError,
  13120. "Out of bounds on buffer access (axis %d)", axis);
  13121. }
  13122. /* RaiseTooManyValuesToUnpack */
  13123. static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
  13124. PyErr_Format(PyExc_ValueError,
  13125. "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
  13126. }
  13127. /* RaiseNeedMoreValuesToUnpack */
  13128. static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
  13129. PyErr_Format(PyExc_ValueError,
  13130. "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
  13131. index, (index == 1) ? "" : "s");
  13132. }
  13133. /* RaiseNoneIterError */
  13134. static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
  13135. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
  13136. }
  13137. /* GetTopmostException */
  13138. #if CYTHON_USE_EXC_INFO_STACK
  13139. static _PyErr_StackItem *
  13140. __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
  13141. {
  13142. _PyErr_StackItem *exc_info = tstate->exc_info;
  13143. while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
  13144. exc_info->previous_item != NULL)
  13145. {
  13146. exc_info = exc_info->previous_item;
  13147. }
  13148. return exc_info;
  13149. }
  13150. #endif
  13151. /* SaveResetException */
  13152. #if CYTHON_FAST_THREAD_STATE
  13153. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  13154. #if CYTHON_USE_EXC_INFO_STACK
  13155. _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
  13156. *type = exc_info->exc_type;
  13157. *value = exc_info->exc_value;
  13158. *tb = exc_info->exc_traceback;
  13159. #else
  13160. *type = tstate->exc_type;
  13161. *value = tstate->exc_value;
  13162. *tb = tstate->exc_traceback;
  13163. #endif
  13164. Py_XINCREF(*type);
  13165. Py_XINCREF(*value);
  13166. Py_XINCREF(*tb);
  13167. }
  13168. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  13169. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13170. #if CYTHON_USE_EXC_INFO_STACK
  13171. _PyErr_StackItem *exc_info = tstate->exc_info;
  13172. tmp_type = exc_info->exc_type;
  13173. tmp_value = exc_info->exc_value;
  13174. tmp_tb = exc_info->exc_traceback;
  13175. exc_info->exc_type = type;
  13176. exc_info->exc_value = value;
  13177. exc_info->exc_traceback = tb;
  13178. #else
  13179. tmp_type = tstate->exc_type;
  13180. tmp_value = tstate->exc_value;
  13181. tmp_tb = tstate->exc_traceback;
  13182. tstate->exc_type = type;
  13183. tstate->exc_value = value;
  13184. tstate->exc_traceback = tb;
  13185. #endif
  13186. Py_XDECREF(tmp_type);
  13187. Py_XDECREF(tmp_value);
  13188. Py_XDECREF(tmp_tb);
  13189. }
  13190. #endif
  13191. /* PyErrExceptionMatches */
  13192. #if CYTHON_FAST_THREAD_STATE
  13193. static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  13194. Py_ssize_t i, n;
  13195. n = PyTuple_GET_SIZE(tuple);
  13196. #if PY_MAJOR_VERSION >= 3
  13197. for (i=0; i<n; i++) {
  13198. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  13199. }
  13200. #endif
  13201. for (i=0; i<n; i++) {
  13202. if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
  13203. }
  13204. return 0;
  13205. }
  13206. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
  13207. PyObject *exc_type = tstate->curexc_type;
  13208. if (exc_type == err) return 1;
  13209. if (unlikely(!exc_type)) return 0;
  13210. if (unlikely(PyTuple_Check(err)))
  13211. return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
  13212. return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
  13213. }
  13214. #endif
  13215. /* GetException */
  13216. #if CYTHON_FAST_THREAD_STATE
  13217. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
  13218. #else
  13219. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
  13220. #endif
  13221. {
  13222. PyObject *local_type, *local_value, *local_tb;
  13223. #if CYTHON_FAST_THREAD_STATE
  13224. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13225. local_type = tstate->curexc_type;
  13226. local_value = tstate->curexc_value;
  13227. local_tb = tstate->curexc_traceback;
  13228. tstate->curexc_type = 0;
  13229. tstate->curexc_value = 0;
  13230. tstate->curexc_traceback = 0;
  13231. #else
  13232. PyErr_Fetch(&local_type, &local_value, &local_tb);
  13233. #endif
  13234. PyErr_NormalizeException(&local_type, &local_value, &local_tb);
  13235. #if CYTHON_FAST_THREAD_STATE
  13236. if (unlikely(tstate->curexc_type))
  13237. #else
  13238. if (unlikely(PyErr_Occurred()))
  13239. #endif
  13240. goto bad;
  13241. #if PY_MAJOR_VERSION >= 3
  13242. if (local_tb) {
  13243. if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
  13244. goto bad;
  13245. }
  13246. #endif
  13247. Py_XINCREF(local_tb);
  13248. Py_XINCREF(local_type);
  13249. Py_XINCREF(local_value);
  13250. *type = local_type;
  13251. *value = local_value;
  13252. *tb = local_tb;
  13253. #if CYTHON_FAST_THREAD_STATE
  13254. #if CYTHON_USE_EXC_INFO_STACK
  13255. {
  13256. _PyErr_StackItem *exc_info = tstate->exc_info;
  13257. tmp_type = exc_info->exc_type;
  13258. tmp_value = exc_info->exc_value;
  13259. tmp_tb = exc_info->exc_traceback;
  13260. exc_info->exc_type = local_type;
  13261. exc_info->exc_value = local_value;
  13262. exc_info->exc_traceback = local_tb;
  13263. }
  13264. #else
  13265. tmp_type = tstate->exc_type;
  13266. tmp_value = tstate->exc_value;
  13267. tmp_tb = tstate->exc_traceback;
  13268. tstate->exc_type = local_type;
  13269. tstate->exc_value = local_value;
  13270. tstate->exc_traceback = local_tb;
  13271. #endif
  13272. Py_XDECREF(tmp_type);
  13273. Py_XDECREF(tmp_value);
  13274. Py_XDECREF(tmp_tb);
  13275. #else
  13276. PyErr_SetExcInfo(local_type, local_value, local_tb);
  13277. #endif
  13278. return 0;
  13279. bad:
  13280. *type = 0;
  13281. *value = 0;
  13282. *tb = 0;
  13283. Py_XDECREF(local_type);
  13284. Py_XDECREF(local_value);
  13285. Py_XDECREF(local_tb);
  13286. return -1;
  13287. }
  13288. /* PyObject_GenericGetAttrNoDict */
  13289. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  13290. static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
  13291. PyErr_Format(PyExc_AttributeError,
  13292. #if PY_MAJOR_VERSION >= 3
  13293. "'%.50s' object has no attribute '%U'",
  13294. tp->tp_name, attr_name);
  13295. #else
  13296. "'%.50s' object has no attribute '%.400s'",
  13297. tp->tp_name, PyString_AS_STRING(attr_name));
  13298. #endif
  13299. return NULL;
  13300. }
  13301. static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
  13302. PyObject *descr;
  13303. PyTypeObject *tp = Py_TYPE(obj);
  13304. if (unlikely(!PyString_Check(attr_name))) {
  13305. return PyObject_GenericGetAttr(obj, attr_name);
  13306. }
  13307. assert(!tp->tp_dictoffset);
  13308. descr = _PyType_Lookup(tp, attr_name);
  13309. if (unlikely(!descr)) {
  13310. return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
  13311. }
  13312. Py_INCREF(descr);
  13313. #if PY_MAJOR_VERSION < 3
  13314. if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
  13315. #endif
  13316. {
  13317. descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
  13318. if (unlikely(f)) {
  13319. PyObject *res = f(descr, obj, (PyObject *)tp);
  13320. Py_DECREF(descr);
  13321. return res;
  13322. }
  13323. }
  13324. return descr;
  13325. }
  13326. #endif
  13327. /* PyObject_GenericGetAttr */
  13328. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  13329. static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
  13330. if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
  13331. return PyObject_GenericGetAttr(obj, attr_name);
  13332. }
  13333. return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
  13334. }
  13335. #endif
  13336. /* SetupReduce */
  13337. static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  13338. int ret;
  13339. PyObject *name_attr;
  13340. name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
  13341. if (likely(name_attr)) {
  13342. ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  13343. } else {
  13344. ret = -1;
  13345. }
  13346. if (unlikely(ret < 0)) {
  13347. PyErr_Clear();
  13348. ret = 0;
  13349. }
  13350. Py_XDECREF(name_attr);
  13351. return ret;
  13352. }
  13353. static int __Pyx_setup_reduce(PyObject* type_obj) {
  13354. int ret = 0;
  13355. PyObject *object_reduce = NULL;
  13356. PyObject *object_reduce_ex = NULL;
  13357. PyObject *reduce = NULL;
  13358. PyObject *reduce_ex = NULL;
  13359. PyObject *reduce_cython = NULL;
  13360. PyObject *setstate = NULL;
  13361. PyObject *setstate_cython = NULL;
  13362. #if CYTHON_USE_PYTYPE_LOOKUP
  13363. if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD;
  13364. #else
  13365. if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD;
  13366. #endif
  13367. #if CYTHON_USE_PYTYPE_LOOKUP
  13368. object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
  13369. #else
  13370. object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
  13371. #endif
  13372. reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD;
  13373. if (reduce_ex == object_reduce_ex) {
  13374. #if CYTHON_USE_PYTYPE_LOOKUP
  13375. object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
  13376. #else
  13377. object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
  13378. #endif
  13379. reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD;
  13380. if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
  13381. reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD;
  13382. ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD;
  13383. ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD;
  13384. setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
  13385. if (!setstate) PyErr_Clear();
  13386. if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
  13387. setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD;
  13388. ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD;
  13389. ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD;
  13390. }
  13391. PyType_Modified((PyTypeObject*)type_obj);
  13392. }
  13393. }
  13394. goto GOOD;
  13395. BAD:
  13396. if (!PyErr_Occurred())
  13397. PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
  13398. ret = -1;
  13399. GOOD:
  13400. #if !CYTHON_USE_PYTYPE_LOOKUP
  13401. Py_XDECREF(object_reduce);
  13402. Py_XDECREF(object_reduce_ex);
  13403. #endif
  13404. Py_XDECREF(reduce);
  13405. Py_XDECREF(reduce_ex);
  13406. Py_XDECREF(reduce_cython);
  13407. Py_XDECREF(setstate);
  13408. Py_XDECREF(setstate_cython);
  13409. return ret;
  13410. }
  13411. /* TypeImport */
  13412. #ifndef __PYX_HAVE_RT_ImportType
  13413. #define __PYX_HAVE_RT_ImportType
  13414. static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
  13415. size_t size, enum __Pyx_ImportType_CheckSize check_size)
  13416. {
  13417. PyObject *result = 0;
  13418. char warning[200];
  13419. Py_ssize_t basicsize;
  13420. #ifdef Py_LIMITED_API
  13421. PyObject *py_basicsize;
  13422. #endif
  13423. result = PyObject_GetAttrString(module, class_name);
  13424. if (!result)
  13425. goto bad;
  13426. if (!PyType_Check(result)) {
  13427. PyErr_Format(PyExc_TypeError,
  13428. "%.200s.%.200s is not a type object",
  13429. module_name, class_name);
  13430. goto bad;
  13431. }
  13432. #ifndef Py_LIMITED_API
  13433. basicsize = ((PyTypeObject *)result)->tp_basicsize;
  13434. #else
  13435. py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
  13436. if (!py_basicsize)
  13437. goto bad;
  13438. basicsize = PyLong_AsSsize_t(py_basicsize);
  13439. Py_DECREF(py_basicsize);
  13440. py_basicsize = 0;
  13441. if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
  13442. goto bad;
  13443. #endif
  13444. if ((size_t)basicsize < size) {
  13445. PyErr_Format(PyExc_ValueError,
  13446. "%.200s.%.200s size changed, may indicate binary incompatibility. "
  13447. "Expected %zd from C header, got %zd from PyObject",
  13448. module_name, class_name, size, basicsize);
  13449. goto bad;
  13450. }
  13451. if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
  13452. PyErr_Format(PyExc_ValueError,
  13453. "%.200s.%.200s size changed, may indicate binary incompatibility. "
  13454. "Expected %zd from C header, got %zd from PyObject",
  13455. module_name, class_name, size, basicsize);
  13456. goto bad;
  13457. }
  13458. else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
  13459. PyOS_snprintf(warning, sizeof(warning),
  13460. "%s.%s size changed, may indicate binary incompatibility. "
  13461. "Expected %zd from C header, got %zd from PyObject",
  13462. module_name, class_name, size, basicsize);
  13463. if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
  13464. }
  13465. return (PyTypeObject *)result;
  13466. bad:
  13467. Py_XDECREF(result);
  13468. return NULL;
  13469. }
  13470. #endif
  13471. /* Import */
  13472. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
  13473. PyObject *empty_list = 0;
  13474. PyObject *module = 0;
  13475. PyObject *global_dict = 0;
  13476. PyObject *empty_dict = 0;
  13477. PyObject *list;
  13478. #if PY_MAJOR_VERSION < 3
  13479. PyObject *py_import;
  13480. py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
  13481. if (!py_import)
  13482. goto bad;
  13483. #endif
  13484. if (from_list)
  13485. list = from_list;
  13486. else {
  13487. empty_list = PyList_New(0);
  13488. if (!empty_list)
  13489. goto bad;
  13490. list = empty_list;
  13491. }
  13492. global_dict = PyModule_GetDict(__pyx_m);
  13493. if (!global_dict)
  13494. goto bad;
  13495. empty_dict = PyDict_New();
  13496. if (!empty_dict)
  13497. goto bad;
  13498. {
  13499. #if PY_MAJOR_VERSION >= 3
  13500. if (level == -1) {
  13501. if (strchr(__Pyx_MODULE_NAME, '.')) {
  13502. module = PyImport_ImportModuleLevelObject(
  13503. name, global_dict, empty_dict, list, 1);
  13504. if (!module) {
  13505. if (!PyErr_ExceptionMatches(PyExc_ImportError))
  13506. goto bad;
  13507. PyErr_Clear();
  13508. }
  13509. }
  13510. level = 0;
  13511. }
  13512. #endif
  13513. if (!module) {
  13514. #if PY_MAJOR_VERSION < 3
  13515. PyObject *py_level = PyInt_FromLong(level);
  13516. if (!py_level)
  13517. goto bad;
  13518. module = PyObject_CallFunctionObjArgs(py_import,
  13519. name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
  13520. Py_DECREF(py_level);
  13521. #else
  13522. module = PyImport_ImportModuleLevelObject(
  13523. name, global_dict, empty_dict, list, level);
  13524. #endif
  13525. }
  13526. }
  13527. bad:
  13528. #if PY_MAJOR_VERSION < 3
  13529. Py_XDECREF(py_import);
  13530. #endif
  13531. Py_XDECREF(empty_list);
  13532. Py_XDECREF(empty_dict);
  13533. return module;
  13534. }
  13535. /* CLineInTraceback */
  13536. #ifndef CYTHON_CLINE_IN_TRACEBACK
  13537. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
  13538. PyObject *use_cline;
  13539. PyObject *ptype, *pvalue, *ptraceback;
  13540. #if CYTHON_COMPILING_IN_CPYTHON
  13541. PyObject **cython_runtime_dict;
  13542. #endif
  13543. if (unlikely(!__pyx_cython_runtime)) {
  13544. return c_line;
  13545. }
  13546. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  13547. #if CYTHON_COMPILING_IN_CPYTHON
  13548. cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
  13549. if (likely(cython_runtime_dict)) {
  13550. __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
  13551. use_cline, *cython_runtime_dict,
  13552. __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
  13553. } else
  13554. #endif
  13555. {
  13556. PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
  13557. if (use_cline_obj) {
  13558. use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
  13559. Py_DECREF(use_cline_obj);
  13560. } else {
  13561. PyErr_Clear();
  13562. use_cline = NULL;
  13563. }
  13564. }
  13565. if (!use_cline) {
  13566. c_line = 0;
  13567. PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
  13568. }
  13569. else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
  13570. c_line = 0;
  13571. }
  13572. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  13573. return c_line;
  13574. }
  13575. #endif
  13576. /* CodeObjectCache */
  13577. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  13578. int start = 0, mid = 0, end = count - 1;
  13579. if (end >= 0 && code_line > entries[end].code_line) {
  13580. return count;
  13581. }
  13582. while (start < end) {
  13583. mid = start + (end - start) / 2;
  13584. if (code_line < entries[mid].code_line) {
  13585. end = mid;
  13586. } else if (code_line > entries[mid].code_line) {
  13587. start = mid + 1;
  13588. } else {
  13589. return mid;
  13590. }
  13591. }
  13592. if (code_line <= entries[mid].code_line) {
  13593. return mid;
  13594. } else {
  13595. return mid + 1;
  13596. }
  13597. }
  13598. static PyCodeObject *__pyx_find_code_object(int code_line) {
  13599. PyCodeObject* code_object;
  13600. int pos;
  13601. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  13602. return NULL;
  13603. }
  13604. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  13605. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  13606. return NULL;
  13607. }
  13608. code_object = __pyx_code_cache.entries[pos].code_object;
  13609. Py_INCREF(code_object);
  13610. return code_object;
  13611. }
  13612. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  13613. int pos, i;
  13614. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  13615. if (unlikely(!code_line)) {
  13616. return;
  13617. }
  13618. if (unlikely(!entries)) {
  13619. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  13620. if (likely(entries)) {
  13621. __pyx_code_cache.entries = entries;
  13622. __pyx_code_cache.max_count = 64;
  13623. __pyx_code_cache.count = 1;
  13624. entries[0].code_line = code_line;
  13625. entries[0].code_object = code_object;
  13626. Py_INCREF(code_object);
  13627. }
  13628. return;
  13629. }
  13630. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  13631. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  13632. PyCodeObject* tmp = entries[pos].code_object;
  13633. entries[pos].code_object = code_object;
  13634. Py_DECREF(tmp);
  13635. return;
  13636. }
  13637. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  13638. int new_max = __pyx_code_cache.max_count + 64;
  13639. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  13640. __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
  13641. if (unlikely(!entries)) {
  13642. return;
  13643. }
  13644. __pyx_code_cache.entries = entries;
  13645. __pyx_code_cache.max_count = new_max;
  13646. }
  13647. for (i=__pyx_code_cache.count; i>pos; i--) {
  13648. entries[i] = entries[i-1];
  13649. }
  13650. entries[pos].code_line = code_line;
  13651. entries[pos].code_object = code_object;
  13652. __pyx_code_cache.count++;
  13653. Py_INCREF(code_object);
  13654. }
  13655. /* AddTraceback */
  13656. #include "compile.h"
  13657. #include "frameobject.h"
  13658. #include "traceback.h"
  13659. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  13660. const char *funcname, int c_line,
  13661. int py_line, const char *filename) {
  13662. PyCodeObject *py_code = 0;
  13663. PyObject *py_srcfile = 0;
  13664. PyObject *py_funcname = 0;
  13665. #if PY_MAJOR_VERSION < 3
  13666. py_srcfile = PyString_FromString(filename);
  13667. #else
  13668. py_srcfile = PyUnicode_FromString(filename);
  13669. #endif
  13670. if (!py_srcfile) goto bad;
  13671. if (c_line) {
  13672. #if PY_MAJOR_VERSION < 3
  13673. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  13674. #else
  13675. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  13676. #endif
  13677. }
  13678. else {
  13679. #if PY_MAJOR_VERSION < 3
  13680. py_funcname = PyString_FromString(funcname);
  13681. #else
  13682. py_funcname = PyUnicode_FromString(funcname);
  13683. #endif
  13684. }
  13685. if (!py_funcname) goto bad;
  13686. py_code = __Pyx_PyCode_New(
  13687. 0,
  13688. 0,
  13689. 0,
  13690. 0,
  13691. 0,
  13692. __pyx_empty_bytes, /*PyObject *code,*/
  13693. __pyx_empty_tuple, /*PyObject *consts,*/
  13694. __pyx_empty_tuple, /*PyObject *names,*/
  13695. __pyx_empty_tuple, /*PyObject *varnames,*/
  13696. __pyx_empty_tuple, /*PyObject *freevars,*/
  13697. __pyx_empty_tuple, /*PyObject *cellvars,*/
  13698. py_srcfile, /*PyObject *filename,*/
  13699. py_funcname, /*PyObject *name,*/
  13700. py_line,
  13701. __pyx_empty_bytes /*PyObject *lnotab*/
  13702. );
  13703. Py_DECREF(py_srcfile);
  13704. Py_DECREF(py_funcname);
  13705. return py_code;
  13706. bad:
  13707. Py_XDECREF(py_srcfile);
  13708. Py_XDECREF(py_funcname);
  13709. return NULL;
  13710. }
  13711. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  13712. int py_line, const char *filename) {
  13713. PyCodeObject *py_code = 0;
  13714. PyFrameObject *py_frame = 0;
  13715. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  13716. if (c_line) {
  13717. c_line = __Pyx_CLineForTraceback(tstate, c_line);
  13718. }
  13719. py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
  13720. if (!py_code) {
  13721. py_code = __Pyx_CreateCodeObjectForTraceback(
  13722. funcname, c_line, py_line, filename);
  13723. if (!py_code) goto bad;
  13724. __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
  13725. }
  13726. py_frame = PyFrame_New(
  13727. tstate, /*PyThreadState *tstate,*/
  13728. py_code, /*PyCodeObject *code,*/
  13729. __pyx_d, /*PyObject *globals,*/
  13730. 0 /*PyObject *locals*/
  13731. );
  13732. if (!py_frame) goto bad;
  13733. __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
  13734. PyTraceBack_Here(py_frame);
  13735. bad:
  13736. Py_XDECREF(py_code);
  13737. Py_XDECREF(py_frame);
  13738. }
  13739. #if PY_MAJOR_VERSION < 3
  13740. static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
  13741. if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
  13742. if (__Pyx_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags);
  13743. PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
  13744. return -1;
  13745. }
  13746. static void __Pyx_ReleaseBuffer(Py_buffer *view) {
  13747. PyObject *obj = view->obj;
  13748. if (!obj) return;
  13749. if (PyObject_CheckBuffer(obj)) {
  13750. PyBuffer_Release(view);
  13751. return;
  13752. }
  13753. if ((0)) {}
  13754. else if (__Pyx_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view);
  13755. view->obj = NULL;
  13756. Py_DECREF(obj);
  13757. }
  13758. #endif
  13759. /* CIntFromPyVerify */
  13760. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  13761. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  13762. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  13763. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  13764. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  13765. {\
  13766. func_type value = func_value;\
  13767. if (sizeof(target_type) < sizeof(func_type)) {\
  13768. if (unlikely(value != (func_type) (target_type) value)) {\
  13769. func_type zero = 0;\
  13770. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  13771. return (target_type) -1;\
  13772. if (is_unsigned && unlikely(value < zero))\
  13773. goto raise_neg_overflow;\
  13774. else\
  13775. goto raise_overflow;\
  13776. }\
  13777. }\
  13778. return (target_type) value;\
  13779. }
  13780. /* CIntToPy */
  13781. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_siz(siz value) {
  13782. const siz neg_one = (siz) ((siz) 0 - (siz) 1), const_zero = (siz) 0;
  13783. const int is_unsigned = neg_one > const_zero;
  13784. if (is_unsigned) {
  13785. if (sizeof(siz) < sizeof(long)) {
  13786. return PyInt_FromLong((long) value);
  13787. } else if (sizeof(siz) <= sizeof(unsigned long)) {
  13788. return PyLong_FromUnsignedLong((unsigned long) value);
  13789. #ifdef HAVE_LONG_LONG
  13790. } else if (sizeof(siz) <= sizeof(unsigned PY_LONG_LONG)) {
  13791. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  13792. #endif
  13793. }
  13794. } else {
  13795. if (sizeof(siz) <= sizeof(long)) {
  13796. return PyInt_FromLong((long) value);
  13797. #ifdef HAVE_LONG_LONG
  13798. } else if (sizeof(siz) <= sizeof(PY_LONG_LONG)) {
  13799. return PyLong_FromLongLong((PY_LONG_LONG) value);
  13800. #endif
  13801. }
  13802. }
  13803. {
  13804. int one = 1; int little = (int)*(unsigned char *)&one;
  13805. unsigned char *bytes = (unsigned char *)&value;
  13806. return _PyLong_FromByteArray(bytes, sizeof(siz),
  13807. little, !is_unsigned);
  13808. }
  13809. }
  13810. /* CIntToPy */
  13811. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  13812. const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
  13813. const int is_unsigned = neg_one > const_zero;
  13814. if (is_unsigned) {
  13815. if (sizeof(long) < sizeof(long)) {
  13816. return PyInt_FromLong((long) value);
  13817. } else if (sizeof(long) <= sizeof(unsigned long)) {
  13818. return PyLong_FromUnsignedLong((unsigned long) value);
  13819. #ifdef HAVE_LONG_LONG
  13820. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  13821. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  13822. #endif
  13823. }
  13824. } else {
  13825. if (sizeof(long) <= sizeof(long)) {
  13826. return PyInt_FromLong((long) value);
  13827. #ifdef HAVE_LONG_LONG
  13828. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  13829. return PyLong_FromLongLong((PY_LONG_LONG) value);
  13830. #endif
  13831. }
  13832. }
  13833. {
  13834. int one = 1; int little = (int)*(unsigned char *)&one;
  13835. unsigned char *bytes = (unsigned char *)&value;
  13836. return _PyLong_FromByteArray(bytes, sizeof(long),
  13837. little, !is_unsigned);
  13838. }
  13839. }
  13840. /* CIntToPy */
  13841. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value) {
  13842. const Py_intptr_t neg_one = (Py_intptr_t) ((Py_intptr_t) 0 - (Py_intptr_t) 1), const_zero = (Py_intptr_t) 0;
  13843. const int is_unsigned = neg_one > const_zero;
  13844. if (is_unsigned) {
  13845. if (sizeof(Py_intptr_t) < sizeof(long)) {
  13846. return PyInt_FromLong((long) value);
  13847. } else if (sizeof(Py_intptr_t) <= sizeof(unsigned long)) {
  13848. return PyLong_FromUnsignedLong((unsigned long) value);
  13849. #ifdef HAVE_LONG_LONG
  13850. } else if (sizeof(Py_intptr_t) <= sizeof(unsigned PY_LONG_LONG)) {
  13851. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  13852. #endif
  13853. }
  13854. } else {
  13855. if (sizeof(Py_intptr_t) <= sizeof(long)) {
  13856. return PyInt_FromLong((long) value);
  13857. #ifdef HAVE_LONG_LONG
  13858. } else if (sizeof(Py_intptr_t) <= sizeof(PY_LONG_LONG)) {
  13859. return PyLong_FromLongLong((PY_LONG_LONG) value);
  13860. #endif
  13861. }
  13862. }
  13863. {
  13864. int one = 1; int little = (int)*(unsigned char *)&one;
  13865. unsigned char *bytes = (unsigned char *)&value;
  13866. return _PyLong_FromByteArray(bytes, sizeof(Py_intptr_t),
  13867. little, !is_unsigned);
  13868. }
  13869. }
  13870. /* Declarations */
  13871. #if CYTHON_CCOMPLEX
  13872. #ifdef __cplusplus
  13873. static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
  13874. return ::std::complex< float >(x, y);
  13875. }
  13876. #else
  13877. static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
  13878. return x + y*(__pyx_t_float_complex)_Complex_I;
  13879. }
  13880. #endif
  13881. #else
  13882. static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
  13883. __pyx_t_float_complex z;
  13884. z.real = x;
  13885. z.imag = y;
  13886. return z;
  13887. }
  13888. #endif
  13889. /* Arithmetic */
  13890. #if CYTHON_CCOMPLEX
  13891. #else
  13892. static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
  13893. return (a.real == b.real) && (a.imag == b.imag);
  13894. }
  13895. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
  13896. __pyx_t_float_complex z;
  13897. z.real = a.real + b.real;
  13898. z.imag = a.imag + b.imag;
  13899. return z;
  13900. }
  13901. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
  13902. __pyx_t_float_complex z;
  13903. z.real = a.real - b.real;
  13904. z.imag = a.imag - b.imag;
  13905. return z;
  13906. }
  13907. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
  13908. __pyx_t_float_complex z;
  13909. z.real = a.real * b.real - a.imag * b.imag;
  13910. z.imag = a.real * b.imag + a.imag * b.real;
  13911. return z;
  13912. }
  13913. #if 1
  13914. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
  13915. if (b.imag == 0) {
  13916. return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
  13917. } else if (fabsf(b.real) >= fabsf(b.imag)) {
  13918. if (b.real == 0 && b.imag == 0) {
  13919. return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag);
  13920. } else {
  13921. float r = b.imag / b.real;
  13922. float s = (float)(1.0) / (b.real + b.imag * r);
  13923. return __pyx_t_float_complex_from_parts(
  13924. (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
  13925. }
  13926. } else {
  13927. float r = b.real / b.imag;
  13928. float s = (float)(1.0) / (b.imag + b.real * r);
  13929. return __pyx_t_float_complex_from_parts(
  13930. (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
  13931. }
  13932. }
  13933. #else
  13934. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
  13935. if (b.imag == 0) {
  13936. return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
  13937. } else {
  13938. float denom = b.real * b.real + b.imag * b.imag;
  13939. return __pyx_t_float_complex_from_parts(
  13940. (a.real * b.real + a.imag * b.imag) / denom,
  13941. (a.imag * b.real - a.real * b.imag) / denom);
  13942. }
  13943. }
  13944. #endif
  13945. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) {
  13946. __pyx_t_float_complex z;
  13947. z.real = -a.real;
  13948. z.imag = -a.imag;
  13949. return z;
  13950. }
  13951. static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
  13952. return (a.real == 0) && (a.imag == 0);
  13953. }
  13954. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) {
  13955. __pyx_t_float_complex z;
  13956. z.real = a.real;
  13957. z.imag = -a.imag;
  13958. return z;
  13959. }
  13960. #if 1
  13961. static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) {
  13962. #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
  13963. return sqrtf(z.real*z.real + z.imag*z.imag);
  13964. #else
  13965. return hypotf(z.real, z.imag);
  13966. #endif
  13967. }
  13968. static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
  13969. __pyx_t_float_complex z;
  13970. float r, lnr, theta, z_r, z_theta;
  13971. if (b.imag == 0 && b.real == (int)b.real) {
  13972. if (b.real < 0) {
  13973. float denom = a.real * a.real + a.imag * a.imag;
  13974. a.real = a.real / denom;
  13975. a.imag = -a.imag / denom;
  13976. b.real = -b.real;
  13977. }
  13978. switch ((int)b.real) {
  13979. case 0:
  13980. z.real = 1;
  13981. z.imag = 0;
  13982. return z;
  13983. case 1:
  13984. return a;
  13985. case 2:
  13986. z = __Pyx_c_prod_float(a, a);
  13987. return __Pyx_c_prod_float(a, a);
  13988. case 3:
  13989. z = __Pyx_c_prod_float(a, a);
  13990. return __Pyx_c_prod_float(z, a);
  13991. case 4:
  13992. z = __Pyx_c_prod_float(a, a);
  13993. return __Pyx_c_prod_float(z, z);
  13994. }
  13995. }
  13996. if (a.imag == 0) {
  13997. if (a.real == 0) {
  13998. return a;
  13999. } else if (b.imag == 0) {
  14000. z.real = powf(a.real, b.real);
  14001. z.imag = 0;
  14002. return z;
  14003. } else if (a.real > 0) {
  14004. r = a.real;
  14005. theta = 0;
  14006. } else {
  14007. r = -a.real;
  14008. theta = atan2f(0.0, -1.0);
  14009. }
  14010. } else {
  14011. r = __Pyx_c_abs_float(a);
  14012. theta = atan2f(a.imag, a.real);
  14013. }
  14014. lnr = logf(r);
  14015. z_r = expf(lnr * b.real - theta * b.imag);
  14016. z_theta = theta * b.real + lnr * b.imag;
  14017. z.real = z_r * cosf(z_theta);
  14018. z.imag = z_r * sinf(z_theta);
  14019. return z;
  14020. }
  14021. #endif
  14022. #endif
  14023. /* Declarations */
  14024. #if CYTHON_CCOMPLEX
  14025. #ifdef __cplusplus
  14026. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  14027. return ::std::complex< double >(x, y);
  14028. }
  14029. #else
  14030. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  14031. return x + y*(__pyx_t_double_complex)_Complex_I;
  14032. }
  14033. #endif
  14034. #else
  14035. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  14036. __pyx_t_double_complex z;
  14037. z.real = x;
  14038. z.imag = y;
  14039. return z;
  14040. }
  14041. #endif
  14042. /* Arithmetic */
  14043. #if CYTHON_CCOMPLEX
  14044. #else
  14045. static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  14046. return (a.real == b.real) && (a.imag == b.imag);
  14047. }
  14048. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  14049. __pyx_t_double_complex z;
  14050. z.real = a.real + b.real;
  14051. z.imag = a.imag + b.imag;
  14052. return z;
  14053. }
  14054. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  14055. __pyx_t_double_complex z;
  14056. z.real = a.real - b.real;
  14057. z.imag = a.imag - b.imag;
  14058. return z;
  14059. }
  14060. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  14061. __pyx_t_double_complex z;
  14062. z.real = a.real * b.real - a.imag * b.imag;
  14063. z.imag = a.real * b.imag + a.imag * b.real;
  14064. return z;
  14065. }
  14066. #if 1
  14067. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  14068. if (b.imag == 0) {
  14069. return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
  14070. } else if (fabs(b.real) >= fabs(b.imag)) {
  14071. if (b.real == 0 && b.imag == 0) {
  14072. return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
  14073. } else {
  14074. double r = b.imag / b.real;
  14075. double s = (double)(1.0) / (b.real + b.imag * r);
  14076. return __pyx_t_double_complex_from_parts(
  14077. (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
  14078. }
  14079. } else {
  14080. double r = b.real / b.imag;
  14081. double s = (double)(1.0) / (b.imag + b.real * r);
  14082. return __pyx_t_double_complex_from_parts(
  14083. (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
  14084. }
  14085. }
  14086. #else
  14087. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  14088. if (b.imag == 0) {
  14089. return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
  14090. } else {
  14091. double denom = b.real * b.real + b.imag * b.imag;
  14092. return __pyx_t_double_complex_from_parts(
  14093. (a.real * b.real + a.imag * b.imag) / denom,
  14094. (a.imag * b.real - a.real * b.imag) / denom);
  14095. }
  14096. }
  14097. #endif
  14098. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
  14099. __pyx_t_double_complex z;
  14100. z.real = -a.real;
  14101. z.imag = -a.imag;
  14102. return z;
  14103. }
  14104. static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
  14105. return (a.real == 0) && (a.imag == 0);
  14106. }
  14107. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
  14108. __pyx_t_double_complex z;
  14109. z.real = a.real;
  14110. z.imag = -a.imag;
  14111. return z;
  14112. }
  14113. #if 1
  14114. static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
  14115. #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
  14116. return sqrt(z.real*z.real + z.imag*z.imag);
  14117. #else
  14118. return hypot(z.real, z.imag);
  14119. #endif
  14120. }
  14121. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  14122. __pyx_t_double_complex z;
  14123. double r, lnr, theta, z_r, z_theta;
  14124. if (b.imag == 0 && b.real == (int)b.real) {
  14125. if (b.real < 0) {
  14126. double denom = a.real * a.real + a.imag * a.imag;
  14127. a.real = a.real / denom;
  14128. a.imag = -a.imag / denom;
  14129. b.real = -b.real;
  14130. }
  14131. switch ((int)b.real) {
  14132. case 0:
  14133. z.real = 1;
  14134. z.imag = 0;
  14135. return z;
  14136. case 1:
  14137. return a;
  14138. case 2:
  14139. z = __Pyx_c_prod_double(a, a);
  14140. return __Pyx_c_prod_double(a, a);
  14141. case 3:
  14142. z = __Pyx_c_prod_double(a, a);
  14143. return __Pyx_c_prod_double(z, a);
  14144. case 4:
  14145. z = __Pyx_c_prod_double(a, a);
  14146. return __Pyx_c_prod_double(z, z);
  14147. }
  14148. }
  14149. if (a.imag == 0) {
  14150. if (a.real == 0) {
  14151. return a;
  14152. } else if (b.imag == 0) {
  14153. z.real = pow(a.real, b.real);
  14154. z.imag = 0;
  14155. return z;
  14156. } else if (a.real > 0) {
  14157. r = a.real;
  14158. theta = 0;
  14159. } else {
  14160. r = -a.real;
  14161. theta = atan2(0.0, -1.0);
  14162. }
  14163. } else {
  14164. r = __Pyx_c_abs_double(a);
  14165. theta = atan2(a.imag, a.real);
  14166. }
  14167. lnr = log(r);
  14168. z_r = exp(lnr * b.real - theta * b.imag);
  14169. z_theta = theta * b.real + lnr * b.imag;
  14170. z.real = z_r * cos(z_theta);
  14171. z.imag = z_r * sin(z_theta);
  14172. return z;
  14173. }
  14174. #endif
  14175. #endif
  14176. /* CIntToPy */
  14177. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
  14178. const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
  14179. const int is_unsigned = neg_one > const_zero;
  14180. if (is_unsigned) {
  14181. if (sizeof(int) < sizeof(long)) {
  14182. return PyInt_FromLong((long) value);
  14183. } else if (sizeof(int) <= sizeof(unsigned long)) {
  14184. return PyLong_FromUnsignedLong((unsigned long) value);
  14185. #ifdef HAVE_LONG_LONG
  14186. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  14187. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14188. #endif
  14189. }
  14190. } else {
  14191. if (sizeof(int) <= sizeof(long)) {
  14192. return PyInt_FromLong((long) value);
  14193. #ifdef HAVE_LONG_LONG
  14194. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  14195. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14196. #endif
  14197. }
  14198. }
  14199. {
  14200. int one = 1; int little = (int)*(unsigned char *)&one;
  14201. unsigned char *bytes = (unsigned char *)&value;
  14202. return _PyLong_FromByteArray(bytes, sizeof(int),
  14203. little, !is_unsigned);
  14204. }
  14205. }
  14206. /* CIntToPy */
  14207. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) {
  14208. const enum NPY_TYPES neg_one = (enum NPY_TYPES) ((enum NPY_TYPES) 0 - (enum NPY_TYPES) 1), const_zero = (enum NPY_TYPES) 0;
  14209. const int is_unsigned = neg_one > const_zero;
  14210. if (is_unsigned) {
  14211. if (sizeof(enum NPY_TYPES) < sizeof(long)) {
  14212. return PyInt_FromLong((long) value);
  14213. } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) {
  14214. return PyLong_FromUnsignedLong((unsigned long) value);
  14215. #ifdef HAVE_LONG_LONG
  14216. } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) {
  14217. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14218. #endif
  14219. }
  14220. } else {
  14221. if (sizeof(enum NPY_TYPES) <= sizeof(long)) {
  14222. return PyInt_FromLong((long) value);
  14223. #ifdef HAVE_LONG_LONG
  14224. } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) {
  14225. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14226. #endif
  14227. }
  14228. }
  14229. {
  14230. int one = 1; int little = (int)*(unsigned char *)&one;
  14231. unsigned char *bytes = (unsigned char *)&value;
  14232. return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES),
  14233. little, !is_unsigned);
  14234. }
  14235. }
  14236. /* CIntFromPy */
  14237. static CYTHON_INLINE siz __Pyx_PyInt_As_siz(PyObject *x) {
  14238. const siz neg_one = (siz) ((siz) 0 - (siz) 1), const_zero = (siz) 0;
  14239. const int is_unsigned = neg_one > const_zero;
  14240. #if PY_MAJOR_VERSION < 3
  14241. if (likely(PyInt_Check(x))) {
  14242. if (sizeof(siz) < sizeof(long)) {
  14243. __PYX_VERIFY_RETURN_INT(siz, long, PyInt_AS_LONG(x))
  14244. } else {
  14245. long val = PyInt_AS_LONG(x);
  14246. if (is_unsigned && unlikely(val < 0)) {
  14247. goto raise_neg_overflow;
  14248. }
  14249. return (siz) val;
  14250. }
  14251. } else
  14252. #endif
  14253. if (likely(PyLong_Check(x))) {
  14254. if (is_unsigned) {
  14255. #if CYTHON_USE_PYLONG_INTERNALS
  14256. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14257. switch (Py_SIZE(x)) {
  14258. case 0: return (siz) 0;
  14259. case 1: __PYX_VERIFY_RETURN_INT(siz, digit, digits[0])
  14260. case 2:
  14261. if (8 * sizeof(siz) > 1 * PyLong_SHIFT) {
  14262. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14263. __PYX_VERIFY_RETURN_INT(siz, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14264. } else if (8 * sizeof(siz) >= 2 * PyLong_SHIFT) {
  14265. return (siz) (((((siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0]));
  14266. }
  14267. }
  14268. break;
  14269. case 3:
  14270. if (8 * sizeof(siz) > 2 * PyLong_SHIFT) {
  14271. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14272. __PYX_VERIFY_RETURN_INT(siz, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14273. } else if (8 * sizeof(siz) >= 3 * PyLong_SHIFT) {
  14274. return (siz) (((((((siz)digits[2]) << PyLong_SHIFT) | (siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0]));
  14275. }
  14276. }
  14277. break;
  14278. case 4:
  14279. if (8 * sizeof(siz) > 3 * PyLong_SHIFT) {
  14280. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14281. __PYX_VERIFY_RETURN_INT(siz, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14282. } else if (8 * sizeof(siz) >= 4 * PyLong_SHIFT) {
  14283. return (siz) (((((((((siz)digits[3]) << PyLong_SHIFT) | (siz)digits[2]) << PyLong_SHIFT) | (siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0]));
  14284. }
  14285. }
  14286. break;
  14287. }
  14288. #endif
  14289. #if CYTHON_COMPILING_IN_CPYTHON
  14290. if (unlikely(Py_SIZE(x) < 0)) {
  14291. goto raise_neg_overflow;
  14292. }
  14293. #else
  14294. {
  14295. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14296. if (unlikely(result < 0))
  14297. return (siz) -1;
  14298. if (unlikely(result == 1))
  14299. goto raise_neg_overflow;
  14300. }
  14301. #endif
  14302. if (sizeof(siz) <= sizeof(unsigned long)) {
  14303. __PYX_VERIFY_RETURN_INT_EXC(siz, unsigned long, PyLong_AsUnsignedLong(x))
  14304. #ifdef HAVE_LONG_LONG
  14305. } else if (sizeof(siz) <= sizeof(unsigned PY_LONG_LONG)) {
  14306. __PYX_VERIFY_RETURN_INT_EXC(siz, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  14307. #endif
  14308. }
  14309. } else {
  14310. #if CYTHON_USE_PYLONG_INTERNALS
  14311. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14312. switch (Py_SIZE(x)) {
  14313. case 0: return (siz) 0;
  14314. case -1: __PYX_VERIFY_RETURN_INT(siz, sdigit, (sdigit) (-(sdigit)digits[0]))
  14315. case 1: __PYX_VERIFY_RETURN_INT(siz, digit, +digits[0])
  14316. case -2:
  14317. if (8 * sizeof(siz) - 1 > 1 * PyLong_SHIFT) {
  14318. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14319. __PYX_VERIFY_RETURN_INT(siz, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14320. } else if (8 * sizeof(siz) - 1 > 2 * PyLong_SHIFT) {
  14321. return (siz) (((siz)-1)*(((((siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0])));
  14322. }
  14323. }
  14324. break;
  14325. case 2:
  14326. if (8 * sizeof(siz) > 1 * PyLong_SHIFT) {
  14327. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14328. __PYX_VERIFY_RETURN_INT(siz, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14329. } else if (8 * sizeof(siz) - 1 > 2 * PyLong_SHIFT) {
  14330. return (siz) ((((((siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0])));
  14331. }
  14332. }
  14333. break;
  14334. case -3:
  14335. if (8 * sizeof(siz) - 1 > 2 * PyLong_SHIFT) {
  14336. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14337. __PYX_VERIFY_RETURN_INT(siz, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14338. } else if (8 * sizeof(siz) - 1 > 3 * PyLong_SHIFT) {
  14339. return (siz) (((siz)-1)*(((((((siz)digits[2]) << PyLong_SHIFT) | (siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0])));
  14340. }
  14341. }
  14342. break;
  14343. case 3:
  14344. if (8 * sizeof(siz) > 2 * PyLong_SHIFT) {
  14345. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14346. __PYX_VERIFY_RETURN_INT(siz, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14347. } else if (8 * sizeof(siz) - 1 > 3 * PyLong_SHIFT) {
  14348. return (siz) ((((((((siz)digits[2]) << PyLong_SHIFT) | (siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0])));
  14349. }
  14350. }
  14351. break;
  14352. case -4:
  14353. if (8 * sizeof(siz) - 1 > 3 * PyLong_SHIFT) {
  14354. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14355. __PYX_VERIFY_RETURN_INT(siz, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14356. } else if (8 * sizeof(siz) - 1 > 4 * PyLong_SHIFT) {
  14357. return (siz) (((siz)-1)*(((((((((siz)digits[3]) << PyLong_SHIFT) | (siz)digits[2]) << PyLong_SHIFT) | (siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0])));
  14358. }
  14359. }
  14360. break;
  14361. case 4:
  14362. if (8 * sizeof(siz) > 3 * PyLong_SHIFT) {
  14363. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14364. __PYX_VERIFY_RETURN_INT(siz, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14365. } else if (8 * sizeof(siz) - 1 > 4 * PyLong_SHIFT) {
  14366. return (siz) ((((((((((siz)digits[3]) << PyLong_SHIFT) | (siz)digits[2]) << PyLong_SHIFT) | (siz)digits[1]) << PyLong_SHIFT) | (siz)digits[0])));
  14367. }
  14368. }
  14369. break;
  14370. }
  14371. #endif
  14372. if (sizeof(siz) <= sizeof(long)) {
  14373. __PYX_VERIFY_RETURN_INT_EXC(siz, long, PyLong_AsLong(x))
  14374. #ifdef HAVE_LONG_LONG
  14375. } else if (sizeof(siz) <= sizeof(PY_LONG_LONG)) {
  14376. __PYX_VERIFY_RETURN_INT_EXC(siz, PY_LONG_LONG, PyLong_AsLongLong(x))
  14377. #endif
  14378. }
  14379. }
  14380. {
  14381. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  14382. PyErr_SetString(PyExc_RuntimeError,
  14383. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  14384. #else
  14385. siz val;
  14386. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  14387. #if PY_MAJOR_VERSION < 3
  14388. if (likely(v) && !PyLong_Check(v)) {
  14389. PyObject *tmp = v;
  14390. v = PyNumber_Long(tmp);
  14391. Py_DECREF(tmp);
  14392. }
  14393. #endif
  14394. if (likely(v)) {
  14395. int one = 1; int is_little = (int)*(unsigned char *)&one;
  14396. unsigned char *bytes = (unsigned char *)&val;
  14397. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  14398. bytes, sizeof(val),
  14399. is_little, !is_unsigned);
  14400. Py_DECREF(v);
  14401. if (likely(!ret))
  14402. return val;
  14403. }
  14404. #endif
  14405. return (siz) -1;
  14406. }
  14407. } else {
  14408. siz val;
  14409. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  14410. if (!tmp) return (siz) -1;
  14411. val = __Pyx_PyInt_As_siz(tmp);
  14412. Py_DECREF(tmp);
  14413. return val;
  14414. }
  14415. raise_overflow:
  14416. PyErr_SetString(PyExc_OverflowError,
  14417. "value too large to convert to siz");
  14418. return (siz) -1;
  14419. raise_neg_overflow:
  14420. PyErr_SetString(PyExc_OverflowError,
  14421. "can't convert negative value to siz");
  14422. return (siz) -1;
  14423. }
  14424. /* CIntFromPy */
  14425. static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
  14426. const size_t neg_one = (size_t) ((size_t) 0 - (size_t) 1), const_zero = (size_t) 0;
  14427. const int is_unsigned = neg_one > const_zero;
  14428. #if PY_MAJOR_VERSION < 3
  14429. if (likely(PyInt_Check(x))) {
  14430. if (sizeof(size_t) < sizeof(long)) {
  14431. __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
  14432. } else {
  14433. long val = PyInt_AS_LONG(x);
  14434. if (is_unsigned && unlikely(val < 0)) {
  14435. goto raise_neg_overflow;
  14436. }
  14437. return (size_t) val;
  14438. }
  14439. } else
  14440. #endif
  14441. if (likely(PyLong_Check(x))) {
  14442. if (is_unsigned) {
  14443. #if CYTHON_USE_PYLONG_INTERNALS
  14444. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14445. switch (Py_SIZE(x)) {
  14446. case 0: return (size_t) 0;
  14447. case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
  14448. case 2:
  14449. if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
  14450. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14451. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14452. } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
  14453. return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14454. }
  14455. }
  14456. break;
  14457. case 3:
  14458. if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
  14459. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14460. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14461. } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
  14462. return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14463. }
  14464. }
  14465. break;
  14466. case 4:
  14467. if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
  14468. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14469. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14470. } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) {
  14471. return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14472. }
  14473. }
  14474. break;
  14475. }
  14476. #endif
  14477. #if CYTHON_COMPILING_IN_CPYTHON
  14478. if (unlikely(Py_SIZE(x) < 0)) {
  14479. goto raise_neg_overflow;
  14480. }
  14481. #else
  14482. {
  14483. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14484. if (unlikely(result < 0))
  14485. return (size_t) -1;
  14486. if (unlikely(result == 1))
  14487. goto raise_neg_overflow;
  14488. }
  14489. #endif
  14490. if (sizeof(size_t) <= sizeof(unsigned long)) {
  14491. __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
  14492. #ifdef HAVE_LONG_LONG
  14493. } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
  14494. __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  14495. #endif
  14496. }
  14497. } else {
  14498. #if CYTHON_USE_PYLONG_INTERNALS
  14499. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14500. switch (Py_SIZE(x)) {
  14501. case 0: return (size_t) 0;
  14502. case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
  14503. case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, +digits[0])
  14504. case -2:
  14505. if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
  14506. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14507. __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14508. } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
  14509. return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14510. }
  14511. }
  14512. break;
  14513. case 2:
  14514. if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
  14515. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14516. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14517. } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
  14518. return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14519. }
  14520. }
  14521. break;
  14522. case -3:
  14523. if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
  14524. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14525. __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14526. } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
  14527. return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14528. }
  14529. }
  14530. break;
  14531. case 3:
  14532. if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
  14533. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14534. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14535. } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
  14536. return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14537. }
  14538. }
  14539. break;
  14540. case -4:
  14541. if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
  14542. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14543. __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14544. } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
  14545. return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14546. }
  14547. }
  14548. break;
  14549. case 4:
  14550. if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
  14551. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14552. __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14553. } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
  14554. return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
  14555. }
  14556. }
  14557. break;
  14558. }
  14559. #endif
  14560. if (sizeof(size_t) <= sizeof(long)) {
  14561. __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
  14562. #ifdef HAVE_LONG_LONG
  14563. } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
  14564. __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
  14565. #endif
  14566. }
  14567. }
  14568. {
  14569. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  14570. PyErr_SetString(PyExc_RuntimeError,
  14571. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  14572. #else
  14573. size_t val;
  14574. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  14575. #if PY_MAJOR_VERSION < 3
  14576. if (likely(v) && !PyLong_Check(v)) {
  14577. PyObject *tmp = v;
  14578. v = PyNumber_Long(tmp);
  14579. Py_DECREF(tmp);
  14580. }
  14581. #endif
  14582. if (likely(v)) {
  14583. int one = 1; int is_little = (int)*(unsigned char *)&one;
  14584. unsigned char *bytes = (unsigned char *)&val;
  14585. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  14586. bytes, sizeof(val),
  14587. is_little, !is_unsigned);
  14588. Py_DECREF(v);
  14589. if (likely(!ret))
  14590. return val;
  14591. }
  14592. #endif
  14593. return (size_t) -1;
  14594. }
  14595. } else {
  14596. size_t val;
  14597. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  14598. if (!tmp) return (size_t) -1;
  14599. val = __Pyx_PyInt_As_size_t(tmp);
  14600. Py_DECREF(tmp);
  14601. return val;
  14602. }
  14603. raise_overflow:
  14604. PyErr_SetString(PyExc_OverflowError,
  14605. "value too large to convert to size_t");
  14606. return (size_t) -1;
  14607. raise_neg_overflow:
  14608. PyErr_SetString(PyExc_OverflowError,
  14609. "can't convert negative value to size_t");
  14610. return (size_t) -1;
  14611. }
  14612. /* CIntFromPy */
  14613. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  14614. const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
  14615. const int is_unsigned = neg_one > const_zero;
  14616. #if PY_MAJOR_VERSION < 3
  14617. if (likely(PyInt_Check(x))) {
  14618. if (sizeof(int) < sizeof(long)) {
  14619. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
  14620. } else {
  14621. long val = PyInt_AS_LONG(x);
  14622. if (is_unsigned && unlikely(val < 0)) {
  14623. goto raise_neg_overflow;
  14624. }
  14625. return (int) val;
  14626. }
  14627. } else
  14628. #endif
  14629. if (likely(PyLong_Check(x))) {
  14630. if (is_unsigned) {
  14631. #if CYTHON_USE_PYLONG_INTERNALS
  14632. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14633. switch (Py_SIZE(x)) {
  14634. case 0: return (int) 0;
  14635. case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
  14636. case 2:
  14637. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  14638. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14639. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14640. } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
  14641. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  14642. }
  14643. }
  14644. break;
  14645. case 3:
  14646. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  14647. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14648. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14649. } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
  14650. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  14651. }
  14652. }
  14653. break;
  14654. case 4:
  14655. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  14656. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14657. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14658. } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
  14659. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  14660. }
  14661. }
  14662. break;
  14663. }
  14664. #endif
  14665. #if CYTHON_COMPILING_IN_CPYTHON
  14666. if (unlikely(Py_SIZE(x) < 0)) {
  14667. goto raise_neg_overflow;
  14668. }
  14669. #else
  14670. {
  14671. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14672. if (unlikely(result < 0))
  14673. return (int) -1;
  14674. if (unlikely(result == 1))
  14675. goto raise_neg_overflow;
  14676. }
  14677. #endif
  14678. if (sizeof(int) <= sizeof(unsigned long)) {
  14679. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  14680. #ifdef HAVE_LONG_LONG
  14681. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  14682. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  14683. #endif
  14684. }
  14685. } else {
  14686. #if CYTHON_USE_PYLONG_INTERNALS
  14687. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14688. switch (Py_SIZE(x)) {
  14689. case 0: return (int) 0;
  14690. case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
  14691. case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
  14692. case -2:
  14693. if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
  14694. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14695. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14696. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  14697. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  14698. }
  14699. }
  14700. break;
  14701. case 2:
  14702. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  14703. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14704. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14705. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  14706. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  14707. }
  14708. }
  14709. break;
  14710. case -3:
  14711. if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  14712. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14713. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14714. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  14715. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  14716. }
  14717. }
  14718. break;
  14719. case 3:
  14720. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  14721. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14722. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14723. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  14724. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  14725. }
  14726. }
  14727. break;
  14728. case -4:
  14729. if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  14730. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14731. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14732. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  14733. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  14734. }
  14735. }
  14736. break;
  14737. case 4:
  14738. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  14739. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14740. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14741. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  14742. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  14743. }
  14744. }
  14745. break;
  14746. }
  14747. #endif
  14748. if (sizeof(int) <= sizeof(long)) {
  14749. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  14750. #ifdef HAVE_LONG_LONG
  14751. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  14752. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  14753. #endif
  14754. }
  14755. }
  14756. {
  14757. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  14758. PyErr_SetString(PyExc_RuntimeError,
  14759. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  14760. #else
  14761. int val;
  14762. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  14763. #if PY_MAJOR_VERSION < 3
  14764. if (likely(v) && !PyLong_Check(v)) {
  14765. PyObject *tmp = v;
  14766. v = PyNumber_Long(tmp);
  14767. Py_DECREF(tmp);
  14768. }
  14769. #endif
  14770. if (likely(v)) {
  14771. int one = 1; int is_little = (int)*(unsigned char *)&one;
  14772. unsigned char *bytes = (unsigned char *)&val;
  14773. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  14774. bytes, sizeof(val),
  14775. is_little, !is_unsigned);
  14776. Py_DECREF(v);
  14777. if (likely(!ret))
  14778. return val;
  14779. }
  14780. #endif
  14781. return (int) -1;
  14782. }
  14783. } else {
  14784. int val;
  14785. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  14786. if (!tmp) return (int) -1;
  14787. val = __Pyx_PyInt_As_int(tmp);
  14788. Py_DECREF(tmp);
  14789. return val;
  14790. }
  14791. raise_overflow:
  14792. PyErr_SetString(PyExc_OverflowError,
  14793. "value too large to convert to int");
  14794. return (int) -1;
  14795. raise_neg_overflow:
  14796. PyErr_SetString(PyExc_OverflowError,
  14797. "can't convert negative value to int");
  14798. return (int) -1;
  14799. }
  14800. /* CIntFromPy */
  14801. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  14802. const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
  14803. const int is_unsigned = neg_one > const_zero;
  14804. #if PY_MAJOR_VERSION < 3
  14805. if (likely(PyInt_Check(x))) {
  14806. if (sizeof(long) < sizeof(long)) {
  14807. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
  14808. } else {
  14809. long val = PyInt_AS_LONG(x);
  14810. if (is_unsigned && unlikely(val < 0)) {
  14811. goto raise_neg_overflow;
  14812. }
  14813. return (long) val;
  14814. }
  14815. } else
  14816. #endif
  14817. if (likely(PyLong_Check(x))) {
  14818. if (is_unsigned) {
  14819. #if CYTHON_USE_PYLONG_INTERNALS
  14820. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14821. switch (Py_SIZE(x)) {
  14822. case 0: return (long) 0;
  14823. case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
  14824. case 2:
  14825. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  14826. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14827. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14828. } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
  14829. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  14830. }
  14831. }
  14832. break;
  14833. case 3:
  14834. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  14835. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14836. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14837. } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
  14838. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  14839. }
  14840. }
  14841. break;
  14842. case 4:
  14843. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  14844. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14845. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14846. } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
  14847. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  14848. }
  14849. }
  14850. break;
  14851. }
  14852. #endif
  14853. #if CYTHON_COMPILING_IN_CPYTHON
  14854. if (unlikely(Py_SIZE(x) < 0)) {
  14855. goto raise_neg_overflow;
  14856. }
  14857. #else
  14858. {
  14859. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14860. if (unlikely(result < 0))
  14861. return (long) -1;
  14862. if (unlikely(result == 1))
  14863. goto raise_neg_overflow;
  14864. }
  14865. #endif
  14866. if (sizeof(long) <= sizeof(unsigned long)) {
  14867. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  14868. #ifdef HAVE_LONG_LONG
  14869. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  14870. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  14871. #endif
  14872. }
  14873. } else {
  14874. #if CYTHON_USE_PYLONG_INTERNALS
  14875. const digit* digits = ((PyLongObject*)x)->ob_digit;
  14876. switch (Py_SIZE(x)) {
  14877. case 0: return (long) 0;
  14878. case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
  14879. case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
  14880. case -2:
  14881. if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
  14882. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14883. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14884. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  14885. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  14886. }
  14887. }
  14888. break;
  14889. case 2:
  14890. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  14891. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  14892. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14893. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  14894. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  14895. }
  14896. }
  14897. break;
  14898. case -3:
  14899. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  14900. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14901. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14902. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  14903. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  14904. }
  14905. }
  14906. break;
  14907. case 3:
  14908. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  14909. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  14910. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14911. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  14912. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  14913. }
  14914. }
  14915. break;
  14916. case -4:
  14917. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  14918. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14919. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14920. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  14921. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  14922. }
  14923. }
  14924. break;
  14925. case 4:
  14926. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  14927. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  14928. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14929. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  14930. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  14931. }
  14932. }
  14933. break;
  14934. }
  14935. #endif
  14936. if (sizeof(long) <= sizeof(long)) {
  14937. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  14938. #ifdef HAVE_LONG_LONG
  14939. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  14940. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  14941. #endif
  14942. }
  14943. }
  14944. {
  14945. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  14946. PyErr_SetString(PyExc_RuntimeError,
  14947. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  14948. #else
  14949. long val;
  14950. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  14951. #if PY_MAJOR_VERSION < 3
  14952. if (likely(v) && !PyLong_Check(v)) {
  14953. PyObject *tmp = v;
  14954. v = PyNumber_Long(tmp);
  14955. Py_DECREF(tmp);
  14956. }
  14957. #endif
  14958. if (likely(v)) {
  14959. int one = 1; int is_little = (int)*(unsigned char *)&one;
  14960. unsigned char *bytes = (unsigned char *)&val;
  14961. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  14962. bytes, sizeof(val),
  14963. is_little, !is_unsigned);
  14964. Py_DECREF(v);
  14965. if (likely(!ret))
  14966. return val;
  14967. }
  14968. #endif
  14969. return (long) -1;
  14970. }
  14971. } else {
  14972. long val;
  14973. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  14974. if (!tmp) return (long) -1;
  14975. val = __Pyx_PyInt_As_long(tmp);
  14976. Py_DECREF(tmp);
  14977. return val;
  14978. }
  14979. raise_overflow:
  14980. PyErr_SetString(PyExc_OverflowError,
  14981. "value too large to convert to long");
  14982. return (long) -1;
  14983. raise_neg_overflow:
  14984. PyErr_SetString(PyExc_OverflowError,
  14985. "can't convert negative value to long");
  14986. return (long) -1;
  14987. }
  14988. /* FastTypeChecks */
  14989. #if CYTHON_COMPILING_IN_CPYTHON
  14990. static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
  14991. while (a) {
  14992. a = a->tp_base;
  14993. if (a == b)
  14994. return 1;
  14995. }
  14996. return b == &PyBaseObject_Type;
  14997. }
  14998. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
  14999. PyObject *mro;
  15000. if (a == b) return 1;
  15001. mro = a->tp_mro;
  15002. if (likely(mro)) {
  15003. Py_ssize_t i, n;
  15004. n = PyTuple_GET_SIZE(mro);
  15005. for (i = 0; i < n; i++) {
  15006. if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
  15007. return 1;
  15008. }
  15009. return 0;
  15010. }
  15011. return __Pyx_InBases(a, b);
  15012. }
  15013. #if PY_MAJOR_VERSION == 2
  15014. static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
  15015. PyObject *exception, *value, *tb;
  15016. int res;
  15017. __Pyx_PyThreadState_declare
  15018. __Pyx_PyThreadState_assign
  15019. __Pyx_ErrFetch(&exception, &value, &tb);
  15020. res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
  15021. if (unlikely(res == -1)) {
  15022. PyErr_WriteUnraisable(err);
  15023. res = 0;
  15024. }
  15025. if (!res) {
  15026. res = PyObject_IsSubclass(err, exc_type2);
  15027. if (unlikely(res == -1)) {
  15028. PyErr_WriteUnraisable(err);
  15029. res = 0;
  15030. }
  15031. }
  15032. __Pyx_ErrRestore(exception, value, tb);
  15033. return res;
  15034. }
  15035. #else
  15036. static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
  15037. int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
  15038. if (!res) {
  15039. res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
  15040. }
  15041. return res;
  15042. }
  15043. #endif
  15044. static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  15045. Py_ssize_t i, n;
  15046. assert(PyExceptionClass_Check(exc_type));
  15047. n = PyTuple_GET_SIZE(tuple);
  15048. #if PY_MAJOR_VERSION >= 3
  15049. for (i=0; i<n; i++) {
  15050. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  15051. }
  15052. #endif
  15053. for (i=0; i<n; i++) {
  15054. PyObject *t = PyTuple_GET_ITEM(tuple, i);
  15055. #if PY_MAJOR_VERSION < 3
  15056. if (likely(exc_type == t)) return 1;
  15057. #endif
  15058. if (likely(PyExceptionClass_Check(t))) {
  15059. if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
  15060. } else {
  15061. }
  15062. }
  15063. return 0;
  15064. }
  15065. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
  15066. if (likely(err == exc_type)) return 1;
  15067. if (likely(PyExceptionClass_Check(err))) {
  15068. if (likely(PyExceptionClass_Check(exc_type))) {
  15069. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
  15070. } else if (likely(PyTuple_Check(exc_type))) {
  15071. return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
  15072. } else {
  15073. }
  15074. }
  15075. return PyErr_GivenExceptionMatches(err, exc_type);
  15076. }
  15077. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
  15078. assert(PyExceptionClass_Check(exc_type1));
  15079. assert(PyExceptionClass_Check(exc_type2));
  15080. if (likely(err == exc_type1 || err == exc_type2)) return 1;
  15081. if (likely(PyExceptionClass_Check(err))) {
  15082. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
  15083. }
  15084. return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
  15085. }
  15086. #endif
  15087. /* CheckBinaryVersion */
  15088. static int __Pyx_check_binary_version(void) {
  15089. char ctversion[4], rtversion[4];
  15090. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  15091. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  15092. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  15093. char message[200];
  15094. PyOS_snprintf(message, sizeof(message),
  15095. "compiletime version %s of module '%.100s' "
  15096. "does not match runtime version %s",
  15097. ctversion, __Pyx_MODULE_NAME, rtversion);
  15098. return PyErr_WarnEx(NULL, message, 1);
  15099. }
  15100. return 0;
  15101. }
  15102. /* InitStrings */
  15103. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  15104. while (t->p) {
  15105. #if PY_MAJOR_VERSION < 3
  15106. if (t->is_unicode) {
  15107. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  15108. } else if (t->intern) {
  15109. *t->p = PyString_InternFromString(t->s);
  15110. } else {
  15111. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  15112. }
  15113. #else
  15114. if (t->is_unicode | t->is_str) {
  15115. if (t->intern) {
  15116. *t->p = PyUnicode_InternFromString(t->s);
  15117. } else if (t->encoding) {
  15118. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  15119. } else {
  15120. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  15121. }
  15122. } else {
  15123. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  15124. }
  15125. #endif
  15126. if (!*t->p)
  15127. return -1;
  15128. if (PyObject_Hash(*t->p) == -1)
  15129. return -1;
  15130. ++t;
  15131. }
  15132. return 0;
  15133. }
  15134. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  15135. return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
  15136. }
  15137. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
  15138. Py_ssize_t ignore;
  15139. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  15140. }
  15141. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  15142. #if !CYTHON_PEP393_ENABLED
  15143. static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  15144. char* defenc_c;
  15145. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  15146. if (!defenc) return NULL;
  15147. defenc_c = PyBytes_AS_STRING(defenc);
  15148. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  15149. {
  15150. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  15151. char* c;
  15152. for (c = defenc_c; c < end; c++) {
  15153. if ((unsigned char) (*c) >= 128) {
  15154. PyUnicode_AsASCIIString(o);
  15155. return NULL;
  15156. }
  15157. }
  15158. }
  15159. #endif
  15160. *length = PyBytes_GET_SIZE(defenc);
  15161. return defenc_c;
  15162. }
  15163. #else
  15164. static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  15165. if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
  15166. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  15167. if (likely(PyUnicode_IS_ASCII(o))) {
  15168. *length = PyUnicode_GET_LENGTH(o);
  15169. return PyUnicode_AsUTF8(o);
  15170. } else {
  15171. PyUnicode_AsASCIIString(o);
  15172. return NULL;
  15173. }
  15174. #else
  15175. return PyUnicode_AsUTF8AndSize(o, length);
  15176. #endif
  15177. }
  15178. #endif
  15179. #endif
  15180. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  15181. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  15182. if (
  15183. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  15184. __Pyx_sys_getdefaultencoding_not_ascii &&
  15185. #endif
  15186. PyUnicode_Check(o)) {
  15187. return __Pyx_PyUnicode_AsStringAndSize(o, length);
  15188. } else
  15189. #endif
  15190. #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
  15191. if (PyByteArray_Check(o)) {
  15192. *length = PyByteArray_GET_SIZE(o);
  15193. return PyByteArray_AS_STRING(o);
  15194. } else
  15195. #endif
  15196. {
  15197. char* result;
  15198. int r = PyBytes_AsStringAndSize(o, &result, length);
  15199. if (unlikely(r < 0)) {
  15200. return NULL;
  15201. } else {
  15202. return result;
  15203. }
  15204. }
  15205. }
  15206. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  15207. int is_true = x == Py_True;
  15208. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  15209. else return PyObject_IsTrue(x);
  15210. }
  15211. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
  15212. int retval;
  15213. if (unlikely(!x)) return -1;
  15214. retval = __Pyx_PyObject_IsTrue(x);
  15215. Py_DECREF(x);
  15216. return retval;
  15217. }
  15218. static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
  15219. #if PY_MAJOR_VERSION >= 3
  15220. if (PyLong_Check(result)) {
  15221. if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
  15222. "__int__ returned non-int (type %.200s). "
  15223. "The ability to return an instance of a strict subclass of int "
  15224. "is deprecated, and may be removed in a future version of Python.",
  15225. Py_TYPE(result)->tp_name)) {
  15226. Py_DECREF(result);
  15227. return NULL;
  15228. }
  15229. return result;
  15230. }
  15231. #endif
  15232. PyErr_Format(PyExc_TypeError,
  15233. "__%.4s__ returned non-%.4s (type %.200s)",
  15234. type_name, type_name, Py_TYPE(result)->tp_name);
  15235. Py_DECREF(result);
  15236. return NULL;
  15237. }
  15238. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
  15239. #if CYTHON_USE_TYPE_SLOTS
  15240. PyNumberMethods *m;
  15241. #endif
  15242. const char *name = NULL;
  15243. PyObject *res = NULL;
  15244. #if PY_MAJOR_VERSION < 3
  15245. if (likely(PyInt_Check(x) || PyLong_Check(x)))
  15246. #else
  15247. if (likely(PyLong_Check(x)))
  15248. #endif
  15249. return __Pyx_NewRef(x);
  15250. #if CYTHON_USE_TYPE_SLOTS
  15251. m = Py_TYPE(x)->tp_as_number;
  15252. #if PY_MAJOR_VERSION < 3
  15253. if (m && m->nb_int) {
  15254. name = "int";
  15255. res = m->nb_int(x);
  15256. }
  15257. else if (m && m->nb_long) {
  15258. name = "long";
  15259. res = m->nb_long(x);
  15260. }
  15261. #else
  15262. if (likely(m && m->nb_int)) {
  15263. name = "int";
  15264. res = m->nb_int(x);
  15265. }
  15266. #endif
  15267. #else
  15268. if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
  15269. res = PyNumber_Int(x);
  15270. }
  15271. #endif
  15272. if (likely(res)) {
  15273. #if PY_MAJOR_VERSION < 3
  15274. if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
  15275. #else
  15276. if (unlikely(!PyLong_CheckExact(res))) {
  15277. #endif
  15278. return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
  15279. }
  15280. }
  15281. else if (!PyErr_Occurred()) {
  15282. PyErr_SetString(PyExc_TypeError,
  15283. "an integer is required");
  15284. }
  15285. return res;
  15286. }
  15287. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  15288. Py_ssize_t ival;
  15289. PyObject *x;
  15290. #if PY_MAJOR_VERSION < 3
  15291. if (likely(PyInt_CheckExact(b))) {
  15292. if (sizeof(Py_ssize_t) >= sizeof(long))
  15293. return PyInt_AS_LONG(b);
  15294. else
  15295. return PyInt_AsSsize_t(b);
  15296. }
  15297. #endif
  15298. if (likely(PyLong_CheckExact(b))) {
  15299. #if CYTHON_USE_PYLONG_INTERNALS
  15300. const digit* digits = ((PyLongObject*)b)->ob_digit;
  15301. const Py_ssize_t size = Py_SIZE(b);
  15302. if (likely(__Pyx_sst_abs(size) <= 1)) {
  15303. ival = likely(size) ? digits[0] : 0;
  15304. if (size == -1) ival = -ival;
  15305. return ival;
  15306. } else {
  15307. switch (size) {
  15308. case 2:
  15309. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  15310. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  15311. }
  15312. break;
  15313. case -2:
  15314. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  15315. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  15316. }
  15317. break;
  15318. case 3:
  15319. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  15320. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  15321. }
  15322. break;
  15323. case -3:
  15324. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  15325. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  15326. }
  15327. break;
  15328. case 4:
  15329. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  15330. return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  15331. }
  15332. break;
  15333. case -4:
  15334. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  15335. return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  15336. }
  15337. break;
  15338. }
  15339. }
  15340. #endif
  15341. return PyLong_AsSsize_t(b);
  15342. }
  15343. x = PyNumber_Index(b);
  15344. if (!x) return -1;
  15345. ival = PyInt_AsSsize_t(x);
  15346. Py_DECREF(x);
  15347. return ival;
  15348. }
  15349. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  15350. return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
  15351. }
  15352. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  15353. return PyInt_FromSize_t(ival);
  15354. }
  15355. #endif /* Py_PYTHON_H */