index
int64 0
731k
| package
stringlengths 2
98
⌀ | name
stringlengths 1
76
| docstring
stringlengths 0
281k
⌀ | code
stringlengths 4
8.19k
| signature
stringlengths 2
42.8k
⌀ | embed_func_code
sequencelengths 768
768
|
---|---|---|---|---|---|---|
725,815 | flask_admin.base | _get_view_url |
Generate URL for the view. Override to change default behavior.
| def _get_view_url(self, admin, url):
"""
Generate URL for the view. Override to change default behavior.
"""
if url is None:
if admin.url != '/':
url = '%s/%s' % (admin.url, self.endpoint)
else:
if self == admin.index_view:
url = '/'
else:
url = '/%s' % self.endpoint
else:
if not url.startswith('/'):
url = '%s/%s' % (admin.url, url)
return url
| (self, admin, url) | [
-0.009386877529323101,
0.0034310161136090755,
0.05359558016061783,
0.05684727430343628,
0.020256144925951958,
0.034161921590566635,
0.049961332231760025,
0.02366086095571518,
-0.05072643980383873,
0.038274358958005905,
0.01608632504940033,
0.012672046199440956,
0.0014979314291849732,
-0.016870558261871338,
0.022417565807700157,
0.034008901566267014,
0.04387875273823738,
-0.02040916681289673,
0.10152938961982727,
-0.021040378138422966,
-0.018085161224007607,
-0.023220926523208618,
0.06067279726266861,
0.013121544383466244,
-0.07547757029533386,
0.024005157873034477,
-0.007206329610198736,
0.00678073987364769,
0.029341762885451317,
-0.05604391545057297,
0.006283422000706196,
-0.044031772762537,
0.07918833196163177,
0.05137677863240242,
0.08791052550077438,
0.003911597654223442,
0.037834424525499344,
0.029246125370264053,
-0.086609847843647,
-0.01738700270652771,
-0.001155427540652454,
-0.024349454790353775,
0.03297600895166397,
-0.046059299260377884,
0.06212649866938591,
0.05520230159163475,
-0.020829973742365837,
0.021097760647535324,
-0.057459358125925064,
-0.03802569955587387,
-0.01526383776217699,
-0.02042829431593418,
-0.010692337527871132,
-0.016545388847589493,
-0.0418512262403965,
0.02547798492014408,
0.041162628680467606,
0.03710757568478584,
0.0024064932949841022,
0.059066079556941986,
0.0022331492509692907,
-0.006436442956328392,
0.01600981503725052,
-0.012844194658100605,
0.02172897197306156,
0.051338523626327515,
-0.04005322977900505,
0.057038553059101105,
0.020370911806821823,
0.052486177533864975,
0.01630629226565361,
0.017645226791501045,
-0.025018922984600067,
-0.005958252586424351,
0.007110691163688898,
-0.0017441995441913605,
0.016641026362776756,
-0.02105950564146042,
0.023966902866959572,
-0.010022871196269989,
0.05034388601779938,
-0.05286873131990433,
0.03844650834798813,
-0.011074889451265335,
0.02612832374870777,
0.0021136016584932804,
-0.03905859217047691,
-0.02972431667149067,
0.004184165969491005,
0.05478149279952049,
-0.00905692670494318,
-0.006608591414988041,
-0.03188573569059372,
-0.05432242900133133,
0.00582914100959897,
-0.008726974949240685,
-0.0664110854268074,
0.00149314955342561,
-0.011132272891700268,
-0.04028275981545448,
0.04854588955640793,
0.03902033716440201,
0.021633334457874298,
-0.003720321459695697,
-0.004351532552391291,
-0.09579110145568848,
-0.006809431593865156,
0.011256602592766285,
-0.029819954186677933,
-0.019538860768079758,
-0.046059299260377884,
-0.03955591097474098,
-0.02402428537607193,
-0.03787267953157425,
0.030125996097922325,
-0.019452786073088646,
-0.021250782534480095,
0.002120774472132325,
-0.009683355689048767,
0.020256144925951958,
0.016574079170823097,
0.011993015184998512,
-0.04177471250295639,
-0.037279725074768066,
0.01667928136885166,
0.016688846051692963,
-0.031426671892404556,
-0.03997671976685524,
0.00573350302875042,
-0.05042039602994919,
0.0249041561037302,
0.03494615480303764,
-0.08048900961875916,
0.008282258175313473,
-0.010395859368145466,
0.04055054485797882,
0.0013305648462846875,
0.06560772657394409,
-0.03087197244167328,
0.06174394488334656,
-0.051988862454891205,
0.017989523708820343,
0.004248721990734339,
0.0029767353553324938,
0.013542352244257927,
0.044261302798986435,
-0.019070234149694443,
0.07830846309661865,
0.04839286953210831,
0.0000054963879847491626,
0.011620027013123035,
0.03592166304588318,
0.05979292839765549,
-0.025573622435331345,
-0.038484763354063034,
-0.014116181060671806,
-0.006517735309898853,
0.018228618428111076,
0.022627970203757286,
-0.049540527164936066,
0.02214977890253067,
0.015359476208686829,
-0.03636159747838974,
-0.01103663444519043,
0.005939125083386898,
0.008138800971210003,
0.041812967509031296,
-0.0263387281447649,
0.02735249139368534,
0.021595079451799393,
-0.022742735221982002,
-0.0007101127412170172,
-0.03190486505627632,
0.04414653778076172,
-0.013571043498814106,
0.02972431667149067,
-0.009501643478870392,
0.024119924753904343,
-0.012729428708553314,
-0.03136929124593735,
0.010156764648854733,
0.057612381875514984,
-0.039211612194776535,
0.04269284009933472,
0.01526383776217699,
-0.00532225938513875,
0.003890078980475664,
0.01970144547522068,
-0.0469009168446064,
0.020083997398614883,
-0.057115063071250916,
-0.038197848945856094,
0.004212857689708471,
-0.05145328864455223,
0.011285293847322464,
0.003096282947808504,
0.007144164759665728,
-0.018859829753637314,
-0.006675538141280413,
0.044490836560726166,
-0.0111800916492939,
-0.016535824164748192,
-0.007655828259885311,
-0.004731694236397743,
0.035826023668050766,
-0.0059534707106649876,
0.00981246680021286,
0.02251320518553257,
0.005527880974113941,
0.029207870364189148,
0.030106868594884872,
0.019290201365947723,
-0.017492204904556274,
0.08033598959445953,
-0.041736457496881485,
-0.060940586030483246,
-0.11071064323186874,
0.03131190687417984,
-0.027256853878498077,
0.03240218386054039,
0.018066033720970154,
-0.03165620565414429,
0.04663312807679176,
0.03421930596232414,
0.011170527897775173,
-0.01572290062904358,
0.05233315750956535,
-0.05596740543842316,
-0.046212319284677505,
0.02626221813261509,
-0.032861243933439255,
-0.03385588154196739,
0.027868937700986862,
0.052409667521715164,
0.06270032376050949,
0.015522060915827751,
-0.02071520872414112,
-0.014986487105488777,
0.005939125083386898,
0.01093143317848444,
-0.04005322977900505,
0.010367168113589287,
0.03226828947663307,
0.00418655714020133,
0.04265458509325981,
-0.0017155080568045378,
-0.05114724487066269,
0.055011022835969925,
-0.04269284009933472,
-0.014087489806115627,
0.01716703549027443,
-0.029246125370264053,
-0.014192691072821617,
-0.029341762885451317,
0.0028858790174126625,
-0.0151490718126297,
-0.029972974210977554,
0.07727556675672531,
-0.05535532161593437,
-0.016641026362776756,
-0.0418512262403965,
0.004884715192019939,
0.06434530019760132,
-0.016048070043325424,
-0.04648010805249214,
-0.061437904834747314,
0.013542352244257927,
-0.04460560157895088,
-0.019012849777936935,
0.0649191290140152,
0.19066408276557922,
0.05042039602994919,
-0.034754879772663116,
0.026816917583346367,
0.028481021523475647,
-0.0375283844769001,
-0.013714500702917576,
-0.015359476208686829,
-0.10489584505558014,
-0.0368015356361866,
0.006943324580788612,
-0.03341594710946083,
0.007392823696136475,
0.007890141569077969,
-0.039135102182626724,
-0.010816667228937149,
-0.036839790642261505,
-0.032574329525232315,
-0.006020417436957359,
0.003466880414634943,
0.06331241130828857,
-0.02366086095571518,
-0.046212319284677505,
-0.03565387800335884,
-0.02006486989557743,
0.012805938720703125,
0.009975051507353783,
0.021403802558779716,
-0.02280011773109436,
0.05325128510594368,
-0.029915591701865196,
-0.005738284904509783,
0.015235146507620811,
0.0022666226141154766,
0.008076636120676994,
0.0021518568973988295,
0.003543390892446041,
-0.048660654574632645,
0.04200424626469612,
-0.0439935177564621,
-0.004805813543498516,
-0.0027041668072342873,
-0.05210362747311592,
0.022819247096776962,
-0.010845358483493328,
0.0022068487014621496,
-0.022321928292512894,
-0.018850265070796013,
0.012844194658100605,
0.050688184797763824,
-0.03165620565414429,
0.07639569789171219,
0.013791011646389961,
-0.015770720317959785,
0.02134642004966736,
-0.014661317691206932,
0.007521935272961855,
0.007655828259885311,
-0.0135327884927392,
0.045141175389289856,
-0.0389629527926445,
0.006139964796602726,
-0.018209490925073624,
0.002325200941413641,
-0.01854422315955162,
-0.03354983776807785,
0.011074889451265335,
-0.008430496789515018,
-0.02107863314449787,
-0.04843112453818321,
0.09280719608068466,
0.031426671892404556,
-0.008024035021662712,
-0.011600899510085583,
-0.07138426601886749,
0.005723939277231693,
0.000961760466452688,
-0.06817082315683365,
0.034525346010923386,
-0.029494784772396088,
-0.03703106567263603,
-0.01796083152294159,
-0.034008901566267014,
-0.05382511392235756,
0.054360684007406235,
0.02899746596813202,
-0.020026614889502525,
-0.05960165336728096,
0.024445094168186188,
0.03490789979696274,
-0.01089317724108696,
-0.0498083122074604,
0.002563100541010499,
-0.03760489448904991,
0.026893429458141327,
0.014422222971916199,
0.02352696843445301,
-0.044261302798986435,
0.07272319495677948,
0.009659445844590664,
-0.03555823862552643,
-0.0009211142896674573,
0.07138426601886749,
-0.058989569544792175,
0.05462847277522087,
-0.0635036826133728,
-0.028978338465094566,
-0.02719946950674057,
-0.02792632021009922,
-0.007474116049706936,
-0.020083997398614883,
0.027448128908872604,
0.05359558016061783,
0.020026614889502525,
-0.029380017891526222,
-0.08148364722728729,
0.0007142969407141209,
0.09747432917356491,
-0.06893593072891235,
-0.007631918881088495,
0.011199219152331352,
-0.025726644322276115,
-0.009697701781988144,
0.02360347844660282,
0.014489169232547283,
-0.021403802558779716,
-0.0685533732175827,
-0.02821323461830616,
-0.06832384318113327,
-0.004724521189928055,
0.06526342779397964,
0.0512237548828125,
-0.026204833760857582,
0.04934924840927124,
0.019873593002557755,
0.016564516350626945,
0.004710175562649965,
0.06384798139333725,
-0.012939832173287868,
-0.0692802295088768,
-0.03362634778022766,
-0.04089484363794327,
-0.07681650668382645,
-0.003906815778464079,
-0.007301967591047287,
-0.03737536072731018,
-0.003830305067822337,
0.022455820813775063,
0.018745064735412598,
0.029819954186677933,
0.059563398361206055,
0.06032850220799446,
0.07769637554883957,
0.03573038801550865,
0.03198137506842613,
-0.012165163643658161,
0.010443678125739098,
0.023546095937490463,
-0.004894278943538666,
0.016554951667785645,
0.013111980631947517,
-0.05837748572230339,
0.0006593050202354789,
-0.04307539016008377,
0.007301967591047287,
0.046786148101091385,
0.054513707756996155,
-0.026816917583346367,
-0.010261965915560722,
0.02857665903866291,
-0.009860286489129066,
-0.03523306921124458,
-0.04582976922392845,
0.0418512262403965,
0.08102457970380783,
0.02084910124540329,
-0.0026922118850052357,
-0.04747474193572998,
0.00665641063824296,
-0.06292986124753952,
-0.014527424238622189,
0.06308288127183914,
-0.052715711295604706,
-0.017520897090435028,
-0.02488502860069275,
-0.009262547828257084,
-0.05742110311985016,
0.06602852791547775,
-0.010625391267240047,
0.07926484197378159,
0.008454406633973122,
-0.0037179305218160152,
-0.02930350787937641,
-0.06220300868153572,
-0.02092561312019825,
-0.012825067155063152,
0.03737536072731018,
-0.018152108415961266,
-0.03768140450119972,
-0.0040000625886023045,
0.01898415945470333,
-0.03875255212187767,
0.005652210675179958,
0.024521604180336,
-0.030718952417373657,
0.0461740642786026,
0.00006059569204808213,
-0.02828974463045597,
0.020370911806821823,
-0.009286457672715187,
-0.0454472154378891,
0.012920704670250416,
0.03110150434076786,
0.014097053557634354,
-0.044988155364990234,
0.024770263582468033,
-0.050496906042099,
0.01644974946975708,
-0.010558444075286388,
0.006541644688695669,
-0.01266248244792223,
0.05562310665845871,
-0.047666020691394806,
0.025956176221370697,
-0.020753463730216026,
0.04911971837282181,
0.008377895690500736,
0.03959416598081589,
0.008028817363083363,
0.005365296266973019,
0.04208075627684593,
0.006431661080569029,
0.014909977093338966,
0.015751592814922333,
-0.0031058466993272305,
-0.04655661806464195,
0.013791011646389961,
0.03529045358300209,
-0.062164753675460815,
-0.03289949893951416,
0.037126705050468445,
0.02641523815691471,
0.05512579157948494,
0.05145328864455223,
-0.0015493369428440928,
-0.0006413728697225451,
-0.02748638391494751,
-0.0073641324415802956,
0.045638494193553925,
-0.012069526128470898,
0.03238305449485779,
-0.02532496489584446,
-0.0020681736059486866,
-0.022742735221982002,
-0.00557570019736886,
0.01529252901673317,
-0.0368015356361866,
0.06836210191249847,
-0.0642305389046669,
0.05309826135635376,
-0.030565930530428886,
0.039211612194776535,
-0.02100212313234806,
0.02446422167122364,
-0.031579695641994476,
0.05650297924876213,
-0.07016009837388992,
-0.008980415761470795,
0.035826023668050766,
0.01399185135960579,
-0.04781904071569443,
-0.039938461035490036,
0.003952243831008673,
-0.024808518588542938,
-0.04208075627684593,
-0.021021250635385513,
0.039708930999040604,
0.03435320034623146,
0.04204250127077103,
-0.033798497170209885,
-0.003619901370257139,
0.053710345178842545,
0.04797206073999405,
0.041009608656167984,
0.028519276529550552,
0.03303339332342148,
-0.008583517745137215,
0.05780365690588951,
0.04292237013578415,
0.0111800916492939,
0.001967753516510129,
-0.016851430758833885,
-0.017205290496349335,
0.049617037177085876,
-0.013523224741220474,
0.03024076111614704,
-0.005030563101172447,
-0.0302981436252594,
-0.0008505812147632241,
-0.059486888349056244,
-0.0490814633667469,
-0.07016009837388992,
-0.036629386246204376,
-0.0060060713440179825,
-0.05374860018491745,
-0.03140754625201225,
0.04012973979115486,
-0.006183002144098282,
0.06315939128398895,
-0.02222629077732563,
-0.019510168582201004,
0.002563100541010499,
0.08117760717868805,
0.029131360352039337,
-0.05520230159163475,
-0.03544347360730171,
0.05853050574660301,
-0.011170527897775173,
-0.0026420019567012787,
-0.011352240107953548,
-0.02431119978427887,
0.0070963455364108086,
-0.047933805733919144,
0.031426671892404556,
0.02857665903866291,
-0.014795211143791676,
-0.021881993860006332,
-0.01889808475971222,
0.004889497067779303,
0.03817872330546379,
-0.0023287872318178415,
0.022207163274288177,
0.03800657391548157,
-0.06212649866938591,
0.000945023784879595,
-0.011342676356434822,
0.043190158903598785,
0.010491497814655304,
-0.04724521189928055,
-0.02584140934050083,
0.00007453045691363513,
0.0012444905005395412,
-0.020982995629310608,
0.009568589739501476,
-0.03724147006869316,
-0.029246125370264053,
-0.06935673952102661,
0.010405423119664192,
-0.01555075217038393,
0.0162297822535038,
-0.046862661838531494,
0.040359269827604294,
0.0032397399190813303,
-0.031082376837730408,
-0.034008901566267014,
0.03282298892736435,
0.04460560157895088,
-0.034085411578416824,
-0.028442764654755592,
0.011553079821169376,
-0.00366054754704237,
-0.014718701131641865,
0.00490623340010643,
-0.005982161965221167,
-0.03299513831734657,
-0.04012973979115486,
-0.0117252292111516,
-0.005221839062869549,
-0.004552372731268406,
0.004193729721009731,
0.02272360771894455,
0.021748099476099014,
-0.0060060713440179825,
-0.015110816806554794,
0.005881742108613253,
0.06411577016115189,
-0.046862661838531494,
0.003366460558027029,
-0.03982369601726532,
-0.025994431227445602,
0.002689820947125554,
0.0627768337726593,
0.06438355892896652,
-0.002711339620873332,
-0.039861951023340225,
0.0498083122074604,
-0.021633334457874298,
-0.041315652430057526,
-0.012203419581055641,
-0.00995592400431633,
-0.006326458882540464,
-0.04586802423000336,
-0.01889808475971222,
-0.07628093659877777,
0.001587592181749642,
0.004688656888902187,
0.04012973979115486,
-0.022972267121076584,
-0.039001211524009705,
-0.04778078570961952,
-0.025803154334425926,
-0.03657200187444687,
0.0070341806858778,
-0.04827810451388359,
0.03852301836013794,
-0.025879664346575737,
0.020390039309859276,
0.026090068742632866,
-0.03016425110399723,
-0.05455196276307106,
0.04429955780506134,
-0.007890141569077969,
-0.00890868715941906,
-0.002737640170380473,
-0.004777122288942337,
0.053786858916282654,
-0.03167533129453659,
-0.05072643980383873,
0.04877542331814766,
0.008215310983359814,
-0.05642646923661232,
-0.009745520539581776,
-0.031484056264162064,
0.025592749938368797,
0.035959918051958084,
-0.011782611720263958,
-0.012184291146695614,
-0.04697742685675621,
-0.02193937636911869,
0.06247079372406006,
0.008989979512989521,
-0.00010819057933986187,
0.012002578936517239,
0.01782693900167942,
0.031560566276311874,
-0.019318891689181328,
0.05830097571015358,
-0.024502476677298546,
-0.06384798139333725,
-0.013666681945323944,
0.02532496489584446,
-0.05592915043234825,
0.03781529888510704,
0.014317020773887634,
0.005121419206261635,
-0.022761862725019455,
-0.03418105095624924,
0.06166743487119675,
-0.04414653778076172,
0.01688968576490879,
0.009888977743685246,
-0.05432242900133133,
0.012978088110685349,
0.008057508617639542,
0.04055054485797882,
0.046441853046417236,
-0.0930367261171341,
-0.006775957997888327,
-0.006292985752224922,
-0.010759283788502216,
-0.023201799020171165,
-0.010233274661004543,
0.06797955185174942,
-0.01747307740151882,
0.007569754030555487,
0.041736457496881485,
-0.053633835166692734,
-0.02589879184961319,
-0.030432038009166718,
0.003065200522542,
0.007569754030555487,
0.011964323930442333,
-0.008903905749320984,
-0.007957088761031628,
0.014728264883160591,
0.028155852109193802,
0.012002578936517239,
0.0009635536698624492,
0.02532496489584446,
0.0368015356361866,
0.035749513655900955,
0.012566844001412392,
-0.015455113723874092,
0.01579941064119339,
0.0022403220646083355,
-0.05130026862025261,
-0.01038629561662674,
0.013542352244257927,
-0.006862032227218151,
-0.024349454790353775,
-0.01497692335397005,
0.009946360252797604,
-0.01367624569684267,
-0.012930268421769142,
0.06606678664684296,
0.05642646923661232,
0.020868228748440742,
0.001564878155477345
] |
725,816 | flask_admin.base | _handle_view |
This method will be executed before calling any view method.
It will execute the ``inaccessible_callback`` if the view is not
accessible.
:param name:
View function name
:param kwargs:
View function arguments
| def _handle_view(self, name, **kwargs):
"""
This method will be executed before calling any view method.
It will execute the ``inaccessible_callback`` if the view is not
accessible.
:param name:
View function name
:param kwargs:
View function arguments
"""
if not self.is_accessible():
return self.inaccessible_callback(name, **kwargs)
| (self, name, **kwargs) | [
-0.05104178935289383,
-0.04919090121984482,
-0.004827435594052076,
0.03479313105344772,
0.03384988754987717,
0.031020166352391243,
0.03600332513451576,
0.030593037605285645,
-0.015278722159564495,
0.01650671474635601,
0.04054155945777893,
0.03844151273369789,
0.05086381733417511,
-0.03986527398228645,
-0.028688760474324226,
0.020466547459363937,
0.04976040497422218,
0.037266913801431656,
0.016337644308805466,
-0.0779508501291275,
-0.04484843462705612,
-0.035593993961811066,
0.04822986200451851,
-0.034099046140909195,
-0.06424716114997864,
0.041289035230875015,
0.00024206697707995772,
0.026481932029128075,
0.04666372761130333,
0.01996823027729988,
-0.03886864334344864,
0.02197929099202156,
0.01916736550629139,
0.07410669326782227,
0.02863536775112152,
0.01693384349346161,
-0.005561561789363623,
0.035593993961811066,
-0.04929768294095993,
-0.024915795773267746,
-0.018437689170241356,
-0.010090897791087627,
-0.010518025606870651,
-0.05417405813932419,
-0.00803089514374733,
-0.0026339555624872446,
-0.02162335254251957,
0.0884866714477539,
0.00483633391559124,
-1.3034910040232717e-8,
-0.020733501762151718,
0.0036795292980968952,
-0.012084160931408405,
-0.0025827891658991575,
-0.0015027339104562998,
0.029738781973719597,
0.036199092864990234,
0.044421304017305374,
0.023936960846185684,
0.0041111065074801445,
-0.04499080777168274,
0.04979600012302399,
0.03301342949271202,
-0.022370826452970505,
-0.004039918538182974,
0.039544928818941116,
-0.004295750055462122,
0.005668343510478735,
-0.004814087878912687,
0.03071761690080166,
0.0003534372372087091,
0.00803089514374733,
0.008773920126259327,
0.06787774711847305,
0.06382003426551819,
0.0027807808946818113,
-0.028332820162177086,
-0.02066231332719326,
-0.004854131024330854,
0.06858962774276733,
0.05709276720881462,
-0.09218844771385193,
-0.012155349366366863,
-0.015759240835905075,
0.0016150774899870157,
-0.026037007570266724,
-0.010873964987695217,
-0.07101001590490341,
0.03982967883348465,
0.06118607521057129,
-0.02381238155066967,
-0.022032681852579117,
-0.0315362773835659,
-0.03965171054005623,
-0.0284573994576931,
0.01874023862183094,
0.036626219749450684,
-0.014433364383876324,
-0.015599068254232407,
-0.0005211183452047408,
0.005307954270392656,
0.043282296508550644,
0.043638236820697784,
0.010340055450797081,
0.008004199713468552,
-0.03511347621679306,
-0.018704643473029137,
-0.0012135327560827136,
-0.012395608238875866,
-0.01251128874719143,
0.04047037288546562,
-0.02870655618607998,
0.004791841376572847,
0.046628132462501526,
-0.04595184698700905,
-0.004814087878912687,
-0.01804615557193756,
-0.02030637301504612,
-0.0787339136004448,
0.015429996885359287,
0.0006256756605580449,
-0.010144288651645184,
-0.008168822154402733,
-0.04648575559258461,
-0.0159728042781353,
0.00971716083586216,
-0.01822412572801113,
0.012413405813276768,
0.057733457535505295,
0.004224562086164951,
0.03607451170682907,
-0.013080793432891369,
-0.025075968354940414,
-0.01138118002563715,
-0.016382135450839996,
0.06492344290018082,
0.056523263454437256,
-0.03267528861761093,
0.022459810599684715,
0.010286664590239525,
-0.04620100557804108,
-0.02258438989520073,
0.03815676271915436,
0.02512936107814312,
0.06196914613246918,
0.004480394069105387,
0.012778243981301785,
0.018313109874725342,
0.06513701379299164,
-0.000973829417489469,
0.0621471144258976,
0.03666181489825249,
0.01601729728281498,
0.0054102870635688305,
-0.04694847762584686,
0.033938873559236526,
0.0013659195974469185,
-0.0009732733014971018,
-0.0013358871219679713,
-0.01891820877790451,
0.013258762657642365,
0.007114349864423275,
-0.015341011807322502,
-0.006099920719861984,
0.02879554219543934,
-0.03861948475241661,
0.022548794746398926,
-0.037516068667173386,
0.04257041588425636,
0.0709388330578804,
-0.01898939535021782,
0.02566326968371868,
-0.037694040685892105,
0.006375774275511503,
0.06403359770774841,
-0.0051566800102591515,
-0.008391284383833408,
-0.028937917202711105,
0.01535880845040083,
-0.003772963536903262,
0.03596772998571396,
-0.023652208968997,
-0.06314374506473541,
0.041289035230875015,
0.012813838198781013,
0.02696245163679123,
0.04061274603009224,
-0.008280052803456783,
-0.012404507026076317,
0.05566900596022606,
-0.02294033020734787,
-0.008360139094293118,
0.037516068667173386,
-0.03201679885387421,
0.026214977726340294,
0.009227743372321129,
-0.018241921439766884,
0.017236391082406044,
0.005383591633290052,
-0.034099046140909195,
0.05008075013756752,
-0.018793629482388496,
-0.01882922276854515,
-0.0028341717552393675,
0.009298930875957012,
0.1103413850069046,
0.036733001470565796,
0.014771508052945137,
-0.04734001308679581,
-0.02117842622101307,
-0.00041934175533242524,
-0.03596772998571396,
-0.002484905766323209,
0.07214902341365814,
-0.018010560423135757,
0.013908353634178638,
-0.016248658299446106,
-0.009120960719883442,
0.034721940755844116,
0.027692127972841263,
0.017325377091765404,
0.05463678017258644,
-0.03263969346880913,
0.01925635151565075,
0.05420965328812599,
-0.009895130060613155,
0.052323173731565475,
-0.04449249431490898,
-0.006375774275511503,
-0.014922781847417355,
-0.023349661380052567,
0.011123123578727245,
-0.024203917011618614,
0.03790760412812233,
-0.011603642255067825,
0.00213563977740705,
0.01791267842054367,
-0.0665963664650917,
-0.07688302546739578,
-0.021605554968118668,
0.016809264197945595,
0.0046049728989601135,
0.03465075418353081,
0.0065537444315850735,
0.0020499916281551123,
-0.02338525466620922,
-0.06713027507066727,
0.059228405356407166,
-0.028831135481595993,
-0.023314066231250763,
-0.005775125697255135,
-0.01996823027729988,
-0.03135830909013748,
-0.034116845577955246,
-0.04755357652902603,
0.003933136351406574,
0.0016929393168538809,
0.06154201552271843,
0.0005428084405139089,
0.030183708295226097,
-0.010242171585559845,
-0.02879554219543934,
-0.0019654559437185526,
-0.014522349461913109,
0.0306464284658432,
-0.01733427494764328,
0.059228405356407166,
-0.03643045201897621,
-0.030610835179686546,
-0.03465075418353081,
0.09354101866483688,
0.02731839008629322,
0.01256468053907156,
0.0035460516810417175,
-0.026481932029128075,
-0.06328612565994263,
0.02557428553700447,
-0.014593537896871567,
-0.09375458210706711,
0.056523263454437256,
0.10485991090536118,
-0.012751548551023006,
-0.03237273916602135,
0.0779508501291275,
-0.04509758949279785,
-0.013107488863170147,
0.0280124731361866,
-0.03651943802833557,
-0.022637780755758286,
-0.055206283926963806,
0.07417788356542587,
-0.023776788264513016,
0.012101958505809307,
0.018170734867453575,
0.0023847976699471474,
-0.020003825426101685,
-0.07068967074155807,
0.020644517615437508,
-0.02642854116857052,
0.05186045169830322,
-0.00636687595397234,
-0.034099046140909195,
-0.01711181364953518,
-0.026481932029128075,
0.046521350741386414,
-0.023225082084536552,
-0.007492535747587681,
0.026464134454727173,
-0.018188530579209328,
0.01721859537065029,
-0.011327789165079594,
-0.005984240211546421,
-0.006197804119437933,
-0.0015038462588563561,
-0.014157511293888092,
0.0029253815300762653,
0.037872008979320526,
0.027531955391168594,
0.017094016075134277,
0.07296768575906754,
-0.03148288652300835,
0.05356896296143532,
-0.05378252640366554,
-0.003539377823472023,
0.011105326004326344,
-0.01751224510371685,
0.0227623600512743,
-0.011737119406461716,
-0.02224624715745449,
0.012715954333543777,
-0.06809131056070328,
-0.01439777109771967,
0.004983159247785807,
-0.03399226441979408,
-0.08877142518758774,
-0.030183708295226097,
-0.008680485188961029,
0.021231817081570625,
0.0005080486298538744,
-0.013757078908383846,
-0.0048185368068516254,
0.006958625745028257,
-0.03231934830546379,
0.041467003524303436,
-0.041538190096616745,
0.03911779820919037,
0.031109150499105453,
-0.004057715181261301,
0.06367765367031097,
-0.00882286112755537,
-0.039616115391254425,
-0.06143523380160332,
-0.020715704187750816,
-0.026926856487989426,
-0.010073100216686726,
-0.014691420830786228,
0.020644517615437508,
-0.006406919099390507,
-0.013908353634178638,
-0.021854713559150696,
0.04232126101851463,
-0.03196340799331665,
-0.03644825145602226,
-0.04043477773666382,
0.010188780725002289,
-0.031571872532367706,
0.004071063362061977,
-0.05004515498876572,
0.058623310178518295,
-0.05986909940838814,
-0.03422362729907036,
-0.03911779820919037,
0.00971716083586216,
0.023865774273872375,
0.03479313105344772,
-0.04520437493920326,
0.05648766830563545,
0.023136096075177193,
-0.04559590667486191,
0.05680801719427109,
-0.024364089593291283,
0.003879745490849018,
0.05655885860323906,
-0.042072102427482605,
-0.020288577303290367,
-0.039260175079107285,
-0.03986527398228645,
0.08172380924224854,
-0.07382194697856903,
-0.023616615682840347,
0.054423216730356216,
-0.03509568050503731,
-0.09211725741624832,
-0.001532766385935247,
0.01776140369474888,
-0.013418936170637608,
-0.0001550285378471017,
-0.0005625519552268088,
0.005583807826042175,
0.03203459456562996,
0.036394860595464706,
0.008404632098972797,
-0.05307064577937126,
-0.029365045949816704,
0.04826545715332031,
0.060723353177309036,
-0.004369162954390049,
0.04612981528043747,
0.022299638018012047,
-0.05937078222632408,
0.021854713559150696,
-0.0012402283027768135,
-0.019131772220134735,
-0.01316977757960558,
0.020982660353183746,
0.03443719074130058,
0.01659570075571537,
0.028065863996744156,
-0.04388739541172981,
-0.019042786210775375,
0.05997588112950325,
0.05413846671581268,
0.03982967883348465,
0.019665682688355446,
0.013276560232043266,
-0.0007736132247373462,
-0.013329951092600822,
0.020982660353183746,
0.05492153391242027,
0.013819368556141853,
0.0005408618599176407,
0.005850763060152531,
-0.0118261044844985,
-0.013579108752310276,
-0.0018230798887088895,
0.026125991716980934,
-0.0024915796238929033,
-0.03021930158138275,
-0.0345795676112175,
0.057733457535505295,
-0.03755166381597519,
0.029792172834277153,
-0.010117593221366405,
-0.03582535684108734,
0.08613746613264084,
0.016221962869167328,
-0.020163998007774353,
0.05552663281559944,
0.014477857388556004,
-0.09489358961582184,
0.014896086417138577,
0.07823559641838074,
-0.017236391082406044,
-0.03879745304584503,
-0.08200856298208237,
-0.00608212361112237,
-0.06499463319778442,
-0.019932636991143227,
0.01155025139451027,
0.048728179186582565,
-0.006985321640968323,
0.024025946855545044,
-0.10108694434165955,
-0.0805136188864708,
0.04047037288546562,
0.08656459301710129,
-0.022708969190716743,
-0.0068073514848947525,
-0.05638088658452034,
-0.029667595401406288,
0.006860742345452309,
-0.03545161709189415,
0.00610437011346221,
-0.06695230305194855,
-0.0297565795481205,
-0.013303255662322044,
0.00797305442392826,
0.0016439976170659065,
0.016230860725045204,
0.03822794929146767,
-0.0032168072648346424,
0.012751548551023006,
0.023064907640218735,
0.008885150775313377,
-0.04132462665438652,
0.021908104419708252,
-0.015091854147613049,
0.02738957852125168,
0.04086190462112427,
-0.03876186162233353,
-0.0014270966639742255,
-0.0025182750541716814,
-0.005984240211546421,
0.018010560423135757,
-0.006375774275511503,
-0.0118261044844985,
0.013819368556141853,
0.013143082149326801,
0.04410095885396004,
-0.006206702906638384,
-0.010767183266580105,
0.018455486744642258,
0.04911971092224121,
-0.011372281238436699,
0.0015361033147200942,
-0.04349585995078087,
0.018455486744642258,
0.006357977166771889,
-0.03719572350382805,
-0.03869067132472992,
-0.0005467014852911234,
0.029560811817646027,
0.025716660544276237,
0.002734063658863306,
0.022815750911831856,
0.008609297685325146,
-0.03336936980485916,
-0.016471121460199356,
-0.018241921439766884,
-0.00543253356590867,
0.06609804928302765,
-0.03659062460064888,
0.04232126101851463,
0.020163998007774353,
0.0019843652844429016,
0.0026739989407360554,
-0.009423510171473026,
0.06282339990139008,
-0.014655827544629574,
0.024275103583931923,
-0.03740928694605827,
-0.007723896764218807,
-0.025805646553635597,
0.006802902091294527,
0.0035193562507629395,
0.030610835179686546,
-0.08328994363546371,
-0.026054803282022476,
-0.07339482009410858,
0.08599509298801422,
-0.00006792056956328452,
-0.04353145509958267,
-0.01690714806318283,
-0.0345795676112175,
-0.021783525124192238,
-0.09240201115608215,
-0.033493947237730026,
-0.03176764026284218,
0.028510790318250656,
-0.05937078222632408,
-0.01655120775103569,
0.015029564499855042,
0.036555033177137375,
0.020982660353183746,
0.09083587676286697,
0.025716660544276237,
-0.0032568504102528095,
0.02461324818432331,
0.0028497441671788692,
-0.009290033020079136,
0.017708012834191322,
0.025805646553635597,
-0.03447278216481209,
-0.011256600730121136,
-0.05759108439087868,
0.0297565795481205,
0.011390077881515026,
-0.01256468053907156,
0.007016465999186039,
-0.06232508271932602,
-0.03361852839589119,
-0.048443425446748734,
-0.016097383573651314,
0.01155915018171072,
-0.033743105828762054,
-0.0004741231387015432,
0.03666181489825249,
-0.007568173110485077,
-0.008115430362522602,
-0.0472688265144825,
-0.002725165104493499,
-0.08535440266132355,
-0.001993263605982065,
-0.007416898850351572,
-0.059477563947439194,
-0.0025961368810385466,
0.02633955515921116,
0.027905691415071487,
0.043638236820697784,
0.010491330176591873,
-0.025787848979234695,
-0.034704145044088364,
-0.02633955515921116,
-0.05193163827061653,
0.03055744431912899,
0.03740928694605827,
-0.05463678017258644,
-0.03219476714730263,
0.010998544283211231,
0.008453574031591415,
-0.009654871188104153,
0.030272692441940308,
-0.010473532602190971,
-0.006998669356107712,
0.014273191802203655,
0.04709085449576378,
-0.03004133142530918,
-0.00011449865269241855,
-0.020021621137857437,
-0.027104826644062996,
-0.02224624715745449,
0.010962950065732002,
0.04516877979040146,
0.045489124953746796,
0.01536770723760128,
0.01370368804782629,
-0.013943946920335293,
0.019914839416742325,
0.03336936980485916,
0.057733457535505295,
-0.01621306501328945,
-0.002498253481462598,
-0.013507921248674393,
-0.004409206099808216,
-0.01986144855618477,
-0.02128520794212818,
0.0787339136004448,
-0.003330263076350093,
-0.029792172834277153,
0.047233231365680695,
-0.006882988847792149,
-0.01711181364953518,
-0.04947565123438835,
-0.0031611917074769735,
0.07058288902044296,
-0.045845065265893936,
-0.0350244902074337,
-0.0223352313041687,
-0.055740196257829666,
-0.01776140369474888,
0.007670505903661251,
-0.047411199659109116,
0.010838371701538563,
-0.020270779728889465,
0.025058172643184662,
0.09183250367641449,
-0.0021934800315648317,
0.049440059810876846,
0.04737560823559761,
-0.008635993115603924,
-0.03694656491279602,
0.0076393610797822475,
0.02310050278902054,
0.000027703528758138418,
-0.017360970377922058,
0.04079071804881096,
-0.027336187660694122,
-0.012707056477665901,
-0.0018575616413727403,
-0.03183882683515549,
-0.06837606430053711,
-0.037088941782712936,
-0.013143082149326801,
-0.019220756366848946,
0.09681566804647446,
0.03098457306623459,
-0.05367574468255043,
-0.018455486744642258,
-0.03424142301082611,
0.02993454970419407,
-0.014255395159125328,
0.009654871188104153,
0.054067276418209076,
0.02423951029777527,
0.010366750881075859,
-0.015136346220970154,
0.029720986261963844,
-0.01439777109771967,
-0.006015385035425425,
-0.02452426217496395,
-0.049582432955503464,
0.009628175757825375,
-0.024737825617194176,
-0.022442013025283813,
-0.03212358057498932,
-0.02617938257753849,
-0.05271470546722412,
-0.07104561477899551,
0.06414037942886353,
-0.02783450298011303,
-0.027158217504620552,
-0.04869258403778076,
0.013445631600916386,
0.04509758949279785,
-0.025787848979234695,
-0.0046539148315787315,
-0.02030637301504612,
-0.007585970219224691,
-0.010286664590239525,
0.05883687362074852,
0.04178734868764877,
-0.03073541447520256,
0.01068709697574377,
0.014904985204339027,
-0.036910973489284515,
-0.015830429270863533,
-0.01020657829940319,
-0.021819118410348892,
0.02137419395148754,
-0.045133184641599655,
-0.027282796800136566,
-0.06189795583486557,
0.06488785147666931,
0.005227867979556322,
-0.0196834784001112,
-0.023420847952365875,
-0.019505508244037628,
0.020181795582175255,
0.059833504259586334,
-0.025859037414193153,
-0.03794319927692413,
0.00903642550110817,
-0.0027407375164330006,
0.013730383478105068,
0.0227623600512743,
-0.004974260926246643,
-0.08677815645933151,
-0.059228405356407166,
0.0411466583609581,
0.024381887167692184,
0.01502066571265459,
-0.03529144451022148,
-0.031037963926792145,
0.03219476714730263,
-0.0030076925177127123,
-0.01751224510371685,
-0.06221830099821091,
0.0455247201025486,
-0.027781112119555473,
0.009227743372321129,
-0.016124079003930092,
-0.024755623191595078,
0.007723896764218807,
-0.0385127030313015,
0.10535822063684464,
0.033671919256448746,
0.00967266783118248,
0.040327996015548706,
0.03666181489825249,
0.05331980437040329,
0.026392947882413864,
0.03694656491279602,
-0.02600141242146492,
-0.009521393105387688,
0.028742151334881783,
0.000013608446352009196,
-0.019932636991143227,
0.008360139094293118,
0.02756754867732525,
-0.009521393105387688,
-0.05242995545268059,
0.04438571259379387,
-0.07204224169254303,
-0.015848226845264435,
0.09517834335565567,
0.025164954364299774,
0.10813455283641815,
0.03872626647353172
] |
725,817 | flask_admin.base | _prettify_class_name |
Split words in PascalCase string into separate words.
:param name:
String to prettify
| def _prettify_class_name(self, name):
"""
Split words in PascalCase string into separate words.
:param name:
String to prettify
"""
return h.prettify_class_name(name)
| (self, name) | [
-0.015966802835464478,
-0.016190355643630028,
0.010206028819084167,
0.0019851026590913534,
-0.02887265756726265,
-0.08391814678907394,
0.010627339594066143,
0.00227636587806046,
0.05041967332363129,
-0.013378754258155823,
-0.007407324388623238,
-0.013327165506780148,
-0.005958532448858023,
-0.01711036078631878,
-0.004789181053638458,
-0.025209836661815643,
0.0586395263671875,
0.013903242535889149,
-0.049697428941726685,
0.010163038037717342,
-0.0006110075046308339,
0.04656769335269928,
0.02264758199453354,
-0.03520091250538826,
-0.000559418520424515,
0.012656508013606071,
0.006779657676815987,
0.03473661094903946,
-0.037935130298137665,
-0.0567479282617569,
-0.05334305390715599,
0.02849433943629265,
-0.026843490079045296,
0.008189758285880089,
0.04835611209273338,
-0.03624988719820976,
0.030970612540841103,
-0.01725653000175953,
-0.04178711026906967,
-0.05413408577442169,
0.002996462630107999,
0.010868088342249393,
-0.07662689685821533,
-0.016181757673621178,
-0.0147630600258708,
0.0073600341565907,
0.07064257562160492,
0.011676316149532795,
-0.0002707080275285989,
-0.04711797833442688,
0.0018335599452257156,
-0.03382520377635956,
-0.019741401076316833,
-0.03432389721274376,
0.01124640740454197,
-0.031469304114580154,
0.05478754639625549,
-0.03600914031267166,
-0.01652568392455578,
0.04818414896726608,
-0.03028275817632675,
-0.04250935837626457,
0.06765040755271912,
-0.0009522474138066173,
-0.0015358482487499714,
0.03621549531817436,
0.02897583693265915,
0.03014518693089485,
-0.01824531890451908,
-0.005524324718862772,
0.031176967546343803,
-0.03683456405997276,
-0.002269917167723179,
0.05121070519089699,
-0.007385828997939825,
0.03447866439819336,
-0.048975180834531784,
-0.04134000465273857,
0.022303655743598938,
-0.025932082906365395,
-0.02409207448363304,
-0.00879592914134264,
-0.025313016027212143,
-0.050213318318128586,
0.027067042887210846,
-0.05165781080722809,
-0.061975616961717606,
-0.07841531932353973,
-0.02995602786540985,
0.07408183813095093,
-0.027514146640896797,
0.02928537130355835,
0.007802840322256088,
0.10118327289819717,
-0.04753068834543228,
0.015261753462255001,
0.012467348016798496,
-0.03437548875808716,
-0.03332651033997536,
0.037281669676303864,
0.025846101343631744,
0.03411754220724106,
-0.020532432943582535,
0.0072611551731824875,
-0.05341183766722679,
-0.07188071310520172,
-0.01509838830679655,
0.016637461259961128,
0.01814214140176773,
0.020377665758132935,
-0.020343272015452385,
-0.059499341994524,
-0.015321941114962101,
0.005064322613179684,
0.0601528026163578,
-0.0592242032289505,
0.021495427936315536,
-0.004535535350441933,
-0.027170220389962196,
0.012011644430458546,
0.020171308889985085,
-0.030901826918125153,
-0.014204178936779499,
-0.011848279275000095,
-0.07621418684720993,
0.03482259437441826,
0.008318730629980564,
0.004402263555675745,
0.027342183515429497,
0.0290962103754282,
0.03893251717090607,
-0.00582096166908741,
-0.03559642657637596,
-0.08797648549079895,
0.09389203041791916,
0.01838289014995098,
0.01453950721770525,
0.060943834483623505,
0.0050514256581664085,
0.05506268888711929,
0.030833041295409203,
0.0017959430115297437,
0.003361884970217943,
-0.002022719709202647,
-0.026671526953577995,
-0.030385935679078102,
0.021839354187250137,
0.024693947285413742,
-0.018726816400885582,
0.04670526459813118,
-0.021117107942700386,
0.0006615218007937074,
0.07587026059627533,
0.01827971078455448,
-0.003703662194311619,
-0.01848606765270233,
-0.03274183347821236,
-0.061666082590818405,
0.00897649023681879,
-0.02369655855000019,
0.01778101734817028,
-0.06424553692340851,
-0.03428950533270836,
0.013662493787705898,
0.04622376710176468,
0.0018378590466454625,
0.00301150931045413,
0.0035338483285158873,
0.015261753462255001,
-0.009182846173644066,
0.04037700966000557,
0.004922452848404646,
-0.037178490310907364,
0.09795036166906357,
0.025398997589945793,
0.018709620460867882,
-0.021340660750865936,
0.049387894570827484,
0.07112406939268112,
-0.001496081706136465,
-0.004849368240684271,
0.01853765733540058,
-0.02945733442902565,
-0.015915215015411377,
0.008052187040448189,
-0.025416193529963493,
0.06799433380365372,
0.03477100282907486,
0.031606875360012054,
-0.005846756044775248,
-0.027668913826346397,
0.0024461797438561916,
0.010214626789093018,
0.015760447829961777,
0.04154636338353157,
0.014023616909980774,
0.0036499234847724438,
0.020171308889985085,
0.02292272448539734,
-0.048975180834531784,
-0.021547015756368637,
0.03528689220547676,
-0.00913985539227724,
0.013266977854073048,
0.08900826424360275,
0.04134000465273857,
0.025777315720915794,
-0.006904331501573324,
-0.010420983657240868,
-0.054993901401758194,
-0.0012198655167594552,
0.0026632833760231733,
0.001195145770907402,
-0.0030136590357869864,
0.015493904240429401,
-0.06321375072002411,
0.05313669517636299,
-0.0147200683131814,
0.024865910410881042,
0.020394861698150635,
-0.022389637306332588,
0.054890722036361694,
0.032191552221775055,
-0.01202884130179882,
-0.026843490079045296,
-0.03509773313999176,
0.008065083995461464,
0.010816498659551144,
0.004526936914771795,
-0.005305071361362934,
0.00034930070978589356,
-0.05375576391816139,
-0.027772093191742897,
0.005025630816817284,
-0.029749670997262,
-0.031675662845373154,
-0.050797995179891586,
-0.04660208523273468,
-0.010455375537276268,
-0.07683325558900833,
0.00416581379249692,
0.020463647320866585,
-0.019827382639050484,
0.03318893909454346,
-0.0016852414701133966,
-0.06369525194168091,
-0.01494362112134695,
-0.00019775793771259487,
0.027806485071778297,
0.03992990776896477,
-0.015777643769979477,
-0.04636133834719658,
-0.005416847765445709,
-0.00008524280565325171,
-0.005231987219303846,
0.0052448841743171215,
-0.028064429759979248,
0.032569870352745056,
-0.019569437950849533,
0.04876882582902908,
-0.0594305582344532,
0.009414996951818466,
0.015227360650897026,
0.060737479478120804,
0.04481366649270058,
0.006938723847270012,
0.028339572250843048,
-0.0001583944249432534,
-0.00888191070407629,
-0.03148650377988815,
0.07291249185800552,
0.012742489576339722,
-0.0294057447463274,
0.0008404712425544858,
-0.04856247082352638,
-0.021426642313599586,
-0.022372441366314888,
0.026585545390844345,
-0.043678708374500275,
-0.02992163598537445,
0.03501175343990326,
-0.04560469835996628,
-0.03676578029990196,
0.037969522178173065,
0.07277491688728333,
-0.01833130046725273,
0.02417805604636669,
-0.055165864527225494,
-0.01209762692451477,
0.0030566498171538115,
0.01446212362498045,
-0.04839050769805908,
0.04154636338353157,
-0.049525465816259384,
0.024831518530845642,
-0.019380277022719383,
0.03931083902716637,
0.02340422198176384,
-0.044710490852594376,
-0.05282716080546379,
0.006594797130674124,
0.038313448429107666,
0.04096168652176857,
-0.015304744243621826,
-0.04515759274363518,
0.020343272015452385,
-0.061390940099954605,
0.01855485327541828,
-0.013696886599063873,
-0.013447539880871773,
-0.07490726560354233,
0.021340660750865936,
-0.006986014079302549,
0.03556203469634056,
-0.0148576395586133,
0.02397170104086399,
0.004193758126348257,
0.05262080579996109,
0.025828905403614044,
0.06400478631258011,
-0.031056594103574753,
-0.038382235914468765,
-0.020807573571801186,
-0.012966041453182697,
0.010696124285459518,
0.009234435856342316,
0.0033382398542016745,
0.031847625970840454,
0.024917500093579292,
-0.020687200129032135,
-0.0590522401034832,
-0.009776120074093342,
-0.004617217928171158,
-0.012398562394082546,
-0.0295949038118124,
0.0006486244965344667,
0.005072921048849821,
0.0012961742468178272,
-0.0071020894683897495,
-0.04268132150173187,
0.03893251717090607,
-0.0294401366263628,
-0.04199346527457237,
0.031882017850875854,
0.000005940630671830149,
0.025106659159064293,
-0.03329211845993996,
0.05114192143082619,
0.038175880908966064,
-0.016241945326328278,
-0.01204603724181652,
-0.06761601567268372,
0.060462336987257004,
0.021994121372699738,
0.061287764459848404,
0.0006394889787770808,
0.027944056317210197,
-0.01711895875632763,
-0.012570526450872421,
-0.007686764933168888,
0.026172831654548645,
-0.027961252257227898,
0.026619937270879745,
0.010059859603643417,
0.014823246747255325,
-0.0287694800645113,
-0.01826251484453678,
0.005717783700674772,
0.0034629134461283684,
-0.00822415016591549,
-0.044022634625434875,
0.030695470049977303,
-0.025622550398111343,
-0.06809751689434052,
-0.06706573069095612,
0.04680844396352768,
0.061081405729055405,
0.03384239971637726,
-0.010077056474983692,
0.010506965219974518,
0.013911840505897999,
0.027135828509926796,
0.05096995830535889,
0.013120808638632298,
-0.014169786125421524,
-0.008353123441338539,
-0.0005932737840339541,
-0.01826251484453678,
0.04078972339630127,
0.008112374693155289,
0.006336851976811886,
0.01766064390540123,
-0.031108181923627853,
0.01774662546813488,
-0.014358945190906525,
-0.02364497072994709,
-0.06324814260005951,
-0.05416847765445709,
-0.00902807991951704,
0.009578362107276917,
0.012054636143147945,
-0.06390160322189331,
-0.015270351432263851,
0.0006110075046308339,
-0.044607311487197876,
0.0020248692017048597,
0.02899303287267685,
0.019517848268151283,
-0.012776882387697697,
0.04171832650899887,
0.01138397864997387,
0.019810186699032784,
-0.056060075759887695,
-0.062181971967220306,
0.07415062934160233,
0.03607792407274246,
0.01177949458360672,
0.025381801649928093,
-0.0009834157535806298,
-0.005640400107949972,
-0.028339572250843048,
-0.015407922677695751,
0.04653330147266388,
0.05337744578719139,
0.007321342825889587,
-0.007884522899985313,
-0.0286147128790617,
-0.010911079123616219,
0.07841531932353973,
-0.043609924614429474,
-0.01764344610273838,
0.02913060411810875,
-0.043988242745399475,
-0.07401305437088013,
0.04746190458536148,
-0.0017411296721547842,
-0.00005941470590187237,
0.0590866319835186,
0.030987808480858803,
-0.024487590417265892,
-0.009165650233626366,
0.03604353219270706,
-0.019792988896369934,
0.01855485327541828,
0.055509790778160095,
-0.00011358990013832226,
-0.049387894570827484,
-0.04192468151450157,
-0.02916499599814415,
-0.055441007018089294,
-0.013052023947238922,
0.03373922407627106,
-0.021031126379966736,
-0.049284715205430984,
0.061631690710783005,
-0.006680778693407774,
-0.043781887739896774,
-0.032088372856378555,
-0.000922153820283711,
0.022080102935433388,
-0.0301795806735754,
0.04794340208172798,
0.0574357807636261,
0.07442577183246613,
-0.031710054725408554,
0.000764699827414006,
0.0023816933389753103,
0.04808097332715988,
0.038038309663534164,
-0.05100435018539429,
0.058158028870821,
-0.012553329579532146,
0.03649063780903816,
0.02307749167084694,
-0.04825293645262718,
0.038622982800006866,
-0.02338702417910099,
0.005029929801821709,
0.011435567401349545,
0.0018324851989746094,
0.008202655240893364,
-0.03879494592547417,
-0.022252066060900688,
-0.007342838216573,
0.02381693385541439,
-0.01146996021270752,
-0.008077981881797314,
0.031658466905355453,
0.012372768484055996,
-0.07215584814548492,
-0.0046860030852258205,
0.04780583083629608,
-0.010335001163184643,
0.01841728202998638,
-0.0026267413049936295,
0.03427230939269066,
0.033550065010786057,
0.04711797833442688,
-0.043059639632701874,
0.01189127005636692,
-0.03635306656360626,
-0.006663582753390074,
0.003656372195109725,
-0.09141575545072556,
0.026069654151797295,
0.04728994145989418,
0.027067042887210846,
-0.0012015943648293614,
0.019775792956352234,
0.009801914915442467,
-0.032707441598176956,
-0.043816279619932175,
0.00144341797567904,
0.003045902121812105,
-0.012381366454064846,
-0.04663648083806038,
-0.033412493765354156,
0.025983672589063644,
-0.03497735783457756,
0.03628428280353546,
0.001988327130675316,
-0.06407357007265091,
-0.03583717718720436,
0.03655942156910896,
-0.02304309792816639,
0.020429253578186035,
0.003920766059309244,
0.013249781914055347,
-0.004707498475909233,
0.04213103652000427,
-0.010928275063633919,
-0.0283051785081625,
0.03532128781080246,
-0.00839181523770094,
0.007218164391815662,
0.0017712232656776905,
-0.11322071403265,
-0.0008216627174988389,
-0.0010145842097699642,
0.06610273569822311,
0.06713452190160751,
-0.04828732833266258,
-0.013817260973155499,
0.00451403995975852,
-0.02276795729994774,
0.021701782941818237,
-0.0147200683131814,
0.024865910410881042,
-0.06400478631258011,
-0.0036585216876119375,
0.0040733832865953445,
-0.043678708374500275,
-0.06362646818161011,
-0.0602215901017189,
0.0579860657453537,
-0.02264758199453354,
-0.06434871256351471,
-0.01720494031906128,
0.014814648777246475,
0.03937962278723717,
-0.011289398185908794,
-0.011598932556807995,
0.02292272448539734,
-0.02871789038181305,
-0.050935566425323486,
0.021289071068167686,
-0.04041140526533127,
0.05179538205265999,
-0.031211361289024353,
0.009905093349516392,
0.07525119185447693,
0.026877881959080696,
0.07126164436340332,
0.07380670309066772,
-0.0585707426071167,
0.08350543677806854,
0.06544927507638931,
0.07401305437088013,
0.014659881591796875,
-0.0032995480578392744,
0.016095776110887527,
0.02835676819086075,
-0.021736176684498787,
-0.000917317345738411,
-0.06971397250890732,
-0.04244057089090347,
-0.013395950198173523,
-0.0601871982216835,
0.025966476649045944,
0.01772942766547203,
-0.019036350771784782,
-0.01817653328180313,
0.021357856690883636,
-0.011177622713148594,
-0.021976925432682037,
-0.019603829830884933,
0.006422833539545536,
0.01812494359910488,
-0.025846101343631744,
-0.002527862321585417,
0.02419525384902954,
0.03475380688905716,
-0.0009533222182653844,
0.07566390186548233,
0.09134697169065475,
0.03683456405997276,
0.008194057270884514,
0.002016270998865366,
-0.01764344610273838,
0.07229342311620712,
-0.007957607507705688,
-0.005760774482041597,
-0.00045086658792570233,
0.02950892224907875,
-0.04453852400183678,
0.07401305437088013,
0.03377361595630646,
-0.07697082310914993,
0.011229211464524269,
-0.008684152737259865,
-0.010696124285459518,
0.03473661094903946,
0.013972028158605099,
0.02918219193816185,
-0.019139528274536133,
-0.020790377631783485,
0.019878970459103584,
-0.08763255923986435,
0.03673138469457626,
-0.08488114178180695,
-0.030747059732675552,
0.024659553542733192,
-0.04120243713259697,
-0.07697082310914993,
-0.021736176684498787,
0.06256029009819031,
-0.021237483248114586,
-0.01781541109085083,
-0.07236220687627792,
-0.026671526953577995,
-0.00889050867408514,
-0.026809096336364746,
0.011813887394964695,
0.02393730729818344,
-0.026035262271761894,
0.0023730951361358166,
-0.006444328930228949,
0.0024698246270418167,
0.009853503666818142,
0.013619503006339073,
-0.04587984085083008,
-0.004129271488636732,
0.002738517476245761,
0.04247496649622917,
-0.009526773355901241,
0.027531344443559647,
-0.01853765733540058,
-0.026757508516311646,
-0.02459076978266239,
-0.03375642001628876,
-0.02933695912361145,
-0.0600496269762516,
-0.021942531690001488,
-0.056060075759887695,
0.016775032505393028,
0.04550152271986008,
0.009096864610910416,
0.025605352595448494,
-0.007673867512494326,
-0.05306791141629219,
-0.02897583693265915,
0.08887069672346115,
0.020755983889102936,
-0.13172398507595062,
-0.0590866319835186,
-0.04753068834543228,
0.0591898076236248,
0.009260229766368866,
0.06837265938520432,
-0.04563909024000168,
-0.0028653405606746674,
-0.012966041453182697,
0.02428123541176319,
-0.05224248766899109,
0.08185458928346634,
0.056060075759887695,
-0.04041140526533127,
-0.031933605670928955,
0.016061384230852127,
-0.00602301862090826,
-0.06964518874883652,
0.037591204047203064,
0.008348824456334114,
0.04725554957985878,
0.026723114773631096,
0.032707441598176956,
0.04670526459813118,
-0.06383281946182251,
0.010249019600450993,
-0.01140117458999157,
0.01754886656999588,
-0.026516759768128395,
-0.012897256761789322,
-0.001840008539147675,
0.004357123281806707,
0.044744882732629776,
0.037522416561841965,
0.0035574932117015123,
0.015855027362704277,
0.025381801649928093,
0.021117107942700386,
-0.000788882200140506,
0.00896789226680994,
0.024848714470863342,
0.050454068928956985,
-0.026430778205394745,
-0.032930996268987656,
0.00071687251329422,
0.07208706438541412,
0.061150193214416504,
0.014049411751329899,
0.003761699888855219,
0.026482366025447845,
-0.002031317912042141,
-0.06438310444355011,
0.011005658656358719,
-0.0147802559658885,
0.008838919922709465,
-0.03583717718720436,
0.002409637439996004,
-0.04216543212532997,
0.003882074262946844,
-0.08219851553440094,
0.06359207630157471,
0.002910480834543705,
-0.0003995462611783296,
0.038279056549072266,
-0.0024741236120462418,
0.026860686019062996,
0.007682465948164463,
-0.027634521946310997,
-0.004961144644767046,
-0.0007394427084363997,
-0.013387352228164673,
-0.02247561886906624,
-0.013421745039522648,
0.055337827652692795,
0.02871789038181305,
0.00585105549544096,
-0.025553764775395393,
0.038898125290870667,
0.037281669676303864,
0.003527399618178606,
-0.032225944101810455,
0.032638657838106155,
-0.039001304656267166,
0.05262080579996109,
-0.037488024681806564,
-0.003836933756247163,
-0.04728994145989418,
-0.001300473348237574,
-0.0021559912711381912,
0.01673204079270363,
0.032449498772621155,
0.031176967546343803,
0.01658587157726288,
0.06403917819261551,
0.015055397525429726
] |
725,818 | flask_admin.base | _run_view |
This method will run actual view function.
While it is similar to _handle_view, can be used to change
arguments that are passed to the view.
:param fn:
View function
:param kwargs:
Arguments
| def _run_view(self, fn, *args, **kwargs):
"""
This method will run actual view function.
While it is similar to _handle_view, can be used to change
arguments that are passed to the view.
:param fn:
View function
:param kwargs:
Arguments
"""
try:
return fn(self, *args, **kwargs)
except TypeError:
return fn(cls=self, **kwargs)
| (self, fn, *args, **kwargs) | [
0.033777378499507904,
-0.07123120874166489,
0.011948460713028908,
0.025328615680336952,
0.028209680691361427,
0.04280942678451538,
-0.0004200630937702954,
0.04570816457271576,
-0.01127680204808712,
-0.014175540767610073,
0.010393040254712105,
0.06437321752309799,
0.03892087563872337,
-0.014741148799657822,
0.017171494662761688,
0.029800452291965485,
0.019283683970570564,
0.040087439119815826,
0.010419553145766258,
-0.02730824239552021,
-0.009032046422362328,
0.008895063772797585,
0.02762639708817005,
0.016004927456378937,
-0.021987996995449066,
0.02200567163527012,
0.05040977895259857,
-0.03031303361058235,
0.05323781818151474,
0.025116512551903725,
0.022907108068466187,
-0.004524860996752977,
-0.011674494482576847,
0.05256615951657295,
-0.007750591728836298,
0.0018978787120431662,
-0.019071582704782486,
0.033954132348299026,
0.013981113210320473,
-0.0256997961550951,
-0.07770034670829773,
-0.025452343747019768,
0.05316711589694023,
-0.012416854500770569,
-0.0506218820810318,
-0.03867341950535774,
0.01580166257917881,
0.02554071880877018,
-0.03513837233185768,
0.013185727410018444,
0.006871248595416546,
-0.01155076827853918,
0.011303314939141273,
0.0021663212683051825,
0.013813198544085026,
0.07190287113189697,
-0.03259313851594925,
0.03153262287378311,
0.04609702154994011,
-0.002839085180312395,
-0.02131633646786213,
0.022076372057199478,
-0.016968227922916412,
0.018894828855991364,
0.012187076732516289,
0.01979626715183258,
-0.041996367275714874,
0.03008325584232807,
0.0029959529638290405,
0.013380154967308044,
0.015421644784510136,
0.0329996682703495,
0.015704449266195297,
0.04581421613693237,
0.06720125675201416,
0.0013112816959619522,
-0.05440438166260719,
-0.015094653703272343,
0.017312895506620407,
0.06044931337237358,
0.07423599809408188,
-0.05175309628248215,
-0.0002607097558211535,
-0.014122514985501766,
0.008015720173716545,
-0.043445736169815063,
-0.02615935169160366,
-0.08505324274301529,
0.0015167563688009977,
0.027644071727991104,
-0.025664445012807846,
-0.035014647990465164,
-0.05988370627164841,
-0.05896459519863129,
-0.028722262009978294,
0.010613980703055859,
0.03183310478925705,
-0.03015395626425743,
-0.04302152991294861,
-0.019743241369724274,
0.06614074110984802,
0.047369636595249176,
0.021510764956474304,
0.0018691563745960593,
0.0352797769010067,
-0.0033715516328811646,
-0.04386994242668152,
0.005797477904707193,
-0.03648168966174126,
0.053273167461156845,
-0.007565001957118511,
0.04673333093523979,
-0.05804548040032387,
0.057939428836107254,
-0.06497417390346527,
-0.01254058163613081,
-0.012363828718662262,
0.0021409131586551666,
-0.04033489152789116,
0.03441368788480759,
-0.013645283877849579,
0.0049932547844946384,
-0.035173725336790085,
-0.030772589147090912,
-0.0141932163387537,
0.04998557269573212,
-0.0272198673337698,
-0.017224518582224846,
0.06373690813779831,
-0.0019950924906879663,
0.04546071216464043,
-0.016853339970111847,
-0.0033030600752681494,
0.003146192291751504,
-0.015138841234147549,
0.05256615951657295,
0.01733057014644146,
0.002084573497995734,
0.011762870475649834,
0.05040977895259857,
-0.022306149825453758,
0.040653046220541,
0.06988789141178131,
0.023455040529370308,
0.01434345543384552,
-0.00701706949621439,
-0.019124608486890793,
0.048430152237415314,
0.05868178978562355,
0.020361874252557755,
0.05475788936018944,
0.04136005789041519,
0.06257034093141556,
0.052813611924648285,
-0.03676449507474899,
0.019442761316895485,
0.06020186096429825,
0.012187076732516289,
0.028209680691361427,
-0.02469230815768242,
-0.01277035940438509,
0.013769010081887245,
0.026583557948470116,
-0.01534210704267025,
0.055182091891765594,
-0.03114376962184906,
0.005510255694389343,
0.020998183637857437,
0.026212377473711967,
0.06196938455104828,
-0.0011262440821155906,
0.022818733006715775,
-0.02108655869960785,
0.012664307840168476,
0.05076328292489052,
0.02631842903792858,
-0.003736103419214487,
-0.029552998021245003,
-0.0001811711845220998,
0.007958276197314262,
0.02048560045659542,
-0.02653053216636181,
-0.04493045434355736,
0.009111585095524788,
0.0004567944270092994,
0.05585375055670738,
-0.005046280566602945,
-0.01702125370502472,
0.007989207282662392,
0.0023419689387083054,
-0.004427647218108177,
0.007162890397012234,
0.002297780942171812,
-0.043375033885240555,
-0.05482858791947365,
-0.008917157538235188,
-0.07169076800346375,
-0.028262706473469734,
0.059105996042490005,
-0.04174891114234924,
0.033795055001974106,
-0.01763105019927025,
0.03499697148799896,
0.010340014472603798,
-0.03259313851594925,
0.041466109454631805,
0.0168710146099329,
0.03512069955468178,
-0.016455646604299545,
-0.007503138389438391,
0.007379411719739437,
-0.06589328497648239,
0.0030136280693113804,
0.07275127619504929,
0.03966323286294937,
-0.008811105974018574,
-0.011135400272905827,
-0.003417949192225933,
0.0010583049152046442,
-0.011524255387485027,
0.06246429309248924,
0.06338340044021606,
-0.01626121811568737,
0.01626121811568737,
0.049667418003082275,
-0.04058234766125679,
0.048218049108982086,
-0.05260150879621506,
-0.033247124403715134,
-0.013901574537158012,
-0.04892506077885628,
-0.024409504607319832,
0.007861061953008175,
0.04121865704655647,
0.01579282432794571,
-0.04270337522029877,
0.017816640436649323,
-0.0012571513652801514,
-0.02562909573316574,
-0.05433368310332298,
0.02762639708817005,
0.006031674798578024,
0.026831012219190598,
-0.011055861599743366,
-0.014900226145982742,
0.006036093924194574,
-0.04998557269573212,
0.06097957119345665,
-0.06066141650080681,
-0.029358569532632828,
0.032946642488241196,
0.0007340747397392988,
-0.006226102821528912,
0.019124608486890793,
-0.02921716868877411,
0.03856736794114113,
0.03994603827595711,
0.012187076732516289,
0.023278288543224335,
0.04111260548233986,
0.026336105540394783,
-0.04256197437644005,
0.03771895915269852,
0.0035129536408931017,
-0.0025120931677520275,
-0.029641374945640564,
-0.03775430843234062,
-0.008311781100928783,
0.012204752303659916,
-0.028492484241724014,
0.09417366981506348,
0.037011947482824326,
0.02202334627509117,
0.023048510774970055,
-0.06165122985839844,
-0.04234987124800682,
-0.0010687995236366987,
-0.02025582268834114,
-0.061792630702257156,
0.02499278634786606,
0.05175309628248215,
-0.05574770271778107,
-0.05309641361236572,
0.041925664991140366,
-0.01596957817673683,
-0.044541601091623306,
0.013406667858362198,
0.0007523022941313684,
0.005178844556212425,
-0.01642029546201229,
0.060555364936590195,
-0.003495278302580118,
0.02193497121334076,
0.014546721242368221,
-0.03252243623137474,
0.01809944398701191,
-0.08809338510036469,
-0.0054042041301727295,
-0.00028998436755500734,
0.025558393448591232,
-0.01671193726360798,
-0.07101910561323166,
0.01422856654971838,
0.005819572135806084,
0.059494853019714355,
0.0023287127260118723,
-0.0207153782248497,
0.016367269679903984,
0.011135400272905827,
-0.002016081940382719,
-0.002467905171215534,
-0.028474807739257812,
-0.015200704336166382,
-0.005731196142733097,
-0.019760916009545326,
0.04570816457271576,
-0.006173077039420605,
-0.0021011438220739365,
-0.006703333929181099,
0.05592445284128189,
-0.04051164537668228,
0.0368351973593235,
-0.019849292933940887,
0.09933483600616455,
0.021987996995449066,
-0.014847200363874435,
0.02018512226641178,
-0.023189911618828773,
-0.003075491404160857,
0.03158564865589142,
-0.01642029546201229,
0.006283547263592482,
0.03722405061125755,
-0.012955949641764164,
-0.07777104526758194,
-0.047899894416332245,
0.010393040254712105,
0.03351224958896637,
0.011480066925287247,
0.02016744576394558,
0.03856736794114113,
0.022765707224607468,
0.0005274954019114375,
0.034502062946558,
-0.00977440644055605,
0.04592026770114899,
0.01933670975267887,
-0.033954132348299026,
0.081306092441082,
-0.07183216512203217,
-0.01664123684167862,
-0.081306092441082,
-0.02087445557117462,
-0.04570816457271576,
-0.03715335205197334,
0.013857387006282806,
0.010737706907093525,
0.012602444738149643,
-0.024886734783649445,
-0.09162843227386475,
-0.005302571225911379,
-0.030648862943053246,
-0.04493045434355736,
-0.023684818297624588,
0.024356478825211525,
-0.0031329358462244272,
-0.02630075439810753,
-0.041996367275714874,
0.0329996682703495,
0.010720032267272472,
0.015138841234147549,
-0.016367269679903984,
0.021740542724728584,
0.032328009605407715,
0.014882550574839115,
-0.03934507817029953,
0.02630075439810753,
0.01664123684167862,
-0.049596719443798065,
0.08554815500974655,
-0.009686030447483063,
-0.012178239412605762,
0.07770034670829773,
-0.0544750839471817,
0.006018418353050947,
-0.04592026770114899,
-0.053662024438381195,
0.0367998443543911,
-0.0460263192653656,
-0.061474479734897614,
0.01763105019927025,
-0.008718310855329037,
-0.043693188577890396,
0.002122133271768689,
0.013459693640470505,
-0.011020511388778687,
0.00216742604970932,
0.025293266400694847,
0.005956555251032114,
0.010030698031187057,
0.010004185140132904,
-0.0001705384347587824,
0.002529768506065011,
0.047440338879823685,
0.05482858791947365,
0.04213776811957359,
-0.0027330336160957813,
0.024144375696778297,
0.017966879531741142,
-0.015050465241074562,
0.008970183320343494,
-0.035244423896074295,
-0.06759011000394821,
0.010172099806368351,
-0.025805847719311714,
0.06889807432889938,
0.0009765569120645523,
0.03344155102968216,
-0.0506218820810318,
-0.03596910834312439,
0.04786454513669014,
0.04998557269573212,
0.03176240250468254,
0.05023302510380745,
0.04471835121512413,
-0.00855481531471014,
0.03284059092402458,
-0.007352898828685284,
0.05433368310332298,
0.03308804705739021,
-0.04535466060042381,
-0.029093442484736443,
-0.04655657708644867,
0.022801056504249573,
0.030737239867448807,
-0.002945136511698365,
-0.027644071727991104,
-0.026371454820036888,
0.028810638934373856,
0.05178844928741455,
-0.03245173767209053,
0.008488533087074757,
0.01963718980550766,
-0.04864225536584854,
0.027820825576782227,
-0.031179120764136314,
-0.02209404669702053,
-0.02062700316309929,
-0.0034687654115259647,
-0.028492484241724014,
0.045071858912706375,
0.06585793942213058,
-0.04280942678451538,
0.0017001369269564748,
-0.0036897058598697186,
-0.029429271817207336,
-0.062393590807914734,
0.01871807686984539,
-0.011789383366703987,
0.04203171655535698,
-0.02423275075852871,
0.00699939439073205,
-0.06352480500936508,
-0.08180100470781326,
-0.01461742166429758,
0.04040559381246567,
-0.010410714894533157,
0.008581328205764294,
-0.06988789141178131,
-0.048606906086206436,
-0.011179587803781033,
-0.03743615373969078,
-0.019212983548641205,
-0.04542536288499832,
0.007246847730129957,
0.04945531487464905,
0.002115505049005151,
-0.05691426619887352,
-0.030189307406544685,
0.017675237730145454,
-0.02393227256834507,
-0.005921204574406147,
0.026053300127387047,
0.06652959436178207,
-0.04270337522029877,
0.0011323199141770601,
0.03276989236474037,
0.018824128434062004,
0.022341500967741013,
-0.032946642488241196,
0.0058725979179143906,
0.025558393448591232,
0.0036278425250202417,
0.012063349597156048,
-0.02730824239552021,
-0.0029142049606889486,
-0.0073484801687300205,
0.02016744576394558,
-0.024656957015395164,
-0.01986696757376194,
0.029093442484736443,
-0.0024546487256884575,
0.05967160314321518,
0.034325312823057175,
0.004078560974448919,
-0.013291778974235058,
-0.0013598885852843523,
0.028580859303474426,
-0.05433368310332298,
-0.052283354103565216,
-0.035792358219623566,
0.020573977380990982,
-0.009465089999139309,
-0.030648862943053246,
0.0172598697245121,
-0.000639622681774199,
-0.03036605939269066,
-0.06373690813779831,
-0.05076328292489052,
0.006181914359331131,
0.04171356186270714,
-0.01618168130517006,
0.013521556742489338,
0.0003488097863737494,
0.03867341950535774,
0.02087445557117462,
0.01848829910159111,
0.065999336540699,
0.060944221913814545,
0.032186608761548996,
-0.03229266032576561,
0.01786082796752453,
0.009615329094231129,
-0.019973019137978554,
0.03185077756643295,
-0.00431275786831975,
-0.08123539388179779,
-0.05730312317609787,
-0.022907108068466187,
0.04687473177909851,
-0.024126699194312096,
-0.013733659870922565,
-0.019672539085149765,
-0.004129377659410238,
-0.03467881679534912,
-0.10336479544639587,
0.028209680691361427,
-0.023949947208166122,
0.03437833860516548,
-0.034095533192157745,
-0.04807664826512337,
-0.005642819683998823,
0.08724497258663177,
0.09686030447483063,
-0.001368726254440844,
0.07939717173576355,
-0.024957437068223953,
0.032628487795591354,
0.015545371919870377,
-0.038779471069574356,
0.016924040392041206,
-0.005284896120429039,
-0.0005037442897446454,
0.04051164537668228,
-0.04256197437644005,
0.03319409862160683,
0.04655657708644867,
0.004193450324237347,
-0.01257593184709549,
-0.06684774905443192,
-0.02117493562400341,
-0.0021011438220739365,
-0.026194702833890915,
-0.023490391671657562,
-0.02900506556034088,
-0.01871807686984539,
0.0036631932016462088,
-0.009686030447483063,
0.012469880282878876,
-0.05323781818151474,
-0.08625516295433044,
-0.07713473588228226,
0.028333406895399094,
-0.0018835176015272737,
-0.08710357546806335,
-0.000399349897634238,
0.007604771293699741,
0.0051655881106853485,
0.01579282432794571,
-0.038319915533065796,
-0.018700402230024338,
-0.06433786451816559,
-0.029270194470882416,
-0.027873851358890533,
0.030931666493415833,
0.01368947234004736,
-0.07140795886516571,
-0.007503138389438391,
0.01265547052025795,
-0.024957437068223953,
-0.03496162220835686,
-0.0005435135681182146,
0.028739936649799347,
-0.014529045671224594,
0.035792358219623566,
0.042915478348731995,
-0.03052513673901558,
0.04355178773403168,
-0.030896315351128578,
0.0071982406079769135,
-0.013813198544085026,
0.019884642213582993,
0.09876923263072968,
0.04956136643886566,
0.017604537308216095,
-0.02645983174443245,
-0.020892132073640823,
0.06044931337237358,
0.023949947208166122,
0.013442019000649452,
-0.029058091342449188,
0.025134189054369926,
-0.038991574198007584,
0.0069154370576143265,
0.00368307763710618,
0.048606906086206436,
0.05804548040032387,
-0.01855899952352047,
-0.01254058163613081,
-0.009579978883266449,
0.0036278425250202417,
-0.026477506384253502,
-0.004476253874599934,
-0.011974973604083061,
0.041536808013916016,
-0.0882347896695137,
-0.032098233699798584,
0.03722405061125755,
-0.05931809917092323,
-0.02868691086769104,
0.04694543406367302,
-0.03158564865589142,
-0.0027153585106134415,
-0.053131766617298126,
0.04288012906908989,
0.011338665150105953,
-0.01077305804938078,
0.012098700739443302,
0.07352899014949799,
0.013371317647397518,
-0.0036897058598697186,
0.01009256113320589,
-0.010110235773026943,
0.027644071727991104,
-0.0013256428064778447,
0.03566863015294075,
0.021387038752436638,
-0.05967160314321518,
0.027343593537807465,
0.001723335706628859,
-0.08017487823963165,
-0.03257546201348305,
-0.030860966071486473,
-0.08392202854156494,
0.03335317596793175,
-0.028245029971003532,
-0.02338434010744095,
-0.015465833246707916,
-0.02707846462726593,
0.0042111254297196865,
-0.00816596020013094,
-0.013212240301072598,
0.004560211207717657,
0.037011947482824326,
-0.0006357562378980219,
0.005046280566602945,
-0.007202659733593464,
-0.019442761316895485,
-0.035085346549749374,
-0.03651704266667366,
-0.06235824152827263,
-0.009482765570282936,
-0.04896041005849838,
-0.027343593537807465,
-0.06783756613731384,
-0.024144375696778297,
-0.09141632914543152,
-0.011974973604083061,
0.031567975878715515,
-0.043233633041381836,
-0.02653053216636181,
-0.0667063519358635,
-0.003340620081871748,
-0.005474905017763376,
-0.03743615373969078,
-0.0038112231995910406,
-0.031567975878715515,
0.003866458311676979,
-0.004979998338967562,
0.05730312317609787,
0.0015244892565533519,
-0.010145586915314198,
0.0065089063718914986,
0.0018437482649460435,
-0.008174797520041466,
-0.022270800545811653,
-0.05362667143344879,
0.0038443643134087324,
0.0011831362498924136,
-0.05348527058959007,
0.018700402230024338,
-0.03867341950535774,
0.06801431626081467,
0.05535884574055672,
-0.047369636595249176,
-0.014202053658664227,
-0.00831619929522276,
0.02676030993461609,
0.02999487891793251,
-0.05433368310332298,
-0.04270337522029877,
-0.023295963183045387,
0.0368351973593235,
0.00832061842083931,
0.04263267293572426,
0.005479323677718639,
-0.06988789141178131,
0.009085072204470634,
0.03489091992378235,
-0.008143865503370762,
0.011515418067574501,
-0.016384946182370186,
0.017277544364333153,
-0.03637563809752464,
-0.06582258641719818,
-0.025823522359132767,
-0.042526621371507645,
-0.01588120125234127,
-0.05299036204814911,
-0.01963718980550766,
-0.026212377473711967,
-0.0028788545168936253,
-0.04037024453282356,
-0.048041295260190964,
0.08604305982589722,
0.05415692925453186,
0.03690589591860771,
0.02377319522202015,
0.03257546201348305,
0.011108887381851673,
0.02615935169160366,
0.06352480500936508,
-0.013371317647397518,
0.06034326180815697,
0.07395319640636444,
0.0035637698601931334,
0.013530394993722439,
0.00007221991836559027,
0.02600027434527874,
-0.050904687494039536,
-0.02767942287027836,
-0.0006777349044568837,
-0.0491018109023571,
-0.008647610433399677,
0.06854457408189774,
0.03920367732644081,
0.07635702937841415,
0.058186884969472885
] |
725,819 | flask_admin.base | create_blueprint |
Create Flask blueprint.
| def create_blueprint(self, admin):
"""
Create Flask blueprint.
"""
# Store admin instance
self.admin = admin
# If the static_url_path is not provided, use the admin's
if not self.static_url_path:
self.static_url_path = admin.static_url_path
# Generate URL
self.url = self._get_view_url(admin, self.url)
# If we're working from the root of the site, set prefix to None
if self.url == '/':
self.url = None
# prevent admin static files from conflicting with flask static files
if not self.static_url_path:
self.static_folder = 'static'
self.static_url_path = '/static/admin'
# If name is not provided, use capitalized endpoint name
if self.name is None:
self.name = self._prettify_class_name(self.__class__.__name__)
# Create blueprint and register rules
self.blueprint = Blueprint(self.endpoint, __name__,
url_prefix=self.url,
subdomain=self.admin.subdomain,
template_folder=op.join('templates', self.admin.template_mode),
static_folder=self.static_folder,
static_url_path=self.static_url_path)
for url, name, methods in self._urls:
self.blueprint.add_url_rule(url,
name,
getattr(self, name),
methods=methods)
return self.blueprint
| (self, admin) | [
0.010245272889733315,
0.0003790058835875243,
0.013586523942649364,
-0.042457886040210724,
-0.010116052813827991,
-0.013281934894621372,
0.020342865958809853,
0.0526108592748642,
-0.06328070908784866,
0.021727362647652626,
0.010337572544813156,
-0.012220487929880619,
-0.021764282137155533,
-0.008916156366467476,
0.008163913153111935,
0.02244730107486248,
0.052721619606018066,
0.008994610980153084,
0.047589752823114395,
-0.03189879655838013,
-0.00580103974789381,
0.002038670936599374,
0.03562770411372185,
0.02451481483876705,
-0.05253702029585838,
0.03108655847609043,
-0.05814884603023529,
0.033892471343278885,
0.06822797656059265,
-0.02706228755414486,
0.05194630101323128,
-0.035646166652441025,
0.08026386797428131,
0.06047480180859566,
0.10485251992940903,
0.002268266398459673,
0.034667789936065674,
0.04075957089662552,
-0.08011619001626968,
0.040685731917619705,
0.08181450515985489,
-0.02781914733350277,
0.0014087250456213951,
-0.034557029604911804,
0.09082295745611191,
0.03821209818124771,
0.008796166628599167,
0.017675403505563736,
-0.050100307911634445,
0.009756084531545639,
-0.02935132198035717,
-0.06475751101970673,
0.03097579814493656,
0.036864522844552994,
0.005574905313551426,
-0.012358937412500381,
0.017130834981799126,
0.025936231017112732,
-0.01706622540950775,
-0.0013302701991051435,
0.008066998794674873,
-0.04127645120024681,
0.0005886993603780866,
-0.05718892812728882,
0.02553011290729046,
0.025714712217450142,
-0.07302756607532501,
0.02093358524143696,
0.0105129424482584,
0.020342865958809853,
-0.0027574552223086357,
0.0204720851033926,
0.013586523942649364,
0.0003412206715438515,
0.007771639619022608,
-0.01849687099456787,
0.07753179222345352,
-0.09761622548103333,
0.020527465268969536,
-0.04744207486510277,
0.027209967374801636,
-0.04699903726577759,
-0.016401667147874832,
0.034206289798021317,
0.04821739345788956,
0.021967342123389244,
-0.03274795413017273,
0.0014664123300462961,
0.005136481486260891,
0.05508449301123619,
-0.02551165223121643,
-0.04788511246442795,
0.024828635156154633,
0.020176727324724197,
-0.02364719659090042,
-0.04950958862900734,
-0.04766359552741051,
0.03987349569797516,
0.045079201459884644,
-0.023296458646655083,
0.001187205663882196,
0.023961016908288002,
0.014094172976911068,
0.03843361884355545,
0.01567249931395054,
-0.05707816779613495,
-0.02553011290729046,
-0.020084427669644356,
-0.04389776289463043,
-0.01752772368490696,
-0.04072265326976776,
0.0035466181579977274,
0.0020975118968635798,
-0.02440405637025833,
-0.03965197503566742,
-0.004836507141590118,
0.051097143441438675,
0.00843158271163702,
0.056450530886650085,
-0.03278487175703049,
-0.012672756798565388,
-0.016475506126880646,
0.05741044878959656,
-0.027892986312508583,
0.05859188362956047,
0.05375537648797035,
-0.014998710714280605,
-0.01035603228956461,
0.007148616015911102,
0.006908636540174484,
0.0027828377205878496,
0.06125011667609215,
-0.09820693731307983,
0.03843361884355545,
0.030698899179697037,
-0.00350739061832428,
0.004617295227944851,
0.07383980602025986,
-0.012755826115608215,
0.030846579000353813,
-0.0523524209856987,
-0.025363972410559654,
-0.017656942829489708,
-0.01090060081332922,
-0.0021413543727248907,
0.03453856706619263,
-0.029185183346271515,
0.02750532701611519,
-0.002482863375917077,
0.0429009273648262,
-0.008140838705003262,
0.03208339586853981,
0.01056832168251276,
-0.00892538670450449,
-0.01958600804209709,
0.00984838418662548,
-0.03068043850362301,
0.021948881447315216,
0.03778751939535141,
-0.011925128288567066,
-0.01264506671577692,
0.037270642817020416,
-0.055269092321395874,
-0.05202014371752739,
-0.03010817989706993,
0.014961790293455124,
0.06686194241046906,
-0.038285937160253525,
0.001447952468879521,
0.034317050129175186,
-0.05342309921979904,
-0.047257475554943085,
0.0020940506365150213,
0.06206235662102699,
0.016724715009331703,
-0.004331165924668312,
0.03769522160291672,
-0.02455173432826996,
0.030495839193463326,
-0.029702061787247658,
0.010328343138098717,
0.021192023530602455,
-0.014694120734930038,
0.014324922114610672,
0.018376881256699562,
0.034889306873083115,
-0.011952818371355534,
0.10544323921203613,
-0.02037978544831276,
0.040131933987140656,
-0.05028490722179413,
0.035535406321287155,
0.03943045437335968,
-0.021635062992572784,
-0.005533370189368725,
-0.02935132198035717,
-0.020010586827993393,
-0.006890176795423031,
-0.0378798209130764,
-0.014694120734930038,
-0.02279803901910782,
0.014961790293455124,
-0.013484993949532509,
0.010614471510052681,
0.08196218311786652,
-0.01732466369867325,
-0.005796424578875303,
0.044525403529405594,
-0.03232337534427643,
-0.048254311084747314,
0.0003317022346891463,
0.0545676164329052,
-0.013097335584461689,
-0.0196229275316,
-0.0392458550632,
-0.09229975938796997,
-0.008390047587454319,
-0.003237413940951228,
-0.01618937775492668,
0.03671684116125107,
0.0035281581804156303,
0.0084269680082798,
0.01940140873193741,
0.0009610712295398116,
-0.05323849990963936,
0.02792990580201149,
0.02772684581577778,
-0.05475221574306488,
-0.032046474516391754,
-0.004125799052417278,
-0.07900859415531158,
-0.030846579000353813,
0.01708468422293663,
0.03559078648686409,
0.05264778062701225,
0.028077585622668266,
0.025160914286971092,
0.028834443539381027,
-0.042457886040210724,
0.05441993474960327,
0.030625058338046074,
0.017213905230164528,
0.030588138848543167,
0.0020086735021322966,
0.019789068028330803,
0.03832285851240158,
-0.01709391549229622,
-0.029738981276750565,
0.017380043864250183,
-0.05648745223879814,
-0.08646640926599503,
-0.01797076314687729,
0.010632932186126709,
0.01849687099456787,
-0.04489460214972496,
-0.04271632805466652,
-0.03453856706619263,
-0.004220406524837017,
-0.047700513154268265,
0.025216292589902878,
-0.00821467861533165,
-0.0009045376209542155,
0.029831280931830406,
0.07900859415531158,
0.02113664336502552,
-0.019733687862753868,
-0.0020098271779716015,
-0.03865513950586319,
-0.007019396405667067,
0.0017975377850234509,
0.11149810254573822,
0.034317050129175186,
0.009949913248419762,
0.007250146009027958,
0.025142453610897064,
-0.08779552578926086,
-0.03010817989706993,
0.026471570134162903,
-0.03319099172949791,
-0.0606963187456131,
0.025013234466314316,
-0.04555916041135788,
0.0214504636824131,
0.006317918188869953,
-0.0016660105902701616,
-0.00649328762665391,
-0.06320687383413315,
0.041977930814027786,
-0.0014433374162763357,
-0.007508585229516029,
0.0328587144613266,
-0.03348635137081146,
-0.033763252198696136,
0.013272704556584358,
-0.013706513680517673,
0.026526950299739838,
-0.01586632803082466,
0.03887665644288063,
0.000669750093948096,
-0.021745823323726654,
-0.008514652028679848,
0.0083854328840971,
0.03536926582455635,
0.04939882829785347,
-0.028169885277748108,
-0.04389776289463043,
0.02900058403611183,
0.00007027039828244597,
0.030274320393800735,
-0.003535080701112747,
0.021081265062093735,
-0.036772221326828,
-0.006594817619770765,
0.06523746997117996,
0.013964952901005745,
-0.011362100020051003,
-0.045079201459884644,
-0.0374552421271801,
0.001651011873036623,
0.04607603698968887,
-0.03483392670750618,
0.0726952850818634,
0.030495839193463326,
0.008736171759665012,
0.032803334295749664,
0.020619764924049377,
0.0398365743458271,
0.023296458646655083,
0.008906926028430462,
0.07084929198026657,
-0.05017414689064026,
0.00925766583532095,
0.01402956247329712,
0.02235500141978264,
-0.011195960454642773,
-0.004672674927860498,
-0.009377655573189259,
-0.06357607245445251,
-0.06232079491019249,
-0.08882928639650345,
0.05774272605776787,
0.025899311527609825,
0.012617376632988453,
0.005911799147725105,
-0.05825960636138916,
-0.008851546794176102,
-0.022945718839764595,
-0.023961016908288002,
-0.021395083516836166,
-0.005381075665354729,
0.019124509766697884,
-0.0440085232257843,
-0.03858129680156708,
0.028428325429558754,
0.016577037051320076,
-0.07487355917692184,
-0.024810174480080605,
-0.03738139942288399,
0.03309869393706322,
-0.01674317568540573,
-0.05257394164800644,
0.019844448193907738,
-0.04829123243689537,
-0.0002179139555664733,
0.046592917293310165,
-0.0029443621169775724,
-0.02551165223121643,
-0.012728136032819748,
0.018026141449809074,
-0.017241595312952995,
0.04378700256347656,
-0.009866843931376934,
0.04500536248087883,
-0.036181505769491196,
0.034113988280296326,
-0.04153488948941231,
0.008676176890730858,
-0.03365249186754227,
-0.007877783849835396,
0.044525403529405594,
-0.02410869672894478,
0.03134499862790108,
-0.0017767703393474221,
0.018764540553092957,
0.021616602316498756,
-0.11016898602247238,
-0.03691990301012993,
0.05434609577059746,
-0.04423004388809204,
0.009216130711138248,
0.01698315516114235,
-0.059588722884655,
0.012377397157251835,
0.02082282491028309,
0.009220745414495468,
-0.05859188362956047,
-0.021948881447315216,
0.017906151711940765,
0.006604047492146492,
0.010365262627601624,
0.06280075758695602,
-0.010199123062193394,
0.02167198248207569,
0.006825566757470369,
0.025696251541376114,
0.01144516933709383,
0.04293784499168396,
0.08033771067857742,
0.013318854384124279,
0.04710979387164116,
-0.004091186448931694,
0.010254503227770329,
-0.047478996217250824,
-0.038618218153715134,
-0.011380559764802456,
-0.04755283519625664,
0.023351838812232018,
0.04478384181857109,
0.039467375725507736,
-0.008140838705003262,
0.06549590826034546,
0.02530859224498272,
0.09281663596630096,
-0.028520625084638596,
-0.0031266543082892895,
0.028520625084638596,
0.0005993715603835881,
0.05729968845844269,
-0.060290198773145676,
0.011426709592342377,
0.029812820255756378,
0.016503196209669113,
0.010605242103338242,
-0.05202014371752739,
0.03599690645933151,
-0.021967342123389244,
0.05202014371752739,
-0.01732466369867325,
-0.0036666078958660364,
0.02772684581577778,
0.038064420223236084,
-0.051318664103746414,
0.016706256195902824,
0.026914609596133232,
-0.008196217939257622,
0.022484220564365387,
-0.030514299869537354,
-0.0281329657882452,
0.12338631600141525,
-0.03917201608419418,
-0.01318963523954153,
-0.02846524491906166,
0.034778546541929245,
0.015201769769191742,
-0.03557232767343521,
-0.015930937603116035,
0.018995290622115135,
-0.02649003081023693,
-0.01122365053743124,
0.07265836745500565,
0.007148616015911102,
-0.03518466651439667,
-0.00029968578019179404,
-0.020398246124386787,
-0.04795895144343376,
-0.03577538579702377,
0.07716259360313416,
0.031492676585912704,
0.0046380627900362015,
0.023813337087631226,
0.05907184258103371,
-0.04744207486510277,
0.03721526265144348,
-0.02586239203810692,
0.0006178314797580242,
0.05275854095816612,
0.01539559941738844,
-0.032157234847545624,
-0.0031843415927141905,
0.0017225441988557577,
0.011795909143984318,
0.0002470460603944957,
-0.06125011667609215,
0.03097579814493656,
-0.04795895144343376,
-0.044303882867097855,
-0.027431488037109375,
0.03162189573049545,
0.005201091058552265,
-0.00019930978305637836,
-0.01423262245953083,
0.02792990580201149,
-0.005274930968880653,
-0.011971278116106987,
-0.022428840398788452,
0.046371396631002426,
0.05257394164800644,
0.01665087603032589,
0.007803944405168295,
-0.006857872009277344,
-0.006027174182236195,
-0.015377139672636986,
-0.036643002182245255,
0.017435424029827118,
-0.02584393136203289,
-0.06940941512584686,
-0.05704125016927719,
-0.026545409113168716,
-0.049546509981155396,
-0.017481572926044464,
0.008177758194506168,
-0.012903505936264992,
-0.018672240898013115,
0.02462557516992092,
-0.015930937603116035,
0.007587039843201637,
-0.020545925945043564,
0.01720467396080494,
0.022502681240439415,
-0.012949655763804913,
0.02431175485253334,
-0.038175180554389954,
0.0019036824814975262,
-0.024791713804006577,
-0.02322261780500412,
-0.021838122978806496,
0.028871363028883934,
0.01034680288285017,
-0.0015517896972596645,
0.03876589611172676,
0.007448590360581875,
0.03769522160291672,
0.01971522718667984,
-0.036421485245227814,
-0.034667789936065674,
0.03490776941180229,
-0.04655599594116211,
-0.027616087347269058,
0.0075455051846802235,
-0.027985285967588425,
0.0429009273648262,
0.0346493273973465,
-0.0034312433563172817,
-0.011694379150867462,
-0.059625640511512756,
-0.08454657346010208,
-0.018376881256699562,
-0.04544840008020401,
0.02999742142856121,
-0.04677751660346985,
0.025234753265976906,
0.05157710239291191,
-0.006908636540174484,
0.04334396496415138,
-0.024034855887293816,
0.047922033816576004,
0.003403553506359458,
0.017121605575084686,
0.02857600525021553,
0.009045376442372799,
-0.02091512456536293,
0.002305186353623867,
-0.004077341873198748,
0.01774001307785511,
0.0302189402282238,
0.0440085232257843,
0.011565159074962139,
0.0013175790663808584,
-0.029074423015117645,
-0.02693306840956211,
-0.043085526674985886,
-0.04710979387164116,
0.0051964763551950455,
0.0034450883977115154,
-0.03562770411372185,
0.011122120544314384,
-0.006244078278541565,
-0.009709934704005718,
0.03315407410264015,
-0.04367624595761299,
-0.002445943420752883,
-0.004462693352252245,
-0.058111924678087234,
-0.01315271481871605,
-0.06221003457903862,
-0.040131933987140656,
0.03780597820878029,
0.02846524491906166,
-0.010125283151865005,
-0.03913509473204613,
-0.057558126747608185,
0.0225580595433712,
-0.025382433086633682,
-0.0623946338891983,
-0.0158755574375391,
0.0035512330941855907,
-0.04515304043889046,
0.006364068016409874,
-0.008837701752781868,
0.05752120912075043,
-0.021727362647652626,
0.035221587866544724,
0.05216782167553902,
-0.05094946548342705,
0.0021990416571497917,
-0.012681986205279827,
0.03747370094060898,
-0.07539044320583344,
-0.01708468422293663,
-0.02835448458790779,
-0.01927218958735466,
0.0006016790284775198,
-0.014675660990178585,
0.05069102719426155,
-0.03226799517869949,
-0.03296947106719017,
-0.08055922389030457,
-0.01653088629245758,
0.004471923224627972,
-0.00821467861533165,
-0.07103389501571655,
0.017444653436541557,
0.05715201050043106,
0.01165745873004198,
-0.03108655847609043,
0.02529013343155384,
0.03972581401467323,
-0.03680914267897606,
-0.015903247520327568,
0.013946493156254292,
-0.011638998985290527,
-0.02399793639779091,
-0.029812820255756378,
-0.009571484290063381,
0.004543455317616463,
-0.0011670150561258197,
-0.017915382981300354,
-0.018229201436042786,
0.026859229430556297,
0.01841380074620247,
0.02859446406364441,
-0.011426709592342377,
0.0044396184384822845,
0.000988184241577983,
0.02399793639779091,
0.05693048983812332,
-0.005773349665105343,
-0.06664042174816132,
-0.00035391186247579753,
-0.0350739061832428,
-0.04061189293861389,
0.10130821168422699,
-0.05083870515227318,
0.04323320463299751,
-0.04437772184610367,
0.019549088552594185,
-0.00542261078953743,
-0.033910930156707764,
-0.03134499862790108,
0.00547337532043457,
0.031492676585912704,
-0.07479972392320633,
0.04234712943434715,
-0.07878707349300385,
-0.022539600729942322,
0.021856581792235374,
0.08137146383523941,
0.008011618629097939,
-0.031271155923604965,
-0.0200475063174963,
0.006645582616329193,
0.001993674784898758,
-0.0013071952853351831,
-0.04962034896016121,
0.007000936660915613,
0.0451161190867424,
-0.05696740746498108,
0.035313885658979416,
0.03972581401467323,
0.006211773492395878,
-0.0084269680082798,
0.015727877616882324,
-0.014814110472798347,
0.01872762106359005,
0.050211068242788315,
0.042568646371364594,
0.008694636635482311,
-0.025917772203683853,
0.02455173432826996,
-0.010596011765301228,
-0.022096561267971992,
0.006211773492395878,
0.018007682636380196,
0.04773743450641632,
-0.03577538579702377,
0.015054089948534966,
0.016392435878515244,
-0.0551583357155323,
-0.02957284264266491,
0.042014848440885544,
0.008020848967134953,
-0.03385554999113083,
0.01927218958735466,
0.04655599594116211,
-0.008237753063440323,
0.006045633926987648,
0.019992128014564514,
-0.036864522844552994,
-0.02682230994105339,
-0.013272704556584358,
0.04570683836936951,
0.04164564982056618,
0.08558033406734467,
-0.020065966993570328,
-0.03865513950586319,
-0.011842058971524239,
-0.0350739061832428,
0.022705739364027977,
-0.044082362204790115,
-0.002729765372350812,
-0.03437243029475212,
0.014204932376742363,
0.018109211698174477,
-0.05925644189119339,
0.04873427003622055,
-0.02497631311416626,
-0.09650862216949463,
0.002612082986161113,
-0.03140037879347801,
-0.04629755765199661,
0.027671467512845993,
-0.022281160578131676,
-0.016484735533595085,
0.03747370094060898,
0.005459530744701624,
-0.005219551268965006,
0.019733687862753868,
-0.020545925945043564,
-0.04688827693462372,
-0.00963609479367733,
0.038064420223236084,
0.029757441952824593,
-0.024902474135160446,
0.04869735240936279,
-0.008879236876964569,
0.0324341356754303,
-0.0057502747513353825,
0.0025543957017362118,
0.07062777131795883,
0.04098109155893326,
-0.00490111717954278,
0.02757916785776615,
-0.04116569086909294,
0.04389776289463043,
-0.0277083870023489,
-0.033135611563920975,
0.03710450232028961,
-0.0005751428543590009,
-0.046814437955617905,
-0.07044317573308945,
-0.014786421321332455,
-0.017989221960306168,
0.006142548751085997,
-0.0024782484397292137,
0.12131880223751068,
0.029628220945596695,
-0.014971020631492138,
-0.004654215183109045
] |
725,820 | flask_admin.base | get_url |
Generate URL for the endpoint. If you want to customize URL generation
logic (persist some query string argument, for example), this is
right place to do it.
:param endpoint:
Flask endpoint name
:param kwargs:
Arguments for `url_for`
| def get_url(self, endpoint, **kwargs):
"""
Generate URL for the endpoint. If you want to customize URL generation
logic (persist some query string argument, for example), this is
right place to do it.
:param endpoint:
Flask endpoint name
:param kwargs:
Arguments for `url_for`
"""
return url_for(endpoint, **kwargs)
| (self, endpoint, **kwargs) | [
0.016235755756497383,
-0.04239238426089287,
0.014028185047209263,
-0.01043978426605463,
0.001926126889884472,
0.03616545349359512,
-0.018276218324899673,
0.008016733452677727,
-0.008306971751153469,
0.0035026485566049814,
-0.012471452355384827,
-0.013421323150396347,
0.03421293944120407,
-0.005215494427829981,
0.061389800161123276,
0.03736158460378647,
0.05769585818052292,
-0.022533046081662178,
0.08647342771291733,
-0.006328074727207422,
0.018628021702170372,
0.022005340084433556,
0.0027022946160286665,
-0.029885750263929367,
-0.02218124270439148,
0.06131943687796593,
-0.02116101048886776,
0.014415169134736061,
0.025400249287486076,
-0.05312240496277809,
0.004463513381779194,
-0.058540187776088715,
0.050659775733947754,
0.05196145176887512,
0.09062471240758896,
0.01183820515871048,
0.009885692968964577,
0.10307857394218445,
-0.07634147256612778,
0.014599866233766079,
-0.007445052266120911,
-0.028812747448682785,
0.023043163120746613,
-0.01667550951242447,
0.07929662615060806,
0.04154805466532707,
-0.05319276452064514,
0.01578720472753048,
-0.07050152122974396,
-0.00878190714865923,
0.005048387683928013,
-0.015796000137925148,
0.028390582650899887,
0.02694818750023842,
-0.03556738421320915,
0.027036137878894806,
-0.005241879727691412,
0.03416017070412636,
0.015215523540973663,
0.08478476852178574,
-0.02116101048886776,
-0.03565533459186554,
-0.0046438127756118774,
-0.0008377332706004381,
-0.017115265130996704,
0.037854112684726715,
-0.06086209416389465,
0.050659775733947754,
0.01350047904998064,
0.03354451060295105,
0.08387007564306259,
0.03686906024813652,
-0.0208267979323864,
-0.00887865386903286,
0.020967518910765648,
-0.05857536569237709,
0.05593683570623398,
-0.019472351297736168,
0.04140733182430267,
-0.041935037821531296,
-0.005778380669653416,
-0.03992975503206253,
-0.04263864457607269,
-0.042146120220422745,
0.029498765245079994,
-0.0049252561293542385,
-0.025664102286100388,
-0.04749353975057602,
0.03115224465727806,
0.019560303539037704,
-0.029498765245079994,
0.030870800837874413,
-0.02652602270245552,
-0.005905909929424524,
0.016068648546934128,
-0.046367768198251724,
-0.037924472242593765,
0.023377375677227974,
0.056429363787174225,
-0.06613915413618088,
0.07535641640424728,
-0.0204046331346035,
-0.03240114822983742,
0.055549852550029755,
-0.012744099833071232,
-0.05136338621377945,
0.028073959052562714,
0.02272653952240944,
-0.03841699659824371,
0.004793329630047083,
0.004333785735070705,
0.007211982272565365,
-0.017291167750954628,
-0.03053658828139305,
-0.021794257685542107,
0.00843010377138853,
0.02080920711159706,
0.014529505744576454,
0.0034168963320553303,
-0.027088908478617668,
-0.04671957343816757,
-0.005140736233443022,
-0.03294644504785538,
-0.0729641541838646,
0.03284090384840965,
0.017924414947628975,
-0.06962200999259949,
0.0023285027127712965,
0.014309627935290337,
-0.08647342771291733,
0.021407274529337883,
0.07465281337499619,
-0.08816208690404892,
0.022832080721855164,
-0.007000899873673916,
0.0310994740575552,
0.010193521156907082,
0.06416904926300049,
-0.002475820714607835,
0.15732675790786743,
-0.017361527308821678,
0.024450378492474556,
-0.0006255515036173165,
0.020686075091362,
0.008346550166606903,
0.02911178208887577,
0.03185585141181946,
0.023377375677227974,
0.04116106778383255,
0.010343037545681,
0.06986827403306961,
0.05361492931842804,
0.07303451001644135,
-0.0030650924891233444,
0.01174145843833685,
-0.02714167907834053,
-0.00785402487963438,
0.0010350733064115047,
0.03968349099159241,
-0.05931415408849716,
0.020650895312428474,
0.019613074138760567,
0.0020173760131001472,
-0.035479433834552765,
0.012541812844574451,
0.026367710903286934,
0.056781165301799774,
0.03672833740711212,
0.034723054617643356,
-0.0029309671372175217,
-0.03532112389802933,
-0.0025725667364895344,
0.005356215871870518,
-0.006798612419515848,
0.041266608983278275,
-0.020123189315199852,
0.032278016209602356,
-0.005817958619445562,
-0.0008817088091745973,
-0.003458673134446144,
0.029270093888044357,
-0.01510118693113327,
-0.04689547419548035,
-0.007603364065289497,
0.03340379148721695,
0.004978026729077101,
-0.03590159863233566,
-0.0035136425867676735,
-0.053579751402139664,
-0.005048387683928013,
-0.07014971971511841,
-0.008693956770002842,
-0.011890975758433342,
0.039015065878629684,
0.003489455906674266,
-0.010782793164253235,
0.014573480933904648,
0.008992989547550678,
-0.01713285595178604,
0.03206693381071091,
0.00874232966452837,
0.01672828011214733,
-0.04042227938771248,
0.0013159668305888772,
0.042814549058675766,
0.002041562693193555,
0.024538328871130943,
-0.019138138741254807,
0.018803924322128296,
0.0024406402371823788,
-0.024643870070576668,
-0.014476735144853592,
-0.022955210879445076,
0.031803082674741745,
-0.0014423964312300086,
0.02284966967999935,
-0.026385299861431122,
0.014599866233766079,
-0.03693941980600357,
0.027194449678063393,
0.044186584651470184,
-0.06367652863264084,
0.07542677968740463,
-0.007752880919724703,
0.03665797784924507,
0.011046646162867546,
0.054459258913993835,
-0.03834663704037666,
-0.06459121406078339,
-0.008337754756212234,
-0.03162718191742897,
-0.028408173471689224,
0.08548837155103683,
0.07852265238761902,
0.04675475135445595,
0.0007728694472461939,
-0.01570804975926876,
0.003726923605427146,
0.020246321335434914,
0.018522480502724648,
-0.01438878383487463,
0.049358103424310684,
0.004828509874641895,
-0.020985109731554985,
0.027774926275014877,
0.04390513896942139,
-0.017115265130996704,
0.06677240133285522,
-0.008830280974507332,
-0.051539286971092224,
0.004041348583996296,
0.02911178208887577,
-0.03331584110856056,
-0.0139754144474864,
-0.03463510423898697,
-0.027335170656442642,
-0.020123189315199852,
0.014309627935290337,
0.007730892859399319,
0.04939328134059906,
-0.04056300222873688,
0.005945487879216671,
0.016367681324481964,
0.002504404867067933,
-0.03841699659824371,
-0.03115224465727806,
-0.012295549735426903,
-0.00805631186813116,
-0.03546184301376343,
0.03219006583094597,
0.09477599710226059,
-0.006253316067159176,
-0.004001770634204149,
0.021618356928229332,
0.0338963158428669,
-0.0258575938642025,
-0.019964877516031265,
0.011715073138475418,
-0.04573452100157738,
-0.024450378492474556,
-0.008139865472912788,
-0.03299921751022339,
0.010175931267440319,
0.003660960355773568,
-0.017168035730719566,
0.0008580719586461782,
0.0014083153801038861,
0.03637653589248657,
0.030694900080561638,
-0.031029112637043,
0.06019366532564163,
-0.022163651883602142,
-0.04784534499049187,
0.03556738421320915,
-0.02768697589635849,
-0.016358885914087296,
0.03408980742096901,
-0.033509332686662674,
0.02497808448970318,
-0.014775767922401428,
-0.031592000275850296,
-0.0010686046443879604,
-0.034388840198516846,
0.02524193748831749,
-0.024503149092197418,
0.009876897558569908,
0.042075760662555695,
-0.0568867065012455,
0.00969220045953989,
-0.05917343497276306,
-0.001926126889884472,
0.025998316705226898,
-0.041935037821531296,
0.007330716121941805,
0.001328060170635581,
0.02856648527085781,
-0.038065195083618164,
-0.026684334501624107,
0.009305216372013092,
0.05808284133672714,
-0.04436248540878296,
0.09245409071445465,
-0.0012565999059006572,
-0.014793358743190765,
-0.009736175648868084,
0.01611262373626232,
-0.005932295229285955,
0.040774084627628326,
-0.014969260431826115,
0.04056300222873688,
-0.018487300723791122,
0.00013598048826679587,
0.021512815728783607,
0.004474507179111242,
-0.05512768775224686,
-0.042357202619314194,
0.013940233737230301,
-0.011917361058294773,
-0.02870720624923706,
-0.016279730945825577,
0.018469709903001785,
-0.03217247501015663,
-0.015488171018660069,
0.031205015257000923,
-0.047106556594371796,
0.01789802871644497,
-0.0028430160600692034,
-0.06357098370790482,
0.04960436373949051,
-0.06392278522253036,
-0.015488171018660069,
0.00542657682672143,
0.010536530055105686,
0.0060554263181984425,
0.026420481503009796,
0.026490841060876846,
-0.029375635087490082,
-0.01864561252295971,
0.010096775367856026,
0.01367638073861599,
-0.00661391532048583,
-0.08612161874771118,
-0.03183826431632042,
-0.03873362019658089,
0.03665797784924507,
0.038874343037605286,
0.043025631457567215,
0.010941104963421822,
0.023148704320192337,
0.02434483729302883,
-0.012568198144435883,
0.0258575938642025,
0.051257845014333725,
-0.013192649930715561,
0.009806537069380283,
-0.05843464657664299,
0.02191738970577717,
-0.00027017449610866606,
0.003135453211143613,
0.03335101902484894,
-0.052559517323970795,
0.04883039742708206,
0.054670341312885284,
0.04545307904481888,
0.019841745495796204,
-0.06543554365634918,
0.009129313752055168,
0.03048381768167019,
-0.020703665912151337,
0.0032080127857625484,
0.002713288413360715,
-0.0456993393599987,
0.00414688978344202,
0.01762538030743599,
0.016033466905355453,
-0.12700124084949493,
-0.04450320824980736,
-0.023289425298571587,
-0.006455603521317244,
0.03883916139602661,
0.07662291079759598,
0.00661391532048583,
0.025259528309106827,
0.0360599122941494,
0.05368529260158539,
-0.009001784957945347,
0.0364820770919323,
0.003918217029422522,
0.028285041451454163,
-0.020598124712705612,
-0.04000011458992958,
-0.011706278659403324,
-0.10877779871225357,
-0.030571768060326576,
0.030642129480838776,
-0.03211970627307892,
0.0015798198292031884,
0.03027273528277874,
0.0279508288949728,
0.014986850321292877,
0.03475823625922203,
-0.01843453012406826,
0.05811802297830582,
0.02761661447584629,
0.004525078926235437,
0.03421293944120407,
-0.00887865386903286,
-0.0018568654777482152,
0.014001799747347832,
0.05769585818052292,
-0.03081803023815155,
-0.03876880183815956,
-0.052348434925079346,
-0.02673710510134697,
0.041196249425411224,
0.0075813764706254005,
0.03873362019658089,
-0.01584877073764801,
-0.00826739426702261,
-0.03229560703039169,
0.0030848814640194178,
-0.040985167026519775,
-0.02116101048886776,
0.014406373724341393,
0.006552349776029587,
-0.032348379492759705,
-0.03400185704231262,
-0.05361492931842804,
0.03824109584093094,
-0.027124088257551193,
0.014766973443329334,
-0.017159240320324898,
-0.03340379148721695,
-0.024749411270022392,
-0.05055423453450203,
-0.06237484887242317,
0.009085338562726974,
0.01620057411491871,
-0.03416017070412636,
0.03641171380877495,
0.024643870070576668,
0.0022537445183843374,
-0.020492583513259888,
-0.024643870070576668,
-0.006530361715704203,
-0.03233078867197037,
-0.0026275361888110638,
0.0039621926844120026,
-0.08907677233219147,
-0.007497822865843773,
-0.0007294436218217015,
-0.04239238426089287,
-0.030466226860880852,
0.004228244535624981,
-0.02612144686281681,
0.06381724774837494,
-0.0013885264052078128,
0.02286726050078869,
0.013623610138893127,
-0.00300132785923779,
-0.050448693335056305,
-0.0029287682846188545,
-0.00751981046050787,
0.058751270174980164,
-0.0047625466249883175,
0.012840846553444862,
-0.015321064740419388,
0.052770599722862244,
-0.04576970264315605,
0.011108211241662502,
-0.0406685434281826,
0.04503091424703598,
-0.005598081275820732,
0.024168934673070908,
-0.012260369956493378,
0.05393155291676521,
0.04960436373949051,
-0.02434483729302883,
-0.038874343037605286,
0.01435360312461853,
0.05210217460989952,
-0.014406373724341393,
0.0666668564081192,
0.03387872502207756,
-0.021547995507717133,
-0.03081803023815155,
-0.022832080721855164,
0.03912060707807541,
-0.0656818076968193,
-0.007445052266120911,
0.05210217460989952,
0.025189166888594627,
0.050096891820430756,
0.038135554641485214,
0.025470610707998276,
-0.006948129273951054,
-0.014969260431826115,
-0.018821515142917633,
-0.0044327303767204285,
0.026490841060876846,
0.02408098429441452,
0.003821471007540822,
0.027669385075569153,
-0.013518068939447403,
-0.012348320335149765,
0.017458273097872734,
0.04467910900712013,
0.03356210142374039,
-0.011952540837228298,
0.07183837890625,
0.008016733452677727,
0.03873362019658089,
0.029780209064483643,
0.046015962958335876,
-0.01364120002835989,
0.05393155291676521,
-0.08541801571846008,
-0.07331595569849014,
0.0127528952434659,
0.04460874944925308,
0.023905081674456596,
0.013350961729884148,
-0.04897111654281616,
-0.04538271576166153,
-0.0616360604763031,
-0.051609646528959274,
0.0005329280975274742,
-0.008962207473814487,
0.08000022917985916,
-0.08035203814506531,
0.015901541337370872,
0.026350120082497597,
0.04735282063484192,
0.001129070995375514,
-0.029375635087490082,
-0.004208455327898264,
-0.006235726177692413,
0.05899753049015999,
-0.00036499666748568416,
0.02469664067029953,
-0.07479353249073029,
0.01506600622087717,
-0.027669385075569153,
0.025892775505781174,
0.0009691101149655879,
0.048337869346141815,
0.023025572299957275,
-0.04471429064869881,
-0.04763426259160042,
-0.06955165416002274,
-0.025189166888594627,
-0.017880437895655632,
-0.02489013411104679,
-0.047036197036504745,
-0.02782769687473774,
0.0176077913492918,
0.037924472242593765,
-0.08562909811735153,
0.06740564852952957,
-0.02700095809996128,
-0.05393155291676521,
0.013570839539170265,
-0.0039116209372878075,
-0.023219063878059387,
-0.047036197036504745,
-0.03795965388417244,
0.004109510686248541,
-0.02884792909026146,
-0.016482017934322357,
-0.05182072892785072,
-0.03831145539879799,
-0.0811963677406311,
-0.02735276147723198,
-0.018117906525731087,
-0.026701923459768295,
0.02673710510134697,
-0.011855795048177242,
-0.007840831764042377,
0.023219063878059387,
-0.0006832693470641971,
-0.007950770668685436,
0.08457368612289429,
0.01735273189842701,
0.0091556990519166,
0.019841745495796204,
-0.01647322252392769,
-0.008087094873189926,
-0.02156558632850647,
-0.08323682844638824,
-0.010369422845542431,
0.021882209926843643,
0.022339554503560066,
0.022638587281107903,
0.025752052664756775,
-0.025224346667528152,
-0.04960436373949051,
-0.036024730652570724,
0.03767820820212364,
-0.0023021174129098654,
0.006490783765912056,
-0.0035400278866291046,
0.00686897337436676,
-0.029692258685827255,
0.050378333777189255,
-0.019542712718248367,
-0.011196162551641464,
0.04390513896942139,
-0.04161841422319412,
-0.03382595628499985,
0.02673710510134697,
-0.0037489114329218864,
-0.01876874454319477,
0.027229629456996918,
-0.05262988060712814,
0.02612144686281681,
-0.05818838253617287,
0.022568227723240852,
0.019964877516031265,
-0.03971867263317108,
-0.003933608531951904,
-0.04390513896942139,
-0.0017854053294286132,
-0.011424834839999676,
-0.014142520725727081,
0.019894516095519066,
0.04763426259160042,
-0.0034388841595500708,
-0.08182961493730545,
0.026913005858659744,
-0.025329887866973877,
0.035532206296920776,
0.021336913108825684,
0.04087962582707405,
0.01296397764235735,
-0.023007981479167938,
0.002260340843349695,
0.001580919255502522,
-0.0071372236125171185,
0.030870800837874413,
-0.0027506675105541945,
-0.019560303539037704,
-0.03686906024813652,
0.03393149748444557,
-0.07060706615447998,
-0.05481106415390968,
0.0035136425867676735,
0.0352155826985836,
-0.029780209064483643,
-0.023183884099125862,
0.015127572230994701,
-0.02163594588637352,
0.029481176286935806,
0.005699224770069122,
-0.026842646300792694,
0.01043978426605463,
-0.013368552550673485,
-0.04675475135445595,
-0.006297291722148657,
-0.015822384506464005,
-0.009604249149560928,
0.008584017865359783,
-0.013693970628082752,
-0.03708014264702797,
0.037994831800460815,
0.013315781950950623,
0.0255057904869318,
0.0362006314098835,
-0.05182072892785072,
0.028812747448682785,
0.030360685661435127,
0.01531226933002472,
-0.051539286971092224,
-0.02633252926170826,
0.009876897558569908,
-0.06008812412619591,
0.0019624067936092615,
-0.03203175589442253,
-0.08900641649961472,
0.04890075698494911,
0.007634147070348263,
0.006640300620347261,
0.028214681893587112,
0.0616360604763031,
0.018610432744026184,
0.02761661447584629,
0.019701024517416954,
0.032629821449518204,
-0.03477582708001137,
-0.05280578136444092,
-0.02237473428249359,
0.012198803946375847,
-0.014142520725727081,
0.011917361058294773,
-0.042005397379398346,
0.022884851321578026,
-0.007752880919724703,
-0.05611274018883705,
0.05203181132674217,
-0.053720470517873764,
0.008306971751153469,
0.0021240166388452053,
-0.03919096663594246,
0.014362398535013199,
-0.08703631162643433,
0.02735276147723198,
0.008636788465082645,
-0.07817085087299347,
-0.006213738117367029,
0.02042222209274769,
-0.043377432972192764,
-0.013456502929329872,
-0.0008509259205311537,
0.0007239466649480164,
0.028320223093032837,
0.027915647253394127,
-0.0362006314098835,
-0.02175907790660858,
-0.04664921015501022,
-0.03421293944120407,
-0.027458302676677704,
0.02184702828526497,
0.023113522678613663,
-0.04647330939769745,
0.011372064240276814,
0.09899764508008957,
0.02939322404563427,
0.052348434925079346,
0.009859307669103146,
-0.012911207042634487,
-0.00288259400986135,
0.01850489154458046,
0.036306172609329224,
-0.045206815004348755,
-0.02401062287390232,
-0.021688716486096382,
-0.06613915413618088,
-0.0009427248151041567,
-0.010756407864391804,
-0.01507480163127184,
-0.02142486348748207,
-0.0670890212059021,
0.028935879468917847,
0.005905909929424524,
-0.02395785227417946,
0.04457356780767441,
0.09519816190004349,
0.010703637264668941,
0.006882166024297476
] |
725,821 | flask_admin.base | inaccessible_callback |
Handle the response to inaccessible views.
By default, it throw HTTP 403 error. Override this method to
customize the behaviour.
| def inaccessible_callback(self, name, **kwargs):
"""
Handle the response to inaccessible views.
By default, it throw HTTP 403 error. Override this method to
customize the behaviour.
"""
return abort(403)
| (self, name, **kwargs) | [
-0.036028195172548294,
-0.016490349546074867,
0.0027194684371352196,
0.028663409873843193,
0.028375590220093727,
0.02013041451573372,
0.0317109078168869,
0.015762334689497948,
0.02311019040644169,
0.027021147310733795,
0.046423546969890594,
0.00556168332695961,
0.019571706652641296,
-0.053703680634498596,
-0.01936854049563408,
-0.012079942040145397,
0.03870322182774544,
0.06873800605535507,
0.012807955965399742,
-0.06054362282156944,
-0.037314917892217636,
-0.0327436700463295,
-0.003464412409812212,
-0.05912145599722862,
-0.04838749021291733,
0.047913435846567154,
-0.023550385609269142,
0.00810972973704338,
0.04320674389600754,
-0.00020779596525244415,
-0.03579116612672806,
0.041073497384786606,
0.033708710223436356,
0.08106344193220139,
0.020299721509218216,
0.01228310912847519,
-0.025378882884979248,
0.026225410401821136,
-0.06694336980581284,
-0.035249389708042145,
-0.052213795483112335,
0.014026954770088196,
-0.04151369258761406,
-0.06149173155426979,
0.0414121076464653,
0.005912992171943188,
-0.035283252596855164,
0.049030851572752,
-0.010005950927734375,
0.013552899472415447,
-0.05099479481577873,
0.00462203798815608,
0.022788511589169502,
-0.02224673330783844,
0.013722204603254795,
0.044256437569856644,
0.011936033144593239,
0.03623136132955551,
0.024938689544796944,
-0.025836007669568062,
-0.04584791138768196,
0.034436725080013275,
0.04300357773900032,
-0.0327436700463295,
0.01582159288227558,
0.05631098523736,
-0.023956717923283577,
0.012113803066313267,
-0.013366663828492165,
0.042563386261463165,
0.03362405672669411,
-0.035926610231399536,
-0.01290953904390335,
0.06345567107200623,
0.0550919845700264,
0.003667578799650073,
-0.02082456834614277,
-0.015364467166364193,
-0.029120532795786858,
0.0772709995508194,
0.06440378725528717,
-0.08458498865365982,
-0.02952686697244644,
0.010623916052281857,
-0.02080763690173626,
-0.02305939979851246,
-0.026360854506492615,
-0.1027345359325409,
0.015229023061692715,
0.053737543523311615,
-0.02531116083264351,
-0.023160982877016068,
-0.027715299278497696,
-0.05333121120929718,
-0.027562923729419708,
0.026191549375653267,
0.04432415962219238,
-0.013976163230836391,
0.015372932888567448,
-0.026953423395752907,
0.005764849949628115,
0.006205043755471706,
0.051536571234464645,
0.02966231107711792,
0.039007969200611115,
-0.02285623364150524,
-0.000028867898436146788,
-0.04466277360916138,
-0.004073911812156439,
-0.025057204067707062,
0.013984628021717072,
-0.013789927586913109,
0.009218680672347546,
0.017963305115699768,
-0.050791628658771515,
0.02446463517844677,
-0.02304246835410595,
-0.039651330560445786,
-0.01789558306336403,
-0.027258174493908882,
-0.01366294827312231,
-0.002484557218849659,
-0.014670315198600292,
-0.058241065591573715,
0.03174476698040962,
0.03130457550287247,
-0.03775510936975479,
0.00885467417538166,
0.028477173298597336,
0.0580378994345665,
-0.015085113234817982,
-0.02002883143723011,
-0.076593779027462,
-0.009032445028424263,
-0.03130457550287247,
0.03162625432014465,
0.08086027204990387,
-0.030762797221541405,
0.041953884065151215,
0.017243757843971252,
-0.051604293286800385,
0.005129954311996698,
0.027562923729419708,
0.050791628658771515,
0.07300449907779694,
0.004116238094866276,
0.02375355176627636,
0.01033609639853239,
0.0816052183508873,
-0.03128764405846596,
0.06440378725528717,
0.05807176232337952,
-0.013434385880827904,
-0.014467149041593075,
-0.053703680634498596,
0.04740551859140396,
-0.009904367849230766,
-0.02974696457386017,
0.011199554428458214,
-0.016642723232507706,
-0.012477810494601727,
-0.01663425751030445,
-0.026191549375653267,
0.00518074631690979,
0.0045585487969219685,
-0.02966231107711792,
0.04056558012962341,
-0.0009253599564544857,
0.015669217333197594,
0.047913435846567154,
-0.01588931493461132,
-0.019046859815716743,
-0.041818439960479736,
-0.02294088527560234,
0.022399108856916428,
0.0016274484805762768,
0.01597396656870842,
-0.015652287751436234,
-0.006403977982699871,
-0.012774094939231873,
0.03860163688659668,
-0.049978964030742645,
-0.07273361086845398,
0.01864052750170231,
0.02952686697244644,
0.02813856303691864,
0.004981812089681625,
0.02602224424481392,
-0.03640066832304001,
0.08180838078260422,
-0.010683172382414341,
-0.011741331778466702,
0.061153121292591095,
0.006971151102334261,
0.0014348635450005531,
0.0018771738978102803,
0.01108950562775135,
0.010632380843162537,
0.009252541698515415,
-0.02824014611542225,
0.024921759963035583,
0.009371055290102959,
-0.03409811481833458,
-0.010496936738491058,
0.021264761686325073,
0.11424729973077774,
-0.0006957395235076547,
-0.029425283893942833,
-0.005790245719254017,
-0.023279495537281036,
-0.012867212295532227,
-0.007051571272313595,
-0.002124783117324114,
0.05258626490831375,
-0.02825707569718361,
0.03853391483426094,
-0.03138922527432442,
-0.029442213475704193,
0.04967421293258667,
0.022686926648020744,
0.0021946216002106667,
0.027783021330833435,
-0.06094995513558388,
-0.02153564989566803,
0.03408118337392807,
0.030661212280392647,
0.0372471958398819,
-0.00007307909982046112,
-0.044730495661497116,
-0.005096093285828829,
-0.022466830909252167,
0.04090419039130211,
-0.002378741279244423,
0.015576099045574665,
-0.0054854960180819035,
0.01605862006545067,
0.02751213125884533,
-0.10740736126899719,
-0.042563386261463165,
0.01791251450777054,
0.00665793614462018,
-0.022822372615337372,
0.027173520997166634,
0.03629908338189125,
0.04513682797551155,
0.01607554964721203,
-0.06301548331975937,
0.07151461392641068,
-0.002711003180593252,
-0.047913435846567154,
-0.01999497041106224,
-0.03250664100050926,
-0.058850567787885666,
-0.054414764046669006,
-0.008659972809255123,
-0.0320495180785656,
-0.04103963449597359,
0.05536287650465965,
0.007098129950463772,
0.03775510936975479,
-0.02532809227705002,
-0.0015872383955866098,
-0.049267880618572235,
-0.004787111189216375,
0.034402862191200256,
-0.009565756656229496,
0.04351149499416351,
0.009159423410892487,
-0.010979456827044487,
0.0032273847609758377,
0.05028371140360832,
0.031609322875738144,
0.018877554684877396,
-0.0038453496526926756,
-0.016363369300961494,
-0.015305210836231709,
0.0428004115819931,
0.021315554156899452,
-0.06467467546463013,
0.014120073057711124,
0.06870414316654205,
-0.02307632938027382,
-0.0007941482472233474,
0.06545347720384598,
-0.05810562148690224,
-0.02145099826157093,
0.042563386261463165,
-0.011182623915374279,
-0.01931774988770485,
-0.06406517326831818,
0.07219183444976807,
-0.013070379383862019,
0.010767824947834015,
0.013789927586913109,
-0.0055320546962320805,
-0.004922555293887854,
-0.04300357773900032,
0.00814359076321125,
-0.020485956221818924,
0.05553217977285385,
0.006420908495783806,
-0.017006730660796165,
-0.033031489700078964,
-0.019470123574137688,
0.042563386261463165,
-0.034555237740278244,
0.03836461156606674,
0.042563386261463165,
-0.027562923729419708,
0.029222117736935616,
0.00012347391748335212,
-0.05069004371762276,
0.004901392385363579,
0.01259632408618927,
-0.007305529434233904,
0.025412743911147118,
0.04662671685218811,
0.005498193670064211,
-0.005599777214229107,
0.04804887995123863,
-0.01933467946946621,
0.04693146422505379,
-0.04286813363432884,
-0.02070605382323265,
-0.0036464156582951546,
-0.02824014611542225,
0.03711175173521042,
0.010251443833112717,
0.003546948777511716,
0.024041371420025826,
0.008905465714633465,
-0.03409811481833458,
-0.00416279723867774,
-0.06961838901042938,
-0.0710405558347702,
0.0073436228558421135,
0.023482663556933403,
-0.04144597053527832,
0.017176035791635513,
-0.029425283893942833,
-0.03282832354307175,
0.002592489356175065,
-0.0039321184158325195,
0.0502498522400856,
-0.06907661259174347,
0.01257092785090208,
0.004440034739673138,
0.015220558270812035,
0.02383820340037346,
0.03431820869445801,
-0.02666560560464859,
0.03653611242771149,
0.008363688364624977,
0.022128218784928322,
0.008037774823606014,
-0.008037774823606014,
0.012714837677776814,
0.03330237790942192,
-0.0320495180785656,
-0.013781461864709854,
0.027766089886426926,
-0.06585980951786041,
-0.013857649639248848,
0.003223152132704854,
0.01852201297879219,
-0.05258626490831375,
0.025531258434057236,
-0.08797109872102737,
0.03629908338189125,
-0.07056650519371033,
-0.052213795483112335,
-0.05465179309248924,
-0.049978964030742645,
0.022128218784928322,
0.058139484375715256,
-0.020655261352658272,
0.004875996150076389,
0.012012219987809658,
-0.04743938148021698,
0.049267880618572235,
-0.0060822973027825356,
-0.005041069351136684,
0.0459156334400177,
0.008871604688465595,
-0.0012179409386590123,
-0.027681438252329826,
-0.04090419039130211,
0.06789147853851318,
-0.03279446065425873,
0.03362405672669411,
0.044188715517520905,
-0.06430219858884811,
-0.05424546077847481,
0.034504447132349014,
-0.010327630676329136,
-0.022585343569517136,
-0.03027181141078472,
-0.01406928151845932,
0.004099307581782341,
0.038161445409059525,
0.010014415718615055,
0.06257528811693192,
-0.09731675684452057,
-0.024989482015371323,
0.03775510936975479,
0.05478723719716072,
-0.003036916023120284,
0.028527963906526566,
0.00200309487991035,
-0.03558799996972084,
0.02004576288163662,
0.030204089358448982,
-0.0012242898810654879,
-0.006890730932354927,
0.05844423547387123,
0.037314917892217636,
-0.002380857476964593,
0.00028570290305651724,
-0.021095456555485725,
-0.012494741007685661,
0.08776793628931046,
0.009785853326320648,
0.10388581454753876,
-0.006061134394258261,
-0.012274643406271935,
-0.008029310032725334,
-0.02678411826491356,
0.003587158862501383,
0.04276655241847038,
-0.008685368113219738,
-0.008033542893826962,
0.014890412800014019,
-0.023144051432609558,
-0.043376050889492035,
-0.013798392377793789,
0.03281139209866524,
-0.02155258134007454,
-0.03623136132955551,
-0.019520916044712067,
0.05241696164011955,
0.012198456563055515,
0.008181684650480747,
0.007119293324649334,
-0.00893086101859808,
0.09691042453050613,
0.013485177420079708,
-0.04889540746808052,
0.08580399304628372,
0.03277752920985222,
-0.07388488948345184,
0.016744306311011314,
0.021298622712492943,
0.020316651090979576,
-0.023939788341522217,
-0.08959643542766571,
0.0036083220038563013,
-0.03853391483426094,
-0.04320674389600754,
0.001732206204906106,
0.03914341330528259,
0.0372471958398819,
0.041073497384786606,
-0.10165097564458847,
-0.08086027204990387,
0.0667063370347023,
0.08106344193220139,
-0.022094357758760452,
0.008520295843482018,
0.007724560331553221,
-0.0017692417604848742,
-0.0007306587649509311,
-0.003695090999826789,
0.012850281782448292,
-0.05421159788966179,
-0.00241895136423409,
0.011267276480793953,
-0.0006618783809244633,
0.024159884080290794,
0.006200811360031366,
0.04578018933534622,
0.019520916044712067,
0.014577197842299938,
0.025023343041539192,
-0.01791251450777054,
-0.04672829806804657,
-0.06149173155426979,
-0.033725641667842865,
0.042021606117486954,
0.0013353965478017926,
-0.029086671769618988,
0.005295027047395706,
-0.02751213125884533,
-0.0032062216196209192,
-0.01658346690237522,
0.010674707591533661,
0.008071635849773884,
-0.02510799467563629,
0.007995449006557465,
0.03394573926925659,
0.0002286945964442566,
-0.020502887666225433,
-0.014280912466347218,
-0.007576418109238148,
-0.00260730367153883,
0.0012793141650035977,
-0.03917727619409561,
0.01485655177384615,
0.00021189633116591722,
0.00612462405115366,
-0.027088869363069534,
-0.0029776592273265123,
0.03850005567073822,
0.05837651342153549,
0.022737719118595123,
0.028392519801855087,
0.00866420567035675,
-0.027884604409337044,
0.005417773500084877,
0.0238212738186121,
0.012308504432439804,
0.06782375276088715,
-0.04164913669228554,
0.026073036715388298,
0.010446145199239254,
0.0053373537957668304,
-0.03501236438751221,
-0.018894486129283905,
0.0007227225578390062,
-0.018301917240023613,
0.06518258899450302,
-0.04026082903146744,
0.020299721509218216,
0.03128764405846596,
-0.03629908338189125,
0.005862200632691383,
0.03558799996972084,
-0.06718039512634277,
0.014187795110046864,
0.006234672386199236,
0.05905373394489288,
-0.020655261352658272,
-0.03282832354307175,
0.002928983885794878,
-0.019131513312458992,
-0.033725641667842865,
-0.07151461392641068,
-0.09101859480142593,
-0.01774320937693119,
0.028527963906526566,
-0.02879885397851467,
-0.011741331778466702,
0.010649311356246471,
0.04964035004377365,
-0.01451794058084488,
0.050080545246601105,
0.008770021609961987,
-0.023431871086359024,
0.016693515703082085,
0.001194661483168602,
0.019622499123215675,
-0.0012475693365558982,
0.008693833835422993,
0.016862820833921432,
-0.07205639034509659,
-0.030237950384616852,
0.014746502973139286,
0.0029311003163456917,
-0.024363050237298012,
-0.0017660672310739756,
-0.06139014661312103,
-0.05404229462146759,
-0.04198774695396423,
-0.012714837677776814,
0.02080763690173626,
-0.036603834480047226,
0.039719052612781525,
0.047913435846567154,
-0.04960649088025093,
0.0038093721959739923,
-0.05285715311765671,
0.017438458278775215,
-0.025836007669568062,
0.023482663556933403,
-0.04598335549235344,
-0.037314917892217636,
0.010547728277742863,
0.018742110580205917,
0.01779399998486042,
0.05140112712979317,
0.02732589654624462,
-0.012655580416321754,
0.0032548969611525536,
-0.03944816440343857,
-0.08397549390792847,
0.029289839789271355,
0.027766089886426926,
-0.0635911226272583,
-0.056141678243875504,
0.007775351870805025,
0.032997626811265945,
0.01786172203719616,
0.03565572202205658,
-0.022432969883084297,
-0.0013057681499049067,
0.03833074867725372,
0.0713791698217392,
-0.025802146643400192,
-0.050080545246601105,
-0.017184501513838768,
-0.02666560560464859,
-0.049911241978406906,
-0.01786172203719616,
0.003530018264427781,
-0.005049534607678652,
-0.005024138372391462,
0.04964035004377365,
-0.026428576558828354,
-0.008249406702816486,
0.03199872747063637,
0.05715751275420189,
-0.03805986046791077,
-0.03636680543422699,
-0.013993093743920326,
0.014026954770088196,
-0.017235292121767998,
-0.03636680543422699,
0.0784899964928627,
0.041886162012815475,
-0.0474732406437397,
0.06061134487390518,
-0.04506910592317581,
0.04838749021291733,
-0.036603834480047226,
0.0031109871342778206,
0.03484305739402771,
-0.010226047597825527,
-0.015753870829939842,
-0.04622038081288338,
-0.023550385609269142,
0.02964537963271141,
-0.0007057919865474105,
-0.024718591943383217,
-0.029357561841607094,
0.025836007669568062,
-0.01036149263381958,
0.07943810522556305,
-0.03248971328139305,
0.04063330218195915,
0.02895122766494751,
-0.05471951514482498,
-0.0332685150206089,
0.038229167461395264,
0.03330237790942192,
-0.016744306311011314,
-0.06071292608976364,
0.020181206986308098,
-0.048658378422260284,
0.007512928452342749,
-0.007373251486569643,
-0.0178447924554348,
-0.02001190185546875,
-0.03238812834024429,
-0.008075868710875511,
-0.020181206986308098,
0.061153121292591095,
0.04100577533245087,
-0.0476425476372242,
-0.08201155066490173,
-0.03035646304488182,
0.028748061507940292,
-0.019639430567622185,
0.009489568881690502,
0.06149173155426979,
0.022483760491013527,
0.009015514515340328,
0.003240082645788789,
0.018047958612442017,
-0.011385790072381496,
-0.005422006361186504,
0.04693146422505379,
-0.02973003312945366,
-0.010530797764658928,
-0.02299167774617672,
-0.03099982440471649,
-0.021857330575585365,
0.027664506807923317,
-0.05536287650465965,
-0.03494463860988617,
0.02150178886950016,
0.0005613532848656178,
-0.045644745230674744,
-0.03609591722488403,
-0.01997804082930088,
0.040328554809093475,
-0.017235292121767998,
-0.03728105500340462,
-0.02509106509387493,
0.020976942032575607,
0.002121608704328537,
0.07679694145917892,
0.04357921704649925,
-0.03789055347442627,
0.026377785950899124,
-0.014052351005375385,
-0.004952183924615383,
-0.03944816440343857,
0.002821051748469472,
-0.049267880618572235,
-0.010014415718615055,
-0.021688025444746017,
-0.03870322182774544,
-0.04151369258761406,
0.054448626935482025,
0.005807176232337952,
0.00006001744986861013,
-0.013425920158624649,
0.01452640537172556,
0.0004983928520232439,
0.04767640680074692,
-0.019520916044712067,
0.0005475972429849207,
-0.004757482558488846,
-0.01791251450777054,
0.024735523387789726,
-0.023465732112526894,
-0.027799950912594795,
-0.052349239587783813,
-0.044865939766168594,
0.024227606132626534,
0.024024439975619316,
0.06321864575147629,
-0.030136365443468094,
-0.05089321359992027,
0.04286813363432884,
-0.00027459225384518504,
0.008346757851541042,
-0.050859350711107254,
0.060509759932756424,
-0.015914710238575935,
0.06504714488983154,
0.01675277203321457,
0.0038390005938708782,
-0.012079942040145397,
-0.03805986046791077,
0.060475900769233704,
0.031456947326660156,
0.0012655580649152398,
0.014839621260762215,
0.04544157534837723,
0.08180838078260422,
0.047033049166202545,
0.002217901172116399,
-0.021688025444746017,
0.0238212738186121,
0.001747020403854549,
0.013425920158624649,
-0.00003439016654738225,
-0.007555254735052586,
-0.02598838321864605,
0.029967060312628746,
-0.04388396814465523,
0.057360678911209106,
-0.07510388642549515,
-0.020604470744729042,
0.07110828161239624,
0.040362413972616196,
0.0760519951581955,
0.0251249261200428
] |
725,822 | flask_admin.base | index | null | def _wrap_view(f):
# Avoid wrapping view method twice
if hasattr(f, '_wrapped'):
return f
@wraps(f)
def inner(self, *args, **kwargs):
# Store current admin view
h.set_current_view(self)
# Check if administrative piece is accessible
abort = self._handle_view(f.__name__, **kwargs)
if abort is not None:
return abort
return self._run_view(f, *args, **kwargs)
inner._wrapped = True
return inner
| (self) | [
0.03029562532901764,
-0.05186469852924347,
0.03377564996480942,
0.0903039276599884,
0.03921649605035782,
0.03607210889458656,
0.009035692550241947,
0.025526052340865135,
-0.06267572939395905,
0.014979994855821133,
0.042113568633794785,
0.01990855485200882,
0.012595207430422306,
-0.05034549906849861,
-0.007291265297681093,
0.04656517133116722,
0.0009268650901503861,
-0.019696572795510292,
0.06097988411784172,
-0.024254165589809418,
0.015138980001211166,
-0.022452326491475105,
0.044833991676568985,
-0.012524547055363655,
-0.04833168163895607,
0.023123599588871002,
-0.004994803573936224,
0.02681560441851616,
0.08712421357631683,
-0.0221696849912405,
0.003976853098720312,
-0.011641292832791805,
0.011261493898928165,
0.05105210468173027,
0.0560336597263813,
0.0064963363111019135,
-0.02882942371070385,
0.00688055157661438,
-0.01554527785629034,
0.00031134719029068947,
-0.021003790199756622,
-0.016410866752266884,
-0.014043744653463364,
-0.03259208798408508,
-0.0006464318139478564,
0.026232656091451645,
0.02958902157843113,
0.08825477957725525,
0.044975314289331436,
0.01623421534895897,
0.002426741411909461,
-0.04490465298295021,
-0.017311785370111465,
-0.005436430685222149,
-0.011067178100347519,
0.02670961245894432,
0.011093675158917904,
0.003769288072362542,
0.05532705411314964,
-0.04218422994017601,
-0.0451519638299942,
0.03119654580950737,
0.03386397287249565,
0.01980256289243698,
0.012515714392066002,
0.06822256743907928,
-0.036107439547777176,
0.03239777311682701,
0.010678545571863651,
0.015872081741690636,
-0.033899303525686264,
0.016905488446354866,
0.007918375544250011,
0.02208136022090912,
0.04017040878534317,
0.025137420743703842,
-0.02727489545941353,
-0.0378032885491848,
0.013549122959375381,
0.024377821013331413,
0.03720267489552498,
-0.06642073392868042,
-0.008201017044484615,
0.010325243696570396,
-0.027133574709296227,
-0.0121712451800704,
0.018212705850601196,
-0.014308720827102661,
0.04713045433163643,
0.034093618392944336,
-0.012798355892300606,
0.019078295677900314,
-0.03370498865842819,
-0.05815346911549568,
-0.0062622735276818275,
0.011667790822684765,
-0.015615938231348991,
-0.004396398551762104,
-0.07090765982866287,
-0.006416843272745609,
0.005957550834864378,
0.09214109927415848,
0.049815546721220016,
0.032486096024513245,
0.0720735564827919,
-0.053807858377695084,
-0.04864965379238129,
-0.03702602535486221,
-0.01596040651202202,
0.006310852710157633,
-0.022399332374334335,
-0.03206213563680649,
-0.07228554040193558,
0.04066503420472145,
-0.02409517951309681,
0.017885901033878326,
-0.03089623898267746,
-0.018866313621401787,
0.021745722740888596,
0.01925494521856308,
0.04409205913543701,
-0.004994803573936224,
0.010581388138234615,
-0.08189535140991211,
0.0035153524950146675,
0.05387851968407631,
-0.032680414617061615,
-0.0017013688338920474,
0.05529172718524933,
-0.019466927275061607,
-0.006708316970616579,
0.026921594515442848,
0.005842728074640036,
0.002300877822563052,
-0.013451964594423771,
0.049462247639894485,
-0.010510727763175964,
0.018866313621401787,
-0.027840178459882736,
0.045187294483184814,
-0.06631474196910858,
0.02110978029668331,
0.016852494329214096,
0.031072890385985374,
0.036814045161008835,
-0.0022202807012945414,
-0.02676260843873024,
0.0862056314945221,
0.04179559648036957,
-0.022311005741357803,
0.025013765320181847,
0.016472695395350456,
0.07977553457021713,
0.008951783180236816,
-0.05946068465709686,
0.06574945896863937,
-0.0044317287392914295,
0.026038339361548424,
0.03840390220284462,
-0.019343271851539612,
0.01960824802517891,
-0.0032393354922533035,
-0.007710810750722885,
-0.018283365294337273,
0.02282329462468624,
-0.006699484772980213,
0.015951573848724365,
-0.07182624936103821,
0.020244190469384193,
0.08846676349639893,
-0.01656102016568184,
-0.01415856834501028,
0.0010063579538837075,
0.057128895074129105,
-0.02912973053753376,
0.04811970144510269,
0.013469629921019077,
-0.06461889296770096,
0.016198886558413506,
-0.01569543033838272,
-0.044339369982481,
0.0032128379680216312,
-0.046600501984357834,
-0.0037339578848332167,
0.010669712908565998,
0.06415960192680359,
0.04419805109500885,
-0.030012983828783035,
-0.0019034132128581405,
0.0051405406557023525,
-0.012939676642417908,
-0.0014408087590709329,
0.06398294866085052,
-0.041406966745853424,
-0.07694912701845169,
-0.011120173148810863,
-0.05327790603041649,
-0.026921594515442848,
0.030224965885281563,
-0.030118975788354874,
-0.00611212057992816,
-0.028105154633522034,
0.027080580592155457,
0.034446921199560165,
-0.005679325666278601,
0.11023014783859253,
0.011623627506196499,
0.020738814026117325,
-0.04108899459242821,
0.005604248959571123,
0.035100530833005905,
-0.02374187856912613,
-0.046989135444164276,
0.0576588474214077,
-0.0029368209652602673,
-0.0018592504784464836,
0.008382083848118782,
0.01551877986639738,
-0.001242076512426138,
0.023724213242530823,
-0.04395074024796486,
0.05267729237675667,
-0.030207300558686256,
0.011208497919142246,
0.0024245332460850477,
-0.039640456438064575,
0.046494510024785995,
-0.06574945896863937,
0.016799498349428177,
-0.03805059939622879,
-0.0225759819149971,
-0.01564243622124195,
-0.014935831539332867,
0.03124953992664814,
-0.006637656595557928,
-0.031973809003829956,
-0.005476177204400301,
-0.03144385665655136,
-0.02736322209239006,
-0.01347846258431673,
0.018407022580504417,
-0.05900139361619949,
0.06451290100812912,
0.019325606524944305,
-0.005904555786401033,
-0.021745722740888596,
-0.07140228897333145,
0.027628198266029358,
0.033228032290935516,
-0.00402543181553483,
-0.02222268097102642,
0.005436430685222149,
0.016525689512491226,
-0.02004987560212612,
0.002914739539846778,
0.015986904501914978,
-0.020933128893375397,
0.003491062903776765,
-0.01751493476331234,
0.01656102016568184,
-0.018513012677431107,
-0.017064474523067474,
0.05377252772450447,
-0.043314795941114426,
-0.020491501316428185,
-0.047307103872299194,
-0.01340780220925808,
-0.03639008104801178,
0.03215045854449272,
-0.026744943112134933,
0.023724213242530823,
0.05271262302994728,
0.02983633428812027,
0.020986124873161316,
-0.02423650026321411,
-0.040947675704956055,
0.03607210889458656,
-0.01436171680688858,
-0.0584714412689209,
0.021993035450577736,
0.04536394774913788,
0.009380161762237549,
-0.014317553490400314,
0.06249907985329628,
-0.042360879480838776,
0.017532600089907646,
-0.04327946528792381,
-0.00334532605484128,
0.01544811949133873,
-0.04903828352689743,
0.03124953992664814,
-0.028246475383639336,
0.0671626627445221,
-0.019696572795510292,
-0.003912817221134901,
-0.0040916758589446545,
-0.12252505123615265,
0.014379381202161312,
-0.006801059003919363,
-0.01013092789798975,
0.006209278479218483,
-0.07055436074733734,
-0.00005506539309863001,
0.04748375713825226,
0.08493374288082123,
-0.025897018611431122,
0.011482306756079197,
-0.0006928026559762657,
0.004804904107004404,
-0.003879694966599345,
-0.004765157587826252,
0.0035882210358977318,
-0.02948303148150444,
-0.02186937816441059,
-0.011552967131137848,
0.006876135710626841,
-0.01966124214231968,
-0.012542212381958961,
0.005184703506529331,
0.04380941763520241,
-0.013257648795843124,
0.054196491837501526,
-0.013575620017945766,
0.05020418018102646,
0.023105934262275696,
-0.03169116750359535,
0.08260194957256317,
-0.0378032885491848,
-0.0239361934363842,
0.006659738253802061,
-0.03381097689270973,
-0.027645863592624664,
-0.003698627697303891,
-0.033793311566114426,
-0.09397827088832855,
0.019943883642554283,
0.048967622220516205,
-0.010793368332087994,
0.0019542004447430372,
-0.02192237414419651,
0.04501064494252205,
0.06122719496488571,
-0.022416995838284492,
0.018636668100953102,
-0.09016261249780655,
0.05564502626657486,
0.030207300558686256,
-0.0061032879166305065,
0.05462045222520828,
-0.07041303813457489,
-0.016578685492277145,
-0.05317191407084465,
-0.012127082794904709,
-0.04893229529261589,
-0.016304876655340195,
-0.007794720120728016,
0.020544497296214104,
-0.004628253169357777,
-0.014979994855821133,
-0.02858211286365986,
-0.0043897745199501514,
-0.004544343799352646,
-0.03598378598690033,
0.007785887457430363,
0.017373614013195038,
0.0005735633312724531,
-0.008912037126719952,
-0.062110450118780136,
0.045540597289800644,
-0.01585441641509533,
-0.013116328045725822,
-0.03642541170120239,
0.07122563570737839,
0.005979632493108511,
0.07518261671066284,
-0.027204236015677452,
-0.0004336227138992399,
0.03653140366077423,
-0.050628140568733215,
0.04062970355153084,
0.05190002918243408,
0.010705043561756611,
0.05568035691976547,
-0.0448693223297596,
-0.009000361897051334,
-0.05741153657436371,
-0.01980256289243698,
0.03709668666124344,
-0.05645762011408806,
-0.017859404906630516,
0.026020674034953117,
-0.03967578709125519,
-0.02761053293943405,
0.06921181827783585,
0.0024797366932034492,
0.014529534615576267,
-0.06101521477103233,
-0.000042334108002251014,
0.006831972859799862,
-0.01161479577422142,
0.08719487488269806,
0.0022655476350337267,
-0.02110978029668331,
-0.04490465298295021,
0.045434605330228806,
0.041512954980134964,
-0.031178880482912064,
0.04550526663661003,
0.016013402491807938,
-0.05497375503182411,
-0.013637447729706764,
-0.029606686905026436,
0.016013402491807938,
0.02605600468814373,
-0.01874265819787979,
0.011455809697508812,
0.0024996099527925253,
0.04229022189974785,
-0.014414711855351925,
-0.03548916056752205,
0.04713045433163643,
0.03506520017981529,
0.029959989711642265,
0.03388163819909096,
-0.025967679917812347,
-0.029359376057982445,
-0.02757520228624344,
-0.012003427371382713,
0.011243828572332859,
0.01090819202363491,
0.009433156810700893,
-0.006748063489794731,
0.015713095664978027,
-0.001659414148889482,
0.001013534376397729,
0.005458512343466282,
-0.0077770547941327095,
-0.014352884143590927,
-0.03695536404848099,
0.06765728443861008,
0.024837113916873932,
-0.012842519208788872,
-0.003762663807719946,
-0.016145890578627586,
0.0456819161772728,
0.02529640682041645,
-0.02801682986319065,
0.05790615826845169,
0.0189016442745924,
-0.046600501984357834,
0.0630996972322464,
0.036708053201436996,
-0.031178880482912064,
0.03430560231208801,
-0.05366653576493263,
0.002019340405240655,
-0.03896918520331383,
-0.03548916056752205,
0.01814204454421997,
0.1050012856721878,
0.0014452249743044376,
0.020738814026117325,
-0.04621186852455139,
-0.07836233079433441,
-0.012356729246675968,
-0.009733463637530804,
-0.021056784316897392,
-0.014679688028991222,
-0.044374700635671616,
-0.03506520017981529,
0.06483086943626404,
-0.05910738557577133,
-0.0052112010307610035,
-0.03407595306634903,
0.047095123678445816,
0.032274115830659866,
-0.005979632493108511,
-0.01192393433302641,
-0.014202730730175972,
0.0010047018295153975,
-0.03352833539247513,
0.02444848231971264,
-0.018919309601187706,
-0.016931986436247826,
-0.03573647141456604,
0.01824803650379181,
0.037767957895994186,
-0.009671635925769806,
0.024466147646307945,
-0.016216550022363663,
0.02096845954656601,
0.06776327639818192,
-0.02110978029668331,
0.011853273957967758,
0.01328414585441351,
0.028988409787416458,
-0.008912037126719952,
0.029765672981739044,
0.024377821013331413,
-0.04363276809453964,
0.010872861370444298,
-0.014282223768532276,
0.0078874621540308,
0.02004987560212612,
0.044374700635671616,
-0.048508331179618835,
-0.03457057848572731,
0.011499972082674503,
-0.02782251313328743,
-0.03225645050406456,
0.011049512773752213,
0.02888241969048977,
0.030613597482442856,
0.005546837579458952,
-0.02282329462468624,
0.0018857481190934777,
-0.06486620008945465,
-0.03176182880997658,
0.014635525643825531,
-0.02842312678694725,
0.03289239481091499,
-0.01819504052400589,
0.03008364513516426,
-0.021498411893844604,
-0.019537586718797684,
-0.00758715532720089,
0.03114354982972145,
0.07020106166601181,
-0.02363588847219944,
0.0024289495777338743,
-0.059602007269859314,
0.015315631404519081,
-0.03925182670354843,
-0.008898788131773472,
0.011120173148810863,
0.038933854550123215,
-0.12160646915435791,
-0.033546000719070435,
-0.035612817853689194,
0.016525689512491226,
-0.02736322209239006,
-0.004743075929582119,
-0.0012111625401303172,
-0.0009467382915318012,
-0.014114405028522015,
-0.06571412831544876,
0.015739593654870987,
-0.04748375713825226,
0.010590219870209694,
-0.05115809664130211,
-0.06454823166131973,
0.00333870155736804,
0.08034081757068634,
0.029871663078665733,
-0.0017554680816829205,
0.04621186852455139,
-0.014812176115810871,
0.012568710371851921,
0.01149113941937685,
-0.038686543703079224,
0.024907773360610008,
0.03524184972047806,
0.02651529759168625,
-0.008545486256480217,
-0.03294539079070091,
0.0016638304805383086,
0.08274327218532562,
0.0009500505402684212,
-0.03744998574256897,
-0.034747228026390076,
-0.0560336597263813,
-0.02238166704773903,
-0.0318324901163578,
0.001679287408478558,
-0.0059222206473350525,
-0.016137057915329933,
0.02828180603682995,
0.0029721511527895927,
0.0051007941365242004,
-0.06405360996723175,
-0.07666648179292679,
-0.0842977985739708,
0.007622485514730215,
-0.002130851149559021,
-0.04889696463942528,
0.012895514257252216,
0.04441003128886223,
0.07772638648748398,
-0.03430560231208801,
0.017850572243332863,
-0.0009307293221354485,
-0.0038951518945395947,
-0.004531095270067453,
-0.029500696808099747,
0.06688002496957779,
-0.00667740311473608,
-0.10139760375022888,
-0.014282223768532276,
0.04356210678815842,
0.036814045161008835,
-0.03462357074022293,
-0.0198555588722229,
-0.03200913965702057,
-0.040241070091724396,
-0.011076009832322598,
0.03405829146504402,
-0.017417777329683304,
-0.031178880482912064,
-0.05967266857624054,
-0.06027327850461006,
-0.03734399750828743,
0.03805059939622879,
0.04398607090115547,
0.02595001459121704,
0.006222527474164963,
0.0035860128700733185,
-0.07730242609977722,
0.011623627506196499,
0.024572137743234634,
-0.0071764420717954636,
-0.017232293263077736,
0.018407022580504417,
-0.025526052340865135,
-0.022646643221378326,
-0.013752271421253681,
0.013028002344071865,
0.10259883105754852,
0.019325606524944305,
-0.03170883283019066,
0.04734243452548981,
-0.013222318142652512,
-0.006858470384031534,
-0.006456589791923761,
0.045328617095947266,
0.04380941763520241,
-0.06984775513410568,
-0.02333558164536953,
-0.006235776003450155,
-0.03582479804754257,
-0.029959989711642265,
0.006536082364618778,
-0.02847612276673317,
0.0007397255394607782,
-0.017143968492746353,
0.039746448397636414,
0.0369906947016716,
-0.009291836060583591,
0.015077152289450169,
-0.0007242686115205288,
-0.0331750363111496,
-0.06461889296770096,
0.07680780440568924,
-0.02252298779785633,
-0.01408790796995163,
-0.0015622562495991588,
-0.024201171472668648,
0.028599778190255165,
-0.04274951294064522,
0.02686859853565693,
0.00878396537154913,
-0.04889696463942528,
-0.025473056361079216,
-0.017903566360473633,
-0.028405461460351944,
0.05967266857624054,
0.01192393433302641,
-0.010828698985278606,
0.006628824397921562,
0.01383176352828741,
-0.0108110336586833,
0.02610900066792965,
-0.057376205921173096,
-0.02711590938270092,
0.035347841680049896,
-0.012524547055363655,
-0.01735594868659973,
0.03531251102685928,
0.026373976841568947,
-0.04197224974632263,
-0.042820174247026443,
-0.030525272712111473,
0.031426191329956055,
-0.008311423473060131,
0.005379019305109978,
-0.038686543703079224,
-0.009636305272579193,
-0.029253385961055756,
-0.04571724683046341,
0.013019169680774212,
-0.05695224553346634,
-0.0475897453725338,
-0.04903828352689743,
-0.003100222907960415,
0.02761053293943405,
0.013213485479354858,
-0.002349456772208214,
-0.01645503006875515,
-0.006920298095792532,
-0.012453886680305004,
0.0530305951833725,
0.06673870235681534,
-0.02374187856912613,
0.017938897013664246,
0.021304097026586533,
-0.0007982411771081388,
-0.03783861920237541,
0.004281575791537762,
-0.020032210275530815,
-0.05504441261291504,
-0.05108743533492088,
0.04822568967938423,
0.0015125732170417905,
0.09892449527978897,
0.04002908989787102,
0.016446197405457497,
-0.019166620448231697,
-0.03008364513516426,
-0.02358289249241352,
0.0663500726222992,
-0.015130148269236088,
0.0018956847488880157,
0.021251101046800613,
0.03624876216053963,
0.012286068871617317,
0.04970955848693848,
0.015509947203099728,
-0.05861276015639305,
-0.006951211951673031,
0.018460016697645187,
-0.004676831886172295,
0.004341195337474346,
-0.01267470046877861,
-0.032132796943187714,
-0.004756324924528599,
-0.0006889384239912033,
0.015898579731583595,
-0.06108587607741356,
0.07935157418251038,
-0.09051591157913208,
-0.030913904309272766,
0.04038239270448685,
-0.00462383683770895,
-0.007494413759559393,
-0.018080217763781548,
0.047201115638017654,
0.04055904224514961,
-0.02004987560212612,
0.008965032175183296,
0.014140903018414974,
0.07048369944095612,
0.017726914957165718,
0.046741824597120285,
-0.013796433806419373,
0.03635475039482117,
0.06589078158140182,
0.011738451197743416,
-0.02137475647032261,
0.0094508221372962,
0.025738032534718513,
-0.0020138199906796217,
-0.02001454494893551,
-0.0034248188603669405,
-0.03139086067676544,
0.04628252983093262,
0.04193691909313202,
0.020403176546096802,
0.0456819161772728,
0.05306592583656311
] |
725,823 | flask_admin.base | is_accessible |
Override this method to add permission checks.
Flask-Admin does not make any assumptions about the authentication system used in your application, so it is
up to you to implement it.
By default, it will allow access for everyone.
| def is_accessible(self):
"""
Override this method to add permission checks.
Flask-Admin does not make any assumptions about the authentication system used in your application, so it is
up to you to implement it.
By default, it will allow access for everyone.
"""
return True
| (self) | [
0.0516572967171669,
-0.00439566932618618,
0.041954100131988525,
0.016666458919644356,
0.06355941295623779,
0.0012194437440484762,
0.03563655540347099,
-0.01591603271663189,
-0.03329801559448242,
0.03520026057958603,
0.020942147821187973,
-0.02785305492579937,
0.009354159235954285,
0.00101874815300107,
-0.010279104113578796,
-0.036718565970659256,
0.012678724713623524,
0.02050585299730301,
0.029249198734760284,
-0.04125602915883064,
-0.029563330113887787,
-0.028132284060120583,
0.06830630451440811,
0.006526969373226166,
-0.0452350378036499,
0.05835878476500511,
-0.016788620501756668,
0.02150060422718525,
0.05141296982765198,
0.012094089761376381,
-0.0027748344000428915,
0.0028511860873550177,
0.07441443204879761,
0.0609765499830246,
0.04488600045442581,
-0.00048646863433532417,
0.01245185174047947,
0.0619189478456974,
-0.05361189693212509,
-0.030627889558672905,
-0.009118559770286083,
0.0072206780314445496,
0.011622891761362553,
-0.06991186738014221,
0.019388938322663307,
0.024851348251104355,
-0.006016504485160112,
0.04694531485438347,
-0.005475498735904694,
0.012102816253900528,
-0.024188179522752762,
-0.0013623302802443504,
0.0205407552421093,
0.013254634104669094,
-0.018132409080863,
-0.022774584591388702,
0.04659627750515938,
0.02291419915854931,
0.010296555235981941,
-0.034798868000507355,
-0.004232058767229319,
-0.011073159985244274,
0.016151631250977516,
-0.07964996248483658,
0.05172710493206978,
0.012792161665856838,
-0.07162214070558548,
0.04495580866932869,
0.012940501794219017,
0.0500517301261425,
-0.06488575041294098,
-0.03294897824525833,
0.00816743727773428,
0.01645703800022602,
0.018114957958459854,
-0.017050398513674736,
-0.011003352701663971,
-0.020104460418224335,
-0.00880879070609808,
-0.006876004859805107,
0.04212861880660057,
-0.06862043589353561,
0.0016655551735311747,
0.07874247431755066,
0.005767816212028265,
0.006849827244877815,
-0.03359469398856163,
-0.019964847713708878,
0.05574101582169533,
0.016867155209183693,
-0.01697186566889286,
-0.0056631057523190975,
0.03211129084229469,
-0.016099276021122932,
-0.033350370824337006,
0.00026177684776484966,
0.014293015003204346,
0.01046234741806984,
-0.012120267376303673,
-0.00021037585975136608,
-0.02547961287200451,
0.08048765361309052,
0.10806147754192352,
0.015427381731569767,
0.018132409080863,
-0.04457186907529831,
-0.057765424251556396,
-0.013682202436029911,
-0.026980465278029442,
0.0025326909963041544,
-0.0442926399409771,
0.0036408796440809965,
0.016832251101732254,
-0.0016622829716652632,
-0.023420300334692,
0.0033420175313949585,
-0.002397439442574978,
-0.06589795649051666,
0.006134303752332926,
-0.026334749534726143,
-0.0002024680288741365,
0.01982523314654827,
0.06376884132623672,
-0.03015669248998165,
0.04980740696191788,
0.08970219641923904,
-0.04453696683049202,
-0.013943979516625404,
-0.005885615944862366,
0.025531968101859093,
-0.018341830000281334,
-0.016840975731611252,
-0.08649107068777084,
0.011980653740465641,
0.02827189862728119,
-0.03392627835273743,
0.07727652043104172,
0.025008413940668106,
0.012294785119593143,
0.06603757292032242,
-0.03225090727210045,
0.01802769862115383,
0.04732925072312355,
0.0069632637314498425,
-0.015069619752466679,
0.02903977781534195,
-0.005191907286643982,
0.04087208956480026,
0.04816693812608719,
-0.051482778042554855,
0.03378666564822197,
0.024589570239186287,
0.010610687546432018,
-0.059685118496418,
-0.06376884132623672,
0.0693185105919838,
-0.04502561688423157,
-0.061779335141181946,
0.07245983183383942,
-0.036753468215465546,
-0.031046733260154724,
-0.004502561409026384,
-0.07846324145793915,
0.04160506650805473,
-0.007329751271754503,
-0.02034878544509411,
0.04146545007824898,
-0.052320465445518494,
-0.0045418282970786095,
0.04649156704545021,
-0.010340184904634953,
-0.03195422515273094,
0.010034779086709023,
0.01419703010469675,
-0.007574076764285564,
0.021640218794345856,
0.003226399654522538,
0.008852420374751091,
0.026072973385453224,
-0.03692798689007759,
-0.02766108512878418,
-0.0018989727832376957,
-0.04177958518266678,
0.03930142894387245,
0.04533974826335907,
0.03930142894387245,
0.008782613091170788,
0.039964597672224045,
-0.0007766046328470111,
0.08041784167289734,
-0.032233454287052155,
0.0006631679716520011,
-0.004576731938868761,
-0.024240534752607346,
-0.025584323331713676,
-0.019650714471936226,
-0.024729184806346893,
-0.01761758141219616,
-0.05214594677090645,
0.017635032534599304,
-0.04184938967227936,
-0.010191844776272774,
-0.045130327343940735,
-0.00045483725261874497,
0.04342005029320717,
0.06429239362478256,
-0.006007778458297253,
0.03727702051401138,
-0.023664625361561775,
-0.05479861795902252,
-0.020959598943591118,
-0.000976754818111658,
-0.004120803903788328,
0.049074430018663406,
-0.0030998741276562214,
-0.026736140251159668,
0.0184465404599905,
-0.0343276709318161,
0.026579074561595917,
0.06069732457399368,
0.047050025314092636,
0.04938856512308121,
-0.027940314263105392,
-0.02284439280629158,
0.0025348723866045475,
0.030121788382530212,
0.038812778890132904,
-0.045933108776807785,
-0.04680569842457771,
-0.035025741904973984,
0.014484984800219536,
-0.018795577809214592,
-0.003575435373932123,
0.06115106865763664,
0.020331334322690964,
0.03469415754079819,
0.04533974826335907,
0.0005131916841492057,
-0.056299470365047455,
0.04052305594086647,
-0.0206978227943182,
0.012006831355392933,
0.05773051828145981,
0.006260829512029886,
0.01224242988973856,
-0.0309594739228487,
-0.04101170599460602,
0.051063936203718185,
0.052285559475421906,
-0.06757333129644394,
-0.03546203672885895,
-0.008363770321011543,
-0.043105918914079666,
-0.011509454809129238,
-0.06150010600686073,
-0.008638635277748108,
-0.03553184121847153,
0.039790078997612,
-0.03668366000056267,
-0.010340184904634953,
-0.024432504549622536,
-0.021779833361506462,
-0.032268356531858444,
0.0073428405448794365,
0.03211129084229469,
0.0006157209281809628,
0.010191844776272774,
0.02300145849585533,
-0.003839393611997366,
0.020872339606285095,
0.11895139515399933,
0.05650889500975609,
-0.015933483839035034,
-0.013813091441988945,
-0.008093267679214478,
-0.047887708991765976,
0.04376908764243126,
0.06052280589938164,
-0.052599694579839706,
-0.00018188037211075425,
-0.003832849208265543,
0.014441356062889099,
-0.038777876645326614,
0.05085451528429985,
-0.0494234673678875,
-0.025968262925744057,
-0.03738173097372055,
0.037556249648332596,
-0.03975517675280571,
-0.01105570886284113,
0.043105918914079666,
0.00701125618070364,
0.0061561185866594315,
-0.03860335797071457,
0.03629972040653229,
0.013341892510652542,
-0.0002934082003775984,
0.012661272659897804,
-0.02043604478240013,
0.0041360738687217236,
-0.003717231098562479,
-0.02130863443017006,
-0.012364592403173447,
-0.008882960304617882,
0.04265217110514641,
-0.0019142430974170566,
0.018952643498778343,
0.028917614370584488,
0.014816569164395332,
0.03811470791697502,
0.01745178923010826,
-0.025270190089941025,
0.012512932531535625,
0.060592614114284515,
0.02528764307498932,
-0.0060470448806881905,
0.002833734266459942,
-0.0064833397045731544,
0.005074107553809881,
0.03989478945732117,
-0.04087208956480026,
0.09654329717159271,
-0.00033867379534058273,
-0.003937560133635998,
0.006417895667254925,
-0.013743284158408642,
0.06003415584564209,
0.012504206970334053,
-0.013551314361393452,
0.0773463323712349,
-0.06830630451440811,
0.011518181301653385,
0.0417097769677639,
-0.04579349607229233,
-0.051063936203718185,
-0.0034685430582612753,
-0.011081886477768421,
-0.05137806758284569,
-0.010567058809101582,
-0.05759090557694435,
-0.004807968158274889,
-0.009685742668807507,
0.03268720209598541,
0.022251030430197716,
-0.021762380376458168,
0.01883048005402088,
-0.018551252782344818,
0.042721979320049286,
-0.010593236424028873,
-0.03469415754079819,
0.03034866228699684,
0.03909200802445412,
-0.05040076747536659,
-0.01664900779724121,
-0.007102878298610449,
-0.07469365745782852,
-0.00498248590156436,
0.010148215107619762,
-0.005802719853818417,
0.006239014677703381,
0.04565387964248657,
-0.057800326496362686,
-0.011762506328523159,
0.02525273896753788,
-0.015837498009204865,
0.001953509636223316,
-0.01509579736739397,
-0.06275663524866104,
0.07350693643093109,
-0.05581082031130791,
0.034833770245313644,
-0.04694531485438347,
-0.015401204116642475,
-0.023542463779449463,
0.03410079702734947,
0.01472930982708931,
-0.015994565561413765,
0.010392540134489536,
-0.05120354890823364,
0.0484461672604084,
0.027451664209365845,
0.024781540036201477,
0.03685817867517471,
0.03937123715877533,
-0.027032822370529175,
-0.041884295642375946,
-0.0410815104842186,
0.044362448155879974,
-0.03769586607813835,
0.012896872125566006,
0.004991211928427219,
-0.06087183952331543,
-0.0564739890396595,
0.03102928213775158,
-0.07012128829956055,
-0.01947619765996933,
-0.0500517301261425,
0.015025991015136242,
0.009825357235968113,
0.019004998728632927,
0.046212337911129,
-0.0037783123552799225,
-0.025654129683971405,
-0.025270190089941025,
0.019895039498806,
0.06921379268169403,
0.015776418149471283,
-0.001474676188081503,
-0.022984007373452187,
0.02062801457941532,
0.014563518576323986,
0.02884780801832676,
-0.008272147737443447,
0.0002227829972980544,
0.04184938967227936,
-0.02471173368394375,
0.0108288349583745,
0.013176101259887218,
0.03513045236468315,
0.014685681089758873,
0.06998167186975479,
-0.0013448784593492746,
0.056264568120241165,
0.010392540134489536,
0.002275276929140091,
0.013882898725569248,
0.009083656594157219,
0.03317585214972496,
-0.024851348251104355,
-0.007744231261312962,
0.0003787583555094898,
0.017530322074890137,
0.021762380376458168,
-0.020523304119706154,
0.019423840567469597,
-0.013402974233031273,
-0.0010225657606497407,
-0.03417060151696205,
-0.05204123631119728,
0.007190137170255184,
0.06362922489643097,
-0.049737598747015,
0.011352389119565487,
-0.007530447095632553,
0.07874247431755066,
-0.005388239864259958,
-0.06006905809044838,
0.08670049160718918,
0.0673988088965416,
-0.03706759959459305,
-0.005261714570224285,
0.047468867152929306,
0.024310342967510223,
0.016404682770371437,
-0.05692773684859276,
0.02708517760038376,
-0.02540980465710163,
-0.01623889058828354,
0.007024344988167286,
0.05570610985159874,
0.034537091851234436,
-0.0073864697478711605,
-0.08188379555940628,
-0.040732476860284805,
0.02624749019742012,
0.014074867591261864,
0.0008600460132583976,
0.04806222766637802,
0.0013219730462878942,
0.03807980567216873,
0.05406564474105835,
-0.06893456727266312,
-0.000014963546163926367,
-0.05567120760679245,
0.018760673701763153,
0.027800699695944786,
0.023053813725709915,
0.03425786271691322,
-0.052285559475421906,
-0.005187544506043196,
-0.02670123800635338,
-0.030907118692994118,
-0.025566870346665382,
0.017381982877850533,
-0.05054038017988205,
-0.10938781499862671,
-0.016858428716659546,
0.006531332153826952,
-0.008699717000126839,
-0.049563080072402954,
0.013402974233031273,
-0.001536848139949143,
-0.0071377819404006,
-0.00201022787950933,
-0.008237244561314583,
0.004655264783650637,
0.003839393611997366,
-0.006343725603073835,
-0.01232096366584301,
0.020959598943591118,
-0.02047094888985157,
0.0176524855196476,
-0.04254746064543724,
0.02746911719441414,
0.014755487442016602,
-0.0676780417561531,
-0.0028511860873550177,
-0.03324566036462784,
-0.00031604099785909057,
-0.0013885080115869641,
0.012425674125552177,
-0.005588935688138008,
0.00293190055526793,
0.004825419746339321,
0.03122125007212162,
0.031552836298942566,
-0.017530322074890137,
0.03230326250195503,
0.0016361052403226495,
0.010418717749416828,
0.006439710035920143,
-0.11329701542854309,
-0.01863851025700569,
-0.015907306224107742,
-0.02762618288397789,
-0.037486445158720016,
-0.00401827460154891,
0.010252926498651505,
-0.037975095212459564,
0.056648507714271545,
-0.002257825341075659,
0.036788370460271835,
-0.008372495882213116,
-0.02040114253759384,
-0.04561897739768028,
0.07329751551151276,
-0.061430297791957855,
0.0063742659986019135,
-0.029563330113887787,
0.022634970024228096,
0.037137407809495926,
-0.01982523314654827,
0.013795639388263226,
-0.012329689227044582,
-0.025462159886956215,
-0.07999899983406067,
-0.06991186738014221,
-0.05193652585148811,
0.07776517421007156,
-0.02532254531979561,
0.011893394403159618,
0.04736415669322014,
0.02047094888985157,
0.021832188591361046,
0.05675321817398071,
-0.006522606126964092,
0.046840600669384,
-0.0025326909963041544,
0.0031849516090005636,
0.03462434932589531,
-0.0015423018485307693,
-0.05532217025756836,
0.031936775892972946,
-0.018306927755475044,
0.011273856274783611,
-0.025165479630231857,
0.005484224762767553,
0.017975343391299248,
-0.03115144371986389,
-0.04129093512892723,
-0.06973735243082047,
-0.05769561603665352,
-0.05130825936794281,
0.044711485505104065,
-0.05752109736204147,
-0.012827064841985703,
0.01608182303607464,
0.024135824292898178,
-0.01794043928384781,
-0.020802533254027367,
-0.006823649629950523,
-0.0014474077615886927,
-0.02685830369591713,
0.010034779086709023,
-0.047538675367832184,
-0.0025239649694412947,
0.0384986475110054,
0.033228207379579544,
0.0042146071791648865,
-0.03724211826920509,
-0.011142967268824577,
0.0266314297914505,
-0.004703257232904434,
-0.10087133944034576,
0.0009391244384460151,
-0.02406601794064045,
-0.0384986475110054,
-0.0378703810274601,
0.019947394728660583,
0.0404183454811573,
-0.020785080268979073,
0.00910983420908451,
-0.0017811732832342386,
-0.05239026993513107,
0.03102928213775158,
-0.007246855646371841,
0.032774459570646286,
-0.05919646844267845,
-0.04725944623351097,
-0.02547961287200451,
-0.04094189777970314,
-0.004960671067237854,
-0.036264818161726,
0.014415177516639233,
0.02111666463315487,
0.011273856274783611,
-0.052215754985809326,
-0.029947269707918167,
0.09088891744613647,
-0.03211129084229469,
-0.09340197592973709,
0.03490357846021652,
0.006858553271740675,
-0.02961568720638752,
-0.018341830000281334,
-0.03780057653784752,
0.04561897739768028,
-0.020156817510724068,
0.004173159133642912,
0.04575859010219574,
-0.027172435075044632,
-0.03186696767807007,
0.023507559671998024,
0.012076637707650661,
0.012067912146449089,
-0.037207216024398804,
-0.03731192648410797,
-0.04935365915298462,
0.04457186907529831,
-0.01905735395848751,
0.03233816474676132,
-0.03249523043632507,
-0.006435347255319357,
0.030243949964642525,
0.021901994943618774,
0.09912616014480591,
-0.035950686782598495,
-0.00541441747918725,
0.015645528212189674,
-0.07692749053239822,
-0.055042944848537445,
0.07588037848472595,
0.006474613677710295,
0.012408222071826458,
-0.0677129402756691,
-0.018149860203266144,
-0.05598533898591995,
-0.008647361770272255,
-0.021936899051070213,
-0.03940613940358162,
0.006780019961297512,
-0.04069757089018822,
0.0076046171598136425,
-0.005104648414999247,
0.03410079702734947,
0.022582614794373512,
-0.0028686379082500935,
0.009371611289680004,
0.004048814997076988,
0.07588037848472595,
0.05696263909339905,
0.004886501003056765,
0.024851348251104355,
0.0044327545911073685,
0.06324528157711029,
0.010436169803142548,
0.030470823869109154,
-0.017731018364429474,
-0.01575024053454399,
-0.0090662045404315,
-0.049179140478372574,
-0.03650914132595062,
-0.04544445872306824,
-0.017460515722632408,
0.00827651098370552,
0.022128868848085403,
0.011649069376289845,
-0.02727714739739895,
0.019580908119678497,
-0.026509268209338188,
-0.05280911549925804,
-0.020942147821187973,
0.0012161715421825647,
0.06376884132623672,
0.012390770018100739,
-0.017669936642050743,
-0.002080035163089633,
0.02582864835858345,
0.017477966845035553,
0.07280886173248291,
0.02999962493777275,
-0.006627317052334547,
-0.004799242131412029,
0.048236746340990067,
-0.002246917923912406,
-0.04328043758869171,
-0.019580908119678497,
-0.016500666737556458,
-0.0023145435843616724,
-0.0353049710392952,
-0.004986848682165146,
0.05884743481874466,
0.06516498327255249,
-0.032582491636276245,
-0.0072773960418999195,
-0.017268545925617218,
0.03298388049006462,
0.021710025146603584,
0.026195134967565536,
-0.02958078309893608,
-0.0314481258392334,
-0.006937086116522551,
-0.007748594507575035,
-0.03506064414978027,
0.047573577612638474,
-0.017704840749502182,
-0.11169145256280899,
-0.019301678985357285,
-0.021710025146603584,
0.01159671414643526,
0.04055795818567276,
-0.02589845471084118,
-0.03513045236468315,
0.06240759789943695,
-0.023053813725709915,
0.0036954162642359734,
-0.04565387964248657,
0.05406564474105835,
-0.0677129402756691,
0.01408359408378601,
0.06645641475915909,
-0.008843693882226944,
-0.007312299683690071,
-0.012809613719582558,
-0.008328866213560104,
0.02361227013170719,
-0.026334749534726143,
0.006640405859798193,
0.038812778890132904,
0.06792236119508743,
0.03985988721251488,
0.009615936316549778,
0.016998043283820152,
0.015409929677844048,
-0.019266774877905846,
0.019895039498806,
-0.018394185230135918,
0.011439647525548935,
-0.04219842702150345,
-0.0058158086612820625,
-0.016518117859959602,
0.011622891761362553,
-0.060627516359090805,
-0.0010318370768800378,
0.057800326496362686,
-0.020942147821187973,
0.02425798773765564,
0.03745153918862343
] |
725,824 | flask_admin.base | is_visible |
Override this method if you want dynamically hide or show administrative views
from Flask-Admin menu structure
By default, item is visible in menu.
Please note that item should be both visible and accessible to be displayed in menu.
| def is_visible(self):
"""
Override this method if you want dynamically hide or show administrative views
from Flask-Admin menu structure
By default, item is visible in menu.
Please note that item should be both visible and accessible to be displayed in menu.
"""
return True
| (self) | [
0.06101265549659729,
-0.0036240904591977596,
0.057516951113939285,
-0.007599553093314171,
0.056147500872612,
0.004353863652795553,
0.009514082223176956,
0.005518347956240177,
-0.020884130150079727,
0.06342720985412598,
-0.021244512870907784,
-0.013811635784804821,
0.02592947706580162,
-0.009514082223176956,
-0.037443678826093674,
0.0242356825619936,
0.01888401061296463,
-0.024722198024392128,
0.08742864429950714,
-0.0455162338912487,
-0.03978615999221802,
0.0355696938931942,
0.061733417212963104,
-0.018523629754781723,
-0.045624349266290665,
0.011388068087399006,
-0.039678048342466354,
0.0193525068461895,
0.022541888058185577,
-0.015811756253242493,
-0.003054236527532339,
-0.02747911959886551,
0.0665985718369484,
0.018001075834035873,
0.03895728290081024,
0.02219952456653118,
-0.0037119335029274225,
0.03920954838395119,
-0.0121178412809968,
-0.0014144988963380456,
0.01078442856669426,
-0.016073033213615417,
0.02221754379570484,
-0.07964439690113068,
-0.002036157762631774,
0.0075590102933347225,
0.02101026475429535,
0.04839928820729256,
-0.006833741907030344,
0.02162291295826435,
0.04054296389222145,
-0.014126970432698727,
0.007049970794469118,
0.02747911959886551,
-0.058526020497083664,
0.017541589215397835,
0.026650240644812584,
0.0022636486683040857,
-0.000956701289396733,
0.00014724979700986296,
0.010568198747932911,
0.0076400963589549065,
-0.011874583549797535,
-0.09665442258119583,
0.06858067214488983,
0.020253462716937065,
-0.06594988703727722,
0.021280551329255104,
-0.011297972872853279,
0.06822029501199722,
-0.08115800470113754,
0.012712471187114716,
0.021694989874958992,
0.06843651831150055,
0.010117721743881702,
-0.034308355301618576,
-0.003524985397234559,
-0.014433294534683228,
0.007288723718374968,
-0.028344035148620605,
0.03618234395980835,
-0.05225537344813347,
0.045191891491413116,
0.034236278384923935,
-0.009036576375365257,
0.01354135014116764,
0.010351969860494137,
-0.001709561562165618,
0.06951766461133957,
0.018001075834035873,
-0.023064441978931427,
0.014928819611668587,
0.004973269999027252,
-0.026578165590763092,
-0.03668687865138054,
0.02378520555794239,
0.05193103104829788,
-0.00025902449851855636,
-0.012325060553848743,
-0.04057900235056877,
0.0010141371749341488,
0.058129601180553436,
0.09687065333127975,
0.026848450303077698,
0.01719021610915661,
-0.06288664042949677,
-0.04266921803355217,
0.0195326991379261,
-0.02156885713338852,
-0.010640275664627552,
0.00043358447146601975,
-0.019190335646271706,
0.03174964338541031,
0.019316470250487328,
0.0003468675713520497,
0.006892303936183453,
-0.014199046418070793,
-0.03675895184278488,
0.007013932801783085,
-0.01623520441353321,
-0.017163187265396118,
0.0009955549612641335,
-0.005360680632293224,
-0.04684964567422867,
0.03686706721782684,
0.03342542052268982,
-0.05351671203970909,
-0.003387589706107974,
0.03407410904765129,
0.028830552473664284,
-0.0007534233736805618,
-0.020757997408509254,
-0.08973509073257446,
0.024614082649350166,
0.023586995899677277,
0.004563335794955492,
0.02863234095275402,
0.026055611670017242,
0.008631146512925625,
0.07841909676790237,
-0.07604058086872101,
-0.01209982205182314,
-0.0036331000737845898,
0.04083126783370972,
-0.045660387724637985,
-0.004928222391754389,
-0.01834343932569027,
0.07088711857795715,
0.03780405968427658,
-0.03360561281442642,
0.005387709476053715,
0.0039123957976698875,
0.01109976228326559,
-0.031136995181441307,
-0.03493902459740639,
0.009360919706523418,
-0.02915489487349987,
-0.0325244665145874,
0.05766110494732857,
-0.046705491840839386,
-0.014036875218153,
0.015838785097002983,
-0.04692172259092331,
0.06061623618006706,
-0.041876375675201416,
-0.038128405809402466,
0.03081265278160572,
-0.03194785490632057,
0.027425061911344528,
0.0462009571492672,
0.003948434256017208,
0.0015226134564727545,
-0.012685442343354225,
-0.0044281925074756145,
-0.0559673085808754,
0.03402005136013031,
-0.022848211228847504,
-0.012766528874635696,
0.01563156396150589,
-0.031623512506484985,
-0.029389142990112305,
-0.0030159458983689547,
-0.07618473470211029,
0.015433354303240776,
0.019172316417098045,
0.030632460489869118,
-0.001776007004082203,
0.023586995899677277,
-0.01786593161523342,
0.07841909676790237,
-0.06537327915430069,
0.014577447436749935,
0.00864466093480587,
-0.038020290434360504,
-0.03504713997244835,
0.0021600390318781137,
-0.0430656373500824,
-0.029371123760938644,
-0.054273512214422226,
-0.02162291295826435,
0.0067166173830628395,
-0.03245238959789276,
-0.0528319850564003,
0.022001314908266068,
0.0411556139588356,
0.07805871963500977,
0.024001434445381165,
0.04029069468379021,
-0.018136218190193176,
-0.005221032537519932,
-0.08829356729984283,
0.02542494237422943,
0.012865633703768253,
0.020109308883547783,
-0.014946838840842247,
-0.040723152458667755,
-0.05996754765510559,
0.013415216468274593,
-0.003973210230469704,
0.02814582549035549,
0.0006115230498835444,
-0.01683884486556053,
-0.011748449876904488,
0.03306503966450691,
-0.01210883166640997,
0.03773198276758194,
0.017415454611182213,
-0.02803771197795868,
-0.023929357528686523,
0.024181624874472618,
-0.009126671589910984,
0.0021510294172912836,
0.004396659322082996,
0.02915489487349987,
0.003765990724787116,
0.03938974067568779,
0.0000053978096730133984,
0.030362173914909363,
-0.06811217963695526,
0.03555167466402054,
-0.030434250831604004,
0.0020699435845017433,
0.03938974067568779,
-0.011784488335251808,
-0.004549821373075247,
-0.018721839413046837,
-0.04753437265753746,
0.03256050497293472,
0.010505132377147675,
-0.029010742902755737,
0.004757041111588478,
-0.06151719018816948,
-0.00311054615303874,
-0.0021825628355145454,
-0.021172435954213142,
0.007797763217240572,
-0.057516951113939285,
0.04587661474943161,
-0.05989547073841095,
-0.008604117669165134,
-0.035263366997241974,
-0.010964618995785713,
-0.025659190490841866,
0.025064561516046524,
0.011820525862276554,
-0.002082331571727991,
0.03382183983922005,
0.03504713997244835,
-0.01611807942390442,
0.0035137233790010214,
0.1496305614709854,
0.049984969198703766,
-0.01570364087820053,
-0.001549642183817923,
0.04472339153289795,
-0.054778046905994415,
0.02474021725356579,
-0.03953389450907707,
-0.11359237134456635,
0.0031533415894955397,
0.022902268916368484,
0.016604594886302948,
-0.03387589752674103,
0.07575227320194244,
-0.050489503890275955,
-0.030073869973421097,
-0.0148207051679492,
0.042380910366773605,
-0.02805573120713234,
0.0070905135944485664,
0.05942697450518608,
0.008775299414992332,
0.033731743693351746,
0.002587992465123534,
0.016316290944814682,
0.02045167237520218,
-0.015955908223986626,
0.0378400981426239,
-0.015325239859521389,
0.01572166010737419,
0.020307520404458046,
-0.024523988366127014,
-0.00582016771659255,
-0.014172017574310303,
0.06822029501199722,
0.011730430647730827,
0.004313320852816105,
0.03877709060907364,
0.02861432172358036,
0.042813368141651154,
-0.016325300559401512,
-0.015541469678282738,
0.0024190633557736874,
0.05456181988120079,
-0.029010742902755737,
-0.04807494580745697,
-0.018154237419366837,
0.003644361859187484,
0.02648806944489479,
0.06252625584602356,
-0.02857828512787819,
0.09031170606613159,
-0.03515525534749031,
0.02751515805721283,
0.01665865257382393,
-0.029497258365154266,
0.038560863584280014,
-0.01487476285547018,
-0.0030609937384724617,
0.055859193205833435,
-0.040795229375362396,
0.0076446011662483215,
0.021947257220745087,
-0.034740813076496124,
-0.04252506420016289,
0.005040841642767191,
-0.011415096931159496,
-0.014496361836791039,
-0.0070905135944485664,
-0.07921194285154343,
0.004121867939829826,
0.024109547957777977,
-0.006473359651863575,
0.010685322806239128,
-0.03259654343128204,
0.01946062222123146,
-0.0008739260956645012,
0.0058562057092785835,
-0.0017658713040873408,
0.011234905570745468,
0.00920775718986988,
-0.030470289289951324,
-0.006266140379011631,
-0.0032254180405288935,
0.012847614474594593,
-0.03508317843079567,
0.00527959456667304,
-0.00893296580761671,
0.011288963258266449,
0.03414618596434593,
0.052075184881687164,
-0.01989307999610901,
-0.05722864344716072,
-0.014712590724229813,
-0.01784791424870491,
-0.04248902574181557,
0.017919989302754402,
-0.04043484851717949,
0.12080001085996628,
-0.09593366086483002,
-0.007360800169408321,
-0.044471126049757004,
0.03194785490632057,
-0.007797763217240572,
0.0430656373500824,
0.0008581593865528703,
-0.001109863631427288,
0.017001016065478325,
-0.02095620706677437,
0.019244393333792686,
0.0015586516819894314,
0.03405608981847763,
0.02747911959886551,
-0.001549642183817923,
0.019082222133874893,
-0.018217304721474648,
-0.019334489479660988,
0.08714034408330917,
-0.061264920979738235,
-0.035803940147161484,
0.04490358382463455,
-0.01719922572374344,
-0.06706707179546356,
0.050525542348623276,
-0.06804010272026062,
-0.05985943228006363,
-0.019857041537761688,
-0.008685203269124031,
0.000013848659364157356,
0.01216288935393095,
0.0662742331624031,
0.019172316417098045,
-0.05607542395591736,
-0.001672397251240909,
0.024469930678606033,
0.031623512506484985,
-0.024397853761911392,
0.016550539061427116,
-0.01733436994254589,
-0.035407520830631256,
0.03848878666758537,
-0.009108652360737324,
-0.07928401976823807,
-0.03311909735202789,
0.018028104677796364,
-0.018154237419366837,
0.03283078968524933,
0.0634632483124733,
0.04252506420016289,
-0.004856145940721035,
0.055246543139219284,
0.024992484599351883,
0.06342720985412598,
-0.013901731930673122,
0.047786638140678406,
-0.005329147446900606,
-0.034254297614097595,
0.00806804932653904,
0.005315633025020361,
0.002756921574473381,
0.0028199884109199047,
-0.0430656373500824,
0.025028523057699203,
-0.018559668213129044,
0.014703581109642982,
0.0018559667514637113,
0.0399303138256073,
-0.060688309371471405,
-0.06411194056272507,
0.03192983567714691,
0.05239952728152275,
-0.01400984637439251,
-0.018181266263127327,
0.014631505124270916,
0.04818306118249893,
0.009811396710574627,
-0.026848450303077698,
0.044507164508104324,
0.10472697764635086,
-0.05394916981458664,
-0.021821124479174614,
0.06728330254554749,
0.0008266259683296084,
0.01157726813107729,
-0.007315752562135458,
-0.054814085364341736,
-0.04029069468379021,
0.00976634956896305,
-0.014703581109642982,
0.09182530641555786,
0.003042974742129445,
-0.01162231620401144,
-0.11164630949497223,
-0.030055850744247437,
0.05712053179740906,
0.012847614474594593,
-0.012865633703768253,
0.03066849894821644,
-0.027389023452997208,
-0.03342542052268982,
0.03450656682252884,
-0.0357498824596405,
-0.00552735710516572,
-0.03510119765996933,
0.013108891434967518,
-0.006207578349858522,
0.03445250913500786,
0.04576849937438965,
-0.04266921803355217,
-0.01622619479894638,
-0.027407042682170868,
-0.015802746638655663,
-0.029983773827552795,
0.014514381065964699,
-0.04029069468379021,
-0.06548138707876205,
-0.02160489372909069,
-0.000024336335627594963,
-0.0015642826911062002,
-0.013424225151538849,
0.015460383147001266,
-0.05466993525624275,
-0.0038853674195706844,
0.017055073752999306,
0.025010503828525543,
-0.00942398700863123,
0.04205656796693802,
0.007360800169408321,
0.034848928451538086,
-0.011270944029092789,
-0.04144391790032387,
0.020812055096030235,
0.007189618889242411,
0.03902935981750488,
0.0314793586730957,
-0.0665985718369484,
0.006004863418638706,
-0.014379237778484821,
-0.05275990813970566,
-0.048795707523822784,
0.0333893820643425,
-0.0231004785746336,
0.03420024365186691,
0.023911338299512863,
0.010397017933428288,
0.031605493277311325,
-0.000020711400793516077,
0.037551794201135635,
0.07942816615104675,
0.022938307374715805,
0.03396599367260933,
-0.10321337729692459,
0.0020890887826681137,
-0.060147739946842194,
-0.03517327457666397,
-0.009005042724311352,
-0.02756921574473381,
0.03841670975089073,
-0.04486754536628723,
0.05236348882317543,
-0.02919093333184719,
0.004977774806320667,
-0.01830740086734295,
0.01628025248646736,
-0.024596063420176506,
0.05020119622349739,
-0.049948930740356445,
0.04684964567422867,
-0.032092008739709854,
0.02971348725259304,
0.029263010248541832,
-0.023010384291410446,
0.03946181759238243,
-0.0015473897801712155,
0.021965276449918747,
-0.05503031611442566,
-0.0009234786266461015,
-0.020307520404458046,
0.0605081208050251,
-0.01735238917171955,
-0.02218150533735752,
0.02490238845348358,
0.022505849599838257,
-0.022794155403971672,
0.04915609210729599,
0.023532938212156296,
0.003166856011375785,
0.01720823533833027,
0.012748509645462036,
0.02272207848727703,
-0.0020755743607878685,
-0.029911696910858154,
0.006860770285129547,
-0.012063783593475819,
-0.0021262532100081444,
-0.00806804932653904,
-0.01297374814748764,
0.015442363917827606,
0.02753317728638649,
-0.0028335025999695063,
-0.02812780626118183,
-0.055246543139219284,
-0.04785871505737305,
0.0306865181773901,
-0.04137184098362923,
0.017919989302754402,
0.08115800470113754,
0.01827136240899563,
-0.015775717794895172,
-0.03632649406790733,
-0.022343678399920464,
-0.00013303160085342824,
-0.011306981556117535,
0.015487411990761757,
-0.07431074976921082,
-0.029533296823501587,
0.03387589752674103,
0.004752536304295063,
0.014622495509684086,
-0.0166496429592371,
0.006824732292443514,
0.04137184098362923,
0.00839689839631319,
-0.05499427765607834,
0.03942577913403511,
-0.03719141334295273,
0.03729952499270439,
-0.025479000061750412,
-0.012334070168435574,
0.06667064875364304,
-0.011703401803970337,
-0.0025001494213938713,
0.051030077040195465,
-0.053192365914583206,
0.07164391875267029,
-0.012748509645462036,
0.00921676680445671,
-0.07196826487779617,
-0.06443627923727036,
-0.036506686359643936,
-0.055823154747486115,
-0.028902627527713776,
-0.01668568141758442,
0.08050931245088577,
0.0018886263715103269,
-0.026055611670017242,
-0.016451433300971985,
-0.06249022111296654,
0.06270644813776016,
-0.010595227591693401,
-0.09932125359773636,
0.04194845259189606,
-0.009243795648217201,
-0.05629165098071098,
-0.02313651703298092,
-0.04688568413257599,
0.020884130150079727,
-0.012910681776702404,
0.02812780626118183,
0.03030811809003353,
-0.0035137233790010214,
-0.03942577913403511,
-0.005995853804051876,
-0.017631683498620987,
0.02430775947868824,
-0.056147500872612,
-0.05185895413160324,
0.009784368798136711,
-0.001770376111380756,
0.012460203841328621,
0.01566760241985321,
-0.04854344204068184,
-0.04468735679984093,
0.01021682657301426,
0.013226015493273735,
0.071499764919281,
-0.004770555533468723,
0.01673072949051857,
-0.0020294005516916513,
-0.04317375272512436,
-0.03277673199772835,
0.06443627923727036,
-0.028326017782092094,
0.02962339110672474,
-0.05466993525624275,
-0.033713724464178085,
-0.012280013412237167,
-0.00783830601722002,
-0.03171360492706299,
-0.031623512506484985,
0.02427172102034092,
-0.06389570981264114,
-0.02922697179019451,
-0.023082461208105087,
0.07625681161880493,
-0.013054833747446537,
0.01732536032795906,
0.01994713768362999,
0.02373114787042141,
0.0066130077466368675,
0.05575107783079147,
-0.020938187837600708,
-0.006428312044590712,
-0.03311909735202789,
0.05139045789837837,
-0.005329147446900606,
-0.027190813794732094,
0.019028164446353912,
0.004500268958508968,
-0.014361218549311161,
-0.04955251142382622,
-0.011036695912480354,
-0.07344582676887512,
-0.018217304721474648,
0.016018975526094437,
0.008279774338006973,
-0.02436181530356407,
-0.03769594803452492,
0.020685920491814613,
-0.02529880963265896,
-0.03558771312236786,
-0.05142649635672569,
-0.015000896528363228,
0.07135561853647232,
0.05679618567228317,
-0.000598571787122637,
0.00011979882401647046,
0.009050090797245502,
-0.02268604002892971,
0.052579719573259354,
0.03441647067666054,
-0.004493511747568846,
0.01400984637439251,
0.04857948049902916,
-0.029551316052675247,
-0.007036456372588873,
-0.019821004942059517,
-0.028776494786143303,
-0.03171360492706299,
0.0016904163639992476,
-0.0044754925183951855,
0.02647005021572113,
0.05762506648898125,
-0.025208713486790657,
-0.02960537187755108,
-0.03468675911426544,
-0.016964977607131004,
0.017037054523825645,
0.009865454398095608,
0.0015834280056878924,
0.008036516606807709,
-0.010568198747932911,
-0.018487591296434402,
-0.01827136240899563,
0.04137184098362923,
-0.0080860685557127,
-0.1072496548295021,
-0.020739978179335594,
-0.007117542438209057,
0.022866230458021164,
0.012703461572527885,
-0.044507164508104324,
-0.035785920917987823,
0.026596182957291603,
-0.0148207051679492,
0.006063425447791815,
-0.05661599710583687,
0.031173033639788628,
-0.07178807258605957,
-0.000665017229039222,
0.09290645271539688,
0.028344035148620605,
0.015009906142950058,
-0.010712351649999619,
-0.028253940865397453,
0.01996515691280365,
-0.008144631050527096,
0.0258934386074543,
0.04317375272512436,
0.048363249748945236,
0.04003842920064926,
0.009604177437722683,
-0.016334310173988342,
0.026758356019854546,
0.04630907252430916,
0.018721839413046837,
-0.015172077342867851,
0.011117781512439251,
-0.02095620706677437,
-0.019748928025364876,
0.015000896528363228,
0.0032321750186383724,
0.0019561978988349438,
0.0032209132332354784,
0.053696900606155396,
-0.00037614861503243446,
-0.0007151328027248383,
0.0021453984081745148
] |
725,825 | flask_admin.base | render |
Render template
:param template:
Template path to render
:param kwargs:
Template arguments
| def render(self, template, **kwargs):
"""
Render template
:param template:
Template path to render
:param kwargs:
Template arguments
"""
# Store self as admin_view
kwargs['admin_view'] = self
kwargs['admin_base_template'] = self.admin.base_template
# Provide i18n support even if flask-babel is not installed
# or enabled.
kwargs['_gettext'] = babel.gettext
kwargs['_ngettext'] = babel.ngettext
kwargs['h'] = h
# Expose get_url helper
kwargs['get_url'] = self.get_url
# Expose config info
kwargs['config'] = current_app.config
# Contribute extra arguments
kwargs.update(self._template_args)
return render_template(template, **kwargs)
| (self, template, **kwargs) | [
0.03510570153594017,
-0.09012788534164429,
0.05862574651837349,
0.038360536098480225,
0.08082836121320724,
-0.005138955544680357,
-0.014753307215869427,
0.035648174583911896,
-0.04107289761304855,
-0.008495502173900604,
0.054324716329574585,
0.017795026302337646,
-0.05653335526585579,
-0.03276144713163376,
-0.016429157927632332,
0.06273303925991058,
0.0314827635884285,
-0.06796401739120483,
0.040685415267944336,
-0.038554273545742035,
0.010035735554993153,
-0.03070780262351036,
-0.003298424882814288,
0.034563228487968445,
-0.012089380994439125,
0.002033059950917959,
-0.03444698452949524,
0.009929179213941097,
0.04777630418539047,
-0.027414221316576004,
0.011198176071047783,
-0.0032403026707470417,
0.021369529888033867,
0.02377190813422203,
0.035008832812309265,
-0.029777849093079567,
-0.0009983668569475412,
0.023171313107013702,
-0.024740608409047127,
-0.004715149290859699,
0.015479831956326962,
-0.004032215569168329,
0.0377986878156662,
-0.015382962301373482,
0.019044648855924606,
0.02987471967935562,
0.001254466944374144,
0.055177174508571625,
-0.0034074035938829184,
-0.017785338684916496,
0.00850034598261118,
0.0013586023123934865,
-0.04134413227438927,
-0.0335751548409462,
-0.06474793702363968,
0.01828906312584877,
0.006320769898593426,
-0.004354308359324932,
-0.016051365062594414,
-0.031444013118743896,
-0.01890903152525425,
0.016526028513908386,
-0.017349423840641975,
-0.02014896832406521,
0.007236192002892494,
0.04254532232880592,
-0.03169587627053261,
0.04332027956843376,
0.00134165002964437,
0.0036471569910645485,
-0.008795799687504768,
0.04688509926199913,
0.023675037547945976,
-0.017756277695298195,
0.0399104543030262,
0.0011624405160546303,
0.0005715332226827741,
-0.020458951592445374,
-0.014172086492180824,
0.012796532362699509,
0.059361960738897324,
-0.07745727896690369,
-0.02561243809759617,
0.05816077068448067,
0.04789254814386368,
-0.027046114206314087,
-0.048667505383491516,
-0.03258708119392395,
-0.029487239196896553,
0.029312873259186745,
-0.024081891402602196,
-0.020323334261775017,
-0.020846432074904442,
0.015886686742305756,
-0.008112865500152111,
-0.00420415960252285,
-0.03975546360015869,
0.0033904514275491238,
0.024701859802007675,
0.03452448174357414,
0.037275590002536774,
0.05273604765534401,
0.028266677632927895,
-0.059555698186159134,
0.011605030857026577,
-0.04669135808944702,
-0.05870324373245239,
0.02499246969819069,
0.00012335793871898204,
-0.0020742297638207674,
-0.016128862276673317,
0.0008712249109521508,
-0.02417876198887825,
-0.005395661108195782,
-0.05060490965843201,
0.020032724365592003,
-0.05711457505822182,
-0.016496967524290085,
0.006194838788360357,
-0.01196344941854477,
-0.03450510650873184,
-0.020517073571681976,
0.038593024015426636,
-0.032916437834501266,
0.011856893077492714,
0.014879237860441208,
-0.03258708119392395,
-0.0735049843788147,
0.016448533162474632,
-0.04932622238993645,
-0.017601285129785538,
0.0272979773581028,
-0.011508160270750523,
-0.022822581231594086,
0.022803207859396935,
0.022338230162858963,
0.0062820217572152615,
-0.008727990090847015,
0.00615609111264348,
0.12058382481336594,
0.002797122346237302,
-0.04479270428419113,
0.006446701008826494,
0.01659383811056614,
-0.04293280094861984,
-0.009410924278199673,
0.029506614431738853,
0.03297455981373787,
-0.004848345182836056,
0.048628758639097214,
0.034175749868154526,
0.009052504785358906,
0.05994318053126335,
-0.05316227674484253,
-0.060214415192604065,
0.04851251468062401,
0.0035672392696142197,
0.022822581231594086,
0.018434368073940277,
0.02119516395032406,
0.0039813583716750145,
0.03318767622113228,
-0.02665863372385502,
0.04874500259757042,
0.009251088835299015,
0.041111644357442856,
0.014385201036930084,
-0.04084040969610214,
0.02900288999080658,
0.015208596363663673,
0.015072978101670742,
-0.012631853111088276,
-0.021098295226693153,
0.026116162538528442,
-0.03324579820036888,
0.016361350193619728,
-0.0420028492808342,
0.01974211446940899,
0.0008990750648081303,
-0.022996947169303894,
-0.016719767823815346,
-0.03088216856122017,
-0.07520990073680878,
0.049093734472990036,
0.010006674565374851,
-0.0008476128568872809,
0.05529341846704483,
0.05618462339043617,
0.005216451361775398,
0.020090846344828606,
-0.03611315041780472,
-0.06606536358594894,
-0.005681427661329508,
-0.0315215103328228,
-0.05777329206466675,
-0.02753046527504921,
0.018201880156993866,
-0.09950490295886993,
-0.008912043645977974,
0.032257724553346634,
-0.03469884768128395,
-0.06420546025037766,
0.014433635398745537,
-0.005899385549128056,
0.049093734472990036,
0.03299393504858017,
0.04893874377012253,
0.004187207203358412,
0.005332695785909891,
-0.013716797344386578,
-0.05843200534582138,
-0.028886646032333374,
-0.019025275483727455,
0.0757136195898056,
0.0022159020882099867,
-0.005240669008344412,
-0.04665261134505272,
-0.000025579744033166207,
-0.03318767622113228,
-0.02014896832406521,
0.04397899657487869,
0.02462436445057392,
0.00034086144296452403,
0.016923194751143456,
-0.011469412595033646,
-0.005492531228810549,
0.016651960089802742,
-0.022570718079805374,
-0.05765704810619354,
0.0018841222627088428,
0.0002677548327483237,
-0.027007367461919785,
0.08919793367385864,
0.08501314371824265,
-0.01742691919207573,
-0.0588194876909256,
0.021156417205929756,
0.02753046527504921,
-0.034795716404914856,
0.03882551193237305,
-0.011837518773972988,
0.056610848754644394,
0.09214278310537338,
-0.014743619598448277,
-0.0012017939006909728,
-0.03560942783951759,
-0.04390150308609009,
0.03746933117508888,
0.018792787566781044,
-0.036268141120672226,
-0.03808929771184921,
0.009062192402780056,
-0.020226463675498962,
-0.02042020484805107,
-0.022570718079805374,
-0.032916437834501266,
0.03423387184739113,
0.05773454159498215,
-0.04242907837033272,
0.033110179007053375,
-0.003608408849686384,
-0.030378444120287895,
0.02981659770011902,
0.004509300459176302,
0.00435915170237422,
-0.07819349318742752,
-0.04118914157152176,
0.04018169268965721,
-0.023713786154985428,
0.05440221354365349,
0.13112328946590424,
0.02776295319199562,
0.0062965527176856995,
0.028072936460375786,
0.00902828760445118,
-0.05091489106416702,
0.004681244492530823,
-0.022105742245912552,
-0.0420028492808342,
-0.012021571397781372,
-0.028673531487584114,
-0.032897066324949265,
0.025089340284466743,
0.04808628559112549,
-0.018163131549954414,
-0.03303268179297447,
-0.054983433336019516,
-0.01481142919510603,
0.012844966724514961,
0.02102079801261425,
0.06966893374919891,
0.0005803120438940823,
-0.057269565761089325,
0.0025912735145539045,
-0.02018771506845951,
-0.026561765000224113,
-0.006078594829887152,
-0.024101264774799347,
0.04812503606081009,
0.009938865900039673,
-0.0009117892477661371,
-0.0441339910030365,
0.03171525150537491,
0.016516340896487236,
-0.011169115081429482,
-0.0120700066909194,
0.0241400133818388,
0.02146640047430992,
0.014520818367600441,
0.030746549367904663,
0.04661386087536812,
0.030436566099524498,
0.01231218222528696,
0.022396352142095566,
-0.044870201498270035,
0.02020709030330181,
-0.030610932037234306,
-0.031850866973400116,
-0.013174325227737427,
0.03278082236647606,
-0.03237396851181984,
0.01408490352332592,
0.03278082236647606,
0.027627333998680115,
0.03634563833475113,
-0.003116793464869261,
0.01846342906355858,
-0.03504757955670357,
0.07590736448764801,
0.07520990073680878,
-0.055370915681123734,
0.02582555264234543,
-0.000517043808940798,
-0.004305873066186905,
-0.05548715963959694,
-0.025050591677427292,
0.01357149239629507,
-0.0136489886790514,
-0.05506093055009842,
-0.057502053678035736,
0.052464812994003296,
0.056417111307382584,
0.027007367461919785,
0.011198176071047783,
-0.0819133073091507,
0.004322825465351343,
0.02981659770011902,
-0.0441727377474308,
-0.025147462263703346,
0.044056493788957596,
-0.05110863223671913,
-0.047195084393024445,
0.01913183182477951,
-0.024953721091151237,
-0.04254532232880592,
-0.034175749868154526,
-0.02078831009566784,
0.011420977301895618,
0.008863608352839947,
-0.0004586190916597843,
-0.04250657185912132,
0.03653937950730324,
-0.022357605397701263,
0.010229475796222687,
0.0003980753244832158,
0.0026058040093630552,
-0.04483145475387573,
0.04146037623286247,
0.04072416573762894,
-0.010820383206009865,
0.014569253660738468,
-0.0032935813069343567,
0.05211608111858368,
0.023481296375393867,
0.04514143615961075,
-0.02609678916633129,
-0.026116162538528442,
0.0028867272194474936,
-0.09229777008295059,
-0.02902226336300373,
-0.01976148784160614,
0.0016649537719786167,
0.039832960814237595,
-0.04859001189470291,
-0.0482800267636776,
-0.010336033068597317,
-0.02270633727312088,
0.04134413227438927,
-0.0220863688737154,
-0.008558467961847782,
-0.03915486857295036,
-0.04533517733216286,
-0.027840448543429375,
-0.04386275261640549,
-0.04436647891998291,
-0.02520558424293995,
0.05711457505822182,
0.040491677820682526,
0.0026808783877640963,
0.014278643764555454,
0.09160030633211136,
-0.010151980444788933,
0.009251088835299015,
0.0231131911277771,
0.05444096028804779,
0.03820554167032242,
0.058083273470401764,
0.025186210870742798,
0.03218022733926773,
-0.017126623541116714,
-0.012137815356254578,
0.009478732943534851,
-0.09152281284332275,
-0.035241320729255676,
-0.023675037547945976,
-0.012021571397781372,
-0.02481810376048088,
0.018376246094703674,
-0.032722700387239456,
-0.002872196724638343,
0.023675037547945976,
0.03946485370397568,
0.04432772845029831,
0.0049597457982599735,
0.01977117545902729,
0.03872863948345184,
0.006756685208529234,
-0.03967796638607979,
-0.053084779530763626,
0.03283894434571266,
-0.04324278607964516,
0.005783141124993563,
-0.06273303925991058,
0.03216085210442543,
0.033303920179605484,
0.01344556175172329,
0.01515047438442707,
-0.02692987024784088,
-0.05211608111858368,
0.010277911089360714,
0.03865114599466324,
-0.010665391571819782,
0.03543505817651749,
0.022861329838633537,
0.00842284969985485,
0.0336913987994194,
-0.07505490630865097,
-0.07211005687713623,
0.003303268225863576,
-0.0420803427696228,
0.031657129526138306,
0.04134413227438927,
-0.04014294221997261,
-0.008461597375571728,
-0.01742691919207573,
-0.05211608111858368,
-0.045102689415216446,
-0.00021659534831997007,
-0.008263014256954193,
0.028072936460375786,
-0.022977573797106743,
-0.008965321816504002,
0.00026760349282994866,
-0.043204035609960556,
-0.02671675570309162,
-0.08718303591012955,
0.0013731328072026372,
0.025321828201413155,
-0.014172086492180824,
-0.0199746023863554,
0.043204035609960556,
-0.025806177407503128,
-0.08144833147525787,
0.03851552680134773,
0.005274573806673288,
0.07102511078119278,
0.0272979773581028,
-0.03068842738866806,
-0.047621309757232666,
-0.05072115361690521,
-0.01893809251487255,
0.015179535374045372,
-0.01873466558754444,
0.016952257603406906,
-0.010481338016688824,
-0.04661386087536812,
0.0694751888513565,
0.00535206962376833,
0.03597753122448921,
-0.04812503606081009,
-0.018540924414992332,
0.0861755833029747,
0.005579714197665453,
0.010684764944016933,
0.005807358771562576,
0.04711758717894554,
-0.033497657626867294,
-0.014249582774937153,
0.039426106959581375,
-0.025379950180649757,
0.018637795001268387,
-0.02189262956380844,
0.09911742061376572,
0.07067637890577316,
-0.014385201036930084,
-0.011256298050284386,
0.0567270927131176,
0.02545744553208351,
0.015111725777387619,
-0.04521893337368965,
-0.014685497619211674,
0.010413529351353645,
0.060834385454654694,
0.04684634879231453,
-0.001972516067326069,
-0.02859603613615036,
-0.07242003828287125,
-0.0031652285251766443,
-0.02880914881825447,
0.047156333923339844,
0.014511131681501865,
-0.03744995594024658,
-0.022590093314647675,
-0.039212990552186966,
-0.0027704830281436443,
0.04366901144385338,
0.043010298162698746,
0.029041636735200882,
-0.008640807121992111,
0.06474793702363968,
-0.09594008326530457,
0.00750742806121707,
-0.005826732609421015,
-0.014268957078456879,
-0.0525810569524765,
0.049946192651987076,
-0.08648557215929031,
0.03442761301994324,
-0.016661645844578743,
-0.02355879358947277,
-0.0399104543030262,
-0.019800236448645592,
0.004107289481908083,
-0.049907442182302475,
-0.023791281506419182,
-0.10826195776462555,
-0.03619064763188362,
-0.06180308386683464,
0.002181997522711754,
-0.034563228487968445,
-0.010113231837749481,
-0.046730104833841324,
0.02877040207386017,
0.07734103500843048,
-0.011895640753209591,
0.07528739422559738,
-0.009483576752245426,
0.047156333923339844,
0.042351581156253815,
0.03865114599466324,
0.008979852311313152,
0.002884305315092206,
0.004526252392679453,
0.03758557513356209,
0.0002271905104862526,
0.0441339910030365,
0.010452277027070522,
0.010868818499147892,
-0.07168383151292801,
-0.034989457577466965,
0.011711587198078632,
0.04037543013691902,
-0.011372542940080166,
0.018221253529191017,
-0.03894175589084625,
0.001508750836364925,
0.088267982006073,
0.02774357981979847,
0.07133509963750839,
-0.017116935923695564,
-0.044443972408771515,
-0.0022946090903133154,
0.013087142258882523,
-0.013009645976126194,
-0.02290007658302784,
-0.004998493939638138,
0.034582603722810745,
-0.0055070617236196995,
-0.035008832812309265,
-0.027859823778271675,
-0.030145956203341484,
-0.00820489227771759,
0.018628109246492386,
0.007768976967781782,
0.046962592750787735,
0.024508120492100716,
-0.005565183702856302,
-0.03136651962995529,
-0.043204035609960556,
-0.03190898895263672,
-0.0056426795199513435,
0.01155659556388855,
0.020458951592445374,
0.0019870465621352196,
0.02753046527504921,
-0.02441124990582466,
-0.005230981856584549,
0.008698929101228714,
-0.05149611085653305,
0.018201880156993866,
0.010142292827367783,
0.003203976433724165,
0.02189262956380844,
0.09601758420467377,
0.004858032334595919,
0.005468313582241535,
-0.04793129488825798,
0.024876225739717484,
0.01019072812050581,
-0.008243639953434467,
-0.03442761301994324,
0.04560641571879387,
-0.008074117824435234,
0.01165346521884203,
-0.01282559335231781,
0.050139930099248886,
0.05533216521143913,
-0.0025670561008155346,
-0.033517032861709595,
0.016719767823815346,
0.007008547428995371,
-0.03190898895263672,
-0.007289470173418522,
0.04607139155268669,
0.016293540596961975,
-0.00842284969985485,
0.009401237592101097,
0.029952215030789375,
0.0029448491986840963,
0.02018771506845951,
0.029370995238423347,
-0.050139930099248886,
0.004594061523675919,
-0.02710423618555069,
0.011537221260368824,
0.11391916126012802,
-0.0025815865956246853,
-0.02146640047430992,
0.0031216370407491922,
0.020672066137194633,
0.0020766514353454113,
0.06443794816732407,
-0.03547380864620209,
0.028034189715981483,
-0.05699833109974861,
0.030979039147496223,
0.021175790578126907,
-0.03905799984931946,
-0.009996987879276276,
0.015169847756624222,
-0.025321828201413155,
0.007119947578758001,
-0.0014167242916300893,
-0.0714900866150856,
0.016564777120947838,
-0.03210273012518883,
-0.019480565562844276,
0.011052871122956276,
0.004950059112161398,
-0.02776295319199562,
0.018996214494109154,
-0.04901624098420143,
0.011091619729995728,
-0.0141817731782794,
0.01240905188024044,
0.02605804055929184,
-0.04351402074098587,
-0.051573608070611954,
0.0014070372562855482,
-0.018831536173820496,
0.050139930099248886,
0.002552525606006384,
-0.022590093314647675,
-0.005448939744383097,
-0.012786844745278358,
0.0046570273116230965,
0.008640807121992111,
0.005632992833852768,
0.0008227899088524282,
-0.018870282918214798,
-0.0010831281542778015,
0.0050663030706346035,
-0.0652904063463211,
-0.008897513151168823,
0.022241361439228058,
-0.022803207859396935,
-0.0013876633020117879,
-0.06184183061122894,
0.0315215103328228,
0.0073524359613657,
0.022531971335411072,
0.016477594152092934,
0.005846106912940741,
0.019838983193039894,
-0.025728682056069374,
-0.008674711920320988,
0.02714298479259014,
-0.04944246634840965,
0.004194472450762987,
-0.014869551174342632,
0.05153486132621765,
0.005017867777496576,
0.12244372814893723,
0.03853490203619003,
0.0010195571230724454,
-0.03450510650873184,
0.005918759386986494,
0.07315625250339508,
0.0013392282417044044,
-0.014772680588066578,
-0.013581179082393646,
-0.02439187653362751,
0.01764972135424614,
-0.006180308293551207,
0.04920997843146324,
0.0005218873266130686,
-0.08237828314304352,
-0.01974211446940899,
0.02040082961320877,
0.022609466686844826,
-0.024682486429810524,
-0.006005942355841398,
-0.05196108669042587,
-0.04091790318489075,
0.0357450433075428,
-0.04266156628727913,
-0.07234254479408264,
-0.026794252917170525,
-0.04262281581759453,
0.03516382351517677,
0.03431136906147003,
-0.008926574140787125,
-0.06556164473295212,
-0.014113964512944221,
0.03345891088247299,
0.046536367386579514,
0.006664658430963755,
0.018821848556399345,
0.052426066249608994,
0.03760495036840439,
0.0136489886790514,
0.003794883843511343,
-0.03109528310596943,
-0.006330457050353289,
0.08586560189723969,
0.02712361142039299,
-0.051186129450798035,
0.0030078147538006306,
-0.015102039091289043,
0.01599324308335781,
0.022648215293884277,
-0.046962592750787735,
0.0037052789703011513,
-0.014888924546539783,
0.04037543013691902,
0.01913183182477951,
0.008243639953434467,
0.01615792326629162
] |
725,826 | flask_admin.base | BaseView |
Base administrative view.
Derive from this class to implement your administrative interface piece. For example::
from flask_admin import BaseView, expose
class MyView(BaseView):
@expose('/')
def index(self):
return 'Hello World!'
Icons can be added to the menu by using `menu_icon_type` and `menu_icon_value`. For example::
admin.add_view(MyView(name='My View', menu_icon_type='glyph', menu_icon_value='glyphicon-home'))
| class BaseView(with_metaclass(AdminViewMeta, BaseViewClass)):
"""
Base administrative view.
Derive from this class to implement your administrative interface piece. For example::
from flask_admin import BaseView, expose
class MyView(BaseView):
@expose('/')
def index(self):
return 'Hello World!'
Icons can be added to the menu by using `menu_icon_type` and `menu_icon_value`. For example::
admin.add_view(MyView(name='My View', menu_icon_type='glyph', menu_icon_value='glyphicon-home'))
"""
@property
def _template_args(self):
"""
Extra template arguments.
If you need to pass some extra parameters to the template,
you can override particular view function, contribute
arguments you want to pass to the template and call parent view.
These arguments are local for this request and will be discarded
in the next request.
Any value passed through ``_template_args`` will override whatever
parent view function passed to the template.
For example::
class MyAdmin(ModelView):
@expose('/')
def index(self):
self._template_args['name'] = 'foobar'
self._template_args['code'] = '12345'
super(MyAdmin, self).index()
"""
args = getattr(g, '_admin_template_args', None)
if args is None:
args = g._admin_template_args = dict()
return args
def __init__(self, name=None, category=None, endpoint=None, url=None,
static_folder=None, static_url_path=None,
menu_class_name=None, menu_icon_type=None, menu_icon_value=None):
"""
Constructor.
:param name:
Name of this view. If not provided, will default to the class name.
:param category:
View category. If not provided, this view will be shown as a top-level menu item. Otherwise, it will
be in a submenu.
:param endpoint:
Base endpoint name for the view. For example, if there's a view method called "index" and
endpoint is set to "myadmin", you can use `url_for('myadmin.index')` to get the URL to the
view method. Defaults to the class name in lower case.
:param url:
Base URL. If provided, affects how URLs are generated. For example, if the url parameter
is "test", the resulting URL will look like "/admin/test/". If not provided, will
use endpoint as a base url. However, if URL starts with '/', absolute path is assumed
and '/admin/' prefix won't be applied.
:param static_url_path:
Static URL Path. If provided, this specifies the path to the static url directory.
:param menu_class_name:
Optional class name for the menu item.
:param menu_icon_type:
Optional icon. Possible icon types:
- `flask_admin.consts.ICON_TYPE_GLYPH` - Bootstrap glyph icon
- `flask_admin.consts.ICON_TYPE_FONT_AWESOME` - Font Awesome icon
- `flask_admin.consts.ICON_TYPE_IMAGE` - Image relative to Flask static directory
- `flask_admin.consts.ICON_TYPE_IMAGE_URL` - Image with full URL
:param menu_icon_value:
Icon glyph name or URL, depending on `menu_icon_type` setting
"""
self.name = name
self.category = category
self.endpoint = self._get_endpoint(endpoint)
self.url = url
self.static_folder = static_folder
self.static_url_path = static_url_path
self.menu = None
self.menu_class_name = menu_class_name
self.menu_icon_type = menu_icon_type
self.menu_icon_value = menu_icon_value
# Initialized from create_blueprint
self.admin = None
self.blueprint = None
# Default view
if self._default_view is None:
raise Exception(u'Attempted to instantiate admin view %s without default view' % self.__class__.__name__)
def _get_endpoint(self, endpoint):
"""
Generate Flask endpoint name. By default converts class name to lower case if endpoint is
not explicitly provided.
"""
if endpoint:
return endpoint
return self.__class__.__name__.lower()
def _get_view_url(self, admin, url):
"""
Generate URL for the view. Override to change default behavior.
"""
if url is None:
if admin.url != '/':
url = '%s/%s' % (admin.url, self.endpoint)
else:
if self == admin.index_view:
url = '/'
else:
url = '/%s' % self.endpoint
else:
if not url.startswith('/'):
url = '%s/%s' % (admin.url, url)
return url
def create_blueprint(self, admin):
"""
Create Flask blueprint.
"""
# Store admin instance
self.admin = admin
# If the static_url_path is not provided, use the admin's
if not self.static_url_path:
self.static_url_path = admin.static_url_path
# Generate URL
self.url = self._get_view_url(admin, self.url)
# If we're working from the root of the site, set prefix to None
if self.url == '/':
self.url = None
# prevent admin static files from conflicting with flask static files
if not self.static_url_path:
self.static_folder = 'static'
self.static_url_path = '/static/admin'
# If name is not provided, use capitalized endpoint name
if self.name is None:
self.name = self._prettify_class_name(self.__class__.__name__)
# Create blueprint and register rules
self.blueprint = Blueprint(self.endpoint, __name__,
url_prefix=self.url,
subdomain=self.admin.subdomain,
template_folder=op.join('templates', self.admin.template_mode),
static_folder=self.static_folder,
static_url_path=self.static_url_path)
for url, name, methods in self._urls:
self.blueprint.add_url_rule(url,
name,
getattr(self, name),
methods=methods)
return self.blueprint
def render(self, template, **kwargs):
"""
Render template
:param template:
Template path to render
:param kwargs:
Template arguments
"""
# Store self as admin_view
kwargs['admin_view'] = self
kwargs['admin_base_template'] = self.admin.base_template
# Provide i18n support even if flask-babel is not installed
# or enabled.
kwargs['_gettext'] = babel.gettext
kwargs['_ngettext'] = babel.ngettext
kwargs['h'] = h
# Expose get_url helper
kwargs['get_url'] = self.get_url
# Expose config info
kwargs['config'] = current_app.config
# Contribute extra arguments
kwargs.update(self._template_args)
return render_template(template, **kwargs)
def _prettify_class_name(self, name):
"""
Split words in PascalCase string into separate words.
:param name:
String to prettify
"""
return h.prettify_class_name(name)
def is_visible(self):
"""
Override this method if you want dynamically hide or show administrative views
from Flask-Admin menu structure
By default, item is visible in menu.
| (name=None, category=None, endpoint=None, url=None, static_folder=None, static_url_path=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None) | [
0.043213654309511185,
-0.038948360830545425,
0.032580453902482986,
-0.011143836192786694,
0.04954151436686516,
-0.01211504265666008,
0.0047458927147090435,
0.03882820904254913,
-0.044575344771146774,
0.015819642692804337,
0.017031146213412285,
0.0003189898270647973,
0.009596915915608406,
0.01033282931894064,
-0.011864732019603252,
0.045055944472551346,
0.027574237436056137,
-0.0422925129532814,
0.09035218507051468,
-0.06059523671865463,
-0.008690791204571724,
0.007148876320570707,
0.0617566779255867,
-0.009646978229284286,
-0.06387931853532791,
0.005081309005618095,
-0.044855695217847824,
0.03554413467645645,
0.07677532732486725,
-0.046137284487485886,
0.0026633068919181824,
-0.024790780618786812,
0.03382199630141258,
0.04289325699210167,
0.06568155437707901,
-0.05034250766038895,
0.0340823195874691,
0.022527972236275673,
-0.014648187905550003,
0.023208817467093468,
0.018182575702667236,
-0.01593979075551033,
-0.0027108658105134964,
-0.07921835780143738,
0.06696314364671707,
0.055508922785520554,
-0.02869562990963459,
0.08174149692058563,
-0.040049728006124496,
0.004861035849899054,
-0.004533128347247839,
-0.040490273386240005,
-0.00935661792755127,
0.028755703940987587,
-0.026012297719717026,
0.013326547108590603,
0.01914376951754093,
0.0261524710804224,
-0.002016253536567092,
-0.006548130419105291,
0.01812250167131424,
0.009081276133656502,
-0.0005922979325987399,
-0.06191688030958176,
0.04501589387655258,
0.024350233376026154,
-0.0617566779255867,
0.03254040330648422,
-0.002986207837238908,
0.03486328944563866,
-0.030537916347384453,
0.004077563062310219,
-0.007869771681725979,
0.023529214784502983,
0.01963437907397747,
-0.00764949806034565,
0.051864396780729294,
-0.09171387553215027,
0.008255249820649624,
-0.0152989961206913,
0.0687253326177597,
-0.0716489627957344,
0.001953675877302885,
0.004938631784170866,
0.051423851400613785,
-0.009877263568341732,
-0.035123612731695175,
-0.009411686100065708,
0.020545510575175285,
0.039388906210660934,
-0.03724624589085579,
0.005957397166639566,
-0.007549373432993889,
-0.008640728890895844,
-0.028575479984283447,
-0.024069886654615402,
-0.01570950634777546,
-0.00893108919262886,
0.011053725145757198,
-0.02394973672926426,
0.018963545560836792,
0.06676289439201355,
0.06315842270851135,
0.01480838656425476,
0.00782972201704979,
-0.07465269416570663,
-0.06011464074254036,
0.006022477522492409,
-0.03952908143401146,
-0.032280080020427704,
-0.02212747372686863,
-0.029196251183748245,
-0.005872291047126055,
-0.005511843599379063,
-0.01567946746945381,
0.00885599572211504,
-0.0261524710804224,
0.006643248721957207,
0.05911339819431305,
-0.021987300366163254,
0.005031247157603502,
-0.019644390791654587,
0.005957397166639566,
-0.0241299606859684,
0.04217236116528511,
0.041411418467760086,
-0.0429733581840992,
-0.031218761578202248,
0.005286564119160175,
-0.0071739074774086475,
-0.004780936054885387,
0.02579202502965927,
-0.06604199856519699,
0.03678567335009575,
0.06740368902683258,
-0.005381681956350803,
-0.020285187289118767,
0.03972933068871498,
-0.01521889679133892,
0.10300789773464203,
-0.03452286496758461,
0.0018560545286163688,
-0.005832241382449865,
0.008685784414410591,
-0.02230769768357277,
-0.00379220861941576,
0.0026683129835873842,
0.03888828679919243,
-0.009531835094094276,
-0.01343668345361948,
-0.012956086546182632,
0.01512878481298685,
0.035403959453105927,
-0.031579211354255676,
-0.030097370967268944,
0.03552410751581192,
-0.049501463770866394,
-0.009651984088122845,
0.02276827022433281,
-0.06167658045887947,
-0.028114909306168556,
-0.0120649803429842,
-0.03452286496758461,
-0.01356684509664774,
-0.010362867265939713,
0.0176318921148777,
0.041851963847875595,
-0.046778082847595215,
0.017722005024552345,
0.05458777770400047,
-0.02659301832318306,
-0.026653094217181206,
-0.006633236072957516,
0.03364177048206329,
-0.01989470236003399,
0.06123603135347366,
-0.0072189634665846825,
-0.036505326628685,
0.01843288727104664,
-0.04870046675205231,
-0.011273997835814953,
-0.006087558344006538,
-0.04545643925666809,
0.021987300366163254,
0.027894634753465652,
0.02232772298157215,
0.0261524710804224,
0.05919349566102028,
-0.0012133815325796604,
0.04930121451616287,
-0.05602956935763359,
-0.026072371751070023,
0.028755703940987587,
-0.029937170445919037,
-0.046417634934186935,
0.010893525555729866,
-0.029997246339917183,
-0.06844498217105865,
0.004225246142596006,
-0.017321506515145302,
-0.009496791288256645,
-0.021266404539346695,
0.0023679400328546762,
-0.018753284588456154,
0.05094325169920921,
0.03087833896279335,
0.025391526520252228,
0.02276827022433281,
0.01013758685439825,
-0.02551167644560337,
-0.054067131131887436,
0.0458969883620739,
-0.006853509694337845,
-0.0042928303591907024,
-0.013857205398380756,
-0.09371636062860489,
-0.03205980733036995,
0.0032890839502215385,
-0.024109935387969017,
0.028355207294225693,
0.043213654309511185,
0.02112623117864132,
-0.016620635986328125,
0.020825859159231186,
-0.03918865695595741,
0.019524242728948593,
0.035644255578517914,
-0.03123878687620163,
0.003969929181039333,
0.018873434513807297,
-0.04653778299689293,
-0.049781810492277145,
0.053706683218479156,
0.054427579045295715,
0.0015319021185860038,
0.015178847126662731,
0.011544333770871162,
0.03964922949671745,
-0.0646803081035614,
0.02286839485168457,
-0.024710681289434433,
0.02451043389737606,
0.03900843486189842,
0.003416742430999875,
0.014117528684437275,
-0.02697349153459072,
-0.027674362063407898,
0.011764607392251492,
0.014087491668760777,
-0.07160891592502594,
-0.023449115455150604,
-0.01702113449573517,
-0.011594396084547043,
0.011143836192786694,
-0.02012498863041401,
-0.011684508062899113,
-0.017601855099201202,
0.04854026809334755,
-0.05767160654067993,
0.0010857230518013239,
-0.0202751737087965,
-0.05262534320354462,
0.058152202516794205,
0.04217236116528511,
0.0022490425035357475,
-0.02995719574391842,
0.012755838222801685,
-0.028915902599692345,
-0.0235091894865036,
0.007699559908360243,
0.14554071426391602,
0.0770556777715683,
-0.027353962883353233,
0.022287672385573387,
0.008926083333790302,
-0.0812208503484726,
0.003734637051820755,
-0.02050545997917652,
-0.09163377434015274,
-0.05018230900168419,
-0.006357894279062748,
-0.04014985263347626,
0.030017269775271416,
0.06732359528541565,
-0.02140657976269722,
-0.021887175738811493,
-0.05022235959768295,
-0.003962419927120209,
-0.010953600518405437,
0.030277593061327934,
0.06163652986288071,
-0.021807076409459114,
-0.004438010510057211,
-0.012815913185477257,
0.012875987216830254,
0.00346179842017591,
-0.027394013479351997,
0.06011464074254036,
0.003717115381732583,
0.0018623123178258538,
0.02140657976269722,
-0.014467963948845863,
0.07244995981454849,
0.012495514936745167,
0.017722005024552345,
-0.012745825573801994,
0.050863154232501984,
-0.01343668345361948,
0.04657783359289169,
0.026072371751070023,
0.021546753123402596,
-0.010923563502728939,
-0.015469207428395748,
0.05094325169920921,
-0.0261524710804224,
-0.017772067338228226,
-0.024029836058616638,
-0.03498343750834465,
0.013837181031703949,
0.06496065855026245,
-0.02823505736887455,
0.08210194110870361,
0.027754461392760277,
0.0071739074774086475,
0.04397460073232651,
-0.0008848486468195915,
0.04962161183357239,
0.015379095450043678,
0.017571818083524704,
0.03640520200133324,
-0.05991439148783684,
-0.008720828220248222,
-0.01663064956665039,
-0.01830272562801838,
-0.02851540595293045,
-0.0061576454900205135,
-0.0182526633143425,
-0.03169935941696167,
-0.044855695217847824,
-0.0917939767241478,
0.07244995981454849,
0.05727111175656319,
0.0025731949135661125,
-0.0016120015643537045,
-0.07765641808509827,
-0.023068642243742943,
0.03882820904254913,
-0.03946900740265846,
-0.04325370490550995,
-0.0032765683718025684,
0.028455331921577454,
-0.055348724126815796,
-0.022167524322867393,
-0.024550482630729675,
0.01198488101363182,
-0.08546611666679382,
0.00785475317388773,
-0.03962920606136322,
0.019674427807331085,
0.015008634887635708,
-0.017361557111144066,
-0.00596740934997797,
-0.050062160938978195,
-0.025471625849604607,
0.02084588259458542,
-0.014307765290141106,
-0.0060525150038301945,
-0.03772684186697006,
0.06423976272344589,
-0.03934885561466217,
0.03688579797744751,
-0.009496791288256645,
0.05394698306918144,
-0.040850721299648285,
0.05334623530507088,
-0.02669314295053482,
0.003629506565630436,
0.016280213370919228,
-0.06796438992023468,
-0.00920142512768507,
0.024390283972024918,
0.009301548823714256,
0.045055944472551346,
0.016800859943032265,
0.002986207837238908,
-0.07557383924722672,
0.003987451083958149,
0.06031488999724388,
-0.06339871883392334,
-0.003872307948768139,
-0.0028760710265487432,
-0.04693828150629997,
-0.003326630452647805,
0.04189201444387436,
-0.014347814954817295,
-0.05198454484343529,
-0.021426605060696602,
0.029736923053860664,
-0.013937304727733135,
-0.0013954826863482594,
0.06944622844457626,
0.002211495768278837,
0.007909821346402168,
0.008645734749734402,
0.05675046518445015,
0.013837181031703949,
0.016921009868383408,
0.07204946130514145,
0.011013675481081009,
0.024790780618786812,
-0.011554346419870853,
0.0000161724237841554,
-0.05130369961261749,
-0.013737056404352188,
-0.0007434230647049844,
-0.058632802218198776,
0.016900984570384026,
0.05182434618473053,
0.022608071565628052,
0.001319137867540121,
0.02296851947903633,
0.046778082847595215,
0.11053724586963654,
-0.006037496495991945,
0.012515540234744549,
0.010843463242053986,
-0.02358928881585598,
0.027654336765408516,
-0.05098330229520798,
0.02787460945546627,
0.012936062179505825,
0.019033633172512054,
0.01225521694868803,
-0.022467896342277527,
0.0088309645652771,
-0.006878540851175785,
0.04433504864573479,
-0.06476040929555893,
-0.03324127197265625,
0.031198738142848015,
0.034743137657642365,
-0.024750731885433197,
0.009391660802066326,
0.04309350624680519,
0.03288082778453827,
0.02284836955368519,
-0.06732359528541565,
0.0071638948284089565,
0.10533078014850616,
-0.05146389827132225,
-0.012885999865829945,
0.031378962099552155,
-0.01170453242957592,
0.0030663071665912867,
-0.04801962152123451,
-0.031378962099552155,
-0.0217670276761055,
0.004748395644128323,
-0.03213990479707718,
0.06540120393037796,
0.0037997178733348846,
-0.025291403755545616,
-0.027894634753465652,
-0.033101100474596024,
-0.012285253964364529,
0.021747002378106117,
0.060435038059949875,
0.02787460945546627,
-0.053145989775657654,
-0.015609380789101124,
0.046497732400894165,
-0.0370660237967968,
-0.006778416223824024,
-0.02376951277256012,
0.003284077625721693,
0.045136041939258575,
0.03458293899893761,
-0.023248866200447083,
-0.04010980203747749,
-0.041211169213056564,
0.03956913203001022,
-0.032740652561187744,
-0.027674362063407898,
0.01694103516638279,
-0.04125121980905533,
-0.0482599213719368,
0.03506353497505188,
0.0016007375670596957,
0.003842270700260997,
-0.025171253830194473,
-0.018332762643694878,
0.028996001929044724,
-0.020525485277175903,
0.018923496827483177,
0.02130645513534546,
0.03946900740265846,
0.021346503868699074,
-0.032660551369190216,
0.026472870260477066,
-0.016260189935564995,
-0.0004292830126360059,
-0.01963437907397747,
0.02797473408281803,
0.035023488104343414,
0.010633202269673347,
-0.05098330229520798,
-0.014968585222959518,
0.021706951782107353,
-0.03424251824617386,
-0.0617566779255867,
-0.015799617394804955,
-0.013216409832239151,
0.03546403348445892,
0.009491785429418087,
-0.006067533511668444,
0.0016232655616477132,
-0.01575956679880619,
0.026552969589829445,
0.06155643239617348,
0.01814252696931362,
0.004014985170215368,
-0.03572435677051544,
-0.006843497045338154,
-0.038567885756492615,
-0.04425494745373726,
0.035644255578517914,
0.012785875238478184,
0.026933440938591957,
-0.030397742986679077,
0.07733602076768875,
-0.03280072659254074,
0.04557659104466438,
-0.0007002444472163916,
-0.01220515463501215,
-0.034202467650175095,
0.07068777084350586,
-0.06275792419910431,
-0.017381582409143448,
0.013216409832239151,
0.006598192732781172,
-0.0041902028024196625,
0.03380196914076805,
-0.0051513961516320705,
-0.009206430986523628,
-0.03528381139039993,
-0.1235133558511734,
0.005466787610203028,
-0.028455331921577454,
0.02194724977016449,
-0.05502832680940628,
-0.008510567247867584,
0.05126365274190903,
0.0013241440756246448,
0.03568430617451668,
-0.010052481666207314,
0.03123878687620163,
0.0060074590146541595,
0.020705709233880043,
0.037566643208265305,
0.012675738893449306,
0.01047300361096859,
-0.008775896392762661,
-0.005747135728597641,
-0.03197970613837242,
0.031579211354255676,
0.06019474193453789,
-0.005536874756217003,
-0.003526879008859396,
-0.0376267172396183,
-0.02987709641456604,
-0.07681537419557571,
-0.04874051734805107,
-0.01157437078654766,
0.012725801207125187,
-0.03051789291203022,
-0.007198938634246588,
0.04045022279024124,
0.01976454071700573,
0.02697349153459072,
-0.049141015857458115,
0.015649430453777313,
-0.00032039781217463315,
-0.028735678642988205,
-0.0006939866580069065,
-0.05687061324715614,
0.009942344389855862,
0.04717857763171196,
0.04761912673711777,
-0.0032940900418907404,
-0.03324127197265625,
-0.03980942815542221,
0.02787460945546627,
-0.02232772298157215,
-0.03488331288099289,
0.024650607258081436,
0.02769438736140728,
-0.00773961003869772,
0.003374189604073763,
-0.018232638016343117,
0.046137284487485886,
-0.012465477921068668,
-0.012585626915097237,
0.05438752844929695,
-0.0506228543817997,
0.02633269503712654,
-0.00008534033986506984,
0.05859275162220001,
-0.03452286496758461,
-0.038668010383844376,
-0.012275241315364838,
-0.012455465272068977,
-0.008095051161944866,
-0.021166281774640083,
0.06812458485364914,
-0.06239747628569603,
-0.05526862293481827,
-0.07721587270498276,
0.01776205375790596,
0.03450284153223038,
-0.00910130050033331,
-0.09051238745450974,
0.02531142719089985,
0.024210060015320778,
-0.01343668345361948,
-0.029937170445919037,
0.031098613515496254,
0.0051964521408081055,
-0.003496841760352254,
-0.04016987606883049,
0.02697349153459072,
0.005767160560935736,
-0.04497584328055382,
-0.028935927897691727,
0.020295199006795883,
0.038848236203193665,
-0.03772684186697006,
-0.023348990827798843,
-0.02312871813774109,
-0.01608997769653797,
0.02050545997917652,
0.04051030054688454,
-0.039048485457897186,
-0.01848294958472252,
0.0317794568836689,
0.010903538204729557,
0.10412929207086563,
-0.0012490508379414678,
-0.043213654309511185,
-0.003777189878746867,
-0.024109935387969017,
-0.0208659078925848,
0.1046098843216896,
-0.04099089652299881,
0.0029611766804009676,
-0.07204946130514145,
0.011123811826109886,
-0.023989787325263023,
-0.05302583798766136,
-0.03560420870780945,
0.01689097285270691,
0.0019874677527695894,
-0.055789269506931305,
0.014558075927197933,
-0.08041985332965851,
0.023929711431264877,
0.0059023285284638405,
0.048340022563934326,
0.031739410012960434,
0.030818264931440353,
0.004004972521215677,
0.04998205974698067,
-0.036505326628685,
0.007869771681725979,
-0.043934550136327744,
0.025091154500842094,
0.018983570858836174,
0.004790948703885078,
0.03336142376065254,
0.019834628328680992,
-0.010037463158369064,
-0.005862278863787651,
0.03770681843161583,
-0.024570507928729057,
0.039749354124069214,
0.015439169481396675,
0.014167590998113155,
-0.011404159478843212,
-0.035123612731695175,
0.040029700845479965,
-0.007329100277274847,
-0.011464234441518784,
-0.02561180107295513,
-0.015799617394804955,
0.03362174704670906,
0.005872291047126055,
-0.02443033456802368,
-0.001851048320531845,
-0.07721587270498276,
-0.018783321604132652,
0.04425494745373726,
0.04024997726082802,
-0.039489030838012695,
0.020345261320471764,
0.04193206503987312,
-0.00016176335338968784,
0.009156368672847748,
0.00660319859161973,
-0.04517609253525734,
-0.02631267160177231,
0.004468047525733709,
0.06868528574705124,
0.035203710198402405,
0.10340839624404907,
-0.025171253830194473,
-0.026012297719717026,
-0.016130028292536736,
-0.010352854616940022,
0.01329650916159153,
-0.03069811686873436,
0.006643248721957207,
-0.005667036399245262,
0.002126390114426613,
0.02505110390484333,
-0.019063670188188553,
0.0570308119058609,
-0.012315290980041027,
-0.09011188894510269,
-0.010037463158369064,
-0.01601989008486271,
-0.016390351578593254,
-0.008200181648135185,
0.003879817435517907,
-0.012785875238478184,
0.024670632556080818,
0.01837281323969364,
-0.03888828679919243,
-0.04091079533100128,
0.004588196985423565,
-0.07721587270498276,
0.003494338598102331,
0.021747002378106117,
0.004615731071680784,
-0.03976937755942345,
0.014077479019761086,
-0.009747102856636047,
0.04653778299689293,
0.007834727875888348,
0.016650674864649773,
0.05855270102620125,
0.04854026809334755,
0.019063670188188553,
-0.0028985990211367607,
-0.05847260355949402,
0.02831515669822693,
0.021066157147288322,
0.003344152122735977,
-0.0014593119267374277,
0.024830831214785576,
-0.024210060015320778,
-0.034022241830825806,
0.02314874157309532,
-0.033481571823358536,
-0.020645635202527046,
0.005837247706949711,
0.10621187835931778,
0.0422925129532814,
-0.007709572557359934,
0.021706951782107353
] |
725,827 | flask_admin.base | __init__ |
Constructor.
:param name:
Name of this view. If not provided, will default to the class name.
:param category:
View category. If not provided, this view will be shown as a top-level menu item. Otherwise, it will
be in a submenu.
:param endpoint:
Base endpoint name for the view. For example, if there's a view method called "index" and
endpoint is set to "myadmin", you can use `url_for('myadmin.index')` to get the URL to the
view method. Defaults to the class name in lower case.
:param url:
Base URL. If provided, affects how URLs are generated. For example, if the url parameter
is "test", the resulting URL will look like "/admin/test/". If not provided, will
use endpoint as a base url. However, if URL starts with '/', absolute path is assumed
and '/admin/' prefix won't be applied.
:param static_url_path:
Static URL Path. If provided, this specifies the path to the static url directory.
:param menu_class_name:
Optional class name for the menu item.
:param menu_icon_type:
Optional icon. Possible icon types:
- `flask_admin.consts.ICON_TYPE_GLYPH` - Bootstrap glyph icon
- `flask_admin.consts.ICON_TYPE_FONT_AWESOME` - Font Awesome icon
- `flask_admin.consts.ICON_TYPE_IMAGE` - Image relative to Flask static directory
- `flask_admin.consts.ICON_TYPE_IMAGE_URL` - Image with full URL
:param menu_icon_value:
Icon glyph name or URL, depending on `menu_icon_type` setting
| def __init__(self, name=None, category=None, endpoint=None, url=None,
static_folder=None, static_url_path=None,
menu_class_name=None, menu_icon_type=None, menu_icon_value=None):
"""
Constructor.
:param name:
Name of this view. If not provided, will default to the class name.
:param category:
View category. If not provided, this view will be shown as a top-level menu item. Otherwise, it will
be in a submenu.
:param endpoint:
Base endpoint name for the view. For example, if there's a view method called "index" and
endpoint is set to "myadmin", you can use `url_for('myadmin.index')` to get the URL to the
view method. Defaults to the class name in lower case.
:param url:
Base URL. If provided, affects how URLs are generated. For example, if the url parameter
is "test", the resulting URL will look like "/admin/test/". If not provided, will
use endpoint as a base url. However, if URL starts with '/', absolute path is assumed
and '/admin/' prefix won't be applied.
:param static_url_path:
Static URL Path. If provided, this specifies the path to the static url directory.
:param menu_class_name:
Optional class name for the menu item.
:param menu_icon_type:
Optional icon. Possible icon types:
- `flask_admin.consts.ICON_TYPE_GLYPH` - Bootstrap glyph icon
- `flask_admin.consts.ICON_TYPE_FONT_AWESOME` - Font Awesome icon
- `flask_admin.consts.ICON_TYPE_IMAGE` - Image relative to Flask static directory
- `flask_admin.consts.ICON_TYPE_IMAGE_URL` - Image with full URL
:param menu_icon_value:
Icon glyph name or URL, depending on `menu_icon_type` setting
"""
self.name = name
self.category = category
self.endpoint = self._get_endpoint(endpoint)
self.url = url
self.static_folder = static_folder
self.static_url_path = static_url_path
self.menu = None
self.menu_class_name = menu_class_name
self.menu_icon_type = menu_icon_type
self.menu_icon_value = menu_icon_value
# Initialized from create_blueprint
self.admin = None
self.blueprint = None
# Default view
if self._default_view is None:
raise Exception(u'Attempted to instantiate admin view %s without default view' % self.__class__.__name__)
| (self, name=None, category=None, endpoint=None, url=None, static_folder=None, static_url_path=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None) | [
0.025898991152644157,
-0.0169413723051548,
0.047285426408052444,
-0.034017737954854965,
0.025706147775053978,
-0.008219989016652107,
0.02063434198498726,
0.06093880534172058,
-0.056117694824934006,
0.026863213628530502,
0.017163144424557686,
0.05380356311798096,
-0.011580301448702812,
0.009835059754550457,
0.0034808400087058544,
0.06892255693674088,
0.03066224604845047,
-0.034750547260046005,
0.0723937526345253,
-0.03718038275837898,
-0.010943914763629436,
0.007858405821025372,
0.0749393031001091,
0.006204765755683184,
-0.040651582181453705,
-0.018358778208494186,
-0.05634910985827446,
0.023912694305181503,
0.06321436911821365,
-0.05145086348056793,
0.03637043759226799,
-0.004601747263222933,
0.02651609294116497,
0.057776156812906265,
0.037971045821905136,
-0.04689973592758179,
0.03552192449569702,
-0.01740419864654541,
-0.0016102499794214964,
0.016362840309739113,
0.04335140064358711,
-0.015803592279553413,
-0.011570658534765244,
-0.08855410665273666,
0.042117197066545486,
0.056117694824934006,
-0.017732035368680954,
0.05175941437482834,
-0.05812327563762665,
-0.012862715870141983,
-0.007978933863341808,
-0.01210098061710596,
-0.0006761603872291744,
0.005737118422985077,
-0.05854753404855728,
0.023314878344535828,
0.01100176852196455,
0.0057178339920938015,
-0.019824394956231117,
0.04300428181886673,
0.0014149951748549938,
0.028772372752428055,
0.017924878746271133,
-0.061285924166440964,
0.031240779906511307,
0.020595772191882133,
-0.05029379576444626,
0.01050037331879139,
0.004608978983014822,
0.06795834004878998,
-0.002462380798533559,
0.025706147775053978,
-0.0017548833275213838,
0.01454046182334423,
0.02873380295932293,
-0.006773656699806452,
0.025185467675328255,
-0.0524536557495594,
-0.0019971439614892006,
-0.005476778373122215,
0.05588628351688385,
-0.04647548124194145,
-0.002531081670895219,
0.005515347234904766,
0.03708396106958389,
-0.0032012155279517174,
-0.041384391486644745,
-0.011030694469809532,
0.01675817184150219,
0.042310044169425964,
-0.05071805417537689,
-0.012573448941111565,
-0.0238355565816164,
-0.025763999670743942,
-0.032185714691877365,
-0.03517480194568634,
0.00944455061107874,
-0.010702859610319138,
0.0231991708278656,
0.005737118422985077,
0.01831056736409664,
0.04716971889138222,
0.06788119673728943,
0.019631551578640938,
-0.000521282316185534,
-0.07794766873121262,
-0.05156657099723816,
0.01814665086567402,
-0.043042849749326706,
-0.04612835869193077,
0.010741428472101688,
0.013566597364842892,
0.012862715870141983,
0.03772034868597984,
-0.04215576872229576,
0.01740419864654541,
-0.04566553235054016,
-0.024973338469862938,
0.056387677788734436,
-0.03341991826891899,
-0.028753086924552917,
0.006985785439610481,
-0.002924002008512616,
-0.005582842975854874,
0.04053587466478348,
0.02329559251666069,
-0.07131382822990417,
-0.05195225775241852,
-0.0014318689936771989,
0.01137781422585249,
0.03594617918133736,
0.022408509626984596,
-0.06267440319061279,
0.05202939733862877,
0.0663384422659874,
-0.02329559251666069,
-0.0019151851302012801,
0.049483850598335266,
-0.007699309382587671,
0.10159038752317429,
-0.07119812071323395,
-0.02937018871307373,
-0.010027904063463211,
-0.0035483355168253183,
-0.0440070740878582,
-0.01035573985427618,
0.008133209310472012,
0.03237856179475784,
-0.014646525494754314,
-0.006841151975095272,
-0.03995734080672264,
0.01684495061635971,
0.04335140064358711,
-0.028791656717658043,
0.002059818245470524,
-0.006368683651089668,
-0.034037020057439804,
-0.04096013307571411,
0.020325791090726852,
-0.03748893365263939,
-0.029910152778029442,
-0.0017874257173389196,
-0.02827097661793232,
-0.004601747263222933,
-0.047941096127033234,
0.015369691886007786,
0.05604055896401405,
-0.04446990042924881,
0.0094879399985075,
0.03897383436560631,
-0.04169294238090515,
-0.03980306535959244,
-0.015437187626957893,
0.03012228198349476,
-0.052337948232889175,
0.03183859586715698,
-0.019727973267436028,
-0.024838346987962723,
0.024529796093702316,
-0.07536356151103973,
0.0015644495142623782,
0.010365381836891174,
-0.026554662734270096,
0.022794198244810104,
0.020017240196466446,
0.010105041787028313,
0.014472966082394123,
0.06957823038101196,
-0.01100176852196455,
0.04292714595794678,
-0.052723634988069534,
-0.04150009527802467,
0.010760712437331676,
-0.032725680619478226,
-0.04836535453796387,
0.007332905195653439,
-0.02163713239133358,
-0.06996391713619232,
0.009998978115618229,
-0.02404768578708172,
0.037874624133110046,
-0.016700318083167076,
-0.00828266330063343,
0.002429838292300701,
0.0475168377161026,
0.0190530177205801,
0.021212873980402946,
0.03638972342014313,
0.004242574796080589,
-0.006156554911285639,
-0.06032170355319977,
0.03297637775540352,
-0.00598299503326416,
0.0031674678903073072,
-0.029620887711644173,
-0.07274087518453598,
-0.048751041293144226,
0.006349399220198393,
-0.03795175999403,
0.029042353853583336,
0.042965713888406754,
0.04925243929028511,
0.004066604655236006,
0.03656328096985817,
-0.022774914279580116,
0.03552192449569702,
0.028656665235757828,
-0.0476711131632328,
-0.004457114264369011,
0.02854095958173275,
-0.05561630055308342,
-0.07474645972251892,
0.07790910452604294,
0.02771172858774662,
-0.03980306535959244,
0.017105290666222572,
0.006980964448302984,
0.03368990123271942,
-0.09163961559534073,
0.024086255580186844,
-0.007680024951696396,
0.020692195743322372,
0.05920320376753807,
0.01053894218057394,
0.03056582435965538,
-0.0038327807560563087,
-0.04335140064358711,
0.006199944764375687,
0.009502403438091278,
-0.06861400604248047,
-0.03529050946235657,
-0.007429327350109816,
-0.008567108772695065,
0.004845213610678911,
0.0020477655343711376,
-0.02134786546230316,
-0.01978582702577114,
0.011763502843677998,
-0.04905959218740463,
0.0030614035204052925,
-0.022389225661754608,
-0.07466931641101837,
0.07729200273752213,
0.044971294701099396,
-0.01685459353029728,
-0.04809537157416344,
0.007786089088767767,
-0.03600403293967247,
0.0016343556344509125,
0.007029175292700529,
0.13082557916641235,
0.05218367278575897,
0.009348127990961075,
0.020132945850491524,
0.02171427011489868,
-0.11115546524524689,
0.006561527960002422,
-0.03772034868597984,
-0.06730266660451889,
-0.024433374404907227,
-0.0015475755790248513,
-0.03039226494729519,
0.03451913222670555,
0.07439933717250824,
-0.029215913265943527,
-0.017847741022706032,
-0.04373709112405777,
-0.014472966082394123,
-0.011252465657889843,
0.02478049509227276,
0.06822831928730011,
0.0013438838068395853,
-0.022794198244810104,
-0.023816272616386414,
0.011888852342963219,
-0.005361071787774563,
-0.018831247463822365,
0.06178731843829155,
0.013788368552923203,
0.03112507238984108,
0.008591214194893837,
-0.04713115096092224,
0.0499081090092659,
0.021772123873233795,
0.015620389953255653,
-0.008875659666955471,
0.02643895521759987,
0.01091498788446188,
0.05121944844722748,
0.04373709112405777,
0.04173151031136513,
0.011618870310485363,
-0.0017368041444569826,
0.06198016181588173,
-0.03671755641698837,
0.023777704685926437,
-0.018165934830904007,
-0.03413344547152519,
0.011830998584628105,
0.050872329622507095,
-0.020692195743322372,
0.07216234505176544,
-0.0009365002042613924,
-0.0006556706503033638,
0.05388070270419121,
-0.006098701618611813,
0.028675949200987816,
0.00806089211255312,
0.017355987802147865,
0.052337948232889175,
-0.045356981456279755,
0.009097430855035782,
0.0012299851514399052,
-0.021579278632998466,
-0.04500986263155937,
-0.001596992020495236,
-0.022794198244810104,
-0.0022165044210851192,
-0.04809537157416344,
-0.10359596461057663,
0.07810194790363312,
0.05461351200938225,
-0.003184341825544834,
-0.01454046182334423,
-0.06452570855617523,
-0.013923360034823418,
0.05912606790661812,
-0.06980964541435242,
-0.04381422698497772,
-0.008422475308179855,
0.019130155444145203,
-0.03239784389734268,
-0.027461031451821327,
-0.02310274913907051,
-0.0041533843614161015,
-0.06178731843829155,
-0.005341787356883287,
-0.06533565372228622,
0.017086006700992584,
0.009960409253835678,
0.006638665683567524,
-0.009873628616333008,
-0.05997458100318909,
-0.015205774456262589,
0.019274789839982986,
-0.02402840182185173,
-0.014897223562002182,
-0.03718038275837898,
0.05766044929623604,
-0.03897383436560631,
0.046822600066661835,
-0.016092857345938683,
0.04392993450164795,
-0.025378311052918434,
0.055384889245033264,
-0.029215913265943527,
0.0066193812526762486,
0.0058190771378576756,
-0.05037093535065651,
-0.02466478757560253,
-0.013508744537830353,
0.01952548697590828,
0.03102865070104599,
0.00902511365711689,
-0.005120016634464264,
-0.06402431428432465,
-0.014945434406399727,
0.06225014477968216,
-0.03368990123271942,
0.012573448941111565,
-0.007463075220584869,
-0.028193838894367218,
0.015523967333137989,
0.03507838025689125,
0.01713421754539013,
-0.048288214951753616,
-0.01658461056649685,
0.02800099551677704,
-0.009516866877675056,
0.021598562598228455,
0.057776156812906265,
-0.0004158205701969564,
0.006889363285154104,
-0.005332145374268293,
0.03608117252588272,
-0.010751070454716682,
-0.01063536386936903,
0.04782538861036301,
0.007284693885594606,
0.012679513543844223,
0.05283934250473976,
-0.01565895788371563,
-0.058894652873277664,
-0.02254350110888481,
-0.0007990986341610551,
-0.049946676939725876,
0.039359524846076965,
0.026554662734270096,
0.027268186211586,
-0.019033733755350113,
0.024510512128472328,
0.054189253598451614,
0.10621865093708038,
-0.032166432589292526,
0.03961022198200226,
0.01228418294340372,
-0.016613537445664406,
0.03239784389734268,
-0.02551330253481865,
-0.008875659666955471,
-0.0056310538202524185,
0.039648789912462234,
0.029505180194973946,
0.0076655615121126175,
-0.009979693219065666,
0.016536399722099304,
0.0428885743021965,
-0.06190302595496178,
-0.023314878344535828,
0.01868661493062973,
0.027287470176815987,
-0.040651582181453705,
0.02466478757560253,
0.05407354608178139,
0.0037918013986200094,
0.01528291217982769,
-0.05766044929623604,
0.014029423706233501,
0.11030694842338562,
-0.05137372389435768,
0.014733306132256985,
0.05577057600021362,
-0.0007539007347077131,
-0.014607956632971764,
-0.028521673753857613,
-0.031433623284101486,
-0.03274496644735336,
0.0020646394696086645,
-0.011233181692659855,
0.07293371856212616,
0.01740419864654541,
-0.028888078406453133,
-0.025648294016718864,
-0.036775410175323486,
-0.012631302699446678,
0.03758535534143448,
0.0725480318069458,
0.03988020494580269,
-0.03694897145032883,
-0.040574442595243454,
0.033747754991054535,
-0.0035531565081328154,
-0.0030734562315046787,
-0.007877690717577934,
-0.01252523809671402,
0.021868545562028885,
0.02651609294116497,
-0.03988020494580269,
-0.05256935954093933,
-0.014289763756096363,
0.03901240602135658,
-0.032552119344472885,
-0.029312336817383766,
0.03895455226302147,
-0.04732399433851242,
-0.05172084644436836,
0.014858654700219631,
-0.005949247162789106,
0.04072871804237366,
-0.008166956715285778,
-0.03461555391550064,
0.03019941970705986,
-0.03675612807273865,
0.011898494325578213,
0.019843680784106255,
0.02763459086418152,
0.023546291515231133,
-0.02761530689895153,
-0.0077571626752614975,
0.0008846733253449202,
0.004242574796080589,
-0.011454951949417591,
0.01528291217982769,
0.02965945564210415,
0.008567108772695065,
-0.044431328773498535,
-0.027017489075660706,
-0.00012723205145448446,
-0.04454703629016876,
-0.07297229021787643,
0.0034784292802214622,
-0.015041857026517391,
0.013373753055930138,
-0.002526260446757078,
-0.010751070454716682,
0.01732706092298031,
-0.04335140064358711,
0.032725680619478226,
0.05781472474336624,
0.011049979366362095,
-0.004201595671474934,
-0.011262107640504837,
0.002543134381994605,
-0.037431079894304276,
-0.08554574102163315,
0.0005743145011365414,
0.026130404323339462,
0.019718332216143608,
-0.013826937414705753,
0.06587561964988708,
-0.037431079894304276,
0.022852052003145218,
-0.017346346750855446,
-0.001115483813919127,
-0.05303218588232994,
0.0853143259882927,
-0.07085099816322327,
0.034750547260046005,
-0.017423484474420547,
-0.003960540052503347,
0.0177802462130785,
0.04778682067990303,
0.00010237321112072095,
-0.02385484240949154,
-0.018214145675301552,
-0.12573449313640594,
-0.00605049030855298,
0.015948224812746048,
0.03498195856809616,
-0.024240531027317047,
0.008947975933551788,
0.043312832713127136,
-0.002270741853863001,
0.03029584139585495,
0.004541483707726002,
0.04809537157416344,
0.023642713204026222,
-0.005505705252289772,
0.04647548124194145,
0.020036524161696434,
0.001138384104706347,
0.006812225561589003,
-0.026651084423065186,
-0.01224561408162117,
0.03176146000623703,
0.06660842895507812,
-0.008576750755310059,
-0.026361817494034767,
-0.006392789073288441,
-0.023642713204026222,
-0.07790910452604294,
-0.07104384899139404,
-0.02107788436114788,
0.03675612807273865,
-0.03529050946235657,
-0.003897865768522024,
0.05800757184624672,
0.03814460709691048,
0.013643735088407993,
-0.023334162309765816,
0.02017151564359665,
0.016044646501541138,
-0.04419991746544838,
-0.001704261638224125,
-0.06988678127527237,
-0.005611769389361143,
0.024819063022732735,
0.025532586500048637,
-0.0013800421729683876,
-0.026014698669314384,
-0.01317126676440239,
0.0119177782908082,
-0.03704539313912392,
-0.027287470176815987,
0.005264649633318186,
0.008711742237210274,
0.02395126409828663,
-0.021964967250823975,
-0.0017741677584126592,
0.044508468359708786,
-0.014704379253089428,
-0.027499599382281303,
0.036775410175323486,
-0.03984163701534271,
0.03519408777356148,
0.02468407154083252,
0.04585837945342064,
-0.03914739564061165,
-0.038163889199495316,
-0.010346097871661186,
0.0038641178980469704,
-0.020788617432117462,
-0.02532045915722847,
0.07960613071918488,
-0.040844425559043884,
-0.059704601764678955,
-0.048751041293144226,
-0.01962190866470337,
0.04998524487018585,
0.002230967627838254,
-0.07235518842935562,
0.0057130130007863045,
0.0403430312871933,
-0.00953615177422762,
-0.047208286821842194,
-0.0005848606233485043,
-0.004129278939217329,
-0.005500884260982275,
-0.025667577981948853,
0.030064428225159645,
0.02964017167687416,
-0.054459236562252045,
-0.014193342067301273,
0.018985522910952568,
0.041577234864234924,
-0.037141814827919006,
-0.0118406405672431,
-0.018358778208494186,
0.02549401856958866,
0.03729609027504921,
0.011387457139790058,
-0.025725431740283966,
-0.01962190866470337,
0.040651582181453705,
0.0009051630040630698,
0.09665357321500778,
-0.0037026109639555216,
-0.015109351836144924,
-0.006455463357269764,
-0.01646890491247177,
-0.0178573839366436,
0.0806860625743866,
-0.04855819791555405,
0.0010968020651489496,
-0.05044807121157646,
-0.015196132473647594,
-0.018985522910952568,
-0.03887741267681122,
-0.04254145547747612,
0.005028415471315384,
0.004946456756442785,
-0.04740113392472267,
0.01980511099100113,
-0.04508700221776962,
0.03039226494729519,
-0.003596546594053507,
0.03775891661643982,
0.04335140064358711,
0.015234701335430145,
0.016439978033304214,
0.03766249492764473,
-0.018435915932059288,
-0.004247396253049374,
-0.02680535987019539,
0.02551330253481865,
0.008403191342949867,
0.011233181692659855,
0.013470175676047802,
0.03858814761042595,
0.0012932622339576483,
-0.02449122816324234,
0.03878099098801613,
-0.029389474540948868,
0.03203143924474716,
0.029890868812799454,
0.03442271053791046,
-0.012216687202453613,
-0.029987290501594543,
0.04269573092460632,
-0.007520928513258696,
-0.012910926714539528,
-0.008793700486421585,
-0.05476778745651245,
0.03507838025689125,
0.006585633382201195,
0.009902555495500565,
-0.0024141697213053703,
-0.09673070907592773,
-0.016276059672236443,
0.054382096976041794,
0.04454703629016876,
-0.020017240196466446,
0.0047753071412444115,
0.06217300891876221,
-0.022852052003145218,
-0.0036905580200254917,
0.01674852892756462,
-0.01584216021001339,
-0.013364111073315144,
-0.004589694552123547,
0.07331940531730652,
0.04196292161941528,
0.09734781086444855,
-0.011657439172267914,
-0.020383644849061966,
-0.016603896394371986,
-0.01621820777654648,
0.0005065176519565284,
-0.042117197066545486,
-0.019650835543870926,
0.005645517259836197,
-0.02890736237168312,
-0.0025286711752414703,
-0.02641967125236988,
0.0663384422659874,
-0.03579190373420715,
-0.11616941541433334,
-0.02586042322218418,
-0.0025913454592227936,
-0.01924586296081543,
-0.015678243711590767,
0.0084706861525774,
0.011773145757615566,
0.013383395969867706,
0.026843929663300514,
-0.0476711131632328,
-0.035599060356616974,
0.006407252512872219,
-0.037874624133110046,
0.013798010535538197,
0.011329603381454945,
0.012833788990974426,
-0.019997956231236458,
0.03073938377201557,
-0.013306258246302605,
0.03748893365263939,
-0.0029481074307113886,
0.016893161460757256,
0.042965713888406754,
0.05735189840197563,
-0.008663530461490154,
-0.023257024586200714,
-0.05330216884613037,
0.05700477957725525,
0.014366901479661465,
-0.03590761125087738,
0.012274540960788727,
0.0019899122416973114,
-0.024433374404907227,
-0.02690178155899048,
0.012091338634490967,
-0.025185467675328255,
0.012448100373148918,
-0.011773145757615566,
0.08261450380086899,
0.027094626799225807,
-0.00297944457270205,
0.0010443724459037185
] |
725,842 | flask_admin.base | expose |
Use this decorator to expose views in your view classes.
:param url:
Relative URL for the view
:param methods:
Allowed HTTP methods. By default only GET is allowed.
| def expose(url='/', methods=('GET',)):
"""
Use this decorator to expose views in your view classes.
:param url:
Relative URL for the view
:param methods:
Allowed HTTP methods. By default only GET is allowed.
"""
def wrap(f):
if not hasattr(f, '_urls'):
f._urls = []
f._urls.append((url, methods))
return f
return wrap
| (url='/', methods=('GET',)) | [
-0.03998883441090584,
-0.10302207618951797,
0.0492280013859272,
-0.0025438927114009857,
0.047587066888809204,
0.047158997505903244,
0.010880101472139359,
0.008191289380192757,
-0.03643942251801491,
0.044198185205459595,
0.03526223078370094,
0.011852175928652287,
0.059608686715364456,
0.03806252032518387,
0.028306100517511368,
0.025737682357430458,
0.05547068268060684,
-0.002601860323920846,
0.033318083733320236,
-0.05197478085756302,
-0.012547789141535759,
0.0005819070502184331,
0.043556079268455505,
-0.03322890028357506,
-0.08925250917673111,
0.05033384636044502,
0.011504369787871838,
0.0005506936577148736,
0.06435312330722809,
-0.051903437823057175,
-0.005899333860725164,
-0.0016197528457269073,
0.0017925413558259606,
-0.0051948027685284615,
0.04059526324272156,
0.024970725178718567,
0.0054088374599814415,
0.05818178877234459,
0.016703631728887558,
0.019744709134101868,
-0.041629765182733536,
0.051047295331954956,
-0.005466805305331945,
-0.05621980503201485,
0.036921001970767975,
0.053758405148983,
0.017113864421844482,
0.07123791426420212,
-0.02761048823595047,
-0.01956634595990181,
-0.023525990545749664,
0.001489325426518917,
0.001989854732528329,
-0.019280966371297836,
0.033835332840681076,
-0.00926592294126749,
0.043770115822553635,
0.1065179780125618,
0.006884785834699869,
-0.01149545144289732,
-0.012833168730139732,
0.0006950556999072433,
0.0492280013859272,
-0.00009503367618890479,
0.00980100966989994,
0.09752851724624634,
-0.0511186420917511,
0.016123954206705093,
0.013127466663718224,
0.016204217448830605,
-0.01033609639853239,
-0.021671021357178688,
-0.01926313154399395,
0.040773626416921616,
0.027128908783197403,
-0.00843207910656929,
0.03365696966648102,
-0.039453744888305664,
0.00250376109033823,
-0.016881993040442467,
0.02825259231030941,
-0.07145194709300995,
-0.004260629881173372,
-0.0006326288566924632,
0.041380058974027634,
0.021599676460027695,
-0.05365138500928879,
-0.05607711523771286,
0.035511936992406845,
0.08539988100528717,
-0.04583911597728729,
0.03390667587518692,
-0.027628323063254356,
-0.06146365776658058,
-0.040559593588113785,
0.01935231126844883,
-0.026397623121738434,
0.027253763750195503,
-0.005350869614630938,
-0.011762995272874832,
0.025416631251573563,
0.05265255644917488,
-0.018264301121234894,
0.02816341072320938,
-0.02834177389740944,
-0.08304549753665924,
-0.027985049411654472,
0.022723359987139702,
-0.04327069967985153,
0.013154221698641777,
0.011762995272874832,
0.003997545689344406,
0.021456986665725708,
0.01333258394151926,
0.009765337221324444,
0.005261688493192196,
-0.01316313911229372,
-0.02761048823595047,
-0.011049546301364899,
0.007705252151936293,
-0.009658319875597954,
0.012208901345729828,
-0.019334476441144943,
-0.0004316925478633493,
-0.0021927417255938053,
0.04348473623394966,
-0.02684352919459343,
0.024025404825806618,
0.04626718536019325,
-0.0268792025744915,
-0.05504261329770088,
0.04152274876832962,
-0.024239439517259598,
0.04027421399950981,
-0.012271327897906303,
0.058110445737838745,
-0.002494842978194356,
0.00993478111922741,
0.020047925412654877,
0.03647509589791298,
-0.07091686129570007,
0.04876425862312317,
0.03240843489766121,
0.03139176964759827,
0.015160797163844109,
-0.029180075973272324,
-0.018299974501132965,
0.017862986773252487,
0.016881993040442467,
0.05033384636044502,
0.020137106999754906,
0.004829159937798977,
0.06524493545293808,
-0.032123055309057236,
0.02204558253288269,
0.0026821233332157135,
0.0016754911048337817,
0.04983443394303322,
0.023169266059994698,
-0.01802351325750351,
0.03094586357474327,
0.04487596079707146,
0.017265472561120987,
0.006403207313269377,
0.0387759692966938,
0.005283983889967203,
0.04626718536019325,
-0.05436483770608902,
0.051903437823057175,
0.08090514689683914,
0.0011905685532838106,
-0.027378616854548454,
0.0309101901948452,
0.0006437764968723059,
0.057896409183740616,
-0.049513380974531174,
0.031748492270708084,
0.004896045662462711,
0.011941357515752316,
0.010371768847107887,
0.027378616854548454,
-0.008565850555896759,
-0.041166022419929504,
0.051047295331954956,
0.019298803061246872,
0.02684352919459343,
0.02192072942852974,
0.0077097113244235516,
-0.06050049886107445,
0.0010172226466238499,
-0.013635799288749695,
0.03215872868895531,
0.03874029591679573,
-0.030767500400543213,
-0.06203441694378853,
-0.051689401268959045,
-0.08276011794805527,
-0.0013555536279454827,
-0.0028939286712557077,
0.010692820884287357,
-0.04623151570558548,
0.038668952882289886,
0.037563104182481766,
-0.003843707963824272,
0.040987662971019745,
0.024667508900165558,
-0.03073182888329029,
-0.028609316796064377,
-0.017131701111793518,
-0.013350419700145721,
0.025612829253077507,
0.0446975976228714,
0.015018107369542122,
0.026897037401795387,
-0.012164310552179813,
0.028413118794560432,
-0.03308621048927307,
0.009836682118475437,
-0.022152600809931755,
0.0015417193062603474,
0.012075128965079784,
0.0468379445374012,
-0.01021124329417944,
0.03253328800201416,
0.031231243163347244,
-0.028395282104611397,
0.03403153270483017,
-0.04644554853439331,
0.0001991248136619106,
-0.0634613111615181,
-0.03622538968920708,
0.0026910414453595877,
-0.011022791266441345,
0.05550635606050491,
0.011468697339296341,
-0.008405324071645737,
-0.02302657626569271,
0.033371590077877045,
0.02944761887192726,
-0.016587696969509125,
0.021974237635731697,
0.015651293098926544,
0.012449690140783787,
-0.014795154333114624,
0.0015617851167917252,
0.03312188386917114,
-0.04904963821172714,
0.014848663471639156,
0.004432303830981255,
-0.00024371538893319666,
-0.00364973908290267,
-0.0349411778151989,
-0.0047043063677847385,
-0.008472210727632046,
-0.002780222799628973,
0.020565176382660866,
-0.08575660735368729,
0.027753178030252457,
-0.04876425862312317,
-0.04812215641140938,
0.013127466663718224,
-0.037135034799575806,
0.049977123737335205,
0.0038905281107872725,
0.024631837382912636,
0.006719800643622875,
0.04027421399950981,
-0.07216539233922958,
-0.03030375950038433,
-0.04669525474309921,
0.05696892738342285,
0.05793208256363869,
-0.020137106999754906,
0.0008656146237626672,
0.03488767147064209,
-0.03431691229343414,
0.006211468018591404,
-0.03205170854926109,
-0.038847312331199646,
0.012743988074362278,
0.010139898397028446,
-0.054043784737586975,
-0.016088280826807022,
0.023401137441396713,
-0.0039150528609752655,
-0.020351141691207886,
-0.05547068268060684,
0.08582794666290283,
-0.012449690140783787,
-0.053366005420684814,
0.08818233013153076,
-0.03287217766046524,
-0.030678318813443184,
-0.015401586890220642,
0.01892424188554287,
0.03651076927781105,
-0.07348527759313583,
-0.01117439940571785,
-0.019495001062750816,
0.003698788583278656,
-0.04904963821172714,
-0.015125124715268612,
0.04216485470533371,
0.03565462678670883,
0.04277128353714943,
-0.018638862296938896,
-0.0038994462229311466,
-0.041415732353925705,
0.016881993040442467,
-0.018942078575491905,
0.03276515752077103,
0.011085218749940395,
-0.07641042023897171,
-0.004323056899011135,
-0.037991173565387726,
-0.027021892368793488,
-0.03895433247089386,
-0.0005618412978947163,
-0.01104062795639038,
0.033585626631975174,
-0.024560492485761642,
0.037777140736579895,
-0.052081797271966934,
-0.03262246772646904,
0.012155392207205296,
0.0063809119164943695,
0.07312855124473572,
-0.008971625007689,
-0.0056808399967849255,
-0.008405324071645737,
-0.06392505764961243,
0.027200253680348396,
0.02259850688278675,
-0.011486534029245377,
-0.09339050948619843,
-0.03112422488629818,
0.004940636456012726,
-0.01492000836879015,
0.005587199702858925,
0.003052225336432457,
0.014804072678089142,
0.004548239056020975,
-0.060036759823560715,
0.008235880173742771,
-0.051689401268959045,
0.034227728843688965,
0.012128638103604317,
-0.020315468311309814,
0.07163030654191971,
0.009836682118475437,
0.01252103503793478,
0.0017891970928758383,
-0.01014881581068039,
-0.023490317165851593,
0.011317089200019836,
0.02439996600151062,
-0.006550356280058622,
-0.029982706531882286,
-0.008222502656280994,
-0.07377065718173981,
0.008280470967292786,
0.022634178400039673,
-0.053187645971775055,
-0.027771012857556343,
0.01492000836879015,
0.014447348192334175,
0.02538095787167549,
-0.07312855124473572,
0.05903792753815651,
-0.0038548556622117758,
-0.018460500985383987,
0.0013522093649953604,
0.005337492562830448,
0.058538515120744705,
0.03913269191980362,
-0.04669525474309921,
0.016150709241628647,
0.013136385008692741,
-0.008601523004472256,
0.08632736653089523,
-0.06331862509250641,
0.02406107820570469,
0.0808338075876236,
-0.019191786646842957,
0.03909702226519585,
-0.014581119641661644,
0.046338532119989395,
0.050619225949048996,
-0.07123791426420212,
0.004432303830981255,
0.014420594088733196,
-0.02696838416159153,
-0.05133267492055893,
-0.0033621296752244234,
-0.027235927060246468,
-0.06121394783258438,
-0.03941807523369789,
0.0044434512965381145,
-0.0020823802333325148,
0.01747058890759945,
0.10095307230949402,
0.007718629669398069,
-0.01626664400100708,
-0.014260067604482174,
0.04491163417696953,
0.05522097647190094,
0.030446449294686317,
-0.017488425597548485,
0.024257276207208633,
-0.07266481220722198,
-0.0035783941857516766,
-0.048692915588617325,
-0.019851727411150932,
0.018184039741754532,
0.060678862035274506,
0.011317089200019836,
0.030446449294686317,
0.025487976148724556,
-0.015597784891724586,
-0.015847492963075638,
0.07484082877635956,
0.01591883786022663,
0.034263402223587036,
0.04833618924021721,
-0.007647284772247076,
-0.003333145985379815,
-0.003257341915741563,
0.006915999110788107,
0.0287698432803154,
0.048264846205711365,
-0.004851455334573984,
-0.029554637148976326,
-0.03526223078370094,
-0.07066715508699417,
0.022420143708586693,
-0.051261331886053085,
0.042699940502643585,
-0.0754115879535675,
-0.020351141691207886,
0.03611836954951286,
0.002532745013013482,
-0.030553465709090233,
0.0043899426236748695,
-0.0072281332686543465,
0.08168994635343552,
-0.038633279502391815,
0.0013845375506207347,
0.029893524944782257,
0.060892898589372635,
-0.09695775806903839,
0.05878822132945061,
0.01695333793759346,
0.02238447219133377,
0.01311854925006628,
-0.00031297013629227877,
-0.023989733308553696,
-0.023686517030000687,
-0.005872579291462898,
-0.007254887372255325,
0.0808338075876236,
0.03749176114797592,
-0.029911361634731293,
-0.04434087499976158,
-0.05440050736069679,
-0.052081797271966934,
-0.013457437045872211,
-0.04252157732844353,
-0.04598180577158928,
-0.024899380281567574,
-0.025184759870171547,
0.015651293098926544,
-0.05279524624347687,
-0.022455817088484764,
-0.052331507205963135,
0.0029541258700191975,
0.050619225949048996,
0.0154550950974226,
-0.014268985949456692,
-0.02752130664885044,
-0.018603190779685974,
-0.03604702651500702,
-0.023311955854296684,
-0.003192685544490814,
0.024132423102855682,
-0.05989406630396843,
0.043770115822553635,
0.0020455929916352034,
0.03472714498639107,
0.031177734956145287,
-0.04815782606601715,
0.01698901131749153,
0.032123055309057236,
-0.0034334748052060604,
0.004298531915992498,
-0.03194469213485718,
0.08711215853691101,
0.005176966544240713,
-0.006938294507563114,
-0.018603190779685974,
-0.02525610476732254,
0.02042248658835888,
-0.019209621474146843,
0.05525664612650871,
0.02705756388604641,
0.022723359987139702,
-0.049085311591625214,
0.016721468418836594,
-0.04023854061961174,
-0.054685886949300766,
-0.04252157732844353,
-0.010782002471387386,
0.04616016894578934,
0.03276515752077103,
0.04423385486006737,
-0.004927259404212236,
-0.0065994057804346085,
-0.04491163417696953,
0.008311684243381023,
-0.02097540907561779,
-0.032729487866163254,
0.031088553369045258,
-0.00020065761054866016,
0.06688587367534637,
0.03870462253689766,
-0.03656427562236786,
0.03984614461660385,
0.026950547471642494,
0.07626772671937943,
-0.03274732083082199,
0.07683848589658737,
-0.018514009192585945,
0.04380578547716141,
-0.06667183339595795,
-0.028323937207460403,
-0.029893524944782257,
0.03258679807186127,
-0.09139285236597061,
-0.041380058974027634,
0.04202216491103172,
0.031106390058994293,
-0.009792091324925423,
-0.0005002505495212972,
0.010407441295683384,
-0.01673930324614048,
-0.03231925144791603,
-0.051225658506155014,
0.018977751955389977,
-0.05882389470934868,
0.048906948417425156,
-0.05493559688329697,
-0.012485362589359283,
0.02076137438416481,
0.0009592548594810069,
-0.014126296155154705,
0.090394027531147,
0.06378236413002014,
-0.001519424025900662,
0.01601693592965603,
-0.007959418930113316,
-0.003674263833090663,
-0.016489597037434578,
-0.016801731660962105,
-0.03158796578645706,
0.028092065826058388,
-0.04455490782856941,
0.0387759692966938,
0.04434087499976158,
-0.011031709611415863,
-0.019637690857052803,
-0.09160689264535904,
-0.022848213091492653,
-0.03809819370508194,
0.013368256390094757,
0.0003012650995515287,
-0.010906856507062912,
-0.010469868779182434,
0.0316058024764061,
-0.0003859872231259942,
0.017399244010448456,
-0.05422214791178703,
-0.04027421399950981,
-0.015053779818117619,
-0.019156113266944885,
-0.0215283315628767,
-0.05322331562638283,
-0.009551302529871464,
0.05008414015173912,
0.030410775914788246,
0.02051166631281376,
0.00128197914455086,
0.027663996443152428,
-0.040951989591121674,
0.009408612735569477,
0.0012942416360601783,
0.006037564482539892,
-0.0382765531539917,
-0.10908639430999756,
0.011031709611415863,
0.03724205121397972,
0.03283650428056717,
0.00015759983216412365,
0.011424106545746326,
-0.001169387949630618,
-0.0839729830622673,
-0.03137393295764923,
0.0333002470433712,
0.007241510320454836,
0.03659994900226593,
0.007272723596543074,
-0.03394234925508499,
-0.035547610372304916,
0.028484463691711426,
-0.0015060468576848507,
0.029483292251825333,
-0.015374831855297089,
-0.01209296565502882,
-0.04879993200302124,
0.010407441295683384,
-0.037135034799575806,
-0.048906948417425156,
-0.02473885379731655,
0.015080534853041172,
0.026611657813191414,
-0.015196469612419605,
0.0321052186191082,
0.022295290604233742,
0.022955231368541718,
-0.01106738205999136,
-0.006211468018591404,
0.0037522974889725447,
-0.0010919118067249656,
-0.0001712556986603886,
-0.03467363491654396,
0.017622197046875954,
-0.007130033802241087,
-0.033032700419425964,
0.0023253988474607468,
-0.023597335442900658,
0.005292901769280434,
-0.020172778517007828,
-0.03296135738492012,
-0.021296462044119835,
-0.0009659434435889125,
-0.023989733308553696,
0.016685795038938522,
0.04412683844566345,
-0.02161751314997673,
-0.010166652500629425,
0.017060356214642525,
-0.0494777075946331,
-0.00909647811204195,
0.05793208256363869,
0.045054323971271515,
-0.032301418483257294,
0.027039729058742523,
0.030125396326184273,
-0.014875417575240135,
-0.020261960104107857,
0.0215283315628767,
-0.002445793244987726,
-0.04894262179732323,
-0.059180617332458496,
0.025095578283071518,
-0.05065489932894707,
0.01981605403125286,
0.04134438559412956,
-0.0193879846483469,
-0.010844429023563862,
-0.021421315148472786,
0.012387263588607311,
-0.010692820884287357,
0.004405549261718988,
0.025113414973020554,
0.019370147958397865,
0.04598180577158928,
-0.01626664400100708,
-0.027164582163095474,
0.00038821675116196275,
-0.018184039741754532,
-0.01725655421614647,
-0.0984560027718544,
0.009569138288497925,
0.011566796340048313,
0.005466805305331945,
-0.047622740268707275,
0.04287830367684364,
-0.049120984971523285,
-0.03973912447690964,
0.005453428253531456,
-0.020743537694215775,
0.0256841741502285,
-0.021260788664221764,
-0.0018761487444862723,
-0.0003411179350223392,
0.002067888155579567,
0.053401678800582886,
0.0018850668566301465,
-0.04616016894578934,
-0.020315468311309814,
0.031320422887802124,
0.0019229687750339508,
0.032551124691963196,
0.011629223823547363,
0.04401982203125954,
0.013939015567302704,
-0.0031414064578711987,
0.04644554853439331,
-0.033318083733320236,
-0.036154042929410934,
-0.06545897573232651,
0.00583244813606143,
0.012119719758629799,
0.04341338947415352,
-0.011441943235695362,
0.03167714923620224,
-0.05711161717772484,
0.0818326324224472,
0.00931051280349493,
-0.012333754450082779,
0.0065771108493208885,
0.020529503002762794,
0.025095578283071518,
0.03934672847390175,
-0.013903343118727207,
-0.022366635501384735,
-0.001970903715118766,
-0.11215423047542572,
-0.006541438400745392,
0.011129808612167835,
-0.04797946661710739,
-0.023775696754455566,
0.02409674972295761,
0.015722637996077538,
0.02730727195739746,
-0.03952509164810181,
-0.042664267122745514,
-0.07612504065036774,
0.003772363066673279,
-0.0468379445374012,
-0.04983443394303322,
-0.008619359694421291,
-0.0033710480201989412,
-0.012592379935085773,
-0.043556079268455505,
0.01644500531256199,
-0.016596613451838493,
0.019637690857052803,
0.01871020719408989,
-0.0019965432584285736,
0.027663996443152428,
-0.006866949610412121,
0.04298532009124756,
-0.02067219279706478,
0.016115035861730576,
0.06488821655511856,
-0.035387083888053894,
0.012101884000003338,
-0.011415189132094383,
0.03219439834356308,
-0.023222774267196655,
-0.057468339800834656,
0.012815332971513271,
0.0011660436866804957,
-0.024239439517259598,
0.09125016629695892,
0.08333087712526321,
0.03438825532793999,
0.00041106942808255553
] |
725,843 | flask_admin.base | expose_plugview |
Decorator to expose Flask's pluggable view classes
(``flask.views.View`` or ``flask.views.MethodView``).
:param url:
Relative URL for the view
.. versionadded:: 1.0.4
| def expose_plugview(url='/'):
"""
Decorator to expose Flask's pluggable view classes
(``flask.views.View`` or ``flask.views.MethodView``).
:param url:
Relative URL for the view
.. versionadded:: 1.0.4
"""
def wrap(v):
handler = expose(url, v.methods)
if hasattr(v, 'as_view'):
return handler(v.as_view(v.__name__))
else:
return handler(v)
return wrap
| (url='/') | [
-0.005102161318063736,
-0.0793631300330162,
-0.006616462022066116,
0.0018434030935168266,
0.061501260846853256,
0.06728313863277435,
0.0025467786472290754,
0.0134394196793437,
-0.03092271089553833,
0.052621953189373016,
0.04178093373775482,
0.00393201969563961,
0.012097198516130447,
0.025054795667529106,
0.005837801843881607,
0.009774123318493366,
0.06563117355108261,
-0.0023833028972148895,
0.04095495492219925,
-0.01663149707019329,
0.03180031478404999,
0.009791331365704536,
0.0469089075922966,
-0.004693471826612949,
-0.0970529168844223,
0.03260909020900726,
0.03999130800366402,
0.018739473074674606,
0.004248215816915035,
-0.0682123675942421,
-0.02648305520415306,
-0.031060373410582542,
0.03436430171132088,
0.02243918366730213,
0.01358568761497736,
0.03658413141965866,
0.029718153178691864,
0.03706595301628113,
0.020081693306565285,
0.027722029015421867,
-0.026689551770687103,
0.05527197942137718,
-0.02763598971068859,
-0.10799717903137207,
0.024813883006572723,
0.06652598828077316,
-0.0014175060205161572,
0.08108392357826233,
-0.03809843212366104,
0.003432988654822111,
-0.005687232129275799,
-0.05898889899253845,
-0.017276795580983162,
0.00718002300709486,
0.0076231276616454124,
0.01681218110024929,
0.06046878546476364,
0.06848769634962082,
0.009094408713281155,
0.01908363215625286,
-0.04628942161798477,
-0.012862952426075935,
0.04821671545505524,
0.0024521348532289267,
0.028083397075533867,
0.07296176254749298,
-0.029133081436157227,
-0.0045773182064294815,
-0.01095286849886179,
-0.018773887306451797,
-0.008169480599462986,
-0.006065807305276394,
0.010290361940860748,
0.042056262493133545,
0.059229809790849686,
-0.019651494920253754,
0.047184236347675323,
-0.048732951283454895,
0.008647001348435879,
-0.026310976594686508,
0.02410835772752762,
-0.057715509086847305,
-0.005768969655036926,
-0.013207112438976765,
0.027739237993955612,
0.018137194216251373,
-0.02591519244015217,
-0.074338398873806,
-0.0034501967020332813,
0.10235296934843063,
-0.04821671545505524,
0.0032523050904273987,
-0.019617078825831413,
-0.014523521065711975,
-0.04229717329144478,
0.0030759235378354788,
0.0051666912622749805,
0.019823573529720306,
0.019290126860141754,
-0.007429538294672966,
0.04525694251060486,
0.05306936055421829,
-0.0407828725874424,
0.03710037097334862,
-0.01097007654607296,
-0.06876302510499954,
-0.049490101635456085,
0.04928360879421234,
-0.04308874160051346,
0.019909614697098732,
0.010453837923705578,
0.00952460803091526,
-0.009318112395703793,
0.0022069213446229696,
0.0031920771580189466,
0.011400275863707066,
0.003099584486335516,
-0.0029533167835325003,
0.0004250904603395611,
0.026603512465953827,
-0.024590179324150085,
0.00032372481655329466,
-0.011064720340073109,
-0.010238738730549812,
-0.04098936915397644,
0.02937399409711361,
0.005226918961852789,
0.030612967908382416,
-0.027808068320155144,
-0.03493216633796692,
-0.036205556243658066,
0.05596029758453369,
-0.04976543039083481,
0.007687657605856657,
-0.009249280206859112,
0.0523122102022171,
-0.027050917968153954,
-0.024332059547305107,
0.023867445066571236,
0.04976543039083481,
-0.06318764388561249,
0.011443295516073704,
-0.004538600333034992,
0.026689551770687103,
0.03371040150523186,
-0.037169199436903,
-0.031697068363428116,
0.03816726431250572,
0.015254859812557697,
0.0028285589069128036,
-0.04260691627860069,
0.03197239711880684,
0.09553861618041992,
-0.015177424065768719,
0.014076114632189274,
0.005265636835247278,
0.014626769348978996,
0.01987519860267639,
0.01649383269250393,
-0.061398014426231384,
0.054033003747463226,
0.006930507253855467,
0.0018713660538196564,
0.03654971346259117,
0.002905994886532426,
-0.04140235856175423,
0.04449979215860367,
-0.024194397032260895,
0.02128625102341175,
0.06824678182601929,
0.014686997048556805,
-0.02605285681784153,
0.02904704213142395,
0.03286721184849739,
0.024555763229727745,
0.045016031712293625,
-0.009378340095281601,
-0.02009890228509903,
0.0301311444491148,
-0.0029748266097158194,
0.02940841019153595,
0.000056093929742928594,
-0.06580325216054916,
0.0714474618434906,
-0.023970693349838257,
-0.01509998831897974,
0.032316554337739944,
-0.005631306208670139,
-0.033796440809965134,
0.026207728311419487,
-0.005119369365274906,
0.027016501873731613,
0.03333182632923126,
-0.029133081436157227,
-0.020632348954677582,
-0.020150525495409966,
-0.04914594441652298,
0.015392523258924484,
-0.0544804111123085,
0.00804472342133522,
-0.01412773784250021,
0.012845744378864765,
-0.01822323352098465,
0.008238312788307667,
0.03081946261227131,
0.02230152115225792,
0.012088594026863575,
-0.019393375143408775,
0.001186273992061615,
-0.03727244958281517,
0.045016031712293625,
0.009593439288437366,
-0.0013174846535548568,
0.03472566977143288,
-0.02233593724668026,
-0.006779937539249659,
-0.03586139529943466,
0.001201330916956067,
0.006104525178670883,
-0.007967286743223667,
0.007278968580067158,
0.033435072749853134,
0.014575145207345486,
0.10180231183767319,
-0.009103012271225452,
-0.003374911844730377,
0.032350972294807434,
-0.06707663834095001,
0.010109678842127323,
-0.04642708599567413,
-0.0321100614964962,
0.008509337902069092,
0.02558824233710766,
0.03964714705944061,
0.02789410948753357,
0.05974604934453964,
-0.022559640929102898,
0.05227779224514961,
0.03878675028681755,
0.00679284380748868,
0.018636224791407585,
0.0057947817258536816,
0.04305432364344597,
-0.02128625102341175,
-0.005274240858852863,
0.026964878663420677,
-0.0717916265130043,
0.025158042088150978,
0.03802959993481636,
0.015426939353346825,
-0.002067106543108821,
-0.04529136046767235,
0.02522687427699566,
0.015306483954191208,
-0.021131379529833794,
0.04842320829629898,
-0.07069031149148941,
-0.013121072202920914,
-0.0519680492579937,
-0.030423680320382118,
-0.013843806460499763,
-0.01811998523771763,
0.06618183106184006,
0.022198272868990898,
-0.01205417886376381,
-0.0537576787173748,
0.021630410104990005,
-0.029959063977003098,
0.010471045970916748,
-0.00804902520030737,
0.04074845835566521,
0.07413190603256226,
-0.03374481573700905,
-0.002624214394018054,
0.02107975445687771,
-0.02450414001941681,
0.004370822571218014,
-0.032677922397851944,
-0.0189459677785635,
0.010221530683338642,
-0.009429964236915112,
-0.03593022748827934,
0.000778660352807492,
0.014187965542078018,
-0.038270510733127594,
-0.0015562452608719468,
-0.039062079042196274,
0.09932436794042587,
-0.017595142126083374,
-0.025674281641840935,
0.06797145307064056,
-0.010797997005283833,
0.009920391254127026,
0.017517706379294395,
0.004650452174246311,
0.06487402319908142,
-0.09478146582841873,
0.03522470220923424,
-0.009369736537337303,
-0.013981470838189125,
0.01645941659808159,
-0.038304928690195084,
0.03586139529943466,
0.04773489013314247,
0.03802959993481636,
-0.013301756232976913,
-0.0073607065714895725,
-0.02496875450015068,
0.0005759290070272982,
0.008126460947096348,
0.025312913581728935,
0.0019444999052211642,
-0.0859021544456482,
-0.011993950232863426,
-0.03730686381459236,
-0.01113355252891779,
-0.03085387870669365,
-0.03882116451859474,
0.00212840992026031,
0.025674281641840935,
-0.002559684682637453,
0.042125094681978226,
-0.01504836417734623,
-0.007287572603672743,
0.005493642296642065,
-0.01779303513467312,
0.05093557387590408,
-0.033572737127542496,
0.010436629876494408,
-0.04770047590136528,
-0.07055264711380005,
0.04009455442428589,
0.0024005109444260597,
-0.022783344611525536,
-0.04680566117167473,
-0.06886626780033112,
0.02089046686887741,
-0.029580488801002502,
-0.01743166707456112,
0.02424602024257183,
0.04229717329144478,
0.01868784800171852,
-0.06597533077001572,
0.01818881742656231,
-0.026534680277109146,
0.045945264399051666,
-0.052415456622838974,
-0.025450577959418297,
0.05967721715569496,
-0.001319635659456253,
0.011193780228495598,
-0.075783871114254,
-0.032316554337739944,
-0.01172722689807415,
0.007365008350461721,
0.00014707431546412408,
-0.004568714182823896,
-0.03634322062134743,
-0.012079990468919277,
-0.03658413141965866,
-0.03142173960804939,
0.02612168900668621,
-0.06917601078748703,
0.0037534870207309723,
0.0483543761074543,
-0.00012865642202086747,
0.010522670112550259,
-0.07303059846162796,
0.029959063977003098,
0.014833264984190464,
-0.0067713335156440735,
0.004084740299731493,
-0.005235522985458374,
0.03964714705944061,
0.032557468861341476,
-0.05943630635738373,
0.03328020125627518,
0.02569148875772953,
-0.016932636499404907,
0.07777999341487885,
-0.03799518197774887,
0.03727244958281517,
0.06945133954286575,
-0.035448405891656876,
0.018033945932984352,
-0.018446937203407288,
-0.005424810573458672,
0.057715509086847305,
-0.0725487768650055,
-0.04195301607251167,
0.02471063658595085,
-0.023798612877726555,
-0.046461500227451324,
0.05076349154114723,
-0.04604851081967354,
-0.04921477660536766,
-0.033039290457963943,
-0.028444763273000717,
0.019651494920253754,
0.017879074439406395,
0.1082725077867508,
-0.027808068320155144,
0.0158743467181921,
-0.0005995899555273354,
0.06649157404899597,
0.04019780457019806,
0.019238503649830818,
0.011279820464551449,
0.02095929905772209,
-0.06824678182601929,
0.0020445212721824646,
0.003714769147336483,
-0.03448475897312164,
0.0062636989168822765,
0.03665296360850334,
0.027739237993955612,
-0.009189052507281303,
0.006900393404066563,
-0.05083232372999191,
0.007567201741039753,
0.08211640268564224,
-0.030113935470581055,
-0.010341986082494259,
0.059918127954006195,
-0.028565218672156334,
-0.004254668951034546,
-0.010694749653339386,
0.01901479996740818,
-0.0012626342941075563,
0.04969659820199013,
-0.002060653641819954,
-0.010815205052495003,
0.034949373453855515,
-0.07031174004077911,
0.008345861919224262,
-0.03408897668123245,
0.04043871536850929,
-0.03384806588292122,
-0.024624595418572426,
0.03548282012343407,
-0.0011152911465615034,
0.0050591412000358105,
0.013602894730865955,
-0.01597759500145912,
0.10407376289367676,
0.007528483867645264,
-0.023643741384148598,
-0.008634096011519432,
0.01891155168414116,
-0.08314888179302216,
0.05719926953315735,
-0.013146883808076382,
0.02309308759868145,
0.026964878663420677,
0.021664826199412346,
-0.03930298984050751,
-0.054721325635910034,
-0.011649791151285172,
0.01663149707019329,
0.08961907774209976,
-0.013026428408920765,
-0.021716449409723282,
-0.011933722533285618,
-0.06662923842668533,
-0.026930462568998337,
-0.01987519860267639,
-0.04821671545505524,
-0.05513431504368782,
-0.037582192569971085,
-0.015925969928503036,
0.04990309476852417,
-0.016648704186081886,
0.012252070009708405,
-0.0649428516626358,
0.02009890228509903,
0.043604981154203415,
0.04026663303375244,
0.0461861751973629,
0.0012196144089102745,
-0.009550419636070728,
-0.05365442857146263,
-0.05296611040830612,
-0.016984259709715843,
0.026035649701952934,
-0.03446755185723305,
0.07261760532855988,
0.006237886846065521,
0.017638161778450012,
0.020219357684254646,
-0.016554061323404312,
-0.0049343835562467575,
0.02503758668899536,
-0.046564750373363495,
-0.007416632492095232,
0.01944499835371971,
0.05454924330115318,
0.030544135719537735,
-0.0022434883285313845,
0.009825747460126877,
-0.024418100714683533,
-0.007050963118672371,
0.004646149929612875,
0.02915029041469097,
0.017595142126083374,
0.04102378338575363,
-0.07062148302793503,
0.017879074439406395,
0.04708098992705345,
-0.05867915600538254,
-0.028496388345956802,
-0.0400601401925087,
0.019617078825831413,
0.049593351781368256,
0.016330357640981674,
0.002275753067806363,
0.005588286090642214,
-0.047184236347675323,
0.005880821496248245,
-0.03085387870669365,
-0.05017842352390289,
0.01904921606183052,
-0.01253600139170885,
0.08473201096057892,
0.02558824233710766,
0.004590224474668503,
0.029029835015535355,
0.0483543761074543,
0.07750466465950012,
-0.05657978355884552,
0.07537087798118591,
-0.015788307413458824,
0.07282409816980362,
-0.06463310867547989,
-0.010316174477338791,
-0.029941856861114502,
0.03961273282766342,
-0.10806600749492645,
0.004628942348062992,
0.015512979589402676,
-0.016932636499404907,
-0.009739707224071026,
0.003921264782547951,
0.032316554337739944,
-0.009972014464437962,
-0.03381364792585373,
-0.030440887436270714,
-0.01597759500145912,
-0.04928360879421234,
0.03999130800366402,
-0.07784882932901382,
-0.0523122102022171,
0.027154166251420975,
0.00889651756733656,
0.0265174712985754,
0.07764232903718948,
0.009447172284126282,
0.009163240902125835,
-0.011469108052551746,
-0.02842755615711212,
-0.04326082020998001,
-0.01815440133213997,
0.009842955507338047,
-0.00018216243188362569,
0.01832648180425167,
-0.023299582302570343,
0.03730686381459236,
0.025278499349951744,
-0.018791096284985542,
-0.03302208334207535,
-0.06274023652076721,
0.011434691958129406,
-0.04188418388366699,
-0.042090680450201035,
-0.011735831387341022,
-0.031697068363428116,
0.0223703533411026,
0.061501260846853256,
0.025880776345729828,
0.006138940807431936,
-0.03470846265554428,
-0.07592153549194336,
0.010961472988128662,
-0.004551506135612726,
0.011735831387341022,
-0.05430833250284195,
-0.01508278027176857,
0.04673682898283005,
0.05041933432221413,
0.007734979502856731,
-0.01353406347334385,
0.028014564886689186,
-0.04887061566114426,
-0.004250367172062397,
-0.03489774838089943,
0.041299112141132355,
-0.03506983071565628,
-0.10662054270505905,
0.030337639153003693,
0.058334995061159134,
0.02908145822584629,
0.007928568869829178,
-0.034261055290699005,
-0.016605684533715248,
-0.05138297751545906,
-0.018532976508140564,
-0.022129440680146217,
-0.012492981739342213,
0.04030105099081993,
-0.003996549639850855,
-0.043570563197135925,
-0.03503541275858879,
0.03181752562522888,
0.006027089431881905,
0.03627438843250275,
0.0014433179749175906,
-0.01412773784250021,
-0.03923415765166283,
0.007726375479251146,
0.013714746572077274,
-0.00465475395321846,
-0.01944499835371971,
0.02035702019929886,
0.0711033046245575,
-0.015392523258924484,
0.04195301607251167,
-0.03665296360850334,
0.010694749653339386,
0.015194632112979889,
0.010737769305706024,
0.01973753422498703,
0.024555763229727745,
-0.015039759688079357,
-0.013284548185765743,
0.004461164586246014,
-0.026930462568998337,
-0.05134856328368187,
-0.034261055290699005,
-0.04315757378935814,
-0.013146883808076382,
0.0021380893886089325,
-0.021750865504145622,
-0.014927908778190613,
0.007334894500672817,
-0.041299112141132355,
0.050901155918836594,
0.015934573486447334,
0.009774123318493366,
0.010574293322861195,
0.012123010121285915,
-0.04095495492219925,
0.006706803571432829,
0.0216476172208786,
0.014996740035712719,
-0.0019229899626225233,
-0.007046660874038935,
0.04842320829629898,
0.05795641988515854,
0.027618780732154846,
-0.002602704567834735,
0.05069465935230255,
-0.020047277212142944,
-0.024091148748993874,
0.01324152760207653,
-0.04921477660536766,
0.017775826156139374,
0.009240676648914814,
0.016794972121715546,
-0.03820167854428291,
-0.025175251066684723,
0.015848534181714058,
0.006083014886826277,
-0.00963645987212658,
-0.04098936915397644,
-0.00511506712064147,
0.03734128177165985,
-0.08665930479764938,
-0.04635825380682945,
0.02089046686887741,
-0.032815586775541306,
-0.04098936915397644,
-0.05310377478599548,
0.014222381636500359,
-0.018739473074674606,
0.01947941444814205,
-0.043570563197135925,
-0.029064251109957695,
0.006199168972671032,
-0.03930298984050751,
-0.011606771498918533,
-0.053241439163684845,
0.005601192358881235,
-0.03723803162574768,
0.00315766129642725,
0.006057203281670809,
0.0033254390582442284,
0.022318728268146515,
0.009705291129648685,
-0.025777529925107956,
-0.010023638606071472,
0.003985794726759195,
0.03737569600343704,
0.02667234279215336,
0.003833073889836669,
0.05362001433968544,
0.030423680320382118,
0.011839078739285469,
0.03431268036365509,
-0.061398014426231384,
-0.03820167854428291,
-0.04604851081967354,
0.007300478406250477,
0.003108188509941101,
0.05076349154114723,
-0.030320432037115097,
0.028737299144268036,
-0.016407793387770653,
-0.01174443494528532,
-0.00038664141902700067,
0.04195301607251167,
0.01789628155529499,
0.0010824884520843625,
-0.01818881742656231,
0.04463745653629303,
0.0033534017857164145,
0.006797145586460829,
0.03816726431250572,
-0.07571504265069962,
0.013207112438976765,
0.002785539021715522,
-0.01904921606183052,
-0.05733693391084671,
-0.02875450626015663,
-0.03820167854428291,
0.014007282443344593,
-0.036859456449747086,
-0.05072907730937004,
-0.07681635022163391,
0.013198507949709892,
-0.026362599804997444,
-0.052484288811683655,
-0.03460521623492241,
0.00024050817592069507,
0.012708080932497978,
-0.01904921606183052,
0.0865904688835144,
-0.003731977194547653,
-0.001660568523220718,
0.015710869804024696,
-0.03185193985700607,
0.06415128707885742,
0.02266288734972477,
0.034949373453855515,
-0.026242144405841827,
0.003409327706322074,
0.07881247252225876,
-0.015478563494980335,
0.013000616803765297,
-0.014652580954134464,
0.0011593865929171443,
-0.05382651090621948,
-0.04088612273335457,
0.01793069764971733,
-0.0004205196164548397,
-0.05348234996199608,
0.058403827250003815,
0.047390732914209366,
0.027790861204266548,
-0.035448405891656876
] |
725,846 | autofaiss.external.quantize | build_index |
Reads embeddings and creates a quantized index from them.
The index is stored on the current machine at the given output path.
Parameters
----------
embeddings : Union[str, np.ndarray, List[str]]
Local path containing all preprocessed vectors and cached files.
This could be a single directory or multiple directories.
Files will be added if empty.
Or directly the Numpy array of embeddings
index_path: Optional(str)
Destination path of the quantized model.
index_infos_path: Optional(str)
Destination path of the metadata file.
ids_path: Optional(str)
Only useful when id_columns is not None and file_format=`parquet`. T
his will be the path (in any filesystem)
where the mapping files Ids->vector index will be store in parquet format
save_on_disk: bool
Whether to save the index on disk, default to True.
file_format: Optional(str)
npy or parquet ; default npy
embedding_column_name: Optional(str)
embeddings column name for parquet ; default embedding
id_columns: Optional(List[str])
Can only be used when file_format=`parquet`.
In this case these are the names of the columns containing the Ids of the vectors,
and separate files will be generated to map these ids to indices in the KNN index ;
default None
index_key: Optional(str)
Optional string to give to the index factory in order to create the index.
If None, an index is chosen based on an heuristic.
index_param: Optional(str)
Optional string with hyperparameters to set to the index.
If None, the hyper-parameters are chosen based on an heuristic.
max_index_query_time_ms: float
Bound on the query time for KNN search, this bound is approximative
max_index_memory_usage: str
Maximum size allowed for the index, this bound is strict
min_nearest_neighbors_to_retrieve: int
Minimum number of nearest neighbors to retrieve when querying the index.
Parameter used only during index hyperparameter finetuning step, it is
not taken into account to select the indexing algorithm.
This parameter has the priority over the max_index_query_time_ms constraint.
current_memory_available: str
Memory available on the machine creating the index, having more memory is a boost
because it reduces the swipe between RAM and disk.
use_gpu: bool
Experimental, gpu training is faster, not tested so far
metric_type: str
Similarity function used for query:
- "ip" for inner product
- "l2" for euclidian distance
nb_cores: Optional[int]
Number of cores to use. Will try to guess the right number if not provided
make_direct_map: bool
Create a direct map allowing reconstruction of embeddings. This is only needed for IVF indices.
Note that might increase the RAM usage (approximately 8GB for 1 billion embeddings)
should_be_memory_mappable: bool
If set to true, the created index will be selected only among the indices that can be memory-mapped on disk.
This makes it possible to use 50GB indices on a machine with only 1GB of RAM. Default to False
distributed: Optional[str]
If "pyspark", create the indices using pyspark.
Only "parquet" file format is supported.
temporary_indices_folder: str
Folder to save the temporary small indices that are generated by each spark executor.
Only used when distributed = "pyspark".
verbose: int
set verbosity of outputs via logging level, default is `logging.INFO`
nb_indices_to_keep: int
Number of indices to keep at most when distributed is "pyspark".
It allows you to build an index larger than `current_memory_available`
If it is not equal to 1,
- You are expected to have at most `nb_indices_to_keep` indices with the following names:
"{index_path}i" where i ranges from 1 to `nb_indices_to_keep`
- `build_index` returns a mapping from index path to metrics
Default to 1.
| def build_index(
embeddings: Union[str, np.ndarray, List[str]],
index_path: Optional[str] = "knn.index",
index_infos_path: Optional[str] = "index_infos.json",
ids_path: Optional[str] = None,
save_on_disk: bool = True,
file_format: str = "npy",
embedding_column_name: str = "embedding",
id_columns: Optional[List[str]] = None,
index_key: Optional[str] = None,
index_param: Optional[str] = None,
max_index_query_time_ms: float = 10.0,
max_index_memory_usage: str = "16G",
min_nearest_neighbors_to_retrieve: int = 20,
current_memory_available: str = "32G",
use_gpu: bool = False,
metric_type: str = "ip",
nb_cores: Optional[int] = None,
make_direct_map: bool = False,
should_be_memory_mappable: bool = False,
distributed: Optional[str] = None,
temporary_indices_folder: str = "hdfs://root/tmp/distributed_autofaiss_indices",
verbose: int = logging.INFO,
nb_indices_to_keep: int = 1,
) -> Tuple[Optional[faiss.Index], Optional[Dict[str, str]]]:
"""
Reads embeddings and creates a quantized index from them.
The index is stored on the current machine at the given output path.
Parameters
----------
embeddings : Union[str, np.ndarray, List[str]]
Local path containing all preprocessed vectors and cached files.
This could be a single directory or multiple directories.
Files will be added if empty.
Or directly the Numpy array of embeddings
index_path: Optional(str)
Destination path of the quantized model.
index_infos_path: Optional(str)
Destination path of the metadata file.
ids_path: Optional(str)
Only useful when id_columns is not None and file_format=`parquet`. T
his will be the path (in any filesystem)
where the mapping files Ids->vector index will be store in parquet format
save_on_disk: bool
Whether to save the index on disk, default to True.
file_format: Optional(str)
npy or parquet ; default npy
embedding_column_name: Optional(str)
embeddings column name for parquet ; default embedding
id_columns: Optional(List[str])
Can only be used when file_format=`parquet`.
In this case these are the names of the columns containing the Ids of the vectors,
and separate files will be generated to map these ids to indices in the KNN index ;
default None
index_key: Optional(str)
Optional string to give to the index factory in order to create the index.
If None, an index is chosen based on an heuristic.
index_param: Optional(str)
Optional string with hyperparameters to set to the index.
If None, the hyper-parameters are chosen based on an heuristic.
max_index_query_time_ms: float
Bound on the query time for KNN search, this bound is approximative
max_index_memory_usage: str
Maximum size allowed for the index, this bound is strict
min_nearest_neighbors_to_retrieve: int
Minimum number of nearest neighbors to retrieve when querying the index.
Parameter used only during index hyperparameter finetuning step, it is
not taken into account to select the indexing algorithm.
This parameter has the priority over the max_index_query_time_ms constraint.
current_memory_available: str
Memory available on the machine creating the index, having more memory is a boost
because it reduces the swipe between RAM and disk.
use_gpu: bool
Experimental, gpu training is faster, not tested so far
metric_type: str
Similarity function used for query:
- "ip" for inner product
- "l2" for euclidian distance
nb_cores: Optional[int]
Number of cores to use. Will try to guess the right number if not provided
make_direct_map: bool
Create a direct map allowing reconstruction of embeddings. This is only needed for IVF indices.
Note that might increase the RAM usage (approximately 8GB for 1 billion embeddings)
should_be_memory_mappable: bool
If set to true, the created index will be selected only among the indices that can be memory-mapped on disk.
This makes it possible to use 50GB indices on a machine with only 1GB of RAM. Default to False
distributed: Optional[str]
If "pyspark", create the indices using pyspark.
Only "parquet" file format is supported.
temporary_indices_folder: str
Folder to save the temporary small indices that are generated by each spark executor.
Only used when distributed = "pyspark".
verbose: int
set verbosity of outputs via logging level, default is `logging.INFO`
nb_indices_to_keep: int
Number of indices to keep at most when distributed is "pyspark".
It allows you to build an index larger than `current_memory_available`
If it is not equal to 1,
- You are expected to have at most `nb_indices_to_keep` indices with the following names:
"{index_path}i" where i ranges from 1 to `nb_indices_to_keep`
- `build_index` returns a mapping from index path to metrics
Default to 1.
"""
setup_logging(verbose)
# if using distributed mode, it doesn't make sense to use indices that are not memory mappable
if distributed == "pyspark":
should_be_memory_mappable = True
if index_path:
index_path = make_path_absolute(index_path)
elif save_on_disk:
logger.error("Please specify a index_path if you set save_on_disk as True")
return None, None
if index_infos_path:
index_infos_path = make_path_absolute(index_infos_path)
elif save_on_disk:
logger.error("Please specify a index_infos_path if you set save_on_disk as True")
return None, None
if ids_path:
ids_path = make_path_absolute(ids_path)
if nb_indices_to_keep < 1:
logger.error("Please specify nb_indices_to_keep an integer value larger or equal to 1")
return None, None
elif nb_indices_to_keep > 1:
if distributed is None:
logger.error('nb_indices_to_keep can only be larger than 1 when distributed is "pyspark"')
return None, None
if not save_on_disk:
logger.error("Please set save_on_disk to True when nb_indices_to_keep is larger than 1")
return None, None
current_bytes = cast_memory_to_bytes(current_memory_available)
max_index_bytes = cast_memory_to_bytes(max_index_memory_usage)
memory_left = current_bytes - max_index_bytes
if nb_indices_to_keep == 1 and memory_left < current_bytes * 0.1:
logger.error(
"You do not have enough memory to build this index, "
"please increase current_memory_available or decrease max_index_memory_usage"
)
return None, None
if nb_cores is None:
nb_cores = multiprocessing.cpu_count()
logger.info(f"Using {nb_cores} omp threads (processes), consider increasing --nb_cores if you have more")
faiss.omp_set_num_threads(nb_cores)
if isinstance(embeddings, np.ndarray):
tmp_dir_embeddings = tempfile.TemporaryDirectory() # pylint: disable=consider-using-with
np.save(os.path.join(tmp_dir_embeddings.name, "emb.npy"), embeddings)
embeddings_path = tmp_dir_embeddings.name
else:
embeddings_path = embeddings # type: ignore
with Timeit("Launching the whole pipeline"):
with Timeit("Reading total number of vectors and dimension"):
embedding_reader = EmbeddingReader(
embeddings_path,
file_format=file_format,
embedding_column=embedding_column_name,
meta_columns=id_columns,
)
nb_vectors = embedding_reader.count
vec_dim = embedding_reader.dimension
logger.info(f"There are {nb_vectors} embeddings of dim {vec_dim}")
with Timeit("Compute estimated construction time of the index", indent=1):
for log_lines in get_estimated_construction_time_infos(nb_vectors, vec_dim, indent=2).split("\n"):
| (embeddings: Union[str, numpy.ndarray, List[str]], index_path: Optional[str] = 'knn.index', index_infos_path: Optional[str] = 'index_infos.json', ids_path: Optional[str] = None, save_on_disk: bool = True, file_format: str = 'npy', embedding_column_name: str = 'embedding', id_columns: Optional[List[str]] = None, index_key: Optional[str] = None, index_param: Optional[str] = None, max_index_query_time_ms: float = 10.0, max_index_memory_usage: str = '16G', min_nearest_neighbors_to_retrieve: int = 20, current_memory_available: str = '32G', use_gpu: bool = False, metric_type: str = 'ip', nb_cores: Optional[int] = None, make_direct_map: bool = False, should_be_memory_mappable: bool = False, distributed: Optional[str] = None, temporary_indices_folder: str = 'hdfs://root/tmp/distributed_autofaiss_indices', verbose: int = 20, nb_indices_to_keep: int = 1) -> Tuple[Optional[faiss.swigfaiss_avx512.Index], Optional[Dict[str, str]]] | [
0.02340095490217209,
-0.04307073354721069,
-0.06724225729703903,
0.015877770259976387,
0.024901535362005234,
0.02149481140077114,
-0.07292013615369797,
-0.00565759651362896,
-0.011619364842772484,
-0.04453076049685478,
-0.035932835191488266,
-0.002051892690360546,
-0.020886467769742012,
-0.004522021859884262,
0.062416065484285355,
0.02845020778477192,
0.036967020481824875,
0.021028414368629456,
0.014701640233397484,
0.013332866132259369,
-0.047248028218746185,
-0.0658227875828743,
-0.02646295167505741,
0.03392530232667923,
0.0225289948284626,
-0.031917765736579895,
0.017631828784942627,
-0.011670060455799103,
0.01888907328248024,
-0.03461475670337677,
0.010514207184314728,
-0.015066646039485931,
0.0003811653587035835,
0.028308261185884476,
-0.0029023063834756613,
-0.03335751220583916,
0.03220166265964508,
0.008172083646059036,
0.030437463894486427,
0.016405003145337105,
0.04497687891125679,
-0.08245085179805756,
-0.0416107103228569,
-0.06342997401952744,
-0.02382679656147957,
0.04367908090353012,
-0.0042837536893785,
0.000021961366655887105,
0.03335751220583916,
0.031228311359882355,
-0.030356351286172867,
-0.06205105781555176,
-0.009008556604385376,
0.026929348707199097,
-0.01607041247189045,
0.03514198958873749,
-0.02605738863348961,
-0.003490372095257044,
0.038244541734457016,
-0.05304757133126259,
0.009495231322944164,
-0.007700617425143719,
0.062416065484285355,
0.06407887488603592,
-0.04951917752623558,
0.03832565248012543,
-0.010321564972400665,
0.001370040699839592,
-0.02226538024842739,
-0.012542019598186016,
0.02502320520579815,
-0.08338364213705063,
0.05669763311743736,
0.0037489181850105524,
-0.05065475404262543,
0.0076600611209869385,
0.007933815941214561,
-0.01987256109714508,
-0.0026234823744744062,
-0.002216652501374483,
0.0067931716330349445,
-0.027740472927689552,
-0.04130654036998749,
-0.05544039234519005,
0.04465242847800255,
0.029017996042966843,
0.05844155326485634,
0.04033318907022476,
-0.026260171085596085,
-0.0993628054857254,
-0.0035942974500358105,
0.05507538467645645,
0.032505832612514496,
0.013109806925058365,
0.014255520887672901,
-0.040211521089076996,
0.026442673057317734,
-0.07944969087839127,
-0.003036648966372013,
-0.01744932495057583,
-0.028328539803624153,
-0.005312868393957615,
0.029403280466794968,
0.016029857099056244,
-0.03232333064079285,
-0.039704564958810806,
-0.0534936897456646,
-0.0431518480181694,
-0.014214964583516121,
-0.06444387882947922,
-0.05114142969250679,
0.016060274094343185,
0.0346350371837616,
-0.009099808521568775,
-0.004537230357527733,
-0.007452210411429405,
0.01883837766945362,
0.04489576816558838,
-0.022305935621261597,
0.015543182380497456,
0.054791491478681564,
-0.021636757999658585,
-0.05913101136684418,
-0.00011065835860790685,
0.020714104175567627,
0.01490442082285881,
-0.004567647352814674,
0.027821585536003113,
0.042624615132808685,
0.014661083929240704,
-0.042867954820394516,
-0.01199450995773077,
-0.003875656519085169,
0.0697161927819252,
0.020389653742313385,
-0.02228565886616707,
-0.0036196450237184763,
-0.014579971320927143,
-0.07040564715862274,
0.059293232858181,
0.031208032742142677,
-0.03366168588399887,
0.038771774619817734,
-0.026888791471719742,
0.01593860611319542,
0.006473790854215622,
-0.008278544060885906,
-0.07644852995872498,
-0.004456117749214172,
-0.048789165914058685,
0.046396348625421524,
-0.015502626076340675,
-0.05272312089800835,
-0.016475975513458252,
-0.029403280466794968,
-0.0496814027428627,
0.042867954820394516,
0.000012129248716519214,
0.019162826240062714,
0.03205971419811249,
0.0015170571859925985,
-0.049721959978342056,
0.037899814546108246,
0.0038477741181850433,
-0.05081697925925255,
0.047329142689704895,
0.007523184176534414,
-0.002471396466717124,
-0.036723680794239044,
0.001954304287210107,
-0.02080535516142845,
0.016719313338398933,
-0.07604296505451202,
-0.003001162316650152,
-0.08330253511667252,
0.06541723012924194,
-0.017895445227622986,
0.012177013792097569,
0.040556248277425766,
0.0017794054001569748,
-0.0485052727162838,
-0.031066086143255234,
-0.06878339499235153,
-0.02210315503180027,
-0.023684848099946976,
0.04522021487355232,
-0.019325051456689835,
0.02526654303073883,
0.10982631891965866,
-0.006752615328878164,
0.0346350371837616,
-0.05053308606147766,
-0.008192362263798714,
0.05827932804822922,
-0.02382679656147957,
0.014782752841711044,
-0.022204546257853508,
-0.0348580963909626,
0.022082876414060593,
0.04242183640599251,
-0.0005931351333856583,
0.048626940697431564,
0.02340095490217209,
-0.02911938540637493,
-0.015735823661088943,
0.016455696895718575,
-0.044327978044748306,
-0.008744941093027592,
-0.0240701325237751,
0.021535366773605347,
-0.02500292658805847,
-0.043557409197092056,
0.03883260861039162,
0.057630427181720734,
0.045098546892404556,
-0.011193524114787579,
-0.06809394061565399,
0.03737258166074753,
0.04122542589902878,
-0.022062599658966064,
0.03412808105349541,
0.01633402891457081,
0.004440909251570702,
-0.0034143291413784027,
0.0013713081134483218,
-0.05235811695456505,
0.04692357778549194,
0.025854608044028282,
-0.012440629303455353,
-0.036622293293476105,
0.023157617077231407,
0.013505230657756329,
0.00937863253057003,
0.01811850443482399,
-0.007872981950640678,
0.019162826240062714,
-0.037575364112854004,
0.037555087357759476,
0.003731174860149622,
-0.010929908603429794,
-0.006047950591892004,
-0.04461187124252319,
-0.006879353430122137,
-0.0416107103228569,
-0.014154130592942238,
0.04242183640599251,
0.039805956184864044,
0.04651801660656929,
-0.0008649887167848647,
-0.04607189819216728,
-0.03564894199371338,
0.008866610005497932,
-0.02577349543571472,
0.013038833625614643,
0.045706890523433685,
-0.017439186573028564,
-0.029099108651280403,
-0.03066052310168743,
0.013211198151111603,
-0.023624014109373093,
-0.059577129781246185,
0.0051962691359221935,
-0.002904841210693121,
0.007426863070577383,
-0.0019505020463839173,
0.00567280501127243,
0.03905566781759262,
0.04307073354721069,
0.005551136564463377,
0.012177013792097569,
0.05227700248360634,
0.0924682468175888,
-0.07421793043613434,
-0.01615152508020401,
-0.024435140192508698,
-0.03451336547732353,
0.014803030528128147,
0.0011723290663212538,
-0.06991896778345108,
0.0735284760594368,
-0.019122270867228508,
0.005353424698114395,
-0.02792297676205635,
-0.028592154383659363,
0.03386446833610535,
0.04165126755833626,
-0.08330253511667252,
-0.05491315945982933,
0.010727128013968468,
-0.010635876096785069,
-0.015127480030059814,
0.016405003145337105,
0.01211617887020111,
-0.01739863120019436,
-0.014762474223971367,
0.009738569147884846,
-0.01833142340183258,
-0.043395183980464935,
-0.03836620971560478,
-0.010463511571288109,
-0.02061271294951439,
0.020207149907946587,
0.062497179955244064,
-0.020044924691319466,
0.015462069772183895,
-0.019122270867228508,
0.033458903431892395,
0.0014955116203054786,
0.05260145291686058,
-0.008440769277513027,
-0.022549273446202278,
-0.011619364842772484,
0.028754379600286484,
0.05990157648921013,
-0.00977405533194542,
-0.054102033376693726,
0.004841402173042297,
-0.03197859972715378,
0.03818370774388313,
0.08305919915437698,
-0.03700757771730423,
0.058968786150217056,
-0.020409932360053062,
-0.04303018003702164,
-0.046315234154462814,
-0.050938647240400314,
0.05592706426978111,
-0.00282626342959702,
0.007938885129988194,
-0.05361536145210266,
-0.013991905376315117,
-0.06594445556402206,
0.03313445299863815,
-0.0067931716330349445,
-0.04627468064427376,
-0.011234080418944359,
0.0037844048347324133,
-0.017500020563602448,
0.035588108003139496,
0.004719733260571957,
0.07592129707336426,
-0.013718150556087494,
-0.02390790730714798,
0.0519525520503521,
-0.03658173605799675,
-0.06655280292034149,
0.0543048158288002,
-0.043232958763837814,
-0.03666284680366516,
0.01293744333088398,
0.04874860867857933,
0.0196292232722044,
-0.006894561927765608,
0.08533034473657608,
0.05260145291686058,
0.007137899752706289,
0.0029631408397108316,
-0.04242183640599251,
-0.045179661363363266,
-0.004950397182255983,
-0.06424109637737274,
-0.012177013792097569,
-0.027030739933252335,
-0.0051379697397351265,
-0.011234080418944359,
-0.013839819468557835,
0.010950187221169472,
-0.017124876379966736,
0.06415998190641403,
-0.049640849232673645,
-0.002664038445800543,
-0.06898617744445801,
0.004592995159327984,
0.0639166459441185,
0.05539983510971069,
-0.009008556604385376,
-0.09611830860376358,
0.023664571344852448,
-0.06809394061565399,
-0.012359516695141792,
-0.05069531127810478,
-0.02133258618414402,
0.013586343266069889,
0.013809402473270893,
-0.0009980639442801476,
0.005077135283499956,
0.07000008225440979,
-0.01689167693257332,
0.0003374406660441309,
0.02159620262682438,
-0.010270869359374046,
-0.00023050523304846138,
0.028916604816913605,
-0.003046788042411208,
0.053169239312410355,
0.055480945855379105,
0.0032723823096603155,
0.023177895694971085,
0.028429929167032242,
-0.056332629173994064,
-0.01843281462788582,
-0.03347918391227722,
-0.0011983104050159454,
0.06724225729703903,
0.008826053701341152,
-0.009556066244840622,
0.04781581461429596,
0.0014638270949944854,
0.01366745587438345,
0.014052740298211575,
-0.014042600989341736,
-0.01734793558716774,
-0.011609225533902645,
0.08541145920753479,
-0.04996529594063759,
0.02938300184905529,
0.03451336547732353,
0.0019124805694445968,
0.035506993532180786,
0.020126037299633026,
0.026239892467856407,
0.018666012212634087,
0.08411365747451782,
-0.0014207360800355673,
-0.028247427195310593,
-0.02295483648777008,
-0.02008548192679882,
-0.0008352052536793053,
-0.043638523668050766,
0.02295483648777008,
-0.061807721853256226,
-0.04607189819216728,
-0.006098645739257336,
0.0028617503121495247,
-0.04566633701324463,
0.01726682297885418,
-0.020602574571967125,
0.005099948029965162,
0.020886467769742012,
0.04266517236828804,
0.05673819035291672,
-0.02895716018974781,
0.020328819751739502,
0.048789165914058685,
0.03940039500594139,
0.04627468064427376,
-0.04392241686582565,
0.057954877614974976,
0.014874003827571869,
-0.01207562256604433,
0.05799543485045433,
-0.020470766350626945,
-0.0053077987395226955,
-0.004192502237856388,
0.013261892832815647,
-0.00855229888111353,
-0.0008339378400705755,
-0.009251894429326057,
-0.0032318260055035353,
0.0010525613324716687,
0.02646295167505741,
0.044084642082452774,
-0.0385284349322319,
-0.005551136564463377,
0.042097385972738266,
0.000839007378090173,
-0.039785679429769516,
-0.039278727024793625,
-0.017226265743374825,
-0.0051962691359221935,
0.029950788244605064,
0.02895716018974781,
-0.03195832297205925,
-0.06253773719072342,
0.02024770714342594,
-0.012065484188497066,
-0.05369647219777107,
-0.014569832012057304,
0.036358676850795746,
-0.050249192863702774,
0.04789692908525467,
-0.06598501652479172,
0.011751173064112663,
0.012440629303455353,
-0.0027882419526576996,
-0.016810564324259758,
0.07377181202173233,
-0.0015183244831860065,
0.006230453494936228,
-0.03333723545074463,
-0.000993628054857254,
-0.0021837004460394382,
0.06006380170583725,
0.010737266391515732,
0.06959452480077744,
0.027274075895547867,
-0.017763637006282806,
0.029180221259593964,
0.037920091301202774,
-0.009155573323369026,
0.04984362795948982,
-0.018868794664740562,
-0.018980324268341064,
-0.02263038605451584,
-0.0037058270536363125,
-0.01207562256604433,
-0.003391516162082553,
-0.04359796643257141,
-0.007898328825831413,
-0.05844155326485634,
-0.048951391130685806,
-0.03668312728404999,
0.037920091301202774,
-0.016688896343111992,
0.05166865885257721,
0.09595607966184616,
-0.009718290530145168,
0.03725091367959976,
0.01301855593919754,
0.022224823012948036,
-0.05320979654788971,
0.03860954940319061,
-0.013424118049442768,
-0.03171498700976372,
-0.029707452282309532,
0.02930188924074173,
-0.0032292911782860756,
-0.031309422105550766,
0.026949627324938774,
0.05231755971908569,
-0.0805041491985321,
0.008937583304941654,
0.004704524762928486,
0.024029577150940895,
0.0007826088694855571,
-0.020308541133999825,
0.06063159182667732,
0.0012154200812801719,
0.10909630358219147,
-0.04996529594063759,
-0.03923816978931427,
0.020734380930662155,
0.005333146546036005,
-0.09603719413280487,
0.002684316597878933,
0.0317758210003376,
0.01798669621348381,
0.03528393432497978,
0.019588667899370193,
-0.0197407528758049,
-0.0062963576056063175,
0.037048131227493286,
0.0708923190832138,
-0.029707452282309532,
0.05681930482387543,
-0.020653270184993744,
0.03374279662966728,
-0.044936321675777435,
-0.008866610005497932,
0.02031867951154709,
0.012521741911768913,
-0.007705687079578638,
0.06931062787771225,
-0.048951391130685806,
0.0025867281947284937,
0.042016271501779556,
-0.010950187221169472,
-0.06809394061565399,
-0.00796930305659771,
-0.0215759240090847,
-0.04700469225645065,
-0.03848787769675255,
-0.010362121276557446,
-0.025935720652341843,
-0.03171498700976372,
-0.030275238677859306,
0.002131737768650055,
-0.010382399894297123,
0.010184687562286854,
-0.04217849671840668,
0.03899483382701874,
0.012237847782671452,
0.041509319096803665,
0.021271752193570137,
0.05426425859332085,
0.07137899845838547,
0.013697872869670391,
0.02648323029279709,
0.03412808105349541,
0.01575610227882862,
0.027821585536003113,
-0.008090971037745476,
0.02536793239414692,
0.013393701054155827,
0.032424721866846085,
0.06562001258134842,
-0.07219012081623077,
-0.00576405692845583,
0.03613561764359474,
-0.04146876186132431,
-0.032079990953207016,
0.02611822448670864,
-0.014610388316214085,
0.03132970258593559,
-0.004760289564728737,
0.0003656399203464389,
0.019132409244775772,
0.07255512475967407,
0.023076504468917847,
-0.025469323620200157,
-0.02759852632880211,
-0.013941210694611073,
-0.030356351286172867,
-0.04033318907022476,
0.0014777682954445481,
-0.011254359036684036,
0.02500292658805847,
0.011294915340840816,
0.03607478365302086,
-0.03862982615828514,
-0.033965855836868286,
-0.015827076509594917,
0.0020366841927170753,
-0.02544904500246048,
0.00721394270658493,
0.04303018003702164,
0.008207570761442184,
-0.0004362965119071305,
-0.0011659921146929264,
0.06882395595312119,
-0.00028991379076614976,
-0.0025753218214958906,
-0.013718150556087494,
0.029099108651280403,
0.03057941049337387,
0.018503788858652115,
0.04566633701324463,
0.018240172415971756,
0.01224798709154129,
0.06562001258134842,
-0.03299250826239586,
0.03193804621696472,
0.02210315503180027,
0.02544904500246048,
-0.0014726987574249506,
-0.05012752115726471,
0.024901535362005234,
-0.03810259327292442,
0.008562438189983368,
0.04558522254228592,
-0.006093576084822416,
-0.033114176243543625,
-0.06375442445278168,
-0.06695836782455444,
-0.00563224870711565,
0.06484944373369217,
-0.07652963697910309,
-0.03193804621696472,
0.0037362442817538977,
-0.010443233884871006,
0.03323584422469139,
-0.008106180466711521,
-0.027699917554855347,
-0.025408489629626274,
-0.04882972314953804,
-0.026158779859542847,
-0.02202204242348671,
-0.006276079453527927,
0.026584619656205177,
0.0534936897456646,
-0.005003626924008131,
-0.012450767681002617,
0.012460906989872456,
0.0076600611209869385,
0.00945974513888359,
0.031410813331604004,
0.05191199854016304,
-0.002737546805292368,
-0.004288823343813419,
-0.018159059807658195,
0.006230453494936228,
0.048261936753988266,
-0.0009879248682409525,
0.046315234154462814,
0.0036906185559928417,
-0.02749713696539402,
-0.022488439455628395,
-0.02449597418308258,
0.031735263764858246,
-0.026158779859542847,
-0.02731463313102722,
0.005490302108228207,
0.026787402108311653,
-0.02605738863348961,
-0.020227428525686264,
0.010037671774625778,
0.01675986871123314,
-0.011791729368269444,
-0.012754940427839756,
-0.009611831046640873,
0.004124063532799482,
0.010240452364087105,
0.021657036617398262,
-0.029788564890623093,
0.007584018167108297,
0.03159331530332565,
-0.040434580296278,
0.06282162666320801,
-0.03278972581028938,
-0.017074180766940117,
0.05081697925925255,
0.019750893115997314,
0.005931351333856583,
0.012734661810100079,
0.0023129736073315144,
0.02946411445736885,
0.01670917496085167,
0.03066052310168743,
-0.02218426764011383,
0.023765960708260536,
0.03940039500594139,
0.01737835258245468,
0.027213241904973984,
0.015695268288254738,
-0.06541723012924194,
-0.0500464104115963,
-0.01272452250123024,
-0.01949741691350937,
0.03822426497936249,
0.01631375029683113,
0.03025496006011963,
-0.011690338142216206,
-0.025732940062880516,
-0.0029073760379105806,
0.020927023142576218,
-0.049640849232673645,
0.04550411179661751,
-0.026077667251229286,
-0.03609506040811539,
0.0018174268770962954,
-0.04538244009017944,
0.050249192863702774,
-0.12588658928871155,
0.01575610227882862,
0.011203663423657417,
0.07563740015029907,
0.046639684587717056,
-0.023705126717686653,
-0.06265940517187119,
-0.022204546257853508,
0.031998880207538605,
0.008790566585958004,
-0.04582855850458145,
0.03583144396543503,
0.017500020563602448,
0.03412808105349541,
0.06306496262550354,
0.02329956367611885,
-0.04114431515336037,
-0.09652387350797653,
0.025996554642915726,
-0.07150066643953323,
-0.05637318640947342,
0.005333146546036005,
-0.03840676695108414,
-0.005097413435578346,
0.03828509896993637,
0.0033129386138170958
] |
725,847 | autofaiss.external.quantize | build_partitioned_indexes |
Create partitioned indexes from a partitioned parquet dataset,
i.e. create one index per parquet partition
Only supported with PySpark. A PySpark session must be active before calling this function
Parameters
----------
partitions : str
List of partitions containing embeddings
output_root_dir: str
Output root directory where indexes, metrics and ids will be written
embedding_column_name: str
Parquet dataset column name containing embeddings
index_key: Optional(str)
Optional string to give to the index factory in order to create the index.
If None, an index is chosen based on an heuristic.
index_path: Optional(str)
Optional path to an index that will be used to add embeddings.
This index must be pre-trained if it needs a training
id_columns: Optional(List[str])
Parquet dataset column name(s) that are used as IDs for embeddings.
A mapping from these IDs to faiss indices will be written in separate files.
max_index_query_time_ms: float
Bound on the query time for KNN search, this bound is approximative
max_index_memory_usage: str
Maximum size allowed for the index, this bound is strict
min_nearest_neighbors_to_retrieve: int
Minimum number of nearest neighbors to retrieve when querying the index.
Parameter used only during index hyperparameter finetuning step, it is
not taken into account to select the indexing algorithm.
This parameter has the priority over the max_index_query_time_ms constraint.
current_memory_available: str
Memory available on the machine creating the index, having more memory is a boost
because it reduces the swipe between RAM and disk.
use_gpu: bool
Experimental, gpu training is faster, not tested so far
metric_type: str
Similarity function used for query:
- "ip" for inner product
- "l2" for euclidean distance
nb_cores: Optional[int]
Number of cores to use. Will try to guess the right number if not provided
make_direct_map: bool
Create a direct map allowing reconstruction of embeddings. This is only needed for IVF indices.
Note that might increase the RAM usage (approximately 8GB for 1 billion embeddings)
should_be_memory_mappable: bool
If set to true, the created index will be selected only among the indices that can be memory-mapped on disk.
This makes it possible to use 50GB indices on a machine with only 1GB of RAM. Default to False
temp_root_dir: str
Temporary directory that will be used to store intermediate results/computation
verbose: int
set verbosity of outputs via logging level, default is `logging.INFO`
nb_splits_per_big_index: int
Number of indices to split a big index into.
This allows you building indices bigger than `current_memory_available`.
big_index_threshold: int
Threshold used to define big indexes.
Indexes with more `than big_index_threshold` embeddings are considered big indexes.
maximum_nb_threads: int
Maximum number of threads to parallelize index creation
| def build_partitioned_indexes(
partitions: List[str],
output_root_dir: str,
embedding_column_name: str = "embedding",
index_key: Optional[str] = None,
index_path: Optional[str] = None,
id_columns: Optional[List[str]] = None,
max_index_query_time_ms: float = 10.0,
max_index_memory_usage: str = "16G",
min_nearest_neighbors_to_retrieve: int = 20,
current_memory_available: str = "32G",
use_gpu: bool = False,
metric_type: str = "ip",
nb_cores: Optional[int] = None,
make_direct_map: bool = False,
should_be_memory_mappable: bool = False,
temp_root_dir: str = "hdfs://root/tmp/distributed_autofaiss_indices",
verbose: int = logging.INFO,
nb_splits_per_big_index: int = 1,
big_index_threshold: int = 5_000_000,
maximum_nb_threads: int = 256,
) -> List[Optional[Dict[str, str]]]:
"""
Create partitioned indexes from a partitioned parquet dataset,
i.e. create one index per parquet partition
Only supported with PySpark. A PySpark session must be active before calling this function
Parameters
----------
partitions : str
List of partitions containing embeddings
output_root_dir: str
Output root directory where indexes, metrics and ids will be written
embedding_column_name: str
Parquet dataset column name containing embeddings
index_key: Optional(str)
Optional string to give to the index factory in order to create the index.
If None, an index is chosen based on an heuristic.
index_path: Optional(str)
Optional path to an index that will be used to add embeddings.
This index must be pre-trained if it needs a training
id_columns: Optional(List[str])
Parquet dataset column name(s) that are used as IDs for embeddings.
A mapping from these IDs to faiss indices will be written in separate files.
max_index_query_time_ms: float
Bound on the query time for KNN search, this bound is approximative
max_index_memory_usage: str
Maximum size allowed for the index, this bound is strict
min_nearest_neighbors_to_retrieve: int
Minimum number of nearest neighbors to retrieve when querying the index.
Parameter used only during index hyperparameter finetuning step, it is
not taken into account to select the indexing algorithm.
This parameter has the priority over the max_index_query_time_ms constraint.
current_memory_available: str
Memory available on the machine creating the index, having more memory is a boost
because it reduces the swipe between RAM and disk.
use_gpu: bool
Experimental, gpu training is faster, not tested so far
metric_type: str
Similarity function used for query:
- "ip" for inner product
- "l2" for euclidean distance
nb_cores: Optional[int]
Number of cores to use. Will try to guess the right number if not provided
make_direct_map: bool
Create a direct map allowing reconstruction of embeddings. This is only needed for IVF indices.
Note that might increase the RAM usage (approximately 8GB for 1 billion embeddings)
should_be_memory_mappable: bool
If set to true, the created index will be selected only among the indices that can be memory-mapped on disk.
This makes it possible to use 50GB indices on a machine with only 1GB of RAM. Default to False
temp_root_dir: str
Temporary directory that will be used to store intermediate results/computation
verbose: int
set verbosity of outputs via logging level, default is `logging.INFO`
nb_splits_per_big_index: int
Number of indices to split a big index into.
This allows you building indices bigger than `current_memory_available`.
big_index_threshold: int
Threshold used to define big indexes.
Indexes with more `than big_index_threshold` embeddings are considered big indexes.
maximum_nb_threads: int
Maximum number of threads to parallelize index creation
"""
setup_logging(verbose)
# Sanity checks
if not partitions:
raise ValueError("partitions can't be empty")
check_not_null_not_empty("output_root_dir", output_root_dir)
check_not_null_not_empty("embedding_column_name", embedding_column_name)
if nb_splits_per_big_index < 1:
raise ValueError(f"nb_indices_to_keep must be > 0; Got {nb_splits_per_big_index}")
if big_index_threshold < 1:
raise ValueError(f"big_index_threshold must be > 0; Got {big_index_threshold}")
if index_path is not None and not index_key:
raise ValueError(
"Please provide the index key of the input index; "
f"Got index_key: {index_key} and index_path: {index_path}"
)
if index_key:
n_dimensions = EmbeddingReader(
partitions[0], file_format="parquet", embedding_column=embedding_column_name
).dimension
# Create an empty index to validate the index key
create_empty_index(n_dimensions, index_key=index_key, metric_type=metric_type)
# Create partitioned indexes
return create_partitioned_indexes(
partitions=partitions,
output_root_dir=output_root_dir,
embedding_column_name=embedding_column_name,
index_key=index_key,
index_path=index_path,
id_columns=id_columns,
should_be_memory_mappable=should_be_memory_mappable,
max_index_query_time_ms=max_index_query_time_ms,
max_index_memory_usage=max_index_memory_usage,
min_nearest_neighbors_to_retrieve=min_nearest_neighbors_to_retrieve,
current_memory_available=current_memory_available,
use_gpu=use_gpu,
metric_type=metric_type,
nb_cores=nb_cores,
make_direct_map=make_direct_map,
temp_root_dir=temp_root_dir,
nb_splits_per_big_index=nb_splits_per_big_index,
big_index_threshold=big_index_threshold,
maximum_nb_threads=maximum_nb_threads,
)
| (partitions: List[str], output_root_dir: str, embedding_column_name: str = 'embedding', index_key: Optional[str] = None, index_path: Optional[str] = None, id_columns: Optional[List[str]] = None, max_index_query_time_ms: float = 10.0, max_index_memory_usage: str = '16G', min_nearest_neighbors_to_retrieve: int = 20, current_memory_available: str = '32G', use_gpu: bool = False, metric_type: str = 'ip', nb_cores: Optional[int] = None, make_direct_map: bool = False, should_be_memory_mappable: bool = False, temp_root_dir: str = 'hdfs://root/tmp/distributed_autofaiss_indices', verbose: int = 20, nb_splits_per_big_index: int = 1, big_index_threshold: int = 5000000, maximum_nb_threads: int = 256) -> List[Optional[Dict[str, str]]] | [
0.03242471069097519,
-0.0335395447909832,
-0.07138726860284805,
0.017204370349645615,
0.011611295863986015,
0.018734905868768692,
-0.041154440492391586,
0.0016238336684182286,
-0.06507616490125656,
-0.05797145143151283,
-0.0018954566912725568,
0.016117878258228302,
-0.036846261471509933,
-0.009976834058761597,
0.04584052786231041,
0.02658599428832531,
0.02275020442903042,
0.021805427968502045,
0.04561378061771393,
0.023789457976818085,
-0.047767870128154755,
-0.06753258407115936,
-0.0013923635706305504,
0.005956812296062708,
0.02159757725894451,
-0.01578720659017563,
-0.005593073554337025,
-0.019093921408057213,
0.015418742783367634,
-0.039567217230796814,
0.020180413499474525,
0.0023052531760185957,
0.015380952507257462,
0.028607815504074097,
-0.005049827508628368,
-0.01850816048681736,
0.02469644322991371,
0.01724216155707836,
0.04330853000283241,
0.03200900927186012,
0.05430572107434273,
-0.0696110874414444,
-0.03983175382018089,
-0.07550649344921112,
0.0073267375119030476,
0.04916613921523094,
0.015976160764694214,
-0.013727594166994095,
0.030969755724072456,
0.02683163620531559,
-0.02384614385664463,
-0.056308645755052567,
-0.009660334326326847,
0.018423130735754967,
-0.03455990180373192,
0.03153662011027336,
-0.02906130813062191,
-0.031139815226197243,
0.016042295843362808,
-0.04425330460071564,
-0.022013278678059578,
-0.01056259498000145,
0.02360050193965435,
0.07852977514266968,
-0.04871264845132828,
0.010175236500799656,
-0.03146103769540787,
-0.02545226365327835,
-0.05989879369735718,
-0.011082221753895283,
0.021937696263194084,
-0.05846273526549339,
0.037091903388500214,
-0.013670907355844975,
-0.07036691159009933,
0.026642682030797005,
0.012830057181417942,
-0.02087954804301262,
0.002683163620531559,
0.007133058272302151,
-0.012480489909648895,
-0.009230460971593857,
-0.04546261951327324,
-0.04085211083292961,
0.07807628065347672,
0.03467327728867531,
0.06518954038619995,
0.0422503799200058,
-0.006764595862478018,
-0.07486404478549957,
0.024072891101241112,
0.04882602021098137,
0.03986954316496849,
0.008493535220623016,
0.018064115196466446,
-0.0632999837398529,
0.00406489847227931,
-0.04878822714090347,
-0.011299519799649715,
-0.02634035237133503,
-0.024053994566202164,
-0.008668319322168827,
0.046747513115406036,
0.013396922498941422,
0.014540101401507854,
-0.05404118448495865,
-0.054834794253110886,
-0.03952942416071892,
-0.03265145421028137,
-0.06398022919893265,
-0.0571022555232048,
-0.0015187272801995277,
0.03295378386974335,
0.008918684907257557,
0.0038145328871905804,
0.011951415799558163,
0.0020147347822785378,
0.046634141355752945,
-0.004908110946416855,
0.0028484994545578957,
0.07403264194726944,
-0.007855812087655067,
-0.04194805026054382,
-0.03565584495663643,
0.00987290870398283,
0.008861998096108437,
0.012319877743721008,
0.040927693247795105,
0.015069176442921162,
0.027360711246728897,
-0.01665639877319336,
0.0034933090209960938,
0.00005993422382744029,
0.04357306659221649,
0.012442698702216148,
-0.015739966183900833,
0.017355533316731453,
0.004851424600929022,
-0.07592219114303589,
0.0093202143907547,
0.02099292166531086,
-0.04735216870903969,
0.03811226040124893,
-0.014644026756286621,
0.02259903959929943,
0.0024989324156194925,
0.011677430011332035,
-0.0658697783946991,
0.023203697055578232,
-0.022939158603549004,
0.02507435344159603,
-0.027757516130805016,
-0.06602094322443008,
-0.0360337533056736,
-0.04493354260921478,
-0.046029482036828995,
0.03301047161221504,
0.018810488283634186,
0.0285511277616024,
0.031479932367801666,
-0.0004053679294884205,
-0.06356452405452728,
0.02694500982761383,
0.013132384978234768,
-0.057555750012397766,
0.045764945447444916,
0.028399964794516563,
-0.02208886109292507,
-0.020085936412215233,
-0.0192734282463789,
0.017072100192308426,
0.012716683559119701,
-0.07282333076000214,
-0.0033090775832533836,
-0.06284649670124054,
0.06783491373062134,
-0.007704647723585367,
0.00189309474080801,
-0.00912653561681509,
0.01050590816885233,
-0.037677664309740067,
-0.024772025644779205,
-0.05162255838513374,
-0.016108429059386253,
-0.019424593076109886,
0.05800924077630043,
-0.01751614548265934,
0.02507435344159603,
0.09092523902654648,
-0.01564548909664154,
-0.020199310034513474,
-0.06345114856958389,
-0.015380952507257462,
0.06813724339008331,
-0.03389855846762657,
0.0041475663892924786,
-0.006353618111461401,
-0.01838533952832222,
-0.013179624453186989,
0.05698888376355171,
-0.004974245093762875,
0.03934046998620033,
0.0459161102771759,
-0.02188101038336754,
-0.011252281256020069,
-0.005262401886284351,
-0.06666339188814163,
-0.02671826258301735,
0.020029250532388687,
0.007170849479734898,
-0.04916613921523094,
-0.06507616490125656,
0.029004620388150215,
0.07373031228780746,
0.033822979778051376,
-0.0012435612734407187,
-0.0633755698800087,
0.031026441603899002,
0.04417772218585014,
0.0034791373182088137,
0.028645606711506844,
0.014388937503099442,
0.05419234558939934,
-0.010987743735313416,
0.028022054582834244,
-0.04557599127292633,
0.05517491325736046,
0.002344225300475955,
-0.013652011752128601,
-0.03610933572053909,
0.0023347774986177683,
-0.008110901340842247,
0.014426728710532188,
0.0007422395865432918,
-0.004936454351991415,
0.029854919761419296,
-0.029155785217881203,
0.008795863948762417,
0.04160793125629425,
0.013907101936638355,
-0.007784953806549311,
-0.02507435344159603,
-0.00968395359814167,
-0.04330853000283241,
-0.017997981980443,
0.03287820145487785,
0.017733443528413773,
0.0608813613653183,
0.006419752258807421,
-0.024375218898057938,
-0.045160289853811264,
0.012593863531947136,
-0.029892710968852043,
0.003531099995598197,
0.06787270307540894,
0.0012884382158517838,
-0.03282151743769646,
-0.03191453218460083,
0.012924534268677235,
0.007397595327347517,
-0.05400339141488075,
-0.013491400517523289,
-0.009584751911461353,
0.0009388710604980588,
0.021578682586550713,
-0.005205715540796518,
0.03922709822654724,
0.04111664742231369,
0.008422677405178547,
0.007284222636371851,
0.00022763195738662034,
0.10974517464637756,
-0.05638422816991806,
0.008772244676947594,
-0.017327191308140755,
-0.014757400378584862,
0.0031012268736958504,
-0.010156340897083282,
-0.03864133730530739,
0.043648649007081985,
-0.009740639477968216,
0.02892903983592987,
-0.04051199182868004,
-0.03429536521434784,
0.029042411595582962,
0.029873814433813095,
-0.0944775938987732,
-0.04550040885806084,
-0.0007298393757082522,
-0.01205534115433693,
-0.04659634828567505,
-0.008521879091858864,
0.005550558678805828,
-0.014540101401507854,
0.0054466333240270615,
0.029363635927438736,
0.007865259423851967,
-0.06133485212922096,
-0.04856148362159729,
-0.041041065007448196,
-0.0008284503710456192,
0.03680846840143204,
0.0384901724755764,
0.016098981723189354,
0.011101117357611656,
0.006230797152966261,
0.019689129665493965,
-0.006193006411194801,
0.06345114856958389,
-0.011356206610798836,
-0.023562710732221603,
-0.022655727341771126,
0.02382724918425083,
0.05910518020391464,
0.015437638387084007,
-0.07263437658548355,
0.037677664309740067,
-0.02386504039168358,
0.02199438400566578,
0.0583871528506279,
-0.04482017084956169,
0.06345114856958389,
-0.010949953459203243,
-0.033615127205848694,
-0.046520765870809555,
-0.029590381309390068,
0.06254416704177856,
-0.006821282207965851,
0.0009719382505863905,
-0.08336702734231949,
-0.013132384978234768,
-0.06866631656885147,
0.02781420387327671,
-0.001811607857234776,
-0.06163718178868294,
-0.018347548320889473,
0.023921726271510124,
-0.026415934786200523,
0.01974581740796566,
0.002900462131947279,
0.0943264290690422,
0.007629065774381161,
0.0021800703834742308,
0.03705411031842232,
-0.03884918615221977,
-0.04610506445169449,
0.036317188292741776,
-0.02647262066602707,
-0.045538198202848434,
0.03803667798638344,
0.061410434544086456,
-0.00795028917491436,
-0.012017549946904182,
0.0783030316233635,
0.06681455671787262,
-0.024772025644779205,
-0.005328536033630371,
-0.02271241322159767,
-0.0509423166513443,
0.030138352885842323,
-0.02324148826301098,
-0.06564303487539291,
-0.008918684907257557,
0.0018883708398789167,
-0.03129097819328308,
-0.03960500657558441,
0.0040294695645570755,
-0.020331578329205513,
0.06719246506690979,
-0.048485901206731796,
0.013944893144071102,
-0.09168105572462082,
0.006254416424781084,
0.03627939522266388,
0.06398022919893265,
-0.037073008716106415,
-0.09546016156673431,
0.03393635153770447,
-0.06802386790513992,
0.02001035399734974,
-0.00994849018752575,
-0.017289400100708008,
0.048372525721788406,
0.010694863274693489,
-0.02248566783964634,
0.012423803098499775,
0.06749479472637177,
-0.025414472445845604,
0.03191453218460083,
0.0093202143907547,
-0.007685752119868994,
0.05166034772992134,
0.047276586294174194,
-0.0040247454307973385,
0.05974762886762619,
0.03801778331398964,
0.005560006480664015,
-0.005970983766019344,
0.019708026200532913,
-0.061523810029029846,
-0.020331578329205513,
-0.03686515614390373,
-0.019556861370801926,
0.07066924124956131,
0.016930384561419487,
-0.03340727835893631,
0.0707448199391365,
-0.0006831911159679294,
0.02286357805132866,
-0.006514229811728001,
-0.03316163644194603,
-0.02123856358230114,
-0.0009624904487282038,
0.09394852072000504,
-0.04893939197063446,
0.019103368744254112,
0.022032175213098526,
0.005696998909115791,
0.030988650396466255,
0.006873244885355234,
0.014209429733455181,
-0.011649087071418762,
0.06662559509277344,
-0.016439100727438927,
-0.03952942416071892,
-0.026850532740354538,
-0.0323113352060318,
-0.007123610470443964,
-0.041910260915756226,
0.018158594146370888,
-0.03737533465027809,
-0.03915151581168175,
-0.021937696263194084,
0.00913598295301199,
-0.01889551803469658,
0.014672369696199894,
-0.012272639200091362,
0.04024745523929596,
0.0021765276324003935,
0.02360050193965435,
0.08586123585700989,
-0.03518345579504967,
0.03250029310584068,
0.02943921834230423,
0.07966350764036179,
0.05653539299964905,
-0.056081898510456085,
0.05740458518266678,
0.0198969803750515,
-0.0007865259540267289,
0.06292207539081573,
-0.008592736907303333,
0.011960863135755062,
-0.003653920954093337,
0.007874707691371441,
-0.0024103596806526184,
0.017478354275226593,
0.006268588360399008,
-0.0360526479780674,
0.016920937225222588,
0.035958170890808105,
0.045009125024080276,
-0.031479932367801666,
0.0015801377594470978,
0.05872727185487747,
-0.005191543605178595,
-0.057064466178417206,
-0.03091306798160076,
-0.005319088697433472,
-0.012773370370268822,
0.016429653391242027,
0.039453841745853424,
-0.03340727835893631,
-0.04542482644319534,
0.03153662011027336,
-0.0002155270049115643,
-0.057555750012397766,
-0.0028319659177213907,
0.044517841190099716,
-0.03790441155433655,
0.05751795694231987,
-0.046898677945137024,
0.026019129902124405,
0.007185020949691534,
-0.000337462144671008,
-0.03639276698231697,
0.038924768567085266,
0.024299636483192444,
-0.0192450862377882,
-0.017997981980443,
-0.00431526405736804,
-0.00031531896092928946,
0.07679139077663422,
0.020312681794166565,
0.06220404803752899,
0.018725458532571793,
-0.010335848666727543,
0.03750760480761528,
0.06197730079293251,
-0.04308178275823593,
0.04194805026054382,
-0.005092342384159565,
0.011346759274601936,
-0.02224002592265606,
0.0030776076018810272,
0.0031531895510852337,
0.009367452934384346,
-0.016070637851953506,
-0.010146893560886383,
-0.05181151255965233,
-0.051962677389383316,
-0.013670907355844975,
0.02422405406832695,
-0.014927459880709648,
0.044631216675043106,
0.0968962162733078,
0.018564846366643906,
0.02756856195628643,
0.013803176581859589,
0.011696325615048409,
-0.02683163620531559,
0.039075933396816254,
-0.009145431220531464,
-0.03699742630124092,
-0.018054667860269547,
0.026623785495758057,
-0.009702849201858044,
-0.026793844997882843,
0.02061501145362854,
0.04368643835186958,
-0.08434959501028061,
0.01577775739133358,
0.014558997005224228,
0.011762460693717003,
0.0008491173502989113,
-0.02161647379398346,
0.005493871867656708,
0.0055033196695148945,
0.11858827620744705,
-0.03937825933098793,
-0.03514566272497177,
0.03737533465027809,
0.005919021088629961,
-0.10747770965099335,
0.005385222844779491,
0.03805557265877724,
0.033860769122838974,
0.04270387068390846,
0.03081859089434147,
-0.011970311403274536,
0.04769228771328926,
0.028003158047795296,
0.06998900324106216,
-0.037224169820547104,
0.032368022948503494,
-0.026926113292574883,
0.010543699376285076,
-0.03491891920566559,
-0.024923188611865044,
0.023052532225847244,
0.020841756835579872,
0.00825261790305376,
0.060314495116472244,
-0.05264291539788246,
0.03488112613558769,
0.012112027034163475,
-0.04618064686655998,
-0.029363635927438736,
0.0037365888711065054,
-0.01951907016336918,
-0.027644144371151924,
-0.027492979541420937,
-0.0020785070955753326,
-0.04357306659221649,
-0.030591843649744987,
-0.03140435367822647,
-0.019915876910090446,
-0.017988532781600952,
-0.019556861370801926,
-0.07357914745807648,
0.00794084183871746,
0.008172311820089817,
0.03486223146319389,
0.019972562789916992,
0.038924768567085266,
0.0596342571079731,
0.03032730706036091,
0.033596232533454895,
0.036695096641778946,
-0.00906512513756752,
0.013463056646287441,
0.031990114599466324,
0.04746554419398308,
0.025433367118239403,
0.0447067953646183,
0.031347665935754776,
-0.0620906725525856,
-0.028116531670093536,
0.02771972492337227,
-0.0757710263133049,
-0.03032730706036091,
0.04236375167965889,
-0.014020474627614021,
0.03754539415240288,
0.005394670646637678,
-0.019320668652653694,
0.03442763537168503,
0.04497133567929268,
0.02435632422566414,
-0.023165905848145485,
-0.02694500982761383,
-0.006811834406107664,
-0.03342617303133011,
-0.06934655457735062,
0.00863997545093298,
-0.003927906043827534,
-0.0026784397196024656,
-0.006363065913319588,
0.040058501064777374,
-0.0596342571079731,
-0.040927693247795105,
0.013585877604782581,
0.005928468890488148,
-0.012433251366019249,
-0.01790350303053856,
0.04311957210302353,
0.023808352649211884,
-0.01049646083265543,
0.000038012469303794205,
0.06390464305877686,
-0.0038239804562181234,
0.013944893144071102,
-0.02384614385664463,
0.014341698959469795,
0.042930617928504944,
-0.008970647118985653,
0.035844799131155014,
-0.0040861559100449085,
0.012574967928230762,
0.023751666769385338,
-0.03276482969522476,
0.035447992384433746,
0.043648649007081985,
0.006230797152966261,
-0.0001451854914193973,
-0.06254416704177856,
0.03367181494832039,
-0.014114952646195889,
0.00040713936323300004,
0.03331279754638672,
-0.0033350589219480753,
-0.005356879439204931,
-0.062052883207798004,
-0.046785302460193634,
-0.00844629667699337,
0.09379735589027405,
-0.06488721072673798,
-0.03813115507364273,
-0.017298847436904907,
0.0049128346145153046,
0.060049958527088165,
-0.01764841377735138,
-0.053587689995765686,
-0.010260266251862049,
-0.048523690551519394,
-0.024998771026730537,
-0.012442698702216148,
-0.010515356436371803,
0.022504562512040138,
0.019282877445220947,
0.00781802088022232,
-0.028758978471159935,
-0.005763133056461811,
-0.012697788886725903,
0.009339109994471073,
0.005191543605178595,
0.02099292166531086,
-0.01914115995168686,
-0.028418859466910362,
-0.016741428524255753,
0.01951907016336918,
0.030459575355052948,
-0.0025367233902215958,
0.058311570435762405,
0.003731864970177412,
-0.021200772374868393,
-0.013548086397349834,
-0.05007312446832657,
0.032594770193099976,
-0.029231367632746696,
-0.008540774695575237,
0.01056259498000145,
-0.00416409969329834,
-0.012811161577701569,
-0.026283666491508484,
-0.0002822517999447882,
0.02547115832567215,
-0.00919266976416111,
-0.0072039165534079075,
-0.010770445689558983,
-0.004697898402810097,
-0.00043784460285678506,
0.007865259423851967,
-0.014285012148320675,
0.005952088162302971,
0.04909055680036545,
-0.03539130464196205,
0.04618064686655998,
-0.04308178275823593,
-0.03008166514337063,
0.04062536358833313,
0.00021936515986453742,
0.00397514458745718,
-0.012149818241596222,
0.008238445967435837,
-0.010033519938588142,
0.025301098823547363,
0.052113838493824005,
0.012442698702216148,
0.0029217195697128773,
0.044404469430446625,
0.009778430685400963,
0.019160056486725807,
0.007288946304470301,
-0.06911980360746384,
-0.04704984277486801,
-0.004785289987921715,
-0.025735696777701378,
0.0285511277616024,
0.035466887056827545,
0.038320112973451614,
-0.0009187945979647338,
-0.021030712872743607,
0.008805311284959316,
0.05014870688319206,
-0.013311892747879028,
0.05162255838513374,
-0.008961199782788754,
-0.04497133567929268,
-0.010279161855578423,
-0.0038239804562181234,
0.039453841745853424,
-0.12266970425844193,
-0.010732654482126236,
-0.0006755148060619831,
0.07633789628744125,
0.04909055680036545,
-0.018602637574076653,
-0.0422503799200058,
0.009339109994471073,
-0.002344225300475955,
-0.0028036225121468306,
-0.05763133242726326,
0.044139932841062546,
-0.0012270277366042137,
0.037828829139471054,
0.057555750012397766,
0.0310453362762928,
-0.04686088487505913,
-0.07369252294301987,
0.009580028243362904,
-0.0571400485932827,
-0.0595964640378952,
-0.012782818637788296,
-0.013529191724956036,
-0.012508832849562168,
0.044026557356119156,
0.005404118448495865
] |
725,851 | autofaiss.external.quantize | score_index |
Compute metrics on a given index, use cached ground truth for fast scoring the next times.
Parameters
----------
index_path : Union[str, faiss.Index]
Path to .index file. Or in memory index
embeddings: Union[str, np.ndarray]
Path containing all preprocessed vectors and cached files. Can also be an in memory array.
save_on_disk: bool
Whether to save on disk
output_index_info_path : str
Path to index infos .json
current_memory_available: str
Memory available on the current machine, having more memory is a boost
because it reduces the swipe between RAM and disk.
verbose: int
set verbosity of outputs via logging level, default is `logging.INFO`
Returns
-------
metric_infos: Optional[Dict[str, Union[str, float, int]]]
Metric infos of the index.
| def score_index(
index_path: Union[str, faiss.Index],
embeddings: Union[str, np.ndarray],
save_on_disk: bool = True,
output_index_info_path: str = "infos.json",
current_memory_available: str = "32G",
verbose: int = logging.INFO,
) -> Optional[Dict[str, Union[str, float, int]]]:
"""
Compute metrics on a given index, use cached ground truth for fast scoring the next times.
Parameters
----------
index_path : Union[str, faiss.Index]
Path to .index file. Or in memory index
embeddings: Union[str, np.ndarray]
Path containing all preprocessed vectors and cached files. Can also be an in memory array.
save_on_disk: bool
Whether to save on disk
output_index_info_path : str
Path to index infos .json
current_memory_available: str
Memory available on the current machine, having more memory is a boost
because it reduces the swipe between RAM and disk.
verbose: int
set verbosity of outputs via logging level, default is `logging.INFO`
Returns
-------
metric_infos: Optional[Dict[str, Union[str, float, int]]]
Metric infos of the index.
"""
setup_logging(verbose)
faiss.omp_set_num_threads(multiprocessing.cpu_count())
if isinstance(index_path, str):
index_path = make_path_absolute(index_path)
with fsspec.open(index_path, "rb").open() as f:
index = faiss.read_index(faiss.PyCallbackIOReader(f.read))
fs, path_in_fs = fsspec.core.url_to_fs(index_path, use_listings_cache=False)
index_memory = fs.size(path_in_fs)
else:
index = index_path
with tempfile.NamedTemporaryFile("wb") as f:
faiss.write_index(index, faiss.PyCallbackIOWriter(f.write))
fs, path_in_fs = fsspec.core.url_to_fs(f.name, use_listings_cache=False)
index_memory = fs.size(path_in_fs)
if isinstance(embeddings, np.ndarray):
tmp_dir_embeddings = tempfile.TemporaryDirectory() # pylint: disable=consider-using-with
np.save(os.path.join(tmp_dir_embeddings.name, "emb.npy"), embeddings)
embeddings_path = tmp_dir_embeddings.name
else:
embeddings_path = embeddings
embedding_reader = EmbeddingReader(embeddings_path, file_format="npy")
infos: Dict[str, Union[str, float, int]] = {}
with Timeit("Compute fast metrics"):
infos.update(compute_fast_metrics(embedding_reader, index))
logger.info("Intermediate recap:")
_log_output_dict(infos)
current_in_bytes = cast_memory_to_bytes(current_memory_available)
memory_left = current_in_bytes - index_memory
if memory_left < current_in_bytes * 0.1:
logger.info(
f"Not enough memory, at least {cast_bytes_to_memory_string(index_memory * 1.1)}"
"is needed, please increase current_memory_available"
)
return None
with Timeit("Compute medium metrics"):
infos.update(compute_medium_metrics(embedding_reader, index, memory_left))
logger.info("Performances recap:")
_log_output_dict(infos)
if save_on_disk:
with fsspec.open(output_index_info_path, "w").open() as f:
json.dump(infos, f)
return infos
| (index_path: Union[str, faiss.swigfaiss_avx512.Index], embeddings: Union[str, numpy.ndarray], save_on_disk: bool = True, output_index_info_path: str = 'infos.json', current_memory_available: str = '32G', verbose: int = 20) -> Optional[Dict[str, Union[str, float, int]]] | [
0.027075471356511116,
-0.025915665552020073,
-0.10502243041992188,
0.01789700612425804,
0.05735040828585625,
0.013917672447860241,
-0.058950141072273254,
0.0037568716797977686,
-0.013257781974971294,
-0.018546897917985916,
0.0053491052240133286,
0.02195632830262184,
-0.0040193279273808,
-0.006853853818029165,
0.06002995744347572,
0.047712020576000214,
0.07938671857118607,
0.012577896006405354,
0.00030526143382303417,
0.009063484147191048,
-0.01898682489991188,
-0.06362935900688171,
-0.02507580630481243,
0.014807523228228092,
0.012447917833924294,
-0.01935676299035549,
0.05679050087928772,
-0.03521411120891571,
0.03841357305645943,
-0.01788700744509697,
0.01893683336675167,
-0.02277619019150734,
-0.008908510208129883,
0.04479250684380531,
-0.01396766398102045,
-0.03353438898921013,
-0.019076809287071228,
-0.007663717959076166,
-0.049071792513132095,
0.012937836349010468,
0.061749670654535294,
-0.048911817371845245,
-0.012627887539565563,
-0.03235458955168724,
-0.017697039991617203,
0.04691215232014656,
-0.050111617892980576,
0.012827854603528976,
0.009468416683375835,
-0.05023159831762314,
-0.030914828181266785,
-0.09686379879713058,
0.005274117924273014,
0.07642721384763718,
-0.01156806480139494,
0.03469419851899147,
-0.007773699704557657,
0.012547900900244713,
0.03407429903745651,
-0.07350770384073257,
0.030074968934059143,
-0.04383266717195511,
0.06054987385869026,
0.037153784185647964,
0.003006997052580118,
-0.0013785194605588913,
-0.005639056675136089,
-0.022556226700544357,
0.001432260381989181,
-0.022036314010620117,
0.007963667623698711,
-0.05923009291291237,
0.06158969923853874,
-0.012787860818207264,
-0.03479418158531189,
0.019246781244874,
0.007133806589990854,
-0.01798699051141739,
0.02251623384654522,
0.021096471697092056,
0.009403427131474018,
-0.01830693706870079,
-0.047871991991996765,
-0.10942170023918152,
0.0007804944762028754,
-0.0237160325050354,
0.11334104090929031,
-0.014307606965303421,
-0.019836682826280594,
-0.0027145459316670895,
-0.011088144965469837,
0.009928339160978794,
0.04779200628399849,
0.010418257676064968,
0.01815696246922016,
-0.0523112490773201,
0.01746707782149315,
-0.06998829543590546,
0.010203293524682522,
-0.03125477209687233,
-0.03547406569123268,
0.02559571899473667,
0.03909346088767052,
0.017707038670778275,
-0.017307104542851448,
-0.007693713065236807,
0.00500666256994009,
-0.03937341272830963,
0.015347433276474476,
-0.025935661047697067,
-0.05767035484313965,
-0.04443256929516792,
-0.02423594705760479,
-0.056190602481365204,
0.00925845094025135,
-0.007888680323958397,
-0.03453422337770462,
0.03259454667568207,
-0.030974818393588066,
0.02751539833843708,
0.035754021257162094,
-0.013057815842330456,
-0.033314429223537445,
-0.03339441493153572,
0.0029395082965493202,
-0.0017884508706629276,
0.009388430044054985,
0.05439090356230736,
0.021356428042054176,
0.039593376219272614,
-0.053591035306453705,
-0.018036983907222748,
0.011118140071630478,
0.08422591537237167,
0.01758705824613571,
0.0028970155399292707,
0.04727209359407425,
-0.029155123978853226,
-0.06362935900688171,
0.021396420896053314,
0.02199632115662098,
-0.05543072894215584,
0.018956828862428665,
-0.05667052045464516,
0.05883016064763069,
-0.019596721976995468,
-0.006003995891660452,
-0.06766868382692337,
-0.005364102777093649,
0.003876851638779044,
0.06162969022989273,
-0.002934509189799428,
-0.05787032097578049,
-0.029155123978853226,
0.012167965061962605,
-0.06442922353744507,
0.02559571899473667,
0.022976156324148178,
0.006163969170302153,
0.006613893900066614,
-0.013017822988331318,
-0.007923674769699574,
0.03125477209687233,
-0.03163470700383186,
-0.028535226359963417,
0.07334773242473602,
-0.059310078620910645,
0.02443591319024563,
-0.022536231204867363,
0.02075652778148651,
-0.03889349475502968,
0.003166970331221819,
-0.06702879071235657,
0.007668717298656702,
-0.012697876431047916,
0.006543905474245548,
-0.03823360428214073,
-0.005059153772890568,
0.08654552698135376,
-0.00545908696949482,
-0.03301447629928589,
-0.06002995744347572,
-0.11342103034257889,
-0.02475585974752903,
-0.07134806364774704,
0.08518575131893158,
0.004174301866441965,
0.006158969830721617,
0.06002995744347572,
0.027695367112755775,
0.057590365409851074,
-0.0038068632129579782,
0.010228289291262627,
-0.009423423558473587,
0.012787860818207264,
-0.039813339710235596,
-0.020156629383563995,
-0.02105647884309292,
0.036593880504369736,
0.03385433554649353,
-0.015927335247397423,
0.028155291453003883,
0.029914995655417442,
-0.02969503216445446,
-0.02823527716100216,
0.010958166792988777,
-0.03603397309780121,
-0.01370770763605833,
-0.09734372049570084,
0.09494411945343018,
-0.055110782384872437,
-0.012307940982282162,
0.01659722439944744,
0.024215949699282646,
0.03597398102283478,
0.004799197427928448,
0.007713709957897663,
0.059310078620910645,
0.022176289930939674,
-0.003434425452724099,
0.06262952089309692,
0.001232293900102377,
-0.04057321324944496,
0.03395432233810425,
0.01143808662891388,
-0.02001665160059929,
0.03465420380234718,
0.047832001000642776,
-0.001570987282320857,
-0.04935174435377121,
-0.0008729789988137782,
0.018946830183267593,
0.03857354819774628,
-0.011428088881075382,
0.0016009821556508541,
0.003934341948479414,
-0.01479752454906702,
0.05371101573109627,
0.020366594195365906,
0.009533405303955078,
0.017917003482580185,
-0.015427419915795326,
-0.041473064571619034,
-0.020876508206129074,
-0.04739207401871681,
-0.03859354555606842,
0.01606731303036213,
-0.012887843884527683,
-0.008418591693043709,
-0.027695367112755775,
0.023776022717356682,
0.015277444384992123,
-0.016777193173766136,
-0.0058090281672775745,
0.004241790622472763,
0.005359103437513113,
-0.10062316805124283,
-0.047832001000642776,
-0.004339274019002914,
-0.025875672698020935,
0.00972337368875742,
-0.010118307545781136,
0.008053652942180634,
0.0026795517187565565,
-0.03847356513142586,
0.007368767634034157,
0.03453422337770462,
0.029355090111494064,
-0.009263450279831886,
0.024415915831923485,
-0.015727369114756584,
0.040273264050483704,
-0.04575234651565552,
-0.03463420644402504,
-0.00996333360671997,
-0.018126968294382095,
0.037573713809251785,
0.019116802141070366,
-0.015377427451312542,
0.09262450784444809,
-0.015597390942275524,
-0.0034569217823445797,
-0.014217621646821499,
-0.07522741705179214,
0.040073297917842865,
0.021916333585977554,
-0.054470889270305634,
0.0061189765110611916,
0.02325611002743244,
0.0011466832365840673,
0.03465420380234718,
0.0003127601812593639,
-0.023276107385754585,
-0.020036648958921432,
0.0008723540813662112,
0.012437919154763222,
-0.04571235552430153,
-0.047192107886075974,
-0.00849857833236456,
-0.007823691703379154,
-0.036693863570690155,
-0.0013985161203891039,
0.02111646719276905,
-0.015307439491152763,
0.03301447629928589,
0.017797023057937622,
-0.014777528122067451,
0.0013560231309384108,
0.0190868079662323,
0.017557064071297646,
0.001997165847569704,
-0.03969335928559303,
0.012937836349010468,
0.059989966452121735,
0.006868850905448198,
-0.05091148242354393,
-0.0071887974627316,
0.020316602662205696,
0.03737374767661095,
0.023796020075678825,
-0.026435578241944313,
0.0646691843867302,
0.020616551861166954,
-0.028575221076607704,
0.0011904258280992508,
-0.08502577990293503,
0.053751010447740555,
-0.028435243293642998,
0.01461755484342575,
-0.04931175336241722,
-0.01866687834262848,
-0.04447256028652191,
0.025095801800489426,
-0.03257455304265022,
-0.04367269575595856,
0.024895835667848587,
-0.035134121775627136,
-0.00044086374691687524,
0.0422329343855381,
0.03207463398575783,
0.06534907221794128,
-0.006433923728764057,
-0.019986657425761223,
0.026615548878908157,
-0.04539240896701813,
-0.05191131681203842,
0.03805363550782204,
-0.027055473998188972,
-0.02459588646888733,
-0.06250954419374466,
-0.002063404768705368,
-0.00831860862672329,
-0.011977996677160263,
0.09678380936384201,
0.002924510743469,
0.0014972495846450329,
0.010478246957063675,
-0.13341768085956573,
-0.00439426489174366,
-0.04955171048641205,
-0.10790195316076279,
0.023576056584715843,
-0.06926841288805008,
-0.009168466553092003,
-0.0013410256942734122,
-0.029255107045173645,
0.02023661509156227,
-0.00592900812625885,
0.0381736159324646,
-0.021436413750052452,
-0.01060822606086731,
-0.010068316012620926,
-0.0015722370008006692,
0.035754021257162094,
0.05191131681203842,
-0.003704380476847291,
-0.03281451016664505,
0.032634541392326355,
-0.08326607197523117,
-0.006538906134665012,
-0.012987827882170677,
0.018706871196627617,
-0.058750174939632416,
0.021716367453336716,
0.037573713809251785,
0.019426750019192696,
0.04107312858104706,
0.0048916819505393505,
-0.01997665874660015,
-0.000902973988559097,
-0.023676039651036263,
0.004114311654120684,
-0.02205631136894226,
-0.022696204483509064,
0.036013975739479065,
0.0669088065624237,
0.037153784185647964,
0.06362935900688171,
-0.0040743183344602585,
-0.013827687129378319,
0.020936498418450356,
-0.027235444635152817,
-0.01487751118838787,
0.03577401489019394,
-0.03677384927868843,
0.016087308526039124,
0.050791505724191666,
0.016407255083322525,
0.004784199874848127,
0.07302778214216232,
-0.028935160487890244,
-0.00023746027727611363,
-0.0026545559521764517,
0.04867186024785042,
-0.07646720856428146,
0.031074801459908485,
-0.0031469736713916063,
0.01484751608222723,
0.005509078502655029,
0.014337602071464062,
0.03239458054304123,
0.015057481825351715,
0.07006827741861343,
0.018476909026503563,
0.004259287379682064,
-0.05887015163898468,
-0.02751539833843708,
-0.020776525139808655,
-0.03717378154397011,
0.02547573857009411,
-0.010828188620507717,
-0.09070482850074768,
-0.012367931194603443,
-0.004221793729811907,
-0.046152278780937195,
-0.005179133731871843,
-0.03155472129583359,
-0.013057815842330456,
0.019126800820231438,
0.02943507581949234,
0.04119310900568962,
0.007583731319755316,
0.06394930183887482,
0.04691215232014656,
0.02631559781730175,
0.05467085540294647,
-0.059310078620910645,
0.037733688950538635,
0.017197122797369957,
-0.03857354819774628,
-0.002404597820714116,
-0.04067319631576538,
-0.00681386049836874,
0.022336263209581375,
0.03905346617102623,
-0.03593399003148079,
-0.026875505223870277,
0.0010073315352201462,
0.030614878982305527,
0.011478080414235592,
0.013177796266973019,
0.029375087469816208,
-0.02053656429052353,
-0.05803029239177704,
0.012897842563688755,
0.006768867839127779,
-0.021416418254375458,
0.017397090792655945,
-0.006898846011608839,
-0.027895333245396614,
0.011868014931678772,
0.024375922977924347,
-0.02277619019150734,
-0.06598896533250809,
0.04227292910218239,
0.0025845677591860294,
-0.06166968494653702,
-0.032634541392326355,
0.010073315352201462,
0.00507165165618062,
0.05399096757173538,
-0.046792171895504,
-0.016407255083322525,
-0.011458083055913448,
0.03161471337080002,
-0.033934324979782104,
0.036333922296762466,
0.009223457425832748,
0.024015983566641808,
-0.06274950504302979,
-0.005299113690853119,
-0.013687710277736187,
0.0659489706158638,
-0.019626718014478683,
0.007053819950670004,
0.010718206875026226,
0.04655221477150917,
0.019336765632033348,
0.02949506603181362,
-0.0077936965972185135,
0.040273264050483704,
-0.02839525043964386,
-0.024895835667848587,
0.012157966382801533,
-0.02137642353773117,
0.03871352598071098,
-0.028015313670039177,
-0.04763203114271164,
0.0048466892912983894,
-0.029215114191174507,
-0.05735040828585625,
0.014107639901340008,
0.0399533174932003,
0.01699715666472912,
0.03543407469987869,
0.059470053762197495,
-0.029135126620531082,
-0.02563571184873581,
0.009748369455337524,
-0.002824527444317937,
-0.05643055960536003,
0.012557899579405785,
0.025875672698020935,
-0.03239458054304123,
0.0034144287928938866,
-0.004736707545816898,
0.015107473358511925,
-0.005884015932679176,
0.014677545055747032,
0.0027895334642380476,
-0.025935661047697067,
0.011768031865358353,
0.009173465892672539,
0.06706877797842026,
0.02741541527211666,
-0.0404532328248024,
0.10182296484708786,
-0.037053801119327545,
0.07294780015945435,
-0.02725544199347496,
0.011198126710951328,
-0.039913322776556015,
-0.013737701810896397,
-0.07590730488300323,
0.05223126336932182,
0.010718206875026226,
0.006283949129283428,
0.0025245777796953917,
0.06478916108608246,
-0.04519243910908699,
-0.037833672016859055,
0.0029295100830495358,
0.06446921825408936,
-0.021236447617411613,
0.03561404347419739,
0.033254437148571014,
0.050311584025621414,
-0.037673696875572205,
0.017927002161741257,
0.0225762240588665,
0.037733688950538635,
-0.018476909026503563,
0.03719377890229225,
-0.036073967814445496,
-0.01606731303036213,
0.0329744853079319,
-0.008198628202080727,
-0.01060822606086731,
-0.0016897174064069986,
-0.05051155015826225,
-0.0035119126550853252,
0.00393934128805995,
0.0172171201556921,
-0.07014826685190201,
-0.025095801800489426,
-0.012217956595122814,
-0.01107814721763134,
-0.04187299683690071,
0.05423092842102051,
-0.019896671175956726,
0.028575221076607704,
-0.004509245976805687,
0.047352079302072525,
0.031334757804870605,
0.058070287108421326,
0.06122975796461105,
-0.003501914208754897,
0.007103811949491501,
0.029155123978853226,
0.029255107045173645,
-0.010838187299668789,
-0.015497407875955105,
0.03989332541823387,
0.009263450279831886,
0.0235560592263937,
0.05299113690853119,
-0.034394245594739914,
-0.0027845343574881554,
0.007438755594193935,
-0.026395585387945175,
-0.057230427861213684,
0.004546739626675844,
-0.019126800820231438,
-0.005074151325970888,
-0.014127637259662151,
0.03127476945519447,
0.04931175336241722,
0.034614209085702896,
0.01909680664539337,
-0.003909346181899309,
-0.02079652063548565,
-0.01586734503507614,
-0.02361604943871498,
-0.01700715534389019,
0.047552045434713364,
-0.003909346181899309,
0.031694699078798294,
0.0086885467171669,
0.004929175600409508,
-0.004789198748767376,
-0.002268370473757386,
-0.015737367793917656,
-0.013737701810896397,
-0.01097816415131092,
0.029415080323815346,
0.044592540711164474,
0.026135629042983055,
-0.01966671086847782,
-0.031954653561115265,
0.016757197678089142,
0.001829693908803165,
-0.019626718014478683,
-0.01751706935465336,
0.028175286948680878,
0.025235779583454132,
0.001834693131968379,
0.05611061304807663,
0.026175621896982193,
-0.02819528430700302,
0.0899849459528923,
-0.03543407469987869,
0.019256779924035072,
0.0285952165722847,
0.013617722317576408,
-0.021456411108374596,
-0.037633705884218216,
0.01564738340675831,
-0.008183631114661694,
0.05795030668377876,
0.07546737790107727,
-0.011358099989593029,
-0.035913992673158646,
-0.06558902561664581,
-0.0224162507802248,
0.032794512808322906,
0.025975655764341354,
-0.00458923215046525,
-0.0388135090470314,
-0.03129476681351662,
-0.016567228361964226,
-0.011878013610839844,
-0.014977495186030865,
-0.01442758645862341,
-0.009273448958992958,
-0.04999163746833801,
-0.050631530582904816,
-0.027035478502511978,
0.03319444879889488,
0.03197465091943741,
0.008518574759364128,
0.01086818240582943,
0.013517739251255989,
0.00904848612844944,
0.03847356513142586,
0.00028807681519538164,
0.0698683112859726,
0.030234942212700844,
0.03979334235191345,
-0.006623892113566399,
-0.019416751340031624,
0.0526311956346035,
0.04707212746143341,
0.007198795676231384,
0.08270616829395294,
-0.01097816415131092,
-0.019876675680279732,
0.032834507524967194,
-0.02007664181292057,
-0.009588396176695824,
0.011398093774914742,
-0.030294932425022125,
-0.009508409537374973,
0.03855355083942413,
-0.05955003947019577,
-0.009153468534350395,
0.005574067588895559,
0.024555891752243042,
0.04291282221674919,
0.009918341413140297,
-0.02517578937113285,
-0.021396420896053314,
0.03423427417874336,
0.030874835327267647,
-0.01632726937532425,
-0.02615562453866005,
0.035654034465551376,
-0.046472225338220596,
0.036693863570690155,
-0.02797532081604004,
-0.0422329343855381,
0.0448325015604496,
-0.005299113690853119,
0.02199632115662098,
0.04955171048641205,
-0.01784701459109783,
0.02449590340256691,
0.04271285608410835,
0.005504079163074493,
0.012207957915961742,
0.015947332605719566,
0.007573733106255531,
0.024895835667848587,
0.018176959827542305,
-0.004286782816052437,
-0.08558568358421326,
-0.05951004475355148,
-0.02625560760498047,
-0.03665386885404587,
0.07030823826789856,
0.01622728630900383,
0.021976323798298836,
-0.08082648366689682,
-0.04107312858104706,
-0.0034844172187149525,
-0.016417253762483597,
-0.02449590340256691,
0.04271285608410835,
-0.04811195284128189,
0.04923176392912865,
-0.001263538608327508,
-0.015987325459718704,
0.06114977225661278,
-0.052551209926605225,
0.03269452974200249,
-0.004654221702367067,
0.050991471856832504,
0.022956160828471184,
-0.018746864050626755,
-0.058790165930986404,
0.0035469066351652145,
0.061709679663181305,
-0.024975823238492012,
-0.036693863570690155,
0.06474916636943817,
0.05267119035124779,
0.03583400696516037,
0.03171469643712044,
-0.03021494671702385,
0.007628723978996277,
-0.036073967814445496,
0.05787032097578049,
-0.059989966452121735,
-0.06654886901378632,
0.0336143784224987,
-0.036533888429403305,
0.007408760953694582,
-0.0033919326961040497,
0.024275939911603928
] |
725,852 | autofaiss.external.quantize | tune_index |
Set hyperparameters to the given index.
If an index_param is given, set this hyperparameters to the index,
otherwise perform a greedy heusistic to make the best out or the max_index_query_time_ms constraint
Parameters
----------
index_path : Union[str, faiss.Index]
Path to .index file
Can also be an index
index_key: str
String to give to the index factory in order to create the index.
index_param: Optional(str)
Optional string with hyperparameters to set to the index.
If None, the hyper-parameters are chosen based on an heuristic.
output_index_path: str
Path to the newly created .index file
save_on_disk: bool
Whether to save the index on disk, default to True.
min_nearest_neighbors_to_retrieve: int
Minimum number of nearest neighbors to retrieve when querying the index.
max_index_query_time_ms: float
Query speed constraint for the index to create.
use_gpu: bool
Experimental, gpu training is faster, not tested so far.
verbose: int
set verbosity of outputs via logging level, default is `logging.INFO`
Returns
-------
index
The faiss index
| def tune_index(
index_path: Union[str, faiss.Index],
index_key: str,
index_param: Optional[str] = None,
output_index_path: Optional[str] = "tuned_knn.index",
save_on_disk: bool = True,
min_nearest_neighbors_to_retrieve: int = 20,
max_index_query_time_ms: float = 10.0,
use_gpu: bool = False,
verbose: int = logging.INFO,
) -> faiss.Index:
"""
Set hyperparameters to the given index.
If an index_param is given, set this hyperparameters to the index,
otherwise perform a greedy heusistic to make the best out or the max_index_query_time_ms constraint
Parameters
----------
index_path : Union[str, faiss.Index]
Path to .index file
Can also be an index
index_key: str
String to give to the index factory in order to create the index.
index_param: Optional(str)
Optional string with hyperparameters to set to the index.
If None, the hyper-parameters are chosen based on an heuristic.
output_index_path: str
Path to the newly created .index file
save_on_disk: bool
Whether to save the index on disk, default to True.
min_nearest_neighbors_to_retrieve: int
Minimum number of nearest neighbors to retrieve when querying the index.
max_index_query_time_ms: float
Query speed constraint for the index to create.
use_gpu: bool
Experimental, gpu training is faster, not tested so far.
verbose: int
set verbosity of outputs via logging level, default is `logging.INFO`
Returns
-------
index
The faiss index
"""
setup_logging(verbose)
if isinstance(index_path, str):
index_path = make_path_absolute(index_path)
with fsspec.open(index_path, "rb").open() as f:
index = faiss.read_index(faiss.PyCallbackIOReader(f.read))
else:
index = index_path
if index_param is None:
with Timeit("Compute best hyperparameters"):
index_param = get_optimal_hyperparameters(
index,
index_key,
max_speed_ms=max_index_query_time_ms,
min_nearest_neighbors_to_retrieve=min_nearest_neighbors_to_retrieve,
)
with Timeit("Set search hyperparameters for the index"):
set_search_hyperparameters(index, index_param, use_gpu)
logger.info(f"The optimal hyperparameters are {index_param}.")
if save_on_disk:
with fsspec.open(output_index_path, "wb").open() as f:
faiss.write_index(index, faiss.PyCallbackIOWriter(f.write))
logger.info("The index with these parameters has been saved on disk.")
return index
| (index_path: Union[str, faiss.swigfaiss_avx512.Index], index_key: str, index_param: Optional[str] = None, output_index_path: Optional[str] = 'tuned_knn.index', save_on_disk: bool = True, min_nearest_neighbors_to_retrieve: int = 20, max_index_query_time_ms: float = 10.0, use_gpu: bool = False, verbose: int = 20) -> faiss.swigfaiss_avx512.Index | [
0.013973206281661987,
-0.015418055467307568,
-0.06950481981039047,
0.010142456740140915,
-0.0025094738230109215,
0.015294482931494713,
-0.07665301859378815,
-0.01720510423183441,
-0.02754717878997326,
-0.040988072752952576,
-0.00361449783667922,
0.010826858691871166,
-0.020417992025613785,
-0.004329793155193329,
0.0378132089972496,
0.010570207610726357,
0.038117386400699615,
0.03127336874604225,
-0.014324912801384926,
-0.005503732245415449,
0.0005519178812392056,
-0.05494226887822151,
0.007899139076471329,
0.021672729402780533,
0.04973321035504341,
-0.051102012395858765,
0.039429157972335815,
-0.0136690279468894,
0.042775120586156845,
-0.04988529905676842,
0.001852400484494865,
-0.016045423224568367,
-0.0006368740578182042,
0.04520855098962784,
0.013478916138410568,
-0.01854539103806019,
0.020227879285812378,
0.020741181448101997,
0.018184179440140724,
0.006872536148875952,
0.023478789255023003,
-0.06368740648031235,
-0.04391579329967499,
-0.03728089481592178,
-0.017442744225263596,
0.052927084267139435,
-0.026615630835294724,
0.053155217319726944,
0.028706859797239304,
-0.020855247974395752,
-0.040683895349502563,
-0.06908657401800156,
-0.03726188465952873,
-0.0011460167588666081,
-0.04547470808029175,
-0.009016045369207859,
-0.02055107057094574,
-0.0007259888807311654,
0.08250845968723297,
-0.053459398448467255,
0.022737354040145874,
-0.04806022718548775,
0.06813601404428482,
0.07345914095640182,
-0.04193863272666931,
-0.008393429219722748,
-0.0598851703107357,
-0.0155986612662673,
-0.006416268181055784,
0.014496013522148132,
0.03984740376472473,
-0.028193557634949684,
0.06011330336332321,
-0.021121405065059662,
-0.04756593704223633,
0.04296523332595825,
-0.03845958784222603,
0.007333557121455669,
-0.03927706927061081,
0.04182456433773041,
0.02910609357059002,
0.020760193467140198,
-0.04608306661248207,
-0.07726137340068817,
-0.008170048706233501,
0.0023300559259951115,
0.05612096190452576,
-0.03851662203669548,
0.04916287213563919,
-0.025056716054677963,
0.024600448086857796,
0.013935184106230736,
0.022014928981661797,
0.0030512921512126923,
0.06083573028445244,
-0.04140631854534149,
0.02397307939827442,
-0.04908682778477669,
-0.04444810375571251,
-0.044600192457437515,
-0.07425761222839355,
0.023345710709691048,
0.06813601404428482,
0.02288944274187088,
0.021672729402780533,
-0.042508967220783234,
-0.024619460105895996,
-0.01194851752370596,
0.005018947646021843,
-0.04961914196610451,
-0.05075981095433235,
-0.010037895292043686,
0.0011893860064446926,
-0.03798430785536766,
-0.0027542426250874996,
0.02576012909412384,
0.0033293303567916155,
0.03505658730864525,
0.00045092107029631734,
-0.008778405375778675,
0.03191974759101868,
0.016872409731149673,
-0.07885831594467163,
0.012404785491526127,
-0.005912472493946552,
0.01628306321799755,
0.020075790584087372,
0.06323113292455673,
0.006901053246110678,
0.017566317692399025,
-0.05600689351558685,
0.009847783483564854,
0.00872612465173006,
0.053421374410390854,
-0.008084498345851898,
-0.008421946316957474,
-0.04787011444568634,
-0.0015494099352508783,
-0.04809824749827385,
0.011007464490830898,
0.015332505106925964,
-0.03334558382630348,
0.02572210691869259,
-0.025912217795848846,
0.07923853397369385,
0.009187146089971066,
-0.01794653944671154,
-0.06311707198619843,
0.0246955044567585,
0.01587432250380516,
0.03359273076057434,
0.0017763557843863964,
-0.06657709926366806,
-0.010589218698441982,
-0.004465247504413128,
-0.0883638933300972,
0.029714452102780342,
0.03382086381316185,
-0.0084504634141922,
-0.0069058057852089405,
0.03043687529861927,
-0.042775120586156845,
0.06741359084844589,
-0.008364913053810596,
-0.05965703725814819,
0.017119554802775383,
-0.06406762450933456,
0.0376991406083107,
0.008792663924396038,
0.0023740192409604788,
-0.050075408071279526,
-0.040683895349502563,
-0.1143711730837822,
0.013440893962979317,
-0.03454328700900078,
0.0363873690366745,
-0.016321085393428802,
-0.0008673844276927412,
0.06657709926366806,
-0.021710751578211784,
-0.025132760405540466,
-0.02680574357509613,
-0.058934614062309265,
-0.024638470262289047,
-0.058934614062309265,
0.050379589200019836,
-0.023307688534259796,
0.040455758571624756,
0.003438644576817751,
0.012015056796371937,
0.06536038964986801,
-0.04471426084637642,
-0.0011032416950911283,
0.0007099481881596148,
-0.02574111707508564,
-0.002837416483089328,
0.018393302336335182,
-0.01975260116159916,
0.06596874445676804,
0.1091240867972374,
0.0273380558937788,
0.05182443559169769,
0.03410603106021881,
-0.0038188679609447718,
0.010560702532529831,
-0.012585391290485859,
0.007575949188321829,
-0.014581563882529736,
-0.038060352206230164,
0.05049365386366844,
-0.02207196317613125,
-0.043079301714897156,
-0.014096778817474842,
0.053193241357803345,
0.002953859744593501,
-0.01480019185692072,
-0.04596899822354317,
0.037337929010391235,
0.047223735600709915,
0.004645853769034147,
0.021938884630799294,
0.004127799067646265,
0.04623515531420708,
0.005750877317041159,
0.08615860342979431,
-0.04916287213563919,
0.032147880643606186,
-0.03513263538479805,
-0.026710687205195427,
-0.03281327337026596,
0.01480019185692072,
0.005926731042563915,
0.039048932492733,
-0.020608102902770042,
0.007262265309691429,
0.033953942358493805,
-0.0074286130256950855,
0.017889507114887238,
-0.040151581168174744,
-0.026729699224233627,
0.03306041657924652,
-0.012376268394291401,
-0.055284470319747925,
-0.03148249164223671,
-0.0701512023806572,
0.015921851620078087,
0.011216587387025356,
0.010094928555190563,
-0.002621164545416832,
-0.03353569656610489,
0.008170048706233501,
0.04741384834051132,
-0.02838367037475109,
0.040189605206251144,
0.0066966828890144825,
0.044372059404850006,
-0.06456191837787628,
-0.030303796753287315,
-0.04847847297787666,
0.00976223312318325,
-0.0857023373246193,
0.00025575957261025906,
-0.02963840775191784,
0.03739496320486069,
0.005636810325086117,
-0.013507433235645294,
0.004719521850347519,
0.04247094318270683,
0.0030988198705017567,
0.01470513641834259,
0.05015145614743233,
0.053193241357803345,
-0.07330705225467682,
-0.018611930310726166,
0.0018904227763414383,
0.006497066002339125,
0.01706252060830593,
-0.002564131049439311,
-0.04387776926159859,
0.061520129442214966,
-0.007766060996800661,
-0.005831675138324499,
-0.007766060996800661,
-0.035227689892053604,
0.010389601811766624,
0.07931458204984665,
-0.04402985796332359,
0.03018973022699356,
-0.004415343049913645,
-0.0004835965228267014,
0.012271706946194172,
0.008778405375778675,
0.014648103155195713,
-0.004481882322579622,
0.03070303238928318,
0.026957832276821136,
-0.056843385100364685,
-0.07121582329273224,
0.035798024386167526,
-0.03659649193286896,
0.0063972570933401585,
0.008631069213151932,
-0.012804020196199417,
-0.014676619321107864,
0.05885856971144676,
-0.005361148621886969,
-0.020684147253632545,
-0.02287043258547783,
0.02290845476090908,
0.019077705219388008,
-0.036330338567495346,
-0.02629244141280651,
0.014400958083570004,
0.03041786514222622,
0.00754743255674839,
-0.10364887118339539,
0.014020734466612339,
-0.03739496320486069,
0.0009155064471997321,
0.05171037092804909,
-0.08266054838895798,
0.06311707198619843,
-0.013478916138410568,
-0.10053104162216187,
0.009424785152077675,
-0.015037831850349903,
0.011482743546366692,
-0.0014662360772490501,
-0.046463288366794586,
-0.051102012395858765,
-0.0416724756360054,
-0.013326826505362988,
0.038155410438776016,
-0.0029467307031154633,
-0.09399120509624481,
0.025684084743261337,
0.01786099001765251,
0.02728102169930935,
0.00468625221401453,
0.03931508958339691,
0.07646290957927704,
0.005232823081314564,
-0.021729761734604836,
0.0155891552567482,
-0.0062926956452429295,
-0.02207196317613125,
0.02106437087059021,
-0.0003252691531088203,
0.013611994683742523,
-0.04817429184913635,
0.02079821564257145,
-0.044372059404850006,
0.017262138426303864,
0.05182443559169769,
0.047489892691373825,
0.016321085393428802,
-0.004054130986332893,
-0.051368169486522675,
-0.014638597145676613,
-0.04958111792802811,
-0.05543655902147293,
0.004322663880884647,
-0.08805971592664719,
-0.0003273485053796321,
0.008882966823875904,
0.02266130968928337,
-0.007295534946024418,
0.03018973022699356,
0.056577228009700775,
-0.009961850941181183,
-0.022224051877856255,
-0.0546761117875576,
0.006012280937284231,
0.03851662203669548,
0.08752740919589996,
-0.041216205805540085,
-0.06475202739238739,
0.022547241300344467,
-0.04034169390797615,
-0.015332505106925964,
-0.001310582272708416,
-0.012851547449827194,
0.039201024919748306,
0.015037831850349903,
-0.008959012106060982,
-0.02129250578582287,
0.0649801641702652,
-0.02501869387924671,
0.05589282512664795,
-0.02680574357509613,
-0.017528293654322624,
0.013992217369377613,
-0.007471388205885887,
0.0299045629799366,
0.04288918897509575,
0.05878252163529396,
0.04923892021179199,
0.023782968521118164,
-0.025836173444986343,
-0.0378132089972496,
-0.011501754634082317,
-0.04212874174118042,
-0.007756555452942848,
0.06904855370521545,
0.029296206310391426,
0.004191962070763111,
0.046805489808321,
0.05920076742768288,
-0.0002747707476373762,
-0.004541292320936918,
-0.033459652215242386,
-0.010845869779586792,
-0.061215952038764954,
0.08912434428930283,
-0.05235674977302551,
0.052470818161964417,
0.013507433235645294,
0.03714781627058983,
0.010085423476994038,
0.04053180292248726,
0.03385888412594795,
-0.026064308360219002,
0.009719458408653736,
0.03739496320486069,
0.005679585505276918,
-0.0169009268283844,
0.0013759330613538623,
-0.03349767252802849,
-0.022699331864714622,
0.03043687529861927,
-0.042775120586156845,
-0.06456191837787628,
-0.0008097568061202765,
0.03870673105120659,
-0.04349754750728607,
-0.021729761734604836,
-0.03150150179862976,
-0.01771840639412403,
0.03543681278824806,
-0.020437002182006836,
0.04889671877026558,
-0.023079555481672287,
0.00025902711786329746,
0.01576976105570793,
0.03169161453843117,
0.026577608659863472,
0.004534163046628237,
0.04707164689898491,
-0.002644928405061364,
-0.048288360238075256,
0.03309844061732292,
-0.009496076963841915,
-0.003854513866826892,
0.023859012871980667,
0.03231897950172424,
-0.032395027577877045,
-0.05406775325536728,
0.0022658933885395527,
0.049505073577165604,
0.053725551813840866,
0.05117805674672127,
0.06406762450933456,
0.006017033942043781,
-0.04296523332595825,
0.004035119898617268,
0.01693894900381565,
0.013868644833564758,
-0.04364963620901108,
0.04897276312112808,
-0.03228095918893814,
-0.030588965862989426,
0.010332568548619747,
-0.07075955718755722,
-0.04056982696056366,
0.03463834524154663,
-0.0016777353594079614,
-0.04083598405122757,
0.008364913053810596,
0.022490208968520164,
-0.019315343350172043,
0.041710495948791504,
-0.0727367177605629,
0.0246955044567585,
0.034239109605550766,
0.02838367037475109,
-0.037318918853998184,
0.014001723378896713,
0.017138564959168434,
-0.04182456433773041,
-0.05258488282561302,
0.025360895320773125,
-0.029049061238765717,
0.03802233189344406,
0.027376078069210052,
-0.010627241805195808,
0.010218501091003418,
0.009847783483564854,
-0.005237576086074114,
0.008032217621803284,
0.003916299901902676,
0.021919874474406242,
-0.04117818549275398,
-0.021425584331154823,
-0.014087273739278316,
0.00400422653183341,
0.027242999523878098,
-0.03537977859377861,
-0.02108338288962841,
-0.01224319078028202,
-0.01975260116159916,
-0.00526134017854929,
0.018630942329764366,
0.014296396635472775,
0.012300224043428898,
0.06707139313220978,
0.03845958784222603,
-0.014429474249482155,
0.001972408499568701,
0.020456014201045036,
-0.021406572312116623,
-0.053155217319726944,
0.04638724401593208,
0.0221289973706007,
-0.030113685876131058,
0.03197678178548813,
0.002419170690700412,
0.015741245821118355,
-0.03138743340969086,
0.046729445457458496,
0.06429576128721237,
-0.017975056543946266,
0.010693780146539211,
-0.00493339728564024,
0.06680523604154587,
0.016064435243606567,
-0.04844044893980026,
0.046995602548122406,
0.00820331834256649,
0.04973321035504341,
-0.0752842128276825,
-0.03353569656610489,
0.007395343389362097,
0.005465710069984198,
-0.07486596703529358,
0.06908657401800156,
0.009990367107093334,
-0.015361021272838116,
0.023098565638065338,
0.002968118293210864,
-0.06288893520832062,
-0.018136652186512947,
0.043839748948812485,
0.041254229843616486,
-0.0012832536594942212,
0.01975260116159916,
0.019438916817307472,
0.03999949246644974,
-0.00579365249723196,
-0.02260427549481392,
0.0002447687438689172,
-0.023364722728729248,
-0.006901053246110678,
0.03950520232319832,
0.00501419510692358,
0.008022711612284184,
0.019600512459874153,
0.01911572739481926,
-0.04186258465051651,
0.00001662548675085418,
-0.06171024218201637,
-0.018840065225958824,
0.01120708230882883,
-0.006601626984775066,
-0.00872612465173006,
-0.03823145478963852,
-0.011910495348274708,
0.0351896658539772,
-0.007471388205885887,
-0.02079821564257145,
-0.03494252264499664,
0.025398917496204376,
0.01040861289948225,
0.06319311261177063,
0.05965703725814819,
0.012423796579241753,
0.06691930443048477,
0.017233621329069138,
0.0016409012023359537,
-0.06087375059723854,
0.008260351605713367,
0.012975119985640049,
-0.011150048114359379,
0.0002827910939231515,
-0.003108325647190213,
0.006302201189100742,
0.06212848797440529,
-0.059999238699674606,
-0.03880178928375244,
0.07372529804706573,
-0.004161068703979254,
-0.0598851703107357,
-0.013298310339450836,
-0.003429139032959938,
-0.001696746563538909,
-0.010931420139968395,
0.022262074053287506,
0.020437002182006836,
0.049048807471990585,
0.02941027283668518,
-0.01911572739481926,
0.02631145343184471,
-0.004158692434430122,
-0.011967528611421585,
0.007609218824654818,
-0.025855185464024544,
0.04973321035504341,
0.03984740376472473,
-0.015170910395681858,
0.04182456433773041,
-0.03583604842424393,
-0.029334228485822678,
0.014648103155195713,
0.023801978677511215,
-0.0034814197570085526,
-0.006078820209950209,
0.010693780146539211,
0.013079681433737278,
-0.06224255636334419,
-0.044334039092063904,
0.03853563219308853,
0.010085423476994038,
-0.02287043258547783,
-0.037794195115566254,
0.04444810375571251,
-0.012899075634777546,
-0.022167019546031952,
0.07144396007061005,
0.02057008072733879,
-0.007190973497927189,
0.04376370459794998,
-0.05125410109758377,
0.083116814494133,
0.04665340110659599,
-0.006173876114189625,
0.025912217795848846,
-0.0325661264359951,
-0.006858278065919876,
-0.009980862028896809,
0.018279235810041428,
0.011634833179414272,
-0.028801916167140007,
-0.038630686700344086,
-0.056615252047777176,
-0.0189066044986248,
0.01833626814186573,
0.009895311668515205,
-0.00354320602491498,
-0.04760395735502243,
0.02393505722284317,
-0.010997959412634373,
-0.01079834159463644,
-0.00644003227353096,
0.008189059793949127,
-0.05254686251282692,
-0.06950481981039047,
-0.013954195193946362,
-0.05798405408859253,
-0.01209110114723444,
-0.04402985796332359,
0.040417738258838654,
0.015560639090836048,
-0.0208362378180027,
-0.03543681278824806,
0.022965487092733383,
0.030379842966794968,
0.027223989367485046,
0.02446736954152584,
-0.0033768583089113235,
-0.04866858199238777,
-0.035969123244285583,
0.048250336199998856,
0.03226194903254509,
0.0022813398391008377,
0.0598851703107357,
0.032927338033914566,
0.05072179064154625,
0.004885869566351175,
-0.01377358939498663,
0.024619460105895996,
0.020855247974395752,
-0.06285091489553452,
-0.045094482600688934,
-0.03401097655296326,
-0.018241213634610176,
0.03349767252802849,
-0.05072179064154625,
0.001454354147426784,
-0.0064115156419575214,
0.0063069541938602924,
-0.03844057768583298,
0.0005563736194744706,
0.0389728881418705,
0.012034067884087563,
0.021729761734604836,
-0.02003776840865612,
0.01745224930346012,
0.0012250320287421346,
0.015741245821118355,
-0.009049315005540848,
-0.06729952245950699,
0.024391325190663338,
-0.02397307939827442,
0.012813525274395943,
0.030493909493088722,
0.014144307002425194,
0.04083598405122757,
0.01920127682387829,
-0.03931508958339691,
-0.02859279327094555,
0.045170530676841736,
0.04570284113287926,
-0.0546380877494812,
0.000888771959580481,
-0.011406699195504189,
-0.02003776840865612,
-0.06699534505605698,
-0.0018488358473405242,
0.0015909968642517924,
0.042775120586156845,
0.03697671741247177,
0.03167260065674782,
-0.06699534505605698,
-0.025589028373360634,
-0.022832410410046577,
0.02885894849896431,
-0.01583630032837391,
0.06083573028445244,
-0.007675758097320795,
0.026596620678901672,
0.01601690612733364,
-0.04182456433773041,
0.0961204543709755,
-0.07707126438617706,
-0.035018566995859146,
0.044600192457437515,
0.04053180292248726,
0.009980862028896809,
-0.024068135768175125,
-0.03625429421663284,
-0.0008537201210856438,
-0.0034980543423444033,
-0.017347687855362892,
0.021254483610391617,
0.05262290686368942,
0.06311707198619843,
0.03148249164223671,
0.010294546373188496,
0.033459652215242386,
-0.018402807414531708,
-0.05288906395435333,
0.065208300948143,
-0.02311757765710354,
0.005042711738497019,
-0.007818342186510563,
-0.030588965862989426,
-0.014248868450522423,
0.04574086517095566,
-0.004175327252596617
] |
725,855 | osqp.interface | OSQP | null | class OSQP(object):
def __init__(self):
self._model = _osqp.OSQP()
def version(self):
return self._model.version()
def setup(self, P=None, q=None, A=None, l=None, u=None, **settings):
"""
Setup OSQP solver problem of the form
minimize 1/2 x' * P * x + q' * x
subject to l <= A * x <= u
solver settings can be specified as additional keyword arguments
"""
# TODO(bart): this will be unnecessary when the derivative will be in C
self._derivative_cache = {'P': P, 'q': q, 'A': A, 'l': l, 'u': u}
unpacked_data, settings = utils.prepare_data(P, q, A, l, u, **settings)
self._model.setup(*unpacked_data, **settings)
def update(self, q=None, l=None, u=None,
Px=None, Px_idx=np.array([]), Ax=None, Ax_idx=np.array([])):
"""
Update OSQP problem arguments
"""
# get problem dimensions
(n, m) = self._model.dimensions()
# check consistency of the input arguments
if q is not None and len(q) != n:
raise ValueError("q must have length n")
if l is not None:
if not isinstance(l, np.ndarray):
raise TypeError("l must be numpy.ndarray, not %s" %
type(l).__name__)
elif len(l) != m:
raise ValueError("l must have length m")
# Convert values to -OSQP_INFTY
l = np.maximum(l, -_osqp.constant('OSQP_INFTY'))
if u is not None:
if not isinstance(u, np.ndarray):
raise TypeError("u must be numpy.ndarray, not %s" %
type(u).__name__)
elif len(u) != m:
raise ValueError("u must have length m")
# Convert values to OSQP_INFTY
u = np.minimum(u, _osqp.constant('OSQP_INFTY'))
if Ax is None:
if len(Ax_idx) > 0:
raise ValueError("Vector Ax has not been specified")
else:
if len(Ax_idx) > 0 and len(Ax) != len(Ax_idx):
raise ValueError("Ax and Ax_idx must have the same lengths")
if Px is None:
if len(Px_idx) > 0:
raise ValueError("Vector Px has not been specified")
else:
if len(Px_idx) > 0 and len(Px) != len(Px_idx):
raise ValueError("Px and Px_idx must have the same lengths")
if q is None and l is None and u is None and Px is None and Ax is None:
raise ValueError("No updatable data has been specified")
# update linear cost
if q is not None:
self._model.update_lin_cost(q)
# update lower bound
if l is not None and u is None:
self._model.update_lower_bound(l)
# update upper bound
if u is not None and l is None:
self._model.update_upper_bound(u)
# update bounds
if l is not None and u is not None:
self._model.update_bounds(l, u)
# update matrix P
if Px is not None and Ax is None:
self._model.update_P(Px, Px_idx, len(Px))
# update matrix A
if Ax is not None and Px is None:
self._model.update_A(Ax, Ax_idx, len(Ax))
# update matrices P and A
if Px is not None and Ax is not None:
self._model.update_P_A(Px, Px_idx, len(Px), Ax, Ax_idx, len(Ax))
# TODO(bart): this will be unnecessary when the derivative will be in C
# update problem data in self._derivative_cache
if q is not None:
self._derivative_cache["q"] = q
if l is not None:
self._derivative_cache["l"] = l
if u is not None:
self._derivative_cache["u"] = u
if Px is not None:
if Px_idx.size == 0:
self._derivative_cache["P"].data = Px
else:
self._derivative_cache["P"].data[Px_idx] = Px
if Ax is not None:
if Ax_idx.size == 0:
self._derivative_cache["A"].data = Ax
else:
self._derivative_cache["A"].data[Ax_idx] = Ax
# delete results from self._derivative_cache to prohibit
# taking the derivative of unsolved problems
if "results" in self._derivative_cache.keys():
del self._derivative_cache["results"]
def update_settings(self, **kwargs):
"""
Update OSQP solver settings
It is possible to change: 'max_iter', 'eps_abs', 'eps_rel',
'eps_prim_inf', 'eps_dual_inf', 'rho'
'alpha', 'delta', 'polish',
'polish_refine_iter',
'verbose', 'scaled_termination',
'check_termination', 'time_limit',
"""
# get arguments
max_iter = kwargs.pop('max_iter', None)
eps_abs = kwargs.pop('eps_abs', None)
eps_rel = kwargs.pop('eps_rel', None)
eps_prim_inf = kwargs.pop('eps_prim_inf', None)
eps_dual_inf = kwargs.pop('eps_dual_inf', None)
rho = kwargs.pop('rho', None)
alpha = kwargs.pop('alpha', None)
delta = kwargs.pop('delta', None)
polish = kwargs.pop('polish', None)
polish_refine_iter = kwargs.pop('polish_refine_iter', None)
verbose = kwargs.pop('verbose', None)
scaled_termination = kwargs.pop('scaled_termination', None)
check_termination = kwargs.pop('check_termination', None)
warm_start = kwargs.pop('warm_start', None)
time_limit = kwargs.pop('time_limit', None)
# update them
if max_iter is not None:
self._model.update_max_iter(max_iter)
if eps_abs is not None:
self._model.update_eps_abs(eps_abs)
if eps_rel is not None:
self._model.update_eps_rel(eps_rel)
if eps_prim_inf is not None:
self._model.update_eps_prim_inf(eps_prim_inf)
if eps_dual_inf is not None:
self._model.update_eps_dual_inf(eps_dual_inf)
if rho is not None:
self._model.update_rho(rho)
if alpha is not None:
self._model.update_alpha(alpha)
if delta is not None:
self._model.update_delta(delta)
if polish is not None:
self._model.update_polish(polish)
if polish_refine_iter is not None:
self._model.update_polish_refine_iter(polish_refine_iter)
if verbose is not None:
self._model.update_verbose(verbose)
if scaled_termination is not None:
self._model.update_scaled_termination(scaled_termination)
if check_termination is not None:
self._model.update_check_termination(check_termination)
if warm_start is not None:
self._model.update_warm_start(warm_start)
if time_limit is not None:
self._model.update_time_limit(time_limit)
if max_iter is None and \
eps_abs is None and \
eps_rel is None and \
eps_prim_inf is None and \
eps_dual_inf is None and \
rho is None and \
alpha is None and \
delta is None and \
polish is None and \
polish_refine_iter is None and \
verbose is None and \
scaled_termination is None and \
check_termination is None and \
warm_start is None:
raise ValueError("No updatable settings has been specified!")
def solve(self):
"""
Solve QP Problem
"""
# Solve QP
results = self._model.solve()
# TODO(bart): this will be unnecessary when the derivative will be in C
self._derivative_cache['results'] = results
return results
def warm_start(self, x=None, y=None):
"""
Warm start primal or dual variables
"""
# get problem dimensions
(n, m) = self._model.dimensions()
if x is not None:
if len(x) != n:
raise ValueError("Wrong | () | [
0.03217048943042755,
-0.04229002818465233,
-0.056091148406267166,
0.05913664773106575,
-0.03180425986647606,
-0.031399477273225784,
-0.05848128721117973,
-0.07170414924621582,
-0.0028431080281734467,
-0.027621516957879066,
-0.020778782665729523,
-0.025983115658164024,
0.0002451578329782933,
0.0462992899119854,
-0.0738244354724884,
0.08388614654541016,
-0.009102764539420605,
0.0015685282414779067,
0.0160274188965559,
0.018485020846128464,
-0.03215121477842331,
-0.04957609251141548,
-0.004216473549604416,
0.0951429232954979,
-0.008466679602861404,
-0.00009336477523902431,
0.025636160746216774,
-0.0037345909513533115,
-0.01592140458524227,
-0.03469555452466011,
-0.00800889078527689,
0.03309570625424385,
0.006707807537168264,
0.004428502172231674,
0.049036383628845215,
-0.02752513997256756,
0.06326156109571457,
0.015429884195327759,
-0.062182147055864334,
-0.01008098665624857,
-0.01822480373084545,
-0.06052446737885475,
0.055821292102336884,
-0.03847351670265198,
0.014051700010895729,
0.008182368241250515,
-0.024248337373137474,
0.09753306210041046,
0.033134255558252335,
0.009136496111750603,
0.029317744076251984,
-0.07525080442428589,
0.028797311708331108,
-0.013772208243608475,
-0.024922974407672882,
0.0731305181980133,
0.0348304845392704,
0.06603720784187317,
0.05805722996592522,
-0.08195861428976059,
0.01175793819129467,
0.006037990562617779,
0.009772581048309803,
-0.0160274188965559,
0.00509831914678216,
0.004599570296704769,
-0.0017432107124477625,
-0.021838923916220665,
0.023438775911927223,
0.04888218268752098,
-0.01383003406226635,
-0.02833470329642296,
-0.02168472297489643,
-0.014523944817483425,
0.05979200825095177,
-0.014119163155555725,
-0.0263878982514143,
-0.04575958102941513,
-0.050308555364608765,
-0.05304564908146858,
0.02282196469604969,
0.015815390273928642,
-0.02756369113922119,
-0.043523646891117096,
-0.011565185151994228,
-0.009830407798290253,
0.04826537147164345,
0.04113350808620453,
0.07756384462118149,
-0.04148046299815178,
-0.03132237493991852,
0.006307844538241625,
0.021183563396334648,
0.0585583858191967,
0.06626851111650467,
0.00009321418474428356,
-0.029086440801620483,
-0.09853538125753403,
-0.002792510436847806,
-0.059406500309705734,
-0.012808443047106266,
0.0357556976377964,
-0.028064848855137825,
0.011786851100623608,
0.013589092530310154,
-0.06530474871397018,
-0.010919461958110332,
-0.02039327658712864,
0.02698543295264244,
-0.08149600774049759,
-0.06268330663442612,
0.059406500309705734,
-0.0493062399327755,
-0.013010833412408829,
-0.07208965718746185,
0.005112775601446629,
-0.06283750385046005,
0.02154979482293129,
0.042135823518037796,
0.027062533423304558,
-0.05728621780872345,
0.02937556989490986,
-0.08434875309467316,
0.00996533501893282,
0.040401045233011246,
0.0035779790487140417,
0.018138065934181213,
0.0472245067358017,
0.007999253459274769,
-0.06557460129261017,
-0.0243061650544405,
-0.009112401865422726,
0.0027009525801986456,
0.03670018911361694,
-0.005185057874768972,
-0.021260665729641914,
-0.0252313781529665,
-0.022879790514707565,
-0.03126455098390579,
0.011902502737939358,
0.01673096790909767,
0.04568248242139816,
0.002411823021247983,
0.0019492155406624079,
0.01464923471212387,
0.023130370303988457,
0.040401045233011246,
-0.029915278777480125,
-0.046646248549222946,
0.020586028695106506,
-0.033037878572940826,
0.034175124019384384,
0.00223352643661201,
-0.025077177211642265,
0.0018829567125067115,
-0.04140336439013481,
0.009946059435606003,
-0.057440418750047684,
-0.021125737577676773,
-0.016451476141810417,
-0.08057078719139099,
-0.0516192764043808,
-0.0013287916081026196,
-0.01566118746995926,
-0.002688905457034707,
0.012924094684422016,
-0.04198162257671356,
-0.023554427549242973,
0.007078857161104679,
0.07956847548484802,
-0.006066903471946716,
-0.020374001935124397,
-0.04626074060797691,
-0.0006740334210917354,
-0.025173552334308624,
0.08350063860416412,
0.02937556989490986,
-0.042598433792591095,
0.017241762951016426,
-0.03519671410322189,
0.032209042459726334,
-0.011709749698638916,
-0.04714740440249443,
-0.024845872074365616,
-0.008514867164194584,
0.050539858639240265,
-0.02442181669175625,
-0.010158088058233261,
-0.0014793799491599202,
0.00875580869615078,
-0.009724393486976624,
-0.04148046299815178,
0.050771161913871765,
-0.0005776569014415145,
-0.024961525574326515,
0.03508106246590614,
0.0719740018248558,
0.0059705269522964954,
0.07933717221021652,
0.04471871629357338,
-0.003592435736209154,
-0.02224370650947094,
0.043292343616485596,
-0.005560926627367735,
-0.02835397981107235,
-0.016171984374523163,
-0.025404857471585274,
-0.012172357179224491,
-0.003626167541369796,
0.02937556989490986,
-0.012846993282437325,
-0.012442211620509624,
-0.026310795918107033,
-0.005069406237453222,
0.0332113578915596,
0.024017034098505974,
0.060331717133522034,
0.0031756071839481592,
0.009719574823975563,
-0.0006300616660155356,
0.013116847723722458,
-0.010167725384235382,
-0.030840493738651276,
-0.010109899565577507,
0.025443406775593758,
-0.0033105341717600822,
0.01923675835132599,
0.07020067423582077,
0.03207411244511604,
-0.04749435931444168,
0.01601778157055378,
-0.017097199335694313,
-0.00019922837964259088,
-0.02108718827366829,
0.06738647818565369,
-0.026118043810129166,
-0.06075577437877655,
0.04764856398105621,
-0.004888700321316719,
-0.029780352488160133,
-0.025192828848958015,
-0.0488436333835125,
-0.005498281680047512,
0.0027419126126915216,
-0.0289322379976511,
-0.006727082654833794,
0.06599865853786469,
0.01716466248035431,
-0.00017182130250148475,
-0.01753089390695095,
0.0010691772913560271,
-0.054009415209293365,
-0.05489607900381088,
0.022879790514707565,
-0.008693164214491844,
-0.01750198006629944,
0.04541262611746788,
0.023939933627843857,
0.04032394662499428,
-0.03271019831299782,
-0.012172357179224491,
0.02444109134376049,
-0.031862083822488785,
0.06210504472255707,
-0.045104220509529114,
0.025038626044988632,
-0.009189503267407417,
-0.005560926627367735,
0.006148823536932468,
0.03920597955584526,
0.057825926691293716,
0.05682361125946045,
-0.06973806768655777,
0.021646171808242798,
-0.010013522580265999,
0.04471871629357338,
-0.021607620641589165,
0.020566754043102264,
-0.008857004344463348,
-0.0050790440291166306,
0.021357042714953423,
-0.017087562009692192,
0.011565185151994228,
0.03652670979499817,
-0.037644676864147186,
0.0019251214107498527,
-0.04818827286362648,
-0.016981547698378563,
0.04348509758710861,
-0.01279880478978157,
-0.007011393550783396,
0.021395592018961906,
0.06784908473491669,
-0.007989615201950073,
0.07305341958999634,
0.013936048373579979,
-0.017569443210959435,
-0.006876466330140829,
0.04032394662499428,
0.0005403109826147556,
0.034310050308704376,
0.0005851862952113152,
0.0186874121427536,
0.01360836811363697,
0.026908330619335175,
-0.010100261308252811,
0.05686216056346893,
-0.003939391113817692,
0.039360180497169495,
-0.023477325215935707,
-0.015535898506641388,
0.002016679150983691,
-0.013010833412408829,
0.05944505333900452,
0.027390213683247566,
-0.030801942571997643,
-0.0034117295872420073,
-0.02180037461221218,
0.012297647073864937,
0.0578644759953022,
-0.03689293935894966,
0.05235173925757408,
0.03193918615579605,
-0.0034189578145742416,
-0.046877551823854446,
-0.025289205834269524,
0.018282629549503326,
0.005450093653053045,
-0.013589092530310154,
-0.07228240370750427,
-0.013858946971595287,
-0.013743295334279537,
0.007314979564398527,
0.03386671841144562,
-0.010023160837590694,
-0.038222938776016235,
0.03722061961889267,
-0.02918281778693199,
0.037413373589515686,
-0.0083028394728899,
0.09614524245262146,
0.07401718199253082,
-0.058712590485811234,
0.024614568799734116,
-0.006057265680283308,
-0.06260620057582855,
0.05142652243375778,
-0.038203660398721695,
0.028219051659107208,
-0.017000822350382805,
-0.06985371559858322,
0.04618363827466965,
-0.006640343926846981,
0.04475726559758186,
0.05385521054267883,
0.016518939286470413,
-0.006934292148798704,
-0.020682405680418015,
0.026233695447444916,
-0.029915278777480125,
-0.0003538826131261885,
0.017251402139663696,
-0.06923691183328629,
0.053431157022714615,
-0.0038333770353347063,
-0.03803018480539322,
-0.016316547989845276,
-0.016277998685836792,
0.015545536763966084,
-0.04067090153694153,
-0.017126111313700676,
-0.06703952699899673,
0.01319394912570715,
-0.006105454172939062,
-0.02686977945268154,
0.046376392245292664,
-0.05084826424717903,
0.03564004600048065,
-0.021954577416181564,
-0.014263728633522987,
0.06958386301994324,
-0.04942189157009125,
-0.034310050308704376,
-0.004763410426676273,
0.017598357051610947,
-0.028527457267045975,
0.03594845160841942,
0.013271049596369267,
0.0661914125084877,
-0.016094882041215897,
0.02222442999482155,
0.0030262235086411238,
0.024460365995764732,
0.03087904490530491,
-0.011362794786691666,
0.022667763754725456,
0.062182147055864334,
0.026831230148673058,
-0.06303025782108307,
-0.04070945084095001,
-0.020239073783159256,
-0.026349347084760666,
-0.003481602529063821,
0.04853522777557373,
0.0075607397593557835,
-0.08704729378223419,
0.06773343682289124,
0.0613340325653553,
-0.0016034647123888135,
0.12413299083709717,
-0.011362794786691666,
-0.007295704446732998,
-0.025327755138278008,
0.011295330710709095,
-0.07490384578704834,
-0.012374748475849628,
0.0048935189843177795,
-0.04336944594979286,
0.04888218268752098,
0.046838998794555664,
0.054009415209293365,
0.02050892822444439,
0.06969951838254929,
0.0474558100104332,
-0.01031228993088007,
-0.016624953597784042,
-0.022185880690813065,
-0.003659899113699794,
-0.029683975502848625,
0.02340022474527359,
-0.03249816969037056,
-0.020239073783159256,
-0.007734217680990696,
-0.028951512649655342,
-0.02237863279879093,
-0.010533955879509449,
0.027872096747159958,
0.00022994840401224792,
0.008577512577176094,
-0.002269667573273182,
0.04090220481157303,
-0.009777400642633438,
0.0033201719634234905,
-0.03030078485608101,
-0.02569398656487465,
-0.030821219086647034,
0.02559760957956314,
-0.046492043882608414,
-0.09575973451137543,
0.02960687316954136,
0.007575196214020252,
0.017106836661696434,
0.03030078485608101,
-0.008273926563560963,
0.010890549048781395,
-0.0015817800303921103,
-0.008697982877492905,
-0.03758685290813446,
-0.04599088802933693,
-0.01636473648250103,
-0.002193771069869399,
0.032324694097042084,
0.011941053904592991,
-0.0007655911613255739,
-0.002173291053622961,
0.059175197035074234,
0.03195846080780029,
-0.027043258771300316,
-0.03377034142613411,
0.0007535440963692963,
0.007252335082739592,
0.00047796740545891225,
-0.002712999703362584,
-0.0537010096013546,
-0.040169741958379745,
-0.028411805629730225,
-0.041788868606090546,
0.05497318133711815,
0.024171236902475357,
-0.06750213354825974,
0.029317744076251984,
-0.05223608762025833,
0.042829737067222595,
0.05358535796403885,
0.0022805100306868553,
-0.03818438574671745,
0.05524303391575813,
-0.0313609279692173,
0.0006469275685958564,
-0.011835039593279362,
-0.03793380782008171,
-0.017675457522273064,
0.06881285458803177,
0.002773235086351633,
-0.006037990562617779,
0.010745984502136707,
-0.022532835602760315,
-0.021511243656277657,
0.06268330663442612,
-0.0564766526222229,
0.034040194004774094,
-0.020104147493839264,
-0.05817288160324097,
0.0021455828100442886,
0.041326262056827545,
-0.02571326121687889,
-0.05200478434562683,
0.031187448650598526,
-0.01649002730846405,
0.005787411238998175,
-0.019988495856523514,
-0.07282211631536484,
0.07228240370750427,
-0.03562077134847641,
0.0189187154173851,
0.018272992223501205,
-0.0025443406775593758,
0.014639596454799175,
-0.0139456856995821,
-0.03550511971116066,
0.00945453904569149,
0.023419499397277832,
0.018629586324095726,
-0.00788842048496008,
0.025983115658164024,
0.03461845591664314,
-0.0371435210108757,
-0.04587523639202118,
0.05489607900381088,
0.015545536763966084,
0.016104521229863167,
-0.014080612920224667,
0.037741053849458694,
0.06144968420267105,
0.030705567449331284,
0.0017877848586067557,
0.00395143823698163,
-0.09151916205883026,
-0.05027000606060028,
-0.0237279050052166,
-0.03421367332339287,
0.053199850022792816,
0.028681660071015358,
-0.04703175276517868,
0.013820396736264229,
-0.0034767838660627604,
0.0038092827890068293,
0.03184280917048454,
-0.03450280427932739,
-0.030127307400107384,
-0.029105715453624725,
0.0095750093460083,
0.0666540190577507,
0.03939872980117798,
0.045027121901512146,
-0.016326187178492546,
0.0033105341717600822,
0.028874412178993225,
0.03008875623345375,
0.013030108995735645,
-0.0506940633058548,
-0.06094852462410927,
0.057903025299310684,
-0.02016197331249714,
-0.02906716614961624,
0.021491969004273415,
-0.022185880690813065,
-0.012654240243136883,
0.016923721879720688,
0.027486590668559074,
0.014254090376198292,
-0.02316892147064209,
0.006813821382820606,
-0.011478446424007416,
-0.05454912409186363,
-0.0474558100104332,
0.015699738636612892,
-0.04159611463546753,
-0.044680166989564896,
-0.014822712168097496,
0.03841568902134895,
-0.00916059035807848,
-0.02802629955112934,
-0.05003870278596878,
0.04656914621591568,
0.03610265254974365,
-0.017463428899645805,
0.057825926691293716,
0.023130370303988457,
-0.000017995307644014247,
-0.020932985469698906,
0.042251475155353546,
-0.02698543295264244,
-0.05801868066191673,
-0.00395143823698163,
0.051812030375003815,
-0.059059545397758484,
-0.021125737577676773,
0.0689670518040657,
-0.0012480762088671327,
-0.0698922723531723,
0.021973852068185806,
0.015034740790724754,
-0.029317744076251984,
0.008635338395833969,
-0.0064524095505476,
-0.03484975919127464,
0.013483078218996525,
0.043176691979169846,
-0.033712513744831085,
0.03299932926893234,
-0.020335450768470764,
0.019063280895352364,
-0.004587523639202118,
-0.06522764265537262,
-0.030917594209313393,
-0.03319208323955536,
0.0253470316529274,
0.07390153408050537,
-0.0030045388266444206,
-0.02881658636033535,
0.03943728283047676,
0.0045296973548829556,
-0.013059021905064583,
-0.04024684429168701,
0.0031635600607842207,
0.04336944594979286,
-0.08828091621398926,
-0.02120283991098404,
-0.015179305337369442,
0.03494613617658615,
0.0036743558011949062,
-0.003768322756513953,
0.034425701946020126,
-0.010399028658866882,
-0.010871274396777153,
0.0147552490234375,
0.009541277773678303,
-0.03338483348488808,
0.038222938776016235,
0.029529772698879242,
0.05886679142713547,
0.011594098061323166,
-0.007536645513027906,
0.010668883100152016,
0.048458125442266464,
-0.023670079186558723,
-0.03955293446779251,
0.03963003307580948,
0.04406335577368736,
-0.042482778429985046,
-0.004180332645773888,
-0.05801868066191673,
-0.026580650359392166,
-0.00023687547945883125,
0.016316547989845276,
0.007883600890636444,
-0.019072918221354485,
0.035890623927116394,
-0.012818080373108387,
-0.005329622887074947,
0.011266417801380157,
0.016191259026527405,
-0.028643108904361725,
-0.013348150998353958,
0.011064027436077595,
0.012451848946511745,
0.002763597294688225,
0.005242884159088135,
0.04148046299815178,
-0.002973216352984309,
-0.04140336439013481,
-0.012085618451237679,
0.025269929319620132,
-0.00928106065839529,
-0.004647758789360523,
0.004358629230409861,
-0.0022359357681125402,
-0.0310139711946249,
-0.009088307619094849,
0.0951429232954979,
0.02754441648721695,
-0.02087515965104103,
-0.008245013654232025,
0.0462992899119854,
0.0023250840604305267,
-0.014919089153409004,
0.028835861012339592,
0.010158088058233261,
-0.028431080281734467,
-0.0476871132850647,
0.023091819137334824,
0.008187186904251575,
-0.0056717596016824245,
0.039128877222537994,
-0.07841195911169052,
-0.06738647818565369,
-0.0302044078707695,
0.0383000373840332,
-0.04772566258907318,
0.048111170530319214,
0.023689353838562965,
-0.022050952538847923,
0.021491969004273415,
0.02397848479449749,
0.07633022218942642,
-0.08272962272167206,
-0.0016191259492188692,
-0.017376691102981567,
-0.04460306465625763,
0.03909032419323921,
0.03754829987883568,
0.01912110671401024,
-0.0666540190577507,
0.04521987587213516,
0.027293836697936058,
0.003973123151808977,
0.005093500483781099,
0.0016058741603046656,
0.03147657960653305,
-0.018764512613415718,
0.011150766164064407,
0.014485394582152367,
-0.04633784294128418,
-0.02166544646024704,
0.008885917253792286,
-0.03330773487687111,
-0.0543949194252491,
0.016345461830496788,
0.020239073783159256,
0.003669536905363202,
0.021626897156238556,
0.0009661748190410435,
-0.011507359333336353,
0.02224370650947094,
-0.05979200825095177,
0.0332113578915596,
0.021742548793554306,
-0.03606410324573517,
0.03519671410322189,
-0.009642473421990871,
0.009531640447676182,
-0.026811953634023666,
-0.0091702276840806,
0.01742487959563732,
0.03687366470694542,
-0.02016197331249714,
-0.00957019068300724,
-0.009377437643706799,
-0.020663131028413773,
0.08095629513263702,
0.011218229308724403,
0.028893686830997467,
0.026811953634023666,
0.041557565331459045,
-0.047185953706502914,
0.011083302088081837,
0.01520821824669838,
-0.02744803950190544,
-0.049730297178030014,
-0.02407485991716385,
-0.031997013837099075,
0.03910960257053375,
0.09660784900188446,
-0.020586028695106506,
0.007633022032678127,
-0.0015420246636494994,
0.026310795918107033
] |
725,856 | osqp.interface | __init__ | null | def __init__(self):
self._model = _osqp.OSQP()
| (self) | [
-0.0008376217447221279,
-0.03413502871990204,
-0.0413951575756073,
0.0043312255293130875,
-0.01708526536822319,
-0.016783500090241432,
-0.04363177344202995,
0.0004287957854103297,
0.04104013741016388,
-0.00012314703781157732,
-0.01599358394742012,
0.011316214688122272,
0.016002457588911057,
0.06844756752252579,
-0.0393715500831604,
0.06383232772350311,
0.03713493421673775,
-0.014111985452473164,
0.03516457974910736,
0.0007211313350126147,
-0.031383633613586426,
0.012736288830637932,
-0.0011460441164672375,
0.07196224480867386,
-0.005036824848502874,
0.03436579182744026,
-0.006616657134145498,
-0.013242189772427082,
0.002944434527307749,
-0.05247173458337784,
-0.036424897611141205,
0.0032639512792229652,
0.024460773915052414,
0.03504032641649246,
0.032750457525253296,
0.023590978235006332,
0.02843698114156723,
-0.0048948172479867935,
-0.07121670991182327,
-0.003798697842285037,
0.04203419014811516,
-0.0413951575756073,
0.02272118255496025,
-0.009612125344574451,
-0.00111497996840626,
0.03553735092282295,
-0.008711266331374645,
0.07476689666509628,
0.06287377327680588,
0.023786239326000214,
-0.02204664796590805,
0.018283452838659286,
-0.0062838271260261536,
0.01571844331920147,
-0.052755746990442276,
0.0742698684334755,
0.007548580877482891,
0.05957210436463356,
-0.008298557251691818,
0.028507985174655914,
-0.05030611902475357,
0.04693344607949257,
0.038626011461019516,
-0.005578228272497654,
0.034046273678541183,
0.012097255326807499,
-0.01899348944425583,
0.03298121690750122,
0.016774624586105347,
0.031010864302515984,
0.03555510193109512,
-0.03788047283887863,
-0.05232972651720047,
0.04395128786563873,
0.07639998197555542,
-0.012301390990614891,
-0.06173771619796753,
0.01988103613257408,
-0.04135965555906296,
-0.031010864302515984,
0.030567092821002007,
0.03601662442088127,
-0.05034162104129791,
-0.011085452511906624,
-0.0030997551511973143,
-0.02234841324388981,
0.033052220940589905,
0.012762914411723614,
0.03784497082233429,
0.02137211337685585,
-0.06429384648799896,
0.02218865603208542,
-0.04022359475493431,
0.05261373892426491,
0.03887452557682991,
-0.031383633613586426,
-0.023768488317728043,
-0.059856116771698,
-0.014822022058069706,
-0.015336798503994942,
-0.0818672627210617,
0.047359466552734375,
-0.09237581491470337,
0.012150507420301437,
-0.010348789393901825,
-0.05087415128946304,
-0.005516099743545055,
-0.0017462471732869744,
0.026821646839380264,
-0.02976830117404461,
-0.010464170016348362,
0.11438696086406708,
-0.024105755612254143,
0.039797574281692505,
-0.055418387055397034,
-0.017040887847542763,
-0.010686056688427925,
0.014502505771815777,
0.05722898244857788,
0.0013291004579514265,
-0.07391484826803207,
0.05236522853374481,
-0.0891096442937851,
0.028685493394732475,
0.06077916547656059,
0.03488056734204292,
0.02877424843609333,
-0.034898318350315094,
0.004655180033296347,
-0.06709849834442139,
0.014884150587022305,
-0.023768488317728043,
0.00008882395923137665,
-0.0091683529317379,
-0.02252592332661152,
-0.003798697842285037,
-0.003905203426256776,
-0.016100088134407997,
-0.018123693764209747,
0.05872005969285965,
-0.01311793364584446,
0.058968570083379745,
0.01777755096554756,
-0.05868455767631531,
0.019277503713965416,
0.07022266089916229,
-0.01120083313435316,
-0.02034256048500538,
-0.01849646307528019,
-0.006554529070854187,
-0.01387234777212143,
0.0237329863011837,
0.02707015909254551,
-0.010792561806738377,
-0.007539705373346806,
-0.029164768755435944,
0.021957892924547195,
-0.049560580402612686,
0.013881223276257515,
-0.02321820892393589,
-0.04395128786563873,
0.011351716704666615,
0.001893801731057465,
-0.0656784176826477,
-0.025951851159334183,
0.003714381018653512,
-0.0508386492729187,
-0.04696894809603691,
-0.016898879781365395,
0.03699292615056038,
-0.05641243979334831,
-0.09748807549476624,
-0.08307432383298874,
-0.03653140366077423,
-0.03312322497367859,
0.02137211337685585,
0.006825230550020933,
0.045513369143009186,
-0.018034938722848892,
-0.029679546132683754,
0.03047833777964115,
0.004271316342055798,
-0.05815202742815018,
0.022472670301795006,
0.015594187192618847,
0.026147112250328064,
0.018052689731121063,
0.012177133932709694,
0.005209896247833967,
-0.02222415804862976,
0.012363518588244915,
0.010810312815010548,
0.02288094162940979,
-0.013756966218352318,
-0.004437731113284826,
0.009141726419329643,
0.05857805162668228,
-0.02167387865483761,
-0.026555383577942848,
0.07206875085830688,
0.033229731023311615,
-0.006590030621737242,
-0.0066477213986217976,
-0.001382353249937296,
-0.03567935898900032,
-0.009887265041470528,
-0.008391750045120716,
0.021336611360311508,
0.002307620132341981,
-0.03504032641649246,
0.008103297092020512,
-0.019313005730509758,
-0.00714474730193615,
0.007286754436790943,
0.026200365275144577,
0.021602874621748924,
-0.005147768184542656,
-0.004943632520735264,
0.016242096200585365,
0.024656035006046295,
0.05925258621573448,
0.004650742281228304,
-0.04909905791282654,
-0.04764348268508911,
-0.05303976312279701,
0.02863224223256111,
-0.0008908745367079973,
-0.001210391172207892,
-0.014298370108008385,
-0.076044961810112,
0.029342278838157654,
0.007646210957318544,
0.004992447327822447,
0.004171467386186123,
0.012399020604789257,
0.01633085124194622,
-0.03468530625104904,
0.050199612975120544,
-0.12020926177501678,
-0.04025909677147865,
0.017946185544133186,
-0.018230199813842773,
-0.02218865603208542,
-0.01337532140314579,
0.007730527780950069,
0.017138518393039703,
0.029573040083050728,
-0.00048537683323957026,
-0.006203948054462671,
-0.029395531862974167,
0.03530658781528473,
-0.07192674279212952,
-0.021105850115418434,
-0.0011937497183680534,
0.014724391512572765,
-0.03488056734204292,
0.001831673551350832,
-0.01748466119170189,
0.03601662442088127,
-0.01758228987455368,
-0.04572638124227524,
0.029679546132683754,
-0.03010556846857071,
0.07455388456583023,
-0.003769852686673403,
0.03638939559459686,
-0.021922392770648003,
0.012106130830943584,
0.02470928616821766,
-0.009443491697311401,
0.15109586715698242,
0.038981031626462936,
-0.019721277058124542,
0.009283733554184437,
-0.022738933563232422,
-0.055915411561727524,
-0.05481485649943352,
0.04068512097001076,
-0.028898505493998528,
-0.00007169709715526551,
0.04991560056805611,
-0.010206781327724457,
0.05406931787729263,
0.05957210436463356,
-0.02978605218231678,
-0.01439599972218275,
-0.015665190294384956,
-0.02873874641954899,
0.004229157697409391,
-0.0639033317565918,
-0.02944878302514553,
0.05943009629845619,
0.022437168285250664,
0.023111702874302864,
0.0715717300772667,
-0.0032972341869026423,
-0.02710566110908985,
0.05232972651720047,
0.06692098826169968,
0.010836939327418804,
0.039620064198970795,
-0.004801624920219183,
0.008768957108259201,
0.021159101277589798,
-0.0033438303507864475,
-0.0038519506342709064,
0.03784497082233429,
0.02069757878780365,
-0.001586488913744688,
-0.017058638855814934,
-0.01633085124194622,
0.06610444188117981,
0.02252592332661152,
0.06855407357215881,
0.02758493646979332,
0.030212074518203735,
0.02943103201687336,
-0.02928902581334114,
0.027513932436704636,
0.07881410419940948,
-0.05868455767631531,
0.019064493477344513,
0.02722991816699505,
-0.006061940919607878,
-0.038945529609918594,
0.013801343739032745,
-0.03717043623328209,
0.0013202250702306628,
-0.045513369143009186,
-0.039265044033527374,
-0.034419041126966476,
0.019774530082941055,
0.020573321729898453,
-0.0036988488864153624,
-0.04767898470163345,
-0.039123035967350006,
0.026644138619303703,
-0.04235370457172394,
-0.03186291083693504,
-0.028206219896674156,
0.056447941809892654,
-0.011609104461967945,
-0.03724144026637077,
0.04579738527536392,
-0.004007271025329828,
-0.04061411693692207,
-0.02896950952708721,
-0.08754756301641464,
0.03617638349533081,
-0.05719348043203354,
-0.04221170023083687,
0.05463734641671181,
0.03347824513912201,
0.07139421999454498,
0.061169687658548355,
0.01869172416627407,
-0.03347824513912201,
0.029821554198861122,
-0.005081202369183302,
-0.013366445899009705,
0.018567467108368874,
0.007499765604734421,
-0.049702588468790054,
0.02016505040228367,
-0.03047833777964115,
-0.00883996021002531,
0.019561517983675003,
0.0019403978949412704,
0.03291021287441254,
0.01286942046135664,
-0.030904360115528107,
-0.07253027707338333,
-0.04043660685420036,
0.0625542551279068,
-0.030709099024534225,
0.058613553643226624,
-0.057797010987997055,
0.00499688507989049,
0.016046835109591484,
-0.05161968991160393,
0.019135497510433197,
-0.015336798503994942,
0.024425271898508072,
-0.004408885724842548,
0.006239450071007013,
-0.03212917223572731,
0.0038652638904750347,
0.06511039286851883,
0.0331764779984951,
0.00281574041582644,
0.015292421914637089,
-0.0233957190066576,
-0.006869607605040073,
-0.013756966218352318,
-0.006803041789680719,
-0.012984801083803177,
0.018727226182818413,
0.020271556451916695,
-0.056092921644449234,
-0.04526485875248909,
0.0030487212352454662,
-0.06511039286851883,
0.01026003435254097,
0.058294035494327545,
0.0010118026984855533,
-0.05321727320551872,
0.03819999098777771,
0.037596456706523895,
0.020963842049241066,
0.007690588012337685,
0.011475972831249237,
-0.009523371234536171,
-0.05616392567753792,
-0.038128986954689026,
-0.03638939559459686,
-0.026218116283416748,
0.05737098678946495,
-0.040294598788022995,
0.06844756752252579,
0.022792186588048935,
0.041821178048849106,
0.07554793357849121,
0.055631399154663086,
0.010322162881493568,
0.015336798503994942,
0.011360591277480125,
0.012461149133741856,
0.028010958805680275,
0.05119366571307182,
0.01092569436877966,
-0.06780853122472763,
0.05832953751087189,
-0.014502505771815777,
-0.03498707339167595,
0.008391750045120716,
0.008498255163431168,
0.012292515486478806,
-0.03670891374349594,
-0.018975738435983658,
0.039620064198970795,
0.03459655120968819,
-0.018744977191090584,
0.005582665558904409,
-0.03133038058876991,
0.010384290479123592,
-0.049880098551511765,
-0.021762633696198463,
0.0005325277452357113,
-0.045868389308452606,
-0.00580011447891593,
0.013748090714216232,
0.021336611360311508,
0.05673195421695709,
0.00021814221690874547,
0.003184072207659483,
-0.03266170248389244,
0.029484285041689873,
-0.05502786487340927,
0.0048460024408996105,
-0.05296875908970833,
-0.048389021307229996,
0.02289869263768196,
-0.02254367433488369,
-0.037915974855422974,
-0.005014636088162661,
0.10096725821495056,
0.03433028981089592,
-0.021283358335494995,
-0.018088191747665405,
-0.009896140545606613,
0.023022949695587158,
0.02893400751054287,
-0.019561517983675003,
-0.055915411561727524,
-0.02424776367843151,
-0.013827970251441002,
-0.030354080721735954,
0.009665378369390965,
-0.013827970251441002,
-0.05389180779457092,
-0.008924277499318123,
-0.07032915949821472,
0.024105755612254143,
0.0854884535074234,
-0.039478056132793427,
0.013419698923826218,
0.0230584517121315,
-0.06241225078701973,
0.014431501738727093,
-0.04125314950942993,
-0.028348226100206375,
0.04945407435297966,
-0.0009618782205507159,
0.01634860225021839,
0.010881316848099232,
0.0715717300772667,
-0.004069399554282427,
0.008072232827544212,
-0.014937402680516243,
-0.03770296275615692,
0.014999531209468842,
0.024017000570893288,
-0.06738250702619553,
-0.04015259072184563,
0.014253992587327957,
-0.029910307377576828,
-0.060140132904052734,
-0.002573884092271328,
-0.034738559275865555,
-0.009709755890071392,
0.007619584444910288,
-0.027300922200083733,
-0.02861449122428894,
-0.037418950349092484,
0.002124563790857792,
0.004455482121556997,
-0.021336611360311508,
0.015452180057764053,
-0.05776150897145271,
-0.015532058663666248,
0.03685091808438301,
0.021443117409944534,
0.011759987100958824,
0.00038025807589292526,
-0.031046366319060326,
0.007229064125567675,
-0.07277879118919373,
-0.0024008124601095915,
0.061169687658548355,
0.057299982756376266,
0.05076764523983002,
-0.015008406713604927,
-0.019472764804959297,
0.060495149344205856,
0.02978605218231678,
0.05094515532255173,
-0.03294571489095688,
-0.038306497037410736,
0.012407896108925343,
-0.021815886721014977,
-0.04899255186319351,
0.020573321729898453,
0.01295817457139492,
-0.007477576844394207,
0.02793995477259159,
-0.004899255000054836,
0.010535174049437046,
0.030584843829274178,
-0.0331764779984951,
-0.009052971377968788,
0.010029272176325321,
-0.044164299964904785,
0.02138986438512802,
-0.014573508873581886,
0.0661754459142685,
0.020129548385739326,
0.01498178020119667,
-0.016357477754354477,
0.027620438486337662,
-0.014857524074614048,
-0.024620532989501953,
0.00867132656276226,
0.011085452511906624,
0.039797574281692505,
-0.01597583293914795,
0.023484474048018456,
-0.015665190294384956,
-0.029147017747163773,
0.02087508700788021,
-0.0026715141721069813,
0.029164768755435944,
-0.07384384423494339,
0.011387217789888382,
0.0420696921646595,
0.00042075238889083266,
-0.027513932436704636,
-0.006341517902910709,
0.023857243359088898,
-0.05133567377924919,
0.01748466119170189,
0.02289869263768196,
0.027496181428432465,
-0.03347824513912201,
-0.0569094642996788,
-0.0008287462987937033,
-0.035075828433036804,
-0.0005400163936428726,
0.012816167436540127,
0.022472670301795006,
0.000445159908849746,
0.01865622214972973,
0.011129830032587051,
-0.04242470860481262,
-0.00008591169898863882,
0.0022477107122540474,
-0.0346498042345047,
-0.0277801975607872,
-0.06606893986463547,
0.042176198214292526,
0.014182988554239273,
-0.036424897611141205,
0.06748901307582855,
0.01767992042005062,
-0.03713493421673775,
0.053110767155885696,
-0.01817694678902626,
-0.07448288053274155,
0.05463734641671181,
0.023590978235006332,
0.012558778747916222,
0.033904265612363815,
0.0021179071627557278,
-0.01682787574827671,
0.01798168569803238,
-0.028898505493998528,
-0.048211511224508286,
-0.05843604356050491,
0.02403475157916546,
0.038590509444475174,
0.01599358394742012,
0.014937402680516243,
0.015239168889820576,
-0.0005475051002576947,
0.011289588175714016,
-0.03891002759337425,
0.019277503713965416,
0.026022855192422867,
-0.12304940819740295,
-0.000732780375983566,
0.0006223918171599507,
0.05144217982888222,
-0.03887452557682991,
0.02625361829996109,
-0.04934757202863693,
0.007011615205556154,
-0.052720244973897934,
-0.02083958499133587,
0.019632522016763687,
0.014857524074614048,
0.0440932959318161,
-0.025792093947529793,
0.019916538149118423,
0.030212074518203735,
-0.04615240544080734,
0.010197905823588371,
0.03028307668864727,
-0.07661299407482147,
-0.027158914133906364,
-0.013561706058681011,
0.0036322828382253647,
-0.031152872368693352,
-0.00786809716373682,
-0.02756718546152115,
0.009075160138309002,
-0.014493630267679691,
0.005347466096282005,
-0.0006601125351153314,
-0.006212823558598757,
0.03518233075737953,
-0.0258808471262455,
-0.05832953751087189,
0.0013302098959684372,
0.06056615337729454,
0.02458503097295761,
0.03157889470458031,
0.022170905023813248,
0.0098428875207901,
-0.015035033226013184,
-0.04057861492037773,
0.033034469932317734,
0.00994051806628704,
0.03498707339167595,
0.003976207226514816,
0.027158914133906364,
-0.030584843829274178,
0.0016275378875434399,
0.020768580958247185,
-0.012319141998887062,
0.008981968276202679,
0.0037343506701290607,
0.018940236419439316,
0.026324620470404625,
0.016046835109591484,
-0.06276726722717285,
0.0591815821826458,
0.03246644139289856,
-0.022259660065174103,
0.04057861492037773,
-0.00999377015978098,
-0.0985531359910965,
-0.03488056734204292,
0.017094140872359276,
-0.005760175175964832,
-0.006909547373652458,
0.017271649092435837,
-0.03731244429945946,
-0.05669645220041275,
-0.07853008806705475,
-0.009523371234536171,
-0.012514402158558369,
0.051229167729616165,
-0.004659617785364389,
-0.013339819386601448,
-0.003927391953766346,
0.016259847208857536,
0.03601662442088127,
-0.05701597034931183,
0.012967050075531006,
-0.041608165949583054,
-0.03990407660603523,
0.03498707339167595,
0.04256671667098999,
-0.008848835714161396,
-0.04757247865200043,
0.03685091808438301,
0.059998124837875366,
-0.026661889627575874,
0.08811558783054352,
-0.059998124837875366,
0.003685535630211234,
-0.01445812825113535,
-0.017493536695837975,
0.03773846477270126,
-0.035590603947639465,
0.0629802793264389,
-0.0016608209116384387,
-0.045655377209186554,
0.0052054584957659245,
0.005489473231136799,
0.004442168865352869,
-0.008555945940315723,
-0.007322256453335285,
-0.034756310284137726,
-0.006749789230525494,
0.022934194654226303,
-0.06695649027824402,
0.023005198687314987,
0.024673786014318466,
0.030247574672102928,
0.02472703717648983,
-0.0022765561006963253,
-0.03251969441771507,
0.0064613367430865765,
0.0065279025584459305,
-0.00405830517411232,
0.01801718771457672,
0.018389957025647163,
-0.006345955654978752,
-0.00925710704177618,
0.016739122569561005,
0.04664942994713783,
0.03770296275615692,
0.06908659636974335,
0.024815792217850685,
-0.02034256048500538,
-0.0544598363339901,
0.026271367445588112,
0.04135965555906296,
-0.042495712637901306,
-0.04075612127780914,
-0.054424334317445755,
-0.025525828823447227,
0.062483254820108414,
0.058791063725948334,
0.029147017747163773,
0.035253334790468216,
0.01970352604985237,
-0.019898787140846252
] |
725,857 | osqp.interface | adjoint_derivative |
Compute adjoint derivative after solve.
| def adjoint_derivative(self, dx=None, dy_u=None, dy_l=None,
P_idx=None, A_idx=None, eps_iter_ref=1e-04):
"""
Compute adjoint derivative after solve.
"""
P, q = self._derivative_cache['P'], self._derivative_cache['q']
A = self._derivative_cache['A']
l, u = self._derivative_cache['l'], self._derivative_cache['u']
try:
results = self._derivative_cache['results']
except KeyError:
raise ValueError("Problem has not been solved. "
"You cannot take derivatives. "
"Please call the solve function.")
if results.info.status != "solved":
raise ValueError("Problem has not been solved to optimality. "
"You cannot take derivatives")
m, n = A.shape
x = results.x
y = results.y
y_u = np.maximum(y, 0)
y_l = -np.minimum(y, 0)
if A_idx is None:
A_idx = A.nonzero()
if P_idx is None:
P_idx = P.nonzero()
if dy_u is None:
dy_u = np.zeros(m)
if dy_l is None:
dy_l = np.zeros(m)
# Make sure M matrix exists
if 'M' not in self._derivative_cache:
# Multiply second-third row by diag(y_u)^-1 and diag(y_l)^-1
# to make the matrix symmetric
inv_dia_y_u = spa.diags(np.reciprocal(y_u + 1e-20))
inv_dia_y_l = spa.diags(np.reciprocal(y_l + 1e-20))
M = spa.bmat([
[P, A.T, -A.T],
[A, spa.diags(A @ x - u) @ inv_dia_y_u, None],
[-A, None, spa.diags(l - A @ x) @ inv_dia_y_l]
], format='csc')
delta = spa.bmat([[eps_iter_ref * spa.eye(n), None],
[None, -eps_iter_ref * spa.eye(2 * m)]],
format='csc')
self._derivative_cache['M'] = M
self._derivative_cache['solver'] = qdldl.Solver(M + delta)
rhs = - np.concatenate([dx, dy_u, dy_l])
r_sol = self.derivative_iterative_refinement(rhs)
r_x, r_yu, r_yl = np.split(r_sol, [n, n+m])
# Extract derivatives for the constraints
rows, cols = A_idx
dA_vals = (y_u[rows] - y_l[rows]) * r_x[cols] + \
(r_yu[rows] - r_yl[rows]) * x[cols]
dA = spa.csc_matrix((dA_vals, (rows, cols)), shape=A.shape)
du = - r_yu
dl = r_yl
# Extract derivatives for the cost (P, q)
rows, cols = P_idx
dP_vals = .5 * (r_x[rows] * x[cols] + r_x[cols] * x[rows])
dP = spa.csc_matrix((dP_vals, P_idx), shape=P.shape)
dq = r_x
return (dP, dq, dA, dl, du)
| (self, dx=None, dy_u=None, dy_l=None, P_idx=None, A_idx=None, eps_iter_ref=0.0001) | [
-0.023181283846497536,
-0.015938350930809975,
-0.03505462408065796,
0.07237083464860916,
-0.03406030312180519,
-0.03764765337109566,
0.0038408013060688972,
-0.07186392694711685,
-0.03363138437271118,
0.016991158947348595,
-0.008232377469539642,
-0.007798581384122372,
-0.010157652199268341,
0.03770614042878151,
-0.058294396847486496,
0.041137516498565674,
-0.019798649474978447,
0.06854952871799469,
-0.03394332528114319,
0.0038432383444160223,
-0.04452989995479584,
-0.06133584305644035,
0.009304682724177837,
0.07174695283174515,
-0.059347204864025116,
-0.040786582976579666,
0.035795487463474274,
-0.015850616618990898,
-0.003163299523293972,
0.006443577818572521,
0.016562238335609436,
0.009411913342773914,
-0.030122021213173866,
-0.012896903790533543,
-0.0397922620177269,
0.03304648771882057,
0.04102053865790367,
-0.007939931005239487,
-0.03780362382531166,
-0.008656425401568413,
0.0037920603062957525,
-0.003736007958650589,
0.06983629614114761,
-0.06149181351065636,
0.039031900465488434,
-0.0008182417950592935,
-0.04476385936141014,
0.033280447125434875,
-0.02766546793282032,
-0.003567851148545742,
0.026183737441897392,
-0.08695418387651443,
0.017117885872721672,
-0.04983293637633324,
0.022654879838228226,
0.04031866788864136,
0.06125785782933235,
0.04527076706290245,
0.029459141194820404,
-0.07244881987571716,
0.008149517700076103,
-0.06511815637350082,
0.028620794415473938,
0.046050623059272766,
0.012740932404994965,
-0.026183737441897392,
0.001486604567617178,
-0.05065178871154785,
0.02600826881825924,
0.03926585614681244,
-0.0017108138417825103,
-0.021524084731936455,
0.014290900900959969,
-0.04932602867484093,
0.08383475244045258,
-0.0050008404068648815,
0.04109852388501167,
-0.09342700988054276,
-0.019077280536293983,
-0.017673535272479057,
-0.009314430877566338,
-0.03402131050825119,
-0.03614642471075058,
-0.015002520754933357,
0.023707687854766846,
0.006721402518451214,
0.02175804227590561,
-0.03392383083701134,
0.07088910788297653,
-0.0212901271879673,
0.0425412617623806,
-0.04456889256834984,
0.005410266108810902,
0.040708594024181366,
0.02600826881825924,
-0.012887155637145042,
0.007472015917301178,
-0.001244726707227528,
0.028854751959443092,
0.031233318150043488,
0.006789640057832003,
0.027879929170012474,
-0.005985411349684,
0.019603684544563293,
0.009587381035089493,
-0.08227503299713135,
-0.014310397207736969,
-0.03981176018714905,
0.036419376730918884,
-0.06761369854211807,
-0.00968486350029707,
0.03462570160627365,
0.01623079739511013,
0.009874953888356686,
-0.06593700498342514,
-0.020997680723667145,
-0.039675284177064896,
-0.010391609743237495,
-0.012653198093175888,
0.017595550045371056,
-0.01777101680636406,
0.023785673081874847,
-0.08773404359817505,
-0.016766950488090515,
0.02012033946812153,
-0.0426192469894886,
0.015002520754933357,
0.05096372961997986,
0.0344502329826355,
-0.014788060449063778,
0.02811388671398163,
0.027977410703897476,
0.0019776716362684965,
0.034274764358997345,
0.00960200373083353,
-0.0092998081818223,
-0.0024309640284627676,
0.008066657930612564,
-0.03871995583176613,
-0.024604525417089462,
-0.006516689900308847,
-0.01639651693403721,
0.04456889256834984,
0.05217251181602478,
0.05147063732147217,
0.044997815042734146,
0.03517160192131996,
0.030628928914666176,
-0.04164442420005798,
0.028074894100427628,
-0.04102053865790367,
0.023590710014104843,
0.007384282071143389,
-0.043321121484041214,
-0.03199367970228195,
-0.05439510568976402,
-0.023064304143190384,
0.024585029110312462,
0.0014110557967796922,
-0.019359977915883064,
-0.02343473769724369,
-0.07159097492694855,
-0.021114658564329147,
0.015675147995352745,
0.01519748568534851,
-0.03250058740377426,
-0.018570372834801674,
-0.00969461165368557,
-0.0007481764187105,
0.04164442420005798,
-0.027509495615959167,
0.007920434698462486,
-0.04671350494027138,
-0.0031218696385622025,
-0.04589465260505676,
0.034937646239995956,
0.004462250974029303,
-0.0185996163636446,
0.03638038411736488,
-0.08609633892774582,
0.0532253198325634,
0.025754814967513084,
-0.00298783159814775,
-0.039129383862018585,
0.00650694128125906,
0.025637837126851082,
-0.024721503257751465,
-0.02509193681180477,
0.02242092229425907,
0.04086456820368767,
-0.05264042690396309,
-0.031077347695827484,
0.030433963984251022,
-0.025403879582881927,
-0.009002487175166607,
0.04566069319844246,
0.020042354241013527,
0.03889542445540428,
0.047181420028209686,
0.03421627730131149,
0.027217049151659012,
-0.018853070214390755,
-0.027977410703897476,
0.01011865958571434,
-0.04316514730453491,
0.0008864793926477432,
-0.06149181351065636,
0.005298161413520575,
-0.025150425732135773,
0.008593061938881874,
0.038544490933418274,
-0.002249403391033411,
-0.05677367374300957,
-0.007949679158627987,
0.010186896659433842,
-0.002415123162791133,
0.033221956342458725,
0.008539446629583836,
0.0793895572423935,
-0.0031023730989545584,
0.01696191541850567,
-0.03881743922829628,
-0.020510269328951836,
0.01625029370188713,
0.030960367992520332,
-0.018726343289017677,
0.027801943942904472,
0.05923022702336311,
0.0092705637216568,
-0.051353659480810165,
-0.009782345965504646,
-0.040786582976579666,
0.0638703852891922,
-0.03665333241224289,
0.08656425774097443,
-0.006458200514316559,
-0.09670241177082062,
0.036984771490097046,
0.055486906319856644,
0.02068573795258999,
-0.026339709758758545,
0.00733066676184535,
0.012409492395818233,
0.015421695075929165,
-0.01655248925089836,
0.0023907525464892387,
0.023142291232943535,
0.03577599301934242,
0.03575649484992027,
-0.020607750862836838,
-0.04004571586847305,
-0.02177753858268261,
-0.048000268638134,
-0.001496352837421,
-0.02335675247013569,
-0.005395643413066864,
0.0638313889503479,
0.013667014427483082,
-0.0008749033440835774,
-0.02554035373032093,
0.0293031707406044,
-0.011405425146222115,
-0.033826347440481186,
0.014895291067659855,
-0.1226716861128807,
0.04585565999150276,
0.038076575845479965,
-0.03246159479022026,
-0.03279303386807442,
0.02762647531926632,
0.07104507833719254,
0.04745436832308769,
-0.0635974332690239,
-0.029147198423743248,
0.001403744681738317,
0.051353659480810165,
-0.003541043493896723,
0.01965242624282837,
-0.00016130269796121866,
0.009163333103060722,
0.004043077118694782,
-0.03335843235254288,
0.00915845949202776,
0.06293455511331558,
-0.0797015056014061,
0.009801842272281647,
-0.021602069959044456,
0.004050388466566801,
0.01760529726743698,
0.015363205224275589,
0.04452989995479584,
0.014817304909229279,
0.08141718804836273,
0.02871827594935894,
0.07911661267280579,
0.04367205500602722,
0.00691636698320508,
0.007062590215355158,
0.020880702883005142,
0.030726410448551178,
-0.0374331921339035,
0.015460687689483166,
0.03920736908912659,
-0.005303035490214825,
-0.042346298694610596,
-0.049793943762779236,
0.03569800779223442,
-0.017556557431817055,
0.03973377123475075,
-0.02080271579325199,
-0.007116205524653196,
0.025715822353959084,
-0.003382634837180376,
0.05997109040617943,
-0.03600994870066643,
-0.06582003086805344,
-0.0159286018460989,
-0.01623079739511013,
0.02503344602882862,
0.037062760442495346,
-0.022459914907813072,
0.059776127338409424,
-0.017371339723467827,
-0.009241319261491299,
-0.014251907356083393,
0.009173081256449223,
0.04944300651550293,
0.012545968405902386,
0.03259807080030441,
-0.019886383786797523,
-0.0032193518709391356,
-0.027918921783566475,
-0.04031866788864136,
0.016893677413463593,
0.05435611307621002,
-0.04199536144733429,
0.038115568459033966,
-0.0638313889503479,
0.027392517775297165,
-0.006199872121214867,
0.028445325791835785,
0.04733739048242569,
-0.03415778651833534,
0.020588254556059837,
0.009294934570789337,
-0.049209050834178925,
0.023941645398736,
0.014758815988898277,
0.024292580783367157,
0.007550001610070467,
-0.04144946113228798,
0.0047546979039907455,
-0.01803421974182129,
-0.001220965408720076,
0.03996773064136505,
-0.009338801726698875,
-0.027392517775297165,
-0.01788799650967121,
0.04667450860142708,
-0.010167400352656841,
-0.03179871663451195,
-0.013413560576736927,
-0.05923022702336311,
0.04051363095641136,
-0.022050488740205765,
-0.024663014337420464,
-0.07771286368370056,
-0.06332448124885559,
0.013744999654591084,
-0.01566540077328682,
-0.004269723314791918,
-0.018443645909428596,
-0.015275471843779087,
0.016123566776514053,
-0.03025849722325802,
-0.0003232146555092186,
0.027957914397120476,
0.05225049704313278,
-0.026417694985866547,
0.01948670484125614,
-0.018463142216205597,
-0.05708561837673187,
0.0017961107660084963,
0.017030151560902596,
-0.0007877785828895867,
-0.022225957363843918,
0.08321086317300797,
-0.017878247424960136,
0.01064506359398365,
-0.006945611443370581,
0.058216411620378494,
-0.021524084731936455,
0.015431443229317665,
0.03392383083701134,
-0.035366568714380264,
-0.04304816946387291,
0.046557530760765076,
0.027489999309182167,
-0.03873945400118828,
-0.010528084821999073,
-0.0037506301887333393,
-0.003173047909513116,
-0.012009815312922001,
0.009060977026820183,
-0.02608625590801239,
-0.021504588425159454,
0.047064438462257385,
0.052913375198841095,
-0.016503747552633286,
0.08126121759414673,
-0.01064506359398365,
-0.0027441259007900953,
0.00503495940938592,
0.019886383786797523,
-0.01724461279809475,
0.017117885872721672,
0.012584961019456387,
-0.003387508913874626,
0.01094725914299488,
0.04043564572930336,
0.02074422687292099,
-0.04562170058488846,
-0.0025662207044661045,
0.03031698614358902,
-0.04952099174261093,
0.003804245498031378,
-0.0640263557434082,
0.0371212475001812,
-0.03838851675391197,
-0.04297018423676491,
0.017819758504629135,
-0.030726410448551178,
0.02017883025109768,
-0.0074184006080031395,
-0.015411946922540665,
0.007257555145770311,
0.05357625335454941,
0.06328549236059189,
0.03279303386807442,
-0.0173420961946249,
0.01594810001552105,
-0.021641064435243607,
-0.005351776722818613,
-0.04215133190155029,
-0.01382298581302166,
-0.025189418345689774,
0.03560052439570427,
-0.033806849271059036,
-0.07104507833719254,
-0.023883156478405,
0.05731957405805588,
0.05536992847919464,
0.028425829485058784,
0.024565530940890312,
-0.051899559795856476,
-0.006614171899855137,
0.011405425146222115,
-0.0905415341258049,
-0.027412014082074165,
0.042892199009656906,
0.02811388671398163,
0.005010588560253382,
0.054629065096378326,
0.008022790774703026,
-0.031116340309381485,
0.020646745339035988,
0.022128475829958916,
-0.054434098303318024,
-0.024877475574612617,
-0.025403879582881927,
0.015811624005436897,
0.025208914652466774,
-0.002097087213769555,
-0.03610743209719658,
-0.023083800449967384,
-0.061413828283548355,
0.020393291488289833,
0.05037883669137955,
-0.006316850893199444,
-0.048039261251688004,
-0.009645870886743069,
-0.05147063732147217,
-0.01065481174737215,
-0.005649097263813019,
0.03870046138763428,
-0.042892199009656906,
0.022186964750289917,
0.020958688110113144,
-0.021075665950775146,
0.01944771222770214,
0.00834935624152422,
0.006740898825228214,
0.03411879390478134,
-0.042892199009656906,
0.019057784229516983,
-0.0318962000310421,
0.02341524139046669,
-0.06543009728193283,
0.07081112265586853,
-0.040708594024181366,
0.009870079346001148,
-0.0642213225364685,
-0.04109852388501167,
0.04328212887048721,
0.027489999309182167,
-0.023025311529636383,
0.03834952414035797,
0.03279303386807442,
-0.02173854596912861,
0.006853003520518541,
-0.07412552088499069,
-0.03657534718513489,
0.04846818372607231,
0.030102524906396866,
0.005887928884476423,
0.02821136824786663,
-0.03409929946064949,
0.010489092208445072,
0.02986856736242771,
-0.03532757610082626,
0.010411106050014496,
0.04936502128839493,
0.0008755126036703587,
-0.008261621929705143,
0.013052876107394695,
0.09319304674863815,
-0.024818984791636467,
-0.016065077856183052,
-0.011688124388456345,
0.003930972423404455,
-0.0639873594045639,
-0.024078119546175003,
0.04082557559013367,
0.0426972322165966,
-0.018209688365459442,
0.00010890597332036123,
-0.006653164979070425,
-0.06987529247999191,
-0.11346936225891113,
-0.03402131050825119,
0.028854751959443092,
0.04378903657197952,
0.006360718049108982,
-0.06110188737511635,
0.00045633886475116014,
0.007140576373785734,
-0.04694746062159538,
0.023532219231128693,
0.019944872707128525,
-0.009528892114758492,
0.009899324737489223,
0.013706007041037083,
0.0036872667260468006,
0.024117114022374153,
0.03127231076359749,
0.03524958714842796,
-0.032637063413858414,
0.01865810714662075,
0.019311238080263138,
0.028503814712166786,
-0.03922686353325844,
-0.08258698135614395,
0.021972503513097763,
-0.021543581038713455,
-0.03413829207420349,
0.017965981736779213,
0.05158761516213417,
-0.038466501981019974,
0.018463142216205597,
0.009031732566654682,
-0.05057379975914955,
-0.051275674253702164,
-0.025247907266020775,
-0.020471276715397835,
-0.07209788262844086,
-0.0006525219650939107,
0.016903424635529518,
-0.10294127464294434,
-0.008173888549208641,
0.006029278505593538,
0.02019832655787468,
-0.016318531706929207,
-0.005785572808235884,
0.02869877964258194,
0.038018085062503815,
0.004508554935455322,
-0.011376180686056614,
0.0185606237500906,
0.06679484993219376,
-0.06051699444651604,
-0.06687283515930176,
-0.012623953633010387,
-0.010401357896625996,
-0.03234461694955826,
-0.00556136341765523,
0.05794345960021019,
-0.04378903657197952,
0.019983865320682526,
0.0584113746881485,
-0.052874382585287094,
-0.003736007958650589,
-0.011502907611429691,
-0.03285152465105057,
0.006136508658528328,
0.004311153199523687,
0.04199536144733429,
-0.047727320343256,
-0.034840162843465805,
0.02975158765912056,
-0.07556825131177902,
0.022576892748475075,
-0.026456687599420547,
0.0532253198325634,
-0.005356650799512863,
-0.0424632765352726,
-0.048117246478796005,
0.023785673081874847,
0.02446804940700531,
0.023064304143190384,
0.0692514032125473,
-0.022537900134921074,
0.041761405766010284,
0.04090356081724167,
-0.006531312130391598,
-0.0092705637216568,
-0.009787219576537609,
0.015606910921633244,
-0.07603617012500763,
0.04144946113228798,
0.08328884840011597,
0.016406266018748283,
0.06620995700359344,
-0.03370936959981918,
0.09194527566432953,
0.010372113436460495,
0.0007835137657821178,
0.07135701924562454,
-0.0318572036921978,
0.01596759632229805,
0.008807523176074028,
-0.022108979523181915,
0.06511815637350082,
-0.020100843161344528,
-0.0007944804965518415,
-0.005785572808235884,
0.04932602867484093,
0.00033996941056102514,
-0.03717973828315735,
0.028952233493328094,
0.002412686124444008,
-0.045426737517118454,
-0.011824599467217922,
-0.04733739048242569,
0.00833960808813572,
0.008558942936360836,
0.00018841495329979807,
0.005356650799512863,
0.06219368800520897,
0.021914014592766762,
0.030999362468719482,
0.013403812423348427,
0.0032973377965390682,
0.0008980553830042481,
-0.06819859892129898,
-0.012740932404994965,
0.0027587481308728456,
0.026710141450166702,
-0.03823254629969597,
0.005190930794924498,
-0.011707620695233345,
-0.023590710014104843,
-0.025364886969327927,
-0.03548354655504227,
0.030960367992520332,
0.0036799556110054255,
-0.037530671805143356,
0.025871794670820236,
-0.02873777225613594,
0.04472486674785614,
-0.013715755194425583,
0.06231066584587097,
0.048156239092350006,
0.009104844182729721,
-0.01066455990076065,
-0.007740091998130083,
0.0033801975660026073,
0.07131803035736084,
-0.02187502197921276,
0.02823086455464363,
-0.033787354826927185,
-0.03127231076359749,
-0.00822750385850668,
0.04991092160344124,
0.004376953933387995,
0.0800914317369461,
-0.05969814211130142,
-0.014700326137244701,
-0.008159265853464603,
-0.0007500041974708438,
-0.02612524852156639,
0.029517631977796555,
0.06504017114639282,
-0.015431443229317665,
0.08453662693500519,
0.004744949284940958,
0.05353726074099541,
-0.015733638778328896,
0.025949779897928238,
-0.0017705217469483614,
-0.026261722669005394,
0.009246192872524261,
-0.009636122733354568,
0.02017883025109768,
-0.024214595556259155,
0.049092069268226624,
-0.014690577983856201,
0.056734681129455566,
-0.029673602432012558,
0.022147972136735916,
0.04215133190155029,
-0.034859661012887955,
-0.016123566776514053,
0.013783993199467659,
-0.028893744572997093,
-0.02286934107542038,
0.014212914742529392,
-0.0002982348087243736,
-0.047883290797472,
-0.003175484947860241,
0.017741773277521133,
-0.0077888332307338715,
0.02704158052802086,
0.03281253203749657,
-0.01700090803205967,
-0.027996907010674477,
-0.027996907010674477,
0.033319439738988876,
0.03634139150381088,
-0.040084708482027054,
0.025306396186351776,
-0.06078994274139404,
0.029459141194820404,
0.012838414870202541,
0.010528084821999073,
-0.0034167536068707705,
0.04195636883378029,
-0.09155534952878952,
-0.02230394259095192,
-0.010206393897533417,
-0.058840297162532806,
0.05997109040617943,
-0.011775857768952847,
0.015548422001302242,
0.02294732630252838,
0.018853070214390755,
-0.03495714068412781,
0.0065654306672513485,
-0.06207671016454697,
-0.0016450133407488465,
-0.039031900465488434,
0.014417627826333046,
0.004208797123283148,
0.01667921617627144,
0.07377458363771439,
-0.027801943942904472,
0.0018460705177858472,
-0.013871726579964161,
0.03140878677368164
] |
725,858 | osqp.interface | codegen |
Generate embeddable C code for the problem
| def codegen(self, folder, project_type='', parameters='vectors',
python_ext_name='emosqp', force_rewrite=False, compile_python_ext=True,
FLOAT=False, LONG=True):
"""
Generate embeddable C code for the problem
"""
# Check parameters arguments
if parameters == 'vectors':
embedded = 1
elif parameters == 'matrices':
embedded = 2
else:
raise ValueError("Unknown value of 'parameters' argument.")
# Set float and long flags
if FLOAT:
float_flag = 'ON'
else:
float_flag = 'OFF'
if LONG:
long_flag = 'ON'
else:
long_flag = 'OFF'
# Check project_type argument
expectedProject = ('', 'Makefile', 'MinGW Makefiles',
'Unix Makefiles', 'CodeBlocks', 'Xcode')
if project_type not in expectedProject:
raise ValueError("Unknown value of 'project_type' argument.")
if project_type == 'Makefile':
if system() == 'Windows':
project_type = 'MinGW Makefiles'
elif system() == 'Linux' or system() == 'Darwin':
project_type = 'Unix Makefiles'
# Convert workspace to Python
sys.stdout.write("Getting workspace from OSQP object... \t\t\t\t")
sys.stdout.flush()
work = self._model._get_workspace()
print("[done]")
# Generate code with codegen module
cg.codegen(work, folder, python_ext_name, project_type, compile_python_ext,
embedded, force_rewrite, float_flag, long_flag)
| (self, folder, project_type='', parameters='vectors', python_ext_name='emosqp', force_rewrite=False, compile_python_ext=True, FLOAT=False, LONG=True) | [
0.037920236587524414,
-0.030461397022008896,
-0.05888368934392929,
0.0049502006731927395,
-0.01958616077899933,
-0.04103255644440651,
-0.09852106869220734,
-0.030783362686634064,
-0.01933574303984642,
-0.0065287197940051556,
0.031337857246398926,
-0.0003795377560891211,
-0.031910236924886703,
0.05931297317147255,
-0.01464043091982603,
0.004757916554808617,
0.021732589229941368,
-0.04360827058553696,
0.058275531977415085,
-0.005728281103074551,
-0.02818976156413555,
0.04453838989138603,
0.02180413529276848,
0.0785592794418335,
0.03695434331893921,
0.005719337612390518,
0.045790474861860275,
-0.00015832704957574606,
0.0010665066074579954,
-0.06442862749099731,
-0.03291190415620804,
0.003255416639149189,
0.005661204922944307,
-0.021857796236872673,
0.031910236924886703,
0.007682425435632467,
-0.003588560037314892,
0.029137765988707542,
-0.04639862850308418,
-0.053696487098932266,
0.01467620488256216,
-0.022662706673145294,
0.02781413495540619,
-0.05076303333044052,
-0.01379974652081728,
0.005231919232755899,
-0.024344075471162796,
0.03309077396988869,
0.0062648882158100605,
0.058311305940151215,
0.041569165885448456,
-0.05562826991081238,
0.010839464142918587,
-0.04718565195798874,
-0.03332330286502838,
0.02759949304163456,
0.003964185249060392,
-0.031176874414086342,
0.0662173181772232,
-0.01726086251437664,
-0.04124720022082329,
0.003923939540982246,
0.010132931172847748,
0.0411398783326149,
0.02879791520535946,
0.04843773692846298,
-0.01645595207810402,
-0.030747588723897934,
0.005272164940834045,
0.07383713871240616,
-0.03731208294630051,
-0.03251839056611061,
0.016482781618833542,
-0.0034611159935593605,
0.067898690700531,
-0.013996502384543419,
-0.04425220191478729,
-0.04468148574233055,
-0.004091629292815924,
-0.04951095208525658,
0.028118213638663292,
-0.00015245791291818023,
-0.029191426932811737,
-0.06886458396911621,
0.012637097388505936,
0.04464571177959442,
0.009336964227259159,
0.022233420982956886,
0.008456033654510975,
-0.0448603555560112,
-0.012574493885040283,
-0.013137931004166603,
-0.0092654163017869,
0.047901127487421036,
-0.006868571043014526,
-0.02341395802795887,
0.02214398793876171,
-0.06342696398496628,
-0.022948898375034332,
0.01168909203261137,
0.062031783163547516,
0.01874547451734543,
0.007360461167991161,
-0.027331190183758736,
0.05151428282260895,
-0.0035438428167253733,
-0.025953898206353188,
0.004453839268535376,
0.0411398783326149,
-0.04024553298950195,
-0.023914789780974388,
0.032679375261068344,
-0.006855155806988478,
-0.0717264860868454,
-0.022304968908429146,
0.03625675290822983,
-0.04689946398139,
0.0338241346180439,
-0.005044106859713793,
0.0018624739022925496,
-0.01842351071536541,
0.005285580176860094,
-0.022090326994657516,
-0.006077075842767954,
0.05165737867355347,
0.022895237430930138,
0.024451397359371185,
0.028672706335783005,
0.013298912905156612,
-0.0672905296087265,
-0.03543395549058914,
-0.024737589061260223,
0.021392736583948135,
0.03870726004242897,
-0.01232407707720995,
0.015391681343317032,
-0.046255532652139664,
-0.06263993680477142,
0.018226755782961845,
0.03065815381705761,
0.012815967202186584,
0.011438675224781036,
0.0387430340051651,
-0.00009187999239657074,
0.012368794530630112,
0.035916902124881744,
0.07240618765354156,
-0.048187319189310074,
-0.04650595039129257,
0.01642017811536789,
0.012172037735581398,
-0.023646486923098564,
0.0317850299179554,
0.0019664415158331394,
-0.029513392597436905,
0.0047758035361766815,
0.06618154793977737,
-0.02486279606819153,
-0.06725475937128067,
-0.011823243461549282,
-0.026383183896541595,
0.025470951572060585,
0.0007529268623329699,
0.03716898709535599,
0.027993004769086838,
-0.021732589229941368,
-0.013862350955605507,
-0.004807105287909508,
-0.037884462624788284,
-0.010043496266007423,
-0.004968087654560804,
-0.060207318514585495,
-0.016464894637465477,
-0.018155207857489586,
0.012207811698317528,
0.02323508821427822,
-0.008259277790784836,
-0.001974266953766346,
0.03255416452884674,
0.0005830012960359454,
-0.029209313914179802,
0.041783809661865234,
-0.014318467117846012,
0.06339118629693985,
0.02271636761724949,
0.02520264871418476,
-0.026204314082860947,
0.007525914814323187,
0.07984714210033417,
-0.07355094701051712,
-0.031105326488614082,
0.03527297452092171,
0.0035729091614484787,
0.016929954290390015,
-0.018709702417254448,
0.0035997394006699324,
0.04364404454827309,
0.028672706335783005,
-0.017386071383953094,
0.08063416182994843,
0.024970117956399918,
0.041855353862047195,
0.041712261736392975,
0.018083659932017326,
-0.042069997638463974,
-0.03037196397781372,
0.026079105213284492,
-0.006099434103816748,
-0.0037450704257935286,
0.004757916554808617,
0.08163583278656006,
0.021213868632912636,
-0.003201755927875638,
-0.0039462982676923275,
0.03877880796790123,
0.04539696127176285,
-0.031373631209135056,
0.023002559319138527,
-0.015078660100698471,
0.01842351071536541,
-0.008058050647377968,
0.024952230975031853,
-0.07151184231042862,
-0.0383852943778038,
0.016545386984944344,
-0.019765028730034828,
0.02180413529276848,
-0.02924508787691593,
-0.024039998650550842,
-0.0628545805811882,
-0.0034029835369437933,
-0.05748850852251053,
-0.029209313914179802,
-0.007141346577554941,
0.03702589124441147,
-0.009363794699311256,
-0.02436196245253086,
0.04435952380299568,
-0.05727386847138405,
-0.025470951572060585,
-0.0011391722364351153,
-0.03062237985432148,
-0.0024549774825572968,
0.02978169545531273,
0.006873042788356543,
0.009551607072353363,
0.018119433894753456,
0.018709702417254448,
0.016429120674729347,
0.03055083192884922,
0.01828041672706604,
-0.07455261796712875,
-0.03935118764638901,
0.000987133476883173,
0.02217976190149784,
0.020444732159376144,
0.008353183977305889,
-0.07626976072788239,
0.01835196278989315,
-0.011018333025276661,
-0.0068238540552556515,
-0.03709743916988373,
0.0036243340000510216,
0.029334522783756256,
0.03935118764638901,
-0.03849261626601219,
-0.031552497297525406,
0.04332208260893822,
0.034646932035684586,
0.015042886137962341,
-0.009363794699311256,
0.08070570975542068,
-0.04310743883252144,
0.02851172536611557,
0.025327855721116066,
-0.00031749255140312016,
-0.03600633889436722,
0.07169070839881897,
-0.019836576655507088,
-0.029924791306257248,
0.005491279531270266,
0.0065018897876143456,
0.0011827715206891298,
0.002530996920540929,
-0.06299767643213272,
-0.0017383834347128868,
-0.03174925595521927,
-0.016965728253126144,
0.007861294783651829,
-0.013996502384543419,
0.007360461167991161,
0.08986380696296692,
-0.024344075471162796,
-0.029066219925880432,
0.08757428079843521,
0.027688927948474884,
-0.014068050310015678,
0.013933897949755192,
0.0704028531908989,
-0.007561688777059317,
-0.014479449018836021,
0.06331963837146759,
0.0734078511595726,
-0.027134433388710022,
0.014738809317350388,
0.02742062322795391,
0.012350907549262047,
-0.08278059214353561,
-0.01372819859534502,
0.05559249594807625,
-0.0350225567817688,
0.011537052690982819,
0.028994672000408173,
0.03716898709535599,
0.02429041638970375,
-0.017743809148669243,
0.07755761593580246,
-0.02636529691517353,
0.03255416452884674,
0.0008965810411609709,
0.0039798361249268055,
-0.01684051938354969,
0.03906499966979027,
-0.011063050478696823,
0.03539818152785301,
-0.025953898206353188,
-0.03511199355125427,
-0.031445179134607315,
0.03877880796790123,
-0.08821821212768555,
0.048008449375629425,
0.02931663580238819,
0.03699011728167534,
0.005786413326859474,
0.07913166284561157,
-0.04364404454827309,
0.04435952380299568,
-0.0367039255797863,
0.005464449059218168,
-0.0038434485904872417,
0.11304523050785065,
-0.00442030094563961,
-0.021911457180976868,
0.04496767744421959,
-0.02228708192706108,
0.007414121646434069,
-0.005535996984690428,
-0.03902922570705414,
-0.03350217267870903,
-0.016008779406547546,
-0.0048026335425674915,
0.010624821297824383,
0.012368794530630112,
0.03194601088762283,
0.018817022442817688,
-0.01527541596442461,
0.021893570199608803,
-0.031015891581773758,
-0.007977559231221676,
0.017135653644800186,
0.026061220094561577,
0.03673969954252243,
0.011671205051243305,
0.046255532652139664,
0.004055855330079794,
-0.06682547181844711,
-0.04421642795205116,
-0.037956010550260544,
0.052301306277513504,
0.027921456843614578,
0.009408511221408844,
-0.031141100451350212,
-0.0004631031188182533,
-0.03062237985432148,
-0.018834909424185753,
0.03631041571497917,
-0.047758035361766815,
0.01423797570168972,
-0.050011783838272095,
-0.016849463805556297,
0.01831618882715702,
-0.03677547350525856,
0.037956010550260544,
-0.053660713136196136,
0.02527419477701187,
0.0037249478045850992,
0.08170738071203232,
0.013343630358576775,
-0.05151428282260895,
-0.0045052641071379185,
-0.022519612684845924,
0.006255944725126028,
0.0008949041948653758,
-0.006774664856493473,
-0.007476726081222296,
-0.012976949103176594,
-0.0265083909034729,
0.07491035759449005,
-0.0989503562450409,
-0.04632708057761192,
-0.029441844671964645,
-0.060028448700904846,
-0.007248668000102043,
0.016008779406547546,
-0.0071279313415288925,
-0.09945118427276611,
0.04053172469139099,
0.010150818154215813,
-0.008657261729240417,
0.05498434230685234,
-0.0058534895069897175,
0.018307246267795563,
-0.04711410403251648,
0.008017804473638535,
-0.01758282631635666,
-0.014980281703174114,
0.02675880864262581,
-0.019836576655507088,
0.028350742533802986,
0.03867148607969284,
0.016849463805556297,
0.02570348046720028,
0.09830642491579056,
0.052372854202985764,
-0.03491523489356041,
0.04875969886779785,
0.041604939848184586,
0.017412900924682617,
-0.0435367226600647,
0.0024348548613488674,
-0.0018401152919977903,
0.015588437207043171,
-0.017877960577607155,
0.005495751276612282,
0.009614210575819016,
-0.020856130868196487,
0.0005715424777008593,
-0.037562496960163116,
0.01800316944718361,
0.019568273797631264,
0.06442862749099731,
-0.03870726004242897,
-0.05036952346563339,
-0.019908124580979347,
-0.02829708158969879,
-0.0037137684412300587,
-0.04650595039129257,
0.0022213298361748457,
-0.04711410403251648,
0.023646486923098564,
0.04493190348148346,
0.09186714142560959,
0.013227365911006927,
-0.0570949986577034,
0.10038130730390549,
-0.05344606935977936,
-0.07108255475759506,
-0.029119879007339478,
-0.0087556391954422,
-0.03146306425333023,
0.016303913667798042,
-0.030049998313188553,
0.07144029438495636,
-0.04850928485393524,
0.047865353524684906,
0.02024797536432743,
-0.013379404321312904,
-0.0024124961346387863,
-0.016196591779589653,
-0.03287613019347191,
0.04096100851893425,
-0.04482458159327507,
-0.010043496266007423,
-0.016885237768292427,
0.04325053468346596,
-0.03885035589337349,
-0.0948721393942833,
0.018888570368289948,
-0.02418309450149536,
-0.03845684230327606,
-0.015588437207043171,
-0.01691206730902195,
0.008889791555702686,
0.08163583278656006,
-0.015633154660463333,
0.014783525839447975,
0.08070570975542068,
-0.04099678248167038,
0.024988004937767982,
-0.04643440246582031,
0.0008250334649346769,
0.05863327160477638,
0.01915687508881092,
-0.015588437207043171,
0.0018524124752730131,
0.008938980288803577,
-0.0346648208796978,
-0.03593479096889496,
-0.058275531977415085,
-0.025828689336776733,
0.0302288681268692,
-0.03511199355125427,
-0.04897434264421463,
-0.04139029607176781,
0.05494856834411621,
-0.030980117619037628,
0.02928086183965206,
-0.035916902124881744,
-0.06482213735580444,
-0.010410178452730179,
-0.0663246437907219,
-0.032929789274930954,
0.035881128162145615,
-0.04672059416770935,
-0.004927841946482658,
0.03652505949139595,
0.022090326994657516,
0.025828689336776733,
-0.0350225567817688,
0.004936785437166691,
0.010866294614970684,
-0.09201023727655411,
0.004418065305799246,
0.045754700899124146,
0.0018300538649782538,
0.032607827335596085,
-0.03266148641705513,
0.0032196426764130592,
0.047936901450157166,
0.053911127150058746,
-0.034503836184740067,
0.01915687508881092,
-0.018021056428551674,
0.05351761728525162,
-0.004371112212538719,
-0.03425342217087746,
0.05029797554016113,
0.019138988107442856,
0.054018449038267136,
-0.01084840763360262,
0.0015237405896186829,
0.04031708091497421,
-0.03684702143073082,
-0.011528109200298786,
-0.03434285521507263,
0.013844463974237442,
0.03146306425333023,
0.006403511855751276,
0.01543639786541462,
-0.030354076996445656,
-0.04357249662280083,
0.015794135630130768,
0.007159233558923006,
0.0400666669011116,
0.05466238036751747,
0.026383183896541595,
0.07147607207298279,
0.012744419276714325,
0.00045164432958699763,
0.012136264704167843,
-0.021571606397628784,
0.02781413495540619,
-0.017484448850154877,
-0.028565386310219765,
-0.030014224350452423,
0.06174559146165848,
0.010204479098320007,
-0.0064392853528261185,
0.027009224519133568,
-0.02010487951338291,
0.046040892601013184,
-0.021500058472156525,
0.04242773726582527,
-0.053660713136196136,
0.012959062121808529,
0.007937313988804817,
-0.04865238070487976,
0.0435367226600647,
-0.037884462624788284,
-0.007816577330231667,
-0.025309968739748,
0.012028942815959454,
-0.014506279490888119,
0.010240252129733562,
0.029191426932811737,
-0.04339363053441048,
0.003961949143558741,
-0.01802999898791313,
0.052086666226387024,
0.022448064759373665,
0.013343630358576775,
0.05573559179902077,
-0.07262083142995834,
-0.02116020768880844,
0.010222366079688072,
0.03870726004242897,
-0.06138785555958748,
0.027295416221022606,
-0.012028942815959454,
-0.019926011562347412,
-0.06528720259666443,
0.013450952246785164,
0.028171874582767487,
0.015552663244307041,
0.003957477398216724,
-0.012207811698317528,
-0.02228708192706108,
0.009283303283154964,
0.025685593485832214,
0.04500345140695572,
0.028565386310219765,
0.007445423863828182,
-0.024701815098524094,
-0.03527297452092171,
-0.04840196296572685,
-0.010195535607635975,
-0.0435367226600647,
0.027366962283849716,
0.033001337200403214,
-0.06471481919288635,
-0.02836862951517105,
0.01915687508881092,
-0.02330663613975048,
-0.06389202177524567,
-0.006671815179288387,
0.047865353524684906,
0.018924344331026077,
-0.04224886745214462,
0.0263295229524374,
0.047614939510822296,
0.0346648208796978,
0.0004712081281468272,
0.04117565229535103,
-0.0367039255797863,
0.01786007359623909,
-0.03917232155799866,
-0.01999755948781967,
0.0070876856334507465,
-0.0017931620823219419,
0.013513555750250816,
0.03258993849158287,
0.0648936852812767,
-0.006121792830526829,
-0.07333630323410034,
0.022412290796637535,
0.00542420381680131,
0.015212811529636383,
-0.04060327261686325,
0.009462172165513039,
-0.040173985064029694,
-0.03731208294630051,
0.0191926471889019,
0.007360461167991161,
-0.023091992363333702,
0.05276636779308319,
0.01312898751348257,
-0.025435177609324455,
-0.02421886846423149,
0.0567372590303421,
-0.006671815179288387,
0.04643440246582031,
-0.02996056340634823,
0.03881458193063736,
-0.05162160471081734,
-0.07991869002580643,
-0.006090490613132715,
0.06850684434175491,
-0.003796495497226715,
0.04106833040714264,
-0.007360461167991161,
0.031141100451350212,
-0.022948898375034332,
0.028958898037672043,
-0.025095326825976372,
-0.014828243292868137,
-0.006001056171953678,
0.017395013943314552,
0.0009921642486006021,
-0.03477214276790619,
-0.02414732053875923,
-0.01765437424182892,
0.02742062322795391,
-0.0224301777780056,
0.023324523121118546,
-0.016706367954611778,
-0.0648936852812767,
0.02548883855342865,
0.026007559150457382,
0.012842796742916107,
-0.06324809044599533,
-0.06353428214788437,
0.051836248487234116,
0.0391007736325264,
-0.04647017642855644,
0.015955118462443352,
0.013665595091879368,
0.002086060121655464,
-0.05262327194213867,
-0.019765028730034828,
0.046148210763931274,
0.05659416317939758,
-0.012467171996831894,
-0.02963859960436821,
0.05112077295780182,
-0.012368794530630112,
0.05534208193421364,
0.0100166667252779,
-0.023968450725078583,
-0.07194112986326218,
-0.058168210089206696,
0.021965118125081062,
0.03462904691696167,
-0.0035729091614484787,
-0.022126100957393646,
-0.007682425435632467,
-0.08134964108467102,
-0.07033130526542664,
0.09887880831956863,
0.027474284172058105,
0.001528212334960699,
-0.03752672299742699,
0.05902678519487381,
0.0275279451161623,
-0.04747184365987778,
-0.01427374966442585,
0.011903734877705574,
-0.025828689336776733,
-0.05534208193421364,
0.031230535358190536,
0.023932676762342453,
0.015329076908528805,
-0.01376397255808115,
0.029656486585736275,
-0.052086666226387024,
0.009900401346385479,
-0.031051665544509888,
0.007208422292023897,
-0.012744419276714325,
-0.019103214144706726,
-0.029584938660264015,
-0.04328630864620209,
0.07433797419071198,
-0.018763361498713493,
-0.021321190521121025,
0.02377169579267502,
0.008201145566999912,
0.004717670846730471,
0.009489002637565136,
0.005383958108723164,
0.02108865976333618,
0.03323386609554291,
0.023968450725078583,
0.04453838989138603,
-0.026526277884840965,
0.027993004769086838,
-0.025041665881872177,
-0.011232975870370865,
0.006139679811894894,
-0.014792469330132008,
-0.04500345140695572,
-0.032321635633707047,
0.008080408908426762,
0.021571606397628784,
0.026383183896541595,
0.0028082439675927162,
0.009082075208425522,
-0.02672303467988968,
-0.0056075444445014
] |
725,859 | osqp.interface | derivative_iterative_refinement | null | def derivative_iterative_refinement(self, rhs, max_iter=20, tol=1e-12):
M = self._derivative_cache['M']
# Prefactor
solver = self._derivative_cache['solver']
sol = solver.solve(rhs)
for k in range(max_iter):
delta_sol = solver.solve(rhs - M @ sol)
sol = sol + delta_sol
if np.linalg.norm(M @ sol - rhs) < tol:
break
if k == max_iter - 1:
warn("max_iter iterative refinement reached.")
return sol
| (self, rhs, max_iter=20, tol=1e-12) | [
0.07105076313018799,
-0.013117901049554348,
-0.04017017036676407,
0.022353049367666245,
-0.055156875401735306,
-0.02910250797867775,
0.024965742602944374,
-0.04448837414383888,
-0.008636405691504478,
0.014097661711275578,
-0.005724340211600065,
0.0036423495039343834,
-0.07613100111484528,
-0.02126442641019821,
-0.026616821065545082,
0.01589388959109783,
-0.03269496187567711,
0.035525381565093994,
-0.05660837143659592,
0.03057214990258217,
-0.009334937669336796,
-0.02208089269697666,
-0.04975004866719246,
-0.0013528402196243405,
-0.015966463834047318,
0.01999436691403389,
0.015231643803417683,
0.019286762923002243,
0.0032386519014835358,
0.04481495916843414,
-0.02648981474339962,
0.020048798993229866,
-0.02650795876979828,
-0.026036221534013748,
0.009248755872249603,
-0.032096222043037415,
-0.0021749769803136587,
0.005252603441476822,
-0.03563424199819565,
-0.039262983947992325,
-0.020121373236179352,
0.024766162037849426,
0.03831951320171356,
0.0012870692880824208,
-0.009325866587460041,
-0.004730971995741129,
-0.017717331647872925,
0.033547718077898026,
0.032767537981271744,
0.022806642577052116,
0.015131852589547634,
-0.07344572991132736,
0.029537957161664963,
-0.02126442641019821,
0.037448614835739136,
0.05530202388763428,
0.026689395308494568,
0.03362029045820236,
0.029374664649367332,
-0.06455531716346741,
-0.0067766751162707806,
-0.11684548109769821,
0.014886912889778614,
0.015258858911693096,
-0.02081083320081234,
-0.04205711558461189,
0.009398440830409527,
-0.017817120999097824,
0.021191852167248726,
0.04336346313357353,
-0.04971376061439514,
-0.005565582774579525,
0.0009349680040031672,
-0.030826160684227943,
-0.0069399685598909855,
-0.008976600132882595,
0.04194825515151024,
-0.07859854400157928,
0.0028599021025002003,
-0.008858665823936462,
-0.01136703323572874,
-0.03817436471581459,
-0.010922512970864773,
0.010332842357456684,
-0.06303124129772186,
-0.031751491129398346,
0.00601010350510478,
-0.07184908539056778,
0.07750992476940155,
-0.013507991097867489,
0.004043778870254755,
0.0006684822728857398,
0.04583100974559784,
-0.024602869525551796,
-0.029610533267259598,
0.027687299996614456,
-0.01544029638171196,
-0.006209684070199728,
0.03089873492717743,
-0.03207807615399361,
0.011267242953181267,
0.09732285141944885,
0.0019901380874216557,
0.021028557792305946,
0.0549391508102417,
-0.0334932878613472,
0.016166044399142265,
-0.08164668828248978,
-0.007570462301373482,
-0.05624549835920334,
-0.0263446643948555,
0.06767603009939194,
-0.030753586441278458,
0.03231394663453102,
-0.05588262155652046,
0.04191196709871292,
-0.04082334414124489,
-0.02489316835999489,
0.09529075771570206,
0.022334905341267586,
-0.004216144327074289,
-0.014360745437443256,
-0.047681666910648346,
-0.017018798738718033,
0.01625676266849041,
0.012401225045323372,
0.036486998200416565,
0.01717302016913891,
0.025491910055279732,
-0.014487751759588718,
0.06644225865602493,
-0.0036310097202658653,
0.005053022876381874,
-0.022498197853565216,
0.026272090151906013,
0.01072293147444725,
-0.032731249928474426,
-0.021572869271039963,
-0.008727123960852623,
-0.04920573905110359,
-0.02939280867576599,
0.013526135124266148,
-0.0320599339902401,
0.07072417438030243,
-0.03198735788464546,
-0.006586166098713875,
-0.03476334735751152,
0.0923151895403862,
0.027197418734431267,
-0.01968592405319214,
-0.03623298555612564,
0.031170891597867012,
-0.00581505848094821,
0.0227703545242548,
0.002177244983613491,
0.022226043045520782,
-0.0016703552100807428,
0.027378857135772705,
-0.015939248725771904,
-0.029011789709329605,
-0.034200891852378845,
-0.035833824425935745,
-0.035833824425935745,
0.0009695544140413404,
0.03202364593744278,
-0.03351143002510071,
-0.005139205604791641,
-0.02814089134335518,
-0.04144022986292839,
0.12671566009521484,
-0.014832481741905212,
-0.02714298851788044,
-0.0396258607506752,
-0.03966214880347252,
0.017517751082777977,
0.04401663690805435,
0.04746394231915474,
-0.01741795986890793,
-0.007679324597120285,
0.012519159354269505,
0.024475863203406334,
-0.030608436092734337,
0.022062750533223152,
-0.04601244628429413,
0.00829167477786541,
0.011466823518276215,
-0.02551005408167839,
0.014560326002538204,
0.025637060403823853,
-0.013653140515089035,
-0.012129069305956364,
-0.03331184759736061,
0.036486998200416565,
-0.018978320062160492,
-0.067385733127594,
-0.0040641906671226025,
0.0702524408698082,
0.07910656929016113,
0.08708979934453964,
0.019069038331508636,
-0.06549879163503647,
-0.02179059386253357,
-0.031116459518671036,
-0.014351673424243927,
-0.033565860241651535,
0.005991959944367409,
-0.047681666910648346,
-0.033692866563797,
0.007801794912666082,
0.03151562064886093,
-0.061362024396657944,
0.0061688609421253204,
0.023804545402526855,
-0.01594831980764866,
0.027197418734431267,
0.01934119313955307,
0.0516732819378376,
-0.04419807344675064,
0.04924202710390091,
0.006790283136069775,
-0.022153468802571297,
-0.06695028394460678,
0.007316450588405132,
-0.011865985579788685,
-0.010459847748279572,
-0.05287076532840729,
-0.003088966477662325,
0.04158538207411766,
-0.006345761939883232,
-0.041222505271434784,
-0.012437512166798115,
0.010967872105538845,
0.04695591703057289,
-0.05853160470724106,
0.053052205592393875,
0.012900176458060741,
-0.06582537293434143,
0.016946224495768547,
0.03813807666301727,
0.04779052734375,
-0.03200550377368927,
-0.03596083074808121,
-0.0198129303753376,
0.07555039972066879,
-0.032440949231386185,
0.017780834808945656,
0.028340473771095276,
-0.008350641466677189,
0.0647367537021637,
0.035035502165555954,
0.015549158677458763,
-0.07054273784160614,
-0.07569555193185806,
0.0028916536830365658,
0.02050239033997059,
-0.028322329744696617,
0.018043918535113335,
0.043327175080776215,
0.042891725897789,
0.014369817450642586,
0.008577438071370125,
0.02745143137872219,
-0.011394249275326729,
0.00768386060371995,
-0.07692932337522507,
0.04858885332942009,
-0.04735507816076279,
-0.036795441061258316,
0.023641252890229225,
0.03770262748003006,
0.05787843093276024,
-0.015140924602746964,
-0.05170956999063492,
0.0012031546793878078,
-0.04546813294291496,
0.052689328789711,
0.013027182780206203,
0.02922951430082321,
-0.03140676021575928,
-0.05541088804602623,
-0.023115085437893867,
-0.06887351721525192,
-0.028576340526342392,
-0.0009916670387610793,
-0.06568022817373276,
0.05835016816854477,
-0.020720114931464195,
-0.003832858521491289,
0.01819813996553421,
0.02046610414981842,
0.03262238949537277,
-0.004222948104143143,
0.06509962677955627,
0.01868801936507225,
0.05838645622134209,
-0.01016047690063715,
0.0030753586906939745,
-0.03120717965066433,
0.041984543204307556,
0.0461575947701931,
0.008305282332003117,
-0.006395657081156969,
-0.07112333923578262,
0.014079517684876919,
-0.014369817450642586,
0.005397753324359655,
-0.011394249275326729,
0.017753619700670242,
0.008799699135124683,
0.018978320062160492,
0.017635684460401535,
0.004005223512649536,
-0.017635684460401535,
0.0038510020822286606,
0.027886880561709404,
-0.016801074147224426,
-0.009021959267556667,
-0.06847435981035233,
-0.009725027717649937,
0.026453526690602303,
0.011539398692548275,
0.04775424301624298,
-0.019958078861236572,
-0.02810460515320301,
-0.020266521722078323,
-0.028213467448949814,
0.026689395308494568,
0.03311226889491081,
0.01785340905189514,
-0.016755715012550354,
0.0068900734186172485,
-0.02924765832722187,
0.019413767382502556,
-0.003610597923398018,
0.07540525496006012,
0.013680356554687023,
0.0653536394238472,
-0.061362024396657944,
0.007275626994669437,
-0.017336314544081688,
0.05591890960931778,
0.050802383571863174,
-0.005538367200642824,
-0.003302155062556267,
-0.006549878977239132,
0.02924765832722187,
0.03806550055742264,
0.0016397376311942935,
0.006159788928925991,
-0.014306314289569855,
-0.06629711389541626,
-0.03392873704433441,
-0.005288891028612852,
0.010468919761478901,
-0.06266836822032928,
0.033711012452840805,
-0.03559795767068863,
-0.009280506521463394,
-0.006091750226914883,
-0.029701251536607742,
-0.0571889691054821,
0.024820594117045403,
-0.003342978423461318,
0.056789807975292206,
-0.014360745437443256,
-0.06241435930132866,
-0.04659304395318031,
-0.011412392370402813,
0.020520534366369247,
-0.028376759961247444,
-0.03864609822630882,
-0.001530875451862812,
0.03173334524035454,
-0.021373288705945015,
-0.01964963600039482,
0.0006100821774452925,
-0.04597615823149681,
0.041839390993118286,
0.032440949231386185,
0.026526102796196938,
0.06419244408607483,
-0.04053304344415665,
-0.017018798738718033,
-0.017254667356610298,
0.03639627993106842,
-0.04278286546468735,
0.050802383571863174,
-0.019069038331508636,
0.09412956237792969,
-0.022643348202109337,
0.020393528044223785,
-0.03463634103536606,
-0.002370022004470229,
0.04405292496085167,
-0.04042418301105499,
-0.0247117318212986,
0.03937184810638428,
0.0056925886310637,
-0.060200825333595276,
0.045250408351421356,
-0.027179274708032608,
0.07634872943162918,
0.027396999299526215,
0.03122532181441784,
-0.007184908725321293,
-0.016383768990635872,
0.030154842883348465,
0.04779052734375,
-0.009334937669336796,
0.07620357722043991,
-0.06415615230798721,
0.006341226398944855,
0.012945536524057388,
0.019740354269742966,
-0.023695683106780052,
0.035525381565093994,
0.009121749550104141,
-0.0365595743060112,
-0.005021271295845509,
0.001710044569335878,
0.05591890960931778,
-0.06553507596254349,
0.03460005298256874,
0.006472768262028694,
-0.06934525817632675,
-0.025310473516583443,
-0.02696155197918415,
-0.04750023037195206,
-0.10262081772089005,
-0.006445552688091993,
-0.04238370433449745,
-0.0307354424148798,
0.02044796012341976,
-0.017463319003582,
0.0044247969053685665,
-0.018615445122122765,
-0.04430693760514259,
0.026126939803361893,
0.014678260311484337,
-0.028975503519177437,
0.017699187621474266,
-0.022498197853565216,
-0.025872929021716118,
-0.015594517812132835,
-0.016166044399142265,
-0.03167891502380371,
0.09891949594020844,
-0.027578437700867653,
-0.043000590056180954,
0.03131604194641113,
-0.0018880796851590276,
-0.030318137258291245,
-0.0026580533012747765,
0.02289736084640026,
0.0002092196373268962,
-0.03447304666042328,
0.052253879606723785,
-0.0015932443784549832,
-0.02505646087229252,
0.025872929021716118,
0.008718051947653294,
0.014968560077250004,
0.07152249664068222,
-0.008028591051697731,
-0.03951699659228325,
0.030118556693196297,
0.03423717990517616,
0.017082301899790764,
-0.016283977776765823,
-0.02454843744635582,
0.026126939803361893,
0.006032783072441816,
0.01292739249765873,
-0.04419807344675064,
-0.024439575150609016,
-0.002255489816889167,
-0.033384423702955246,
0.0494234636425972,
0.0353257991373539,
-0.021899456158280373,
-0.023677539080381393,
-0.023441672325134277,
0.015267930924892426,
-0.019214186817407608,
0.012292362749576569,
-0.0745343565940857,
-0.02033909782767296,
-0.023623108863830566,
-0.01195670384913683,
0.004681076854467392,
-0.017200235277414322,
-0.0002942682767752558,
0.03394687920808792,
0.03151562064886093,
0.05149184539914131,
-0.033094123005867004,
0.007620357442647219,
0.029156940057873726,
0.09391183406114578,
-0.03427346423268318,
0.0007830144022591412,
-0.022498197853565216,
-0.03824693709611893,
0.03590640053153038,
-0.015340506099164486,
-0.0012394421501085162,
-0.03157005459070206,
0.010541494935750961,
0.01594831980764866,
0.02033909782767296,
0.03937184810638428,
-0.04470609873533249,
-0.014487751759588718,
0.003318030619993806,
0.03890011087059975,
-0.028630772605538368,
0.012482871301472187,
-0.02273406647145748,
0.004399849567562342,
-0.03639627993106842,
0.008246315643191338,
-0.04829855263233185,
-0.06560765206813812,
-0.05261675640940666,
0.04223855212330818,
-0.010314698331058025,
-0.04017017036676407,
-0.023532390594482422,
0.0373760387301445,
-0.04147651791572571,
0.00853661447763443,
0.022516341879963875,
0.06404729187488556,
0.020085085183382034,
-0.02128257043659687,
-0.01317233219742775,
0.060055676847696304,
-0.07627615332603455,
-0.05072981119155884,
0.018415864557027817,
-0.029465382918715477,
0.0277780182659626,
0.021500295028090477,
-0.04488753527402878,
-0.03483591973781586,
-0.002086526481434703,
-0.020701970905065536,
-0.013907152228057384,
-0.004812618717551231,
0.0009689874132163823,
0.0091398935765028,
0.08193698525428772,
-0.021046701818704605,
0.015512870624661446,
-0.050620947033166885,
0.037920352071523666,
0.00322958012111485,
0.008296211250126362,
0.021554725244641304,
0.014179307967424393,
0.013698499649763107,
-0.031588196754455566,
0.07482465356588364,
-0.011357961222529411,
0.05069352313876152,
0.02598179131746292,
0.069853276014328,
-0.0129183204844594,
-0.013952512294054031,
0.04993148520588875,
-0.004871585872024298,
-0.01195670384913683,
0.013108829967677593,
0.026689395308494568,
0.010060686618089676,
0.023477958515286446,
0.02665310725569725,
-0.09093626588582993,
0.0077745793387293816,
-0.01738167367875576,
0.0023246626369655132,
-0.03572496399283409,
0.06920010596513748,
0.021718019619584084,
0.033094123005867004,
0.041186217218637466,
-0.05316106602549553,
0.0680026188492775,
-0.023006223142147064,
-0.015068350359797478,
-0.022788498550653458,
0.03215065225958824,
-0.05051208660006523,
-0.1055963858962059,
-0.009725027717649937,
0.017000654712319374,
-0.09362153708934784,
0.01543122436851263,
0.05526573583483696,
0.011566614732146263,
-0.025546342134475708,
-0.0455407090485096,
-0.024276282638311386,
0.039589572697877884,
-0.029374664649367332,
0.008808770217001438,
-0.03966214880347252,
-0.05864046514034271,
0.04180310294032097,
-0.00006608987314393744,
-0.025455623865127563,
-0.019105324521660805,
0.06832920759916306,
-0.03882753476500511,
-0.0643375888466835,
0.004971376154571772,
0.01113116554915905,
0.052725616842508316,
0.016882721334695816,
0.03360214829444885,
-0.0182797871530056,
0.018579157069325447,
-0.008727123960852623,
-0.0038895574398338795,
0.005411360878497362,
0.034672629088163376,
0.012301434762775898,
-0.006604310125112534,
-0.012437512166798115,
0.051274120807647705,
-0.03788406401872635,
0.05283448100090027,
-0.007116869557648897,
0.03951699659228325,
-0.015721524134278297,
0.01047799177467823,
0.04387148842215538,
0.0158303864300251,
-0.046411607414484024,
0.03264053165912628,
-0.024294426664710045,
0.06894609332084656,
-0.022534485906362534,
0.04180310294032097,
-0.08708979934453964,
0.03984358534216881,
0.0412587933242321,
0.0025129036512225866,
0.026943407952785492,
0.0030368033330887556,
-0.019069038331508636,
0.01984921656548977,
-0.013371913693845272,
0.009779458865523338,
-0.011965775862336159,
-0.05689867213368416,
0.03608783707022667,
0.03313041105866432,
0.03813807666301727,
0.003719460219144821,
0.052580468356609344,
-0.04082334414124489,
-0.015730595216155052,
-0.07736477255821228,
-0.005846810061484575,
-0.0013641801197081804,
0.005288891028612852,
-0.05301591753959656,
-0.017082301899790764,
-0.038283225148916245,
0.0012757295044139028,
0.0011770731071010232,
-0.04924202710390091,
0.0041254255920648575,
-0.021754305809736252,
-0.021246282383799553,
-0.033239275217056274,
0.022842928767204285,
0.007493351586163044,
0.05312477797269821,
0.05359651520848274,
0.014496822841465473,
-0.036632146686315536,
0.06578908860683441,
0.011430536396801472,
0.03706759586930275,
-0.01008790172636509,
0.07319171726703644,
0.05083867162466049,
-0.035670530050992966,
-0.030154842883348465,
-0.004025635309517384,
0.02846747823059559,
-0.013199548237025738,
0.038573525846004486,
-0.014732691459357738,
-0.020720114931464195,
0.035362087190151215,
0.04470609873533249,
-0.011330746114253998,
0.04394406080245972,
0.06640597432851791,
0.02275221049785614,
0.013689428567886353,
0.06364812701940536,
0.003422357141971588,
-0.021536583080887794,
-0.02081083320081234,
-0.018434008583426476,
-0.030318137258291245,
0.030499573796987534,
0.025945503264665604,
-0.010922512970864773,
-0.04191196709871292,
-0.001962922513484955,
0.0277780182659626,
0.02375011518597603,
-0.03904525935649872,
-0.0032273121178150177,
0.019141612574458122,
0.041984543204307556,
-0.026888975873589516,
-0.007770043332129717,
0.027741730213165283,
-0.044270649552345276,
0.04114993289113045,
0.0013415004359558225,
0.0062913307920098305,
-0.033094123005867004,
0.037920352071523666,
0.004653861280530691,
-0.00568351661786437,
0.029810113832354546,
0.009380297735333443,
-0.04630274325609207,
-0.013589637354016304,
0.010242123156785965,
0.021572869271039963,
-0.013725715689361095,
0.03423717990517616,
0.013526135124266148,
0.023477958515286446,
0.006554414983838797,
0.047863103449344635,
-0.012174428440630436,
0.05490286275744438,
-0.06716801226139069,
-0.007629429455846548,
0.026054365560412407,
-0.03300340473651886,
0.03853723779320717,
-0.01999436691403389,
0.05867675319314003,
0.05022178590297699,
-0.024766162037849426,
0.009362153708934784,
-0.02356867678463459,
-0.05896705389022827,
-0.019450055435299873,
0.020520534366369247,
0.02618137188255787,
0.006032783072441816,
0.06488189846277237,
0.018533797934651375,
-0.06807519495487213,
-0.0014254151610657573,
0.004554070997983217,
0.03142490237951279
] |
725,860 | osqp.interface | setup |
Setup OSQP solver problem of the form
minimize 1/2 x' * P * x + q' * x
subject to l <= A * x <= u
solver settings can be specified as additional keyword arguments
| def setup(self, P=None, q=None, A=None, l=None, u=None, **settings):
"""
Setup OSQP solver problem of the form
minimize 1/2 x' * P * x + q' * x
subject to l <= A * x <= u
solver settings can be specified as additional keyword arguments
"""
# TODO(bart): this will be unnecessary when the derivative will be in C
self._derivative_cache = {'P': P, 'q': q, 'A': A, 'l': l, 'u': u}
unpacked_data, settings = utils.prepare_data(P, q, A, l, u, **settings)
self._model.setup(*unpacked_data, **settings)
| (self, P=None, q=None, A=None, l=None, u=None, **settings) | [
-0.023703651502728462,
0.004844058305025101,
-0.02702428214251995,
0.026476731523871422,
-0.019623514264822006,
0.023685988038778305,
-0.0320405550301075,
-0.11155906319618225,
-0.004835227038711309,
0.01831645704805851,
-0.022679202258586884,
-0.03122805990278721,
0.012708477675914764,
0.08018969744443893,
-0.08372228592634201,
0.05471975728869438,
0.010332813486456871,
-0.006888542324304581,
0.027041945606470108,
0.008606262505054474,
-0.031987566500902176,
-0.0233150664716959,
0.029585406184196472,
0.11304274946451187,
-0.0000325315268128179,
-0.03684487193822861,
-0.028101719915866852,
-0.003764411900192499,
-0.005285631865262985,
-0.0528474859893322,
0.012761466205120087,
0.07566799223423004,
-0.03310032933950424,
0.028366664424538612,
0.039847567677497864,
0.018528413027524948,
0.07093432545661926,
0.0055549913085997105,
0.02946176566183567,
-0.02723623812198639,
-0.024003921076655388,
-0.01807800866663456,
0.059771351516246796,
0.000287850562017411,
0.034831296652555466,
0.02432185411453247,
0.008473790250718594,
0.05079858377575874,
0.05256487801671028,
0.03931768238544464,
0.04027147963643074,
-0.01108348835259676,
0.00008307096868520603,
-0.05440182238817215,
-0.009396678768098354,
0.012938096188008785,
0.045782312750816345,
0.05514366552233696,
0.04528775066137314,
-0.04285026714205742,
0.022255290299654007,
0.032817721366882324,
-0.030097631737589836,
0.01017384696751833,
0.0033095914404839277,
-0.03089246340095997,
-0.0010354892583563924,
-0.01253184862434864,
0.03952963650226593,
0.01858140155673027,
0.002486057346686721,
-0.013344342820346355,
-0.027819113805890083,
0.008562104776501656,
0.10611888021230698,
0.023209089413285255,
-0.024869404733181,
-0.03790464624762535,
-0.07262996584177017,
-0.018025020137429237,
0.023491695523262024,
0.025558259338140488,
-0.06545881927013397,
-0.01462490577250719,
-0.0168592669069767,
0.014174500480294228,
0.049491528421640396,
0.0033537487033754587,
0.12618397176265717,
-0.013423826545476913,
-0.02034769393503666,
-0.005669800564646721,
-0.015181288123130798,
0.04330950230360031,
0.06616533547639847,
0.0332416333258152,
-0.02539929188787937,
-0.0499860905110836,
-0.0528474859893322,
-0.009158228524029255,
-0.018563738092780113,
0.025152010843157768,
-0.007740778848528862,
0.015048815868794918,
0.008314823731780052,
-0.05390726029872894,
0.013344342820346355,
0.006968025583773851,
0.010482948273420334,
-0.07262996584177017,
-0.011498566716909409,
0.06990987807512283,
-0.05818168818950653,
0.029779698699712753,
-0.04507579654455185,
-0.012001960538327694,
-0.041048649698495865,
-0.0060539692640304565,
0.0363503098487854,
0.020630301907658577,
-0.08188533782958984,
0.0777168869972229,
-0.08075491338968277,
-0.006605935748666525,
0.0233150664716959,
-0.015587535686790943,
0.024551471695303917,
-0.019075963646173477,
-0.004194945562630892,
-0.10336346179246902,
-0.00979409459978342,
0.005320957396179438,
-0.010624252259731293,
-0.0035392094869166613,
-0.012293399311602116,
-0.02154877409338951,
-0.05934744328260422,
-0.016576658934354782,
-0.022325942292809486,
0.01786605268716812,
0.004049226641654968,
0.04458123445510864,
0.00044543700641952455,
0.0045791142620146275,
0.02202567271888256,
0.05146977677941322,
0.041649188846349716,
-0.040377456694841385,
-0.017186030745506287,
0.03709215298295021,
-0.015534546226263046,
0.023527022451162338,
0.012611331418156624,
-0.026847653090953827,
-0.038752466440200806,
-0.06870879232883453,
0.030627518892288208,
-0.029090844094753265,
0.012814455665647984,
0.0022542313672602177,
-0.03548482432961464,
-0.021743066608905792,
0.0025059280451387167,
0.017256682738661766,
-0.02350935898721218,
-0.03235848620533943,
-0.015605198219418526,
-0.0249930452555418,
0.03857583925127983,
0.01898765005171299,
-0.0004978738143108785,
-0.0789179652929306,
-0.013282522559165955,
0.0346723310649395,
-0.02426886558532715,
-0.0011022771941497922,
0.027518844231963158,
-0.04359211027622223,
-0.002700220327824354,
-0.0702984556555748,
0.034160107374191284,
0.054825734347105026,
-0.0026052820030599833,
-0.026582708582282066,
-0.014315804466605186,
-0.002399950521066785,
-0.030097631737589836,
-0.021778391674160957,
-0.02520500123500824,
-0.006795811932533979,
0.0021515656262636185,
-0.015817154198884964,
0.003731293836608529,
-0.0045305415987968445,
-0.00560798030346632,
0.08061361312866211,
0.06489360332489014,
-0.03121039643883705,
0.023262077942490578,
0.04906761646270752,
0.05323607102036476,
-0.017018232494592667,
0.022325942292809486,
0.005479923915117979,
-0.041260603815317154,
-0.010968679562211037,
-0.02276751585304737,
0.0124965226277709,
0.01905830018222332,
0.002190203173086047,
0.06807292997837067,
-0.03684487193822861,
-0.01700056903064251,
-0.025964505970478058,
-0.009449667297303677,
0.023809628561139107,
0.01571117527782917,
0.01266432087868452,
0.05736919492483139,
-0.008456127718091011,
0.008804970420897007,
0.006526452489197254,
-0.0540485642850399,
0.010659578256309032,
-0.004115462768822908,
0.01587897352874279,
-0.014651400037109852,
-0.0035127149894833565,
-0.03426608443260193,
-0.037268780171871185,
0.026812326163053513,
-0.013512141071259975,
0.022113988175988197,
-0.02993866614997387,
0.058817554265260696,
-0.021460458636283875,
-0.06849683821201324,
0.052741508930921555,
-0.052282270044088364,
-0.04574698582291603,
-0.008513531647622585,
-0.05012739449739456,
0.00043908937368541956,
0.0019186356803402305,
-0.021937359124422073,
0.009855914860963821,
-0.00022285649902187288,
0.020559649914503098,
0.021725403144955635,
-0.012770297937095165,
-0.012761466205120087,
-0.010156184434890747,
-0.061396341770887375,
0.02857862040400505,
-0.024816416203975677,
0.0018546076025813818,
0.10216238349676132,
0.009997217915952206,
0.00615111505612731,
-0.02202567271888256,
-0.04885566234588623,
-0.030309587717056274,
0.018157491460442543,
0.04546438157558441,
-0.016470681875944138,
0.0033714117016643286,
-0.021319156512618065,
-0.014925175346434116,
-0.017415648326277733,
-0.003907923121005297,
0.06023059040307999,
0.06160829961299896,
0.001419657957740128,
0.025169674307107925,
0.005987733136862516,
-0.0008577560074627399,
-0.05256487801671028,
0.04108397290110588,
0.02898486703634262,
0.0020213015377521515,
0.05796973407268524,
0.00753765506669879,
0.029426440596580505,
0.059170812368392944,
-0.050586629658937454,
0.021389808505773544,
-0.02967372164130211,
-0.008367813192307949,
0.06397513300180435,
-0.038469862192869186,
-0.0351492278277874,
0.05136379972100258,
0.03509623929858208,
-0.02264387533068657,
0.056521374732255936,
0.017256682738661766,
0.013220702297985554,
0.03488428518176079,
0.0927657037973404,
0.007462587673217058,
-0.0013390708481892943,
-0.015799490734934807,
0.017848391085863113,
0.026476731523871422,
0.027889765799045563,
-0.015481557697057724,
0.061466995626688004,
-0.030592193827033043,
0.007458171807229519,
-0.026794664561748505,
-0.010853869840502739,
0.06521153450012207,
-0.017662929370999336,
0.09297765791416168,
-0.001453879871405661,
-0.02183138020336628,
-0.0021339026279747486,
-0.004117670468986034,
-0.022414257749915123,
0.015048815868794918,
-0.01776890642940998,
0.0009339273674413562,
0.029832687228918076,
-0.04175516590476036,
-0.049774136394262314,
0.01043879147619009,
-0.01845776103436947,
-0.0033559566363692284,
-0.012072612531483173,
-0.05157575383782387,
-0.028560956940054893,
0.027395203709602356,
0.010712566785514355,
0.025222662836313248,
-0.07326582819223404,
0.002521383110433817,
0.031334035098552704,
-0.03191691264510155,
0.04433395341038704,
-0.02305012382566929,
0.07912992686033249,
0.0375513881444931,
-0.10060804337263107,
-0.00042970594950020313,
-0.00017897515499498695,
-0.055108338594436646,
0.012708477675914764,
-0.04920892044901848,
0.027730800211429596,
-0.0325174517929554,
-0.04242635518312454,
0.054295845329761505,
0.012187421321868896,
-0.005647721700370312,
0.06263274699449539,
0.027006618678569794,
-0.027183247730135918,
0.009785262867808342,
0.04147255793213844,
-0.017283177003264427,
0.023156100884079933,
-0.03864648938179016,
-0.042073097079992294,
0.01226690411567688,
-0.04684209078550339,
-0.036120690405368805,
0.01247002836316824,
-0.007727531716227531,
-0.002744377590715885,
0.01836944743990898,
0.04242635518312454,
-0.08089621365070343,
-0.0016007029917091131,
0.016232231631875038,
-0.023809628561139107,
0.04701871797442436,
-0.026035157963633537,
0.01927025616168976,
-0.02384495548903942,
-0.033877499401569366,
0.05892353132367134,
-0.05440182238817215,
-0.009900071658194065,
-0.0012176382588222623,
-0.00034028736990876496,
-0.03899974748492241,
0.042673636227846146,
0.03163430839776993,
0.05532029643654823,
0.006839969661086798,
0.018528413027524948,
0.014130343683063984,
0.08096686750650406,
0.03854051232337952,
0.02365066297352314,
0.01664731092751026,
0.022060999646782875,
0.02723623812198639,
-0.054295845329761505,
-0.009776431135833263,
0.010138521902263165,
-0.09495590627193451,
0.006848800927400589,
0.020630301907658577,
0.040236152708530426,
-0.06012461334466934,
-0.01250535435974598,
0.09057550132274628,
0.004526125732809305,
0.07312452793121338,
-0.01439528726041317,
-0.017689423635601997,
-0.02197268418967724,
0.014836860820651054,
-0.08690161257982254,
-0.0423203781247139,
0.04588828980922699,
-0.03896442428231239,
0.05076326057314873,
0.03094545193016529,
0.03435439616441727,
-0.007104913238435984,
0.019164279103279114,
0.007687789853662252,
0.01999443583190441,
0.03543183580040932,
-0.0022476078011095524,
0.00966162234544754,
0.018122166395187378,
0.04864370822906494,
-0.045570358633995056,
0.020771605893969536,
0.022891156375408173,
-0.022043336182832718,
0.00012474444520194083,
0.016779782250523567,
0.03541417419910431,
0.01602027751505375,
-0.02587619237601757,
-0.015614029951393604,
0.05563822761178017,
-0.012134432792663574,
-0.025593584403395653,
-0.032464463263750076,
-0.018828682601451874,
0.003004905767738819,
-0.0019517537439242005,
-0.0040977997705340385,
-0.0963689461350441,
0.03786931931972504,
-0.013264860026538372,
0.05927679315209389,
0.004998608957976103,
-0.004084552638232708,
0.0029055518098175526,
0.02116018906235695,
-0.000679470831528306,
-0.058958858251571655,
-0.05175238475203514,
0.025169674307107925,
0.031263384968042374,
-0.027554169297218323,
0.007197643630206585,
-0.00013709468476008624,
-0.0049897776916623116,
0.04694806784391403,
0.024286527186632156,
-0.04083669185638428,
-0.03991822153329849,
0.004064681474119425,
-0.014227489940822124,
-0.0015024528838694096,
-0.006733991671353579,
0.003978574648499489,
-0.02871992252767086,
-0.061926230788230896,
-0.01786605268716812,
0.061996880918741226,
0.004548204131424427,
-0.04465188458561897,
0.023527022451162338,
-0.039494309574365616,
0.048007842153310776,
0.07347778975963593,
0.00547550804913044,
-0.022537898272275925,
0.047477953135967255,
-0.030115295201539993,
0.008950689807534218,
0.027501180768013,
-0.021107200533151627,
-0.020577313378453255,
0.044969819486141205,
-0.007842340506613255,
-0.0060142274014651775,
0.00007734430982964113,
-0.0063586547039449215,
-0.0339481495320797,
0.004941204562783241,
-0.030362576246261597,
0.03101610392332077,
0.002057731384411454,
-0.031263384968042374,
-0.00963512808084488,
0.05316541716456413,
-0.0035127149894833565,
-0.03744541108608246,
0.011021668091416359,
-0.01523427665233612,
0.03567911684513092,
-0.015393243171274662,
-0.026406079530715942,
0.027660148218274117,
-0.022873492911458015,
0.018599065020680428,
0.032764732837677,
-0.01182533148676157,
0.055991485714912415,
-0.02999165467917919,
-0.029214484617114067,
0.0052944631315767765,
0.02871992252767086,
0.05567355453968048,
0.014951669611036777,
0.0009471746161580086,
0.04242635518312454,
-0.019782481715083122,
-0.023332729935646057,
0.03414244204759598,
0.004614440258592367,
0.02419821359217167,
-0.035378847271203995,
-0.028613945469260216,
0.06810825318098068,
0.051999665796756744,
0.023685988038778305,
-0.032411474734544754,
-0.04249700903892517,
-0.02405690960586071,
-0.028825901448726654,
-0.04122527688741684,
0.04938555136322975,
0.032870713621377945,
-0.003126338589936495,
0.05146977677941322,
-0.006027474533766508,
-0.019641177728772163,
0.05161108076572418,
-0.06690717488527298,
-0.05461377650499344,
-0.03854051232337952,
-0.03163430839776993,
0.021319156512618065,
0.06114906072616577,
0.08492336422204971,
-0.0475839301943779,
0.027112597599625587,
0.041790492832660675,
0.024887068197131157,
0.007065171841531992,
-0.05002141743898392,
-0.07453756034374237,
-0.02771313674747944,
0.05574420467019081,
-0.018139827996492386,
-0.044227976351976395,
-0.029567744582891464,
-0.03917637839913368,
-0.005091339349746704,
0.009237712249159813,
0.02568189986050129,
0.007581812329590321,
-0.018157491460442543,
-0.011286611668765545,
-0.052953463047742844,
-0.09036354720592499,
0.017583446577191353,
-0.004117670468986034,
-0.05146977677941322,
0.06231481581926346,
0.006305665709078312,
-0.006190856918692589,
-0.05627409368753433,
0.010067869909107685,
0.045994266867637634,
-0.008866790682077408,
0.024092236533761024,
0.02850796841084957,
-0.0022961809299886227,
-0.008566521108150482,
-0.001246340456418693,
-0.012717309407889843,
-0.017927873879671097,
-0.009326026774942875,
-0.010482948273420334,
-0.01050944346934557,
-0.006062800530344248,
-0.08174403756856918,
0.061466995626688004,
-0.0028349002823233604,
-0.06584740430116653,
0.030168283730745316,
-0.001601806958205998,
-0.022785179316997528,
0.005824351217597723,
-0.021336818113923073,
-0.06157297268509865,
0.07181747257709503,
0.020383020862936974,
-0.024904729798436165,
0.0609724335372448,
-0.012584837153553963,
0.005616811569780111,
0.0006927180220372975,
-0.04189646989107132,
-0.04684209078550339,
-0.025169674307107925,
-0.0124965226277709,
0.042532335966825485,
-0.01659432239830494,
-0.029302800074219704,
0.02804873138666153,
0.005232642870396376,
0.018828682601451874,
-0.02384495548903942,
0.02690064162015915,
0.003556872485205531,
-0.11113515496253967,
-0.0013225118163973093,
-0.005298878997564316,
0.054295845329761505,
-0.022520234808325768,
-0.0032367317471653223,
0.04684209078550339,
-0.009873577393591404,
-0.023703651502728462,
-0.015481557697057724,
0.024957720190286636,
-0.0056830476969480515,
-0.010182678699493408,
-0.015931962057948112,
0.056733328849077225,
0.03843453526496887,
-0.03981224447488785,
0.044298626482486725,
0.06471697241067886,
-0.018025020137429237,
-0.050515979528427124,
-0.00839430745691061,
-0.004645350389182568,
-0.031175071373581886,
-0.03974159061908722,
-0.01884634606540203,
0.03642095997929573,
0.01609092950820923,
0.017415648326277733,
-0.010085532441735268,
-0.006460216362029314,
0.05115184560418129,
-0.03288837522268295,
-0.025840865448117256,
0.026706349104642868,
0.05249422788619995,
0.02797807939350605,
-0.004910294432193041,
0.018157491460442543,
0.02121317759156227,
-0.007767273113131523,
-0.03642095997929573,
0.03843453526496887,
-0.013397332280874252,
-0.03426608443260193,
0.015914298593997955,
-0.009290700778365135,
0.006592688616365194,
-0.009476161561906338,
0.008495869114995003,
-0.056945282965898514,
-0.027342215180397034,
-0.0351492278277874,
0.010067869909107685,
0.01893465965986252,
0.016196906566619873,
-0.053483352065086365,
0.03235848620533943,
0.03142235055565834,
-0.011507398448884487,
0.0076833744533360004,
0.006667756009846926,
0.012991084717214108,
-0.03642095997929573,
0.04737197607755661,
0.006221767049282789,
-0.008959520608186722,
0.052812159061431885,
-0.10004283487796783,
-0.01844009757041931,
-0.09234179556369781,
0.04885566234588623,
-0.029885675758123398,
0.055037688463926315,
0.030380237847566605,
-0.029143834486603737,
0.01755695231258869,
-0.017707087099552155,
0.02967372164130211,
-0.06478762626647949,
0.02033003233373165,
-0.03020360879600048,
-0.026847653090953827,
0.007727531716227531,
-0.05041000247001648,
0.0035789511166512966,
-0.07319518178701401,
0.07075769454240799,
0.04013017565011978,
-0.002993866568431258,
0.04839642718434334,
-0.014368792995810509,
0.03995354473590851,
-0.04235570505261421,
-0.017159536480903625,
0.013070567511022091,
-0.06182025372982025,
0.030168283730745316,
-0.008937442675232887,
-0.0304862167686224,
-0.03175794705748558,
-0.004049226641654968,
0.010006049647927284,
-0.024480819702148438,
0.02116018906235695,
0.005762530956417322,
-0.003861557925119996,
0.00840755458921194,
-0.045570358633995056,
-0.02458679862320423,
0.05860560014843941,
-0.032941363751888275,
-0.007709868717938662,
-0.006327744573354721,
0.02087758295238018,
-0.019075963646173477,
-0.01034164521843195,
0.024516146630048752,
-0.012690815143287182,
-0.04684209078550339,
-0.022113988175988197,
-0.026988957077264786,
0.020630301907658577,
0.013706433586776257,
0.004307547118514776,
0.03525520861148834,
-0.0008649315568618476,
0.0005610740045085549,
-0.0702984556555748,
0.009237712249159813,
0.013238365761935711,
-0.03446037694811821,
-0.06418708711862564,
-0.05546160042285919,
-0.026176461949944496,
0.04383939132094383,
0.06563544273376465,
0.025628911331295967,
-0.006879711057990789,
0.030574530363082886,
0.009873577393591404
] |
725,861 | osqp.interface | solve |
Solve QP Problem
| def solve(self):
"""
Solve QP Problem
"""
# Solve QP
results = self._model.solve()
# TODO(bart): this will be unnecessary when the derivative will be in C
self._derivative_cache['results'] = results
return results
| (self) | [
0.03714119642972946,
-0.05837920680642128,
-0.05496897175908089,
0.03876190260052681,
-0.04642649367451668,
-0.015498008579015732,
-0.027822133153676987,
-0.10581864416599274,
0.04487331956624985,
0.007976915687322617,
-0.0015531772514805198,
-0.02169383503496647,
-0.022909365594387054,
0.050545793026685715,
-0.06871121376752853,
0.05071461573243141,
0.0027243911754339933,
-0.017726479098200798,
-0.015759684145450592,
0.036972373723983765,
-0.03774896264076233,
-0.022740541025996208,
0.011463123373687267,
0.06462568044662476,
-0.008854798972606659,
-0.028531191870570183,
0.04271237552165985,
-0.03872813656926155,
-0.02770395576953888,
-0.023854777216911316,
-0.04129425808787346,
0.05824415013194084,
-0.021795129403471947,
-0.00842851959168911,
-0.012940330430865288,
0.018486186861991882,
0.04284743592143059,
-0.02405736595392227,
-0.019971834495663643,
-0.02260548248887062,
-0.054597560316324234,
-0.004701737780123949,
0.03687107935547829,
-0.03825543075799942,
0.01912771537899971,
-0.024293718859553337,
0.0007417688029818237,
0.06354521214962006,
0.026370249688625336,
0.015717478469014168,
0.05999991297721863,
-0.028007838875055313,
-0.005642929580062628,
-0.04936402663588524,
-0.0017336074961349368,
0.009479446336627007,
0.010323564521968365,
0.031434956938028336,
0.0371074303984642,
-0.0481484979391098,
0.012189065106213093,
-0.02770395576953888,
0.0008050776086747646,
0.034980252385139465,
-0.002143004909157753,
0.009445681236684322,
0.05223402753472328,
-0.011471564881503582,
0.013446801342070103,
0.02015754021704197,
-0.023837894201278687,
-0.03933590278029442,
-0.028075367212295532,
-0.039943668991327286,
0.06462568044662476,
-0.01814853958785534,
0.01231568306684494,
-0.038019079715013504,
-0.04321884736418724,
-0.0006979801692068577,
-0.011471564881503582,
-0.01385197788476944,
-0.04119296371936798,
-0.0854247510433197,
-0.03734378516674042,
-0.018401773646473885,
0.04561614245176315,
0.00238674390129745,
0.05682602897286415,
-0.02821042761206627,
0.010897564701735973,
-0.007559077348560095,
-0.0022263615392148495,
0.06496332585811615,
0.06303873658180237,
-0.004870561417192221,
-0.005102694034576416,
-0.046966731548309326,
-0.013970154337584972,
-0.01917836256325245,
-0.024327483028173447,
0.12675277888774872,
-0.03481142967939377,
-0.005727341398596764,
0.03185701742768288,
-0.08495204150676727,
-0.0063097826205194,
-0.038896963000297546,
0.05547543987631798,
-0.049127671867609024,
-0.029493486508727074,
0.09170498698949814,
-0.038052842020988464,
0.014138977974653244,
-0.028936367481946945,
-0.0055331941694021225,
-0.06709050387144089,
0.035486724227666855,
0.047506965696811676,
0.05371967703104019,
-0.05675850063562393,
0.05577932298183441,
-0.05669097229838371,
0.017371950671076775,
0.008871681056916714,
0.039470963180065155,
0.02069777622818947,
0.017794009298086166,
0.021525012329220772,
-0.03663472458720207,
0.016696656122803688,
-0.017456362023949623,
0.021339304745197296,
0.017996598035097122,
-0.00845384318381548,
0.04207084700465202,
0.0201744232326746,
-0.05466508865356445,
0.021221129223704338,
0.054091088473796844,
0.011311182752251625,
0.03384913504123688,
0.0012229160638526082,
0.0017874200129881501,
0.023804130032658577,
0.010137857869267464,
0.04443437606096268,
0.01808100938796997,
-0.048080965876579285,
0.0059890178963541985,
-0.01283059548586607,
0.03327513486146927,
0.036398373544216156,
-0.022841835394501686,
0.016688214614987373,
-0.04592002555727959,
0.06178944557905197,
-0.0027307220734655857,
-0.02621830813586712,
-0.02562742494046688,
-0.05081591010093689,
-0.03317384049296379,
0.0017895303899422288,
0.013742242939770222,
0.003857619594782591,
-0.010433299466967583,
-0.02015754021704197,
-0.04065272584557533,
-0.03157001733779907,
0.07981980592012405,
-0.046561554074287415,
-0.03687107935547829,
-0.08839605003595352,
0.008812593296170235,
-0.04332014173269272,
0.05638708919286728,
0.02620142512023449,
0.0009923663455992937,
0.02356777712702751,
-0.08279110491275787,
0.020225070416927338,
-0.006968195084482431,
-0.038019079715013504,
0.0025576779153198004,
0.022031482309103012,
0.004916987847536802,
-0.015590861439704895,
0.003994788974523544,
0.00034213162143714726,
-0.006626327056437731,
-0.04328637570142746,
-0.02209901250898838,
0.07603815943002701,
-0.03077654540538788,
-0.013624066486954689,
0.023837894201278687,
0.06091156229376793,
0.024867719039320946,
0.031029781326651573,
0.04774332046508789,
0.008398975245654583,
-0.07536286115646362,
0.03859307989478111,
0.01283903606235981,
-0.06101285666227341,
-0.00880415178835392,
-0.06320756673812866,
-0.034980252385139465,
0.010213828645646572,
0.00929374061524868,
-0.030303839594125748,
-0.00269484706223011,
-0.03504778444766998,
-0.04946532100439072,
0.016308361664414406,
0.04473825916647911,
0.048486143350601196,
-0.020478304475545883,
0.031873900443315506,
0.0037056785076856613,
0.017709597945213318,
-0.051524966955184937,
-0.003026163438335061,
-0.0051280176267027855,
-0.03337642922997475,
-0.024293718859553337,
-0.016181744635105133,
0.0602700337767601,
-0.026285838335752487,
-0.0806976929306984,
0.03157001733779907,
-0.014485066756606102,
0.001633368548937142,
-0.08272357285022736,
0.05689356103539467,
0.0105852410197258,
-0.08677534013986588,
0.0595272071659565,
0.01510971412062645,
-0.003317384049296379,
-0.011471564881503582,
-0.057163678109645844,
0.019870540127158165,
0.04973543807864189,
-0.02311195433139801,
-0.023280777037143707,
0.06513215601444244,
-0.009099593386054039,
0.06769827008247375,
0.0022495747543871403,
0.01811477355659008,
-0.06860991567373276,
-0.04669661447405815,
0.01456947810947895,
0.02711307257413864,
-0.053652144968509674,
0.04588625952601433,
0.018823834136128426,
0.05425991117954254,
0.009006740525364876,
-0.019516009837388992,
0.03229595720767975,
-0.028531191870570183,
0.022841835394501686,
-0.06202579662203789,
0.0662463903427124,
-0.04571743682026863,
0.0013674712972715497,
0.0019266995368525386,
0.03514907881617546,
0.06692168116569519,
0.028885722160339355,
-0.06411921232938766,
-0.0010773057583719492,
-0.016848597675561905,
0.04976920410990715,
-0.014282478019595146,
0.09433864057064056,
-0.05044449865818024,
-0.022537952288985252,
-0.00395680358633399,
-0.0074451216496527195,
0.02157565765082836,
-0.00757173914462328,
-0.028835074976086617,
0.033528368920087814,
-0.04163190349936485,
-0.03114795684814453,
0.057129912078380585,
-0.010298240929841995,
0.0038934946060180664,
0.021980835124850273,
0.05945967882871628,
-0.011209888383746147,
0.0803600400686264,
0.0046553113497793674,
-0.02159254066646099,
0.0071707833558321,
0.051524966955184937,
0.06908262521028519,
-0.020309481769800186,
0.024378130212426186,
0.01431624311953783,
0.04038260877132416,
-0.008745063096284866,
0.034507546573877335,
0.04737190902233124,
0.006512370891869068,
0.016696656122803688,
-0.028311720117926598,
-0.057602617889642715,
0.03720872476696968,
-0.0014508279273286462,
0.07887439429759979,
-0.010669652372598648,
-0.04183449223637581,
-0.00959762278944254,
-0.012113094329833984,
0.0163336843252182,
0.026235191151499748,
-0.023787247017025948,
0.035520490258932114,
0.03487895801663399,
0.03182325139641762,
-0.03562178462743759,
0.008685975335538387,
-0.005891944281756878,
-0.013733801431953907,
0.029527250677347183,
-0.06847485899925232,
0.023449601605534554,
-0.013429919257760048,
0.005347487982362509,
0.008863239549100399,
0.021305540576577187,
-0.035959430038928986,
0.07070333510637283,
-0.021238010376691818,
0.013514330610632896,
0.0015004199231043458,
0.0962969958782196,
0.02113671787083149,
-0.031080428510904312,
0.001519412617199123,
0.018806951120495796,
-0.017371950671076775,
-0.006292900536209345,
-0.011885182932019234,
0.021001657471060753,
-0.03471013531088829,
-0.07954969257116318,
-0.0071665626019239426,
0.018992656841874123,
0.024496307596564293,
0.01715247891843319,
0.00034951764973811805,
0.01692456752061844,
0.026015719398856163,
-0.01431624311953783,
-0.012712418101727962,
0.011015741154551506,
0.01685703918337822,
-0.07948216050863266,
0.043016258627176285,
-0.029780486598610878,
-0.04369155317544937,
-0.0186381284147501,
-0.01078782882541418,
0.015126596204936504,
0.0010609509190544486,
-0.024327483028173447,
-0.032937489449977875,
-0.006934429984539747,
0.0126195652410388,
-0.021238010376691818,
0.026826072484254837,
-0.03812037408351898,
0.04443437606096268,
0.023871660232543945,
-0.006419518031179905,
0.03211025148630142,
-0.07212144881486893,
-0.054124850779771805,
-0.019938070327043533,
0.007554857060313225,
0.01858748123049736,
0.029459722340106964,
0.025424836203455925,
0.06384909152984619,
-0.016747303307056427,
-0.0196341872215271,
-0.04277990385890007,
0.005334826186299324,
0.025931308045983315,
-0.04281366989016533,
-0.0021472254302352667,
0.072053924202919,
0.006086091510951519,
-0.06989298015832901,
-0.03687107935547829,
-0.025053424760699272,
-0.032431017607450485,
-0.011530653573572636,
0.022250952199101448,
-0.009108033962547779,
-0.0825209841132164,
0.022419776767492294,
0.09312310814857483,
-0.0016354788094758987,
0.030979134142398834,
-0.029966192319989204,
-0.04183449223637581,
-0.011876741424202919,
0.02758578024804592,
-0.08272357285022736,
-0.015185684897005558,
0.014409095980226994,
-0.049026377499103546,
0.04085531458258629,
0.04730437695980072,
0.04473825916647911,
0.009065828286111355,
0.03314007818698883,
-0.0014149529160931706,
-0.04281366989016533,
0.025965072214603424,
-0.00210290914401412,
0.034456901252269745,
-0.01078782882541418,
0.021930187940597534,
-0.0035199725534766912,
-0.021879540756344795,
0.019752362743020058,
-0.025914425030350685,
-0.025880660861730576,
-0.03568931296467781,
0.029932428151369095,
0.0256105437874794,
-0.012509830296039581,
0.03464260697364807,
0.025981955230236053,
0.00930218119174242,
-0.0037879799492657185,
-0.03936966881155968,
0.001145890331827104,
-0.05068084970116615,
0.0582779124379158,
-0.06199203431606293,
-0.10082146525382996,
0.02015754021704197,
0.042543552815914154,
0.0196341872215271,
0.030590839684009552,
-0.010906006209552288,
0.013919507153332233,
0.03933590278029442,
-0.015371390618383884,
-0.05979732424020767,
-0.0593583844602108,
0.0186381284147501,
0.012079330161213875,
0.026809191331267357,
0.021879540756344795,
0.011150799691677094,
-0.04389414191246033,
0.018401773646473885,
-0.01605512574315071,
-0.04085531458258629,
-0.03383225202560425,
-0.02007312886416912,
0.0016101552173495293,
0.00808665156364441,
-0.045042142271995544,
-0.04767578840255737,
-0.04970167204737663,
-0.026285838335752487,
-0.061147913336753845,
0.034980252385139465,
0.000326831970596686,
-0.03585813567042351,
-0.0317557230591774,
-0.072053924202919,
0.010264475829899311,
0.05017437785863876,
0.027974072843790054,
-0.04213837534189224,
0.06540226936340332,
-0.021221129223704338,
-0.018519951030611992,
-0.05277426168322563,
0.005685135256499052,
0.027568897232413292,
0.04335390403866768,
-0.01760830357670784,
-0.02810913324356079,
0.014999978244304657,
-0.030557075515389442,
-0.015185684897005558,
0.01857059821486473,
-0.058581795543432236,
0.009234651923179626,
-0.018874481320381165,
-0.05631956085562706,
0.018300481140613556,
0.027450719848275185,
-0.028902603313326836,
0.012391653843224049,
0.05547543987631798,
0.03261672332882881,
0.02115359902381897,
-0.042104609310626984,
-0.0636802688241005,
0.02265612967312336,
-0.04693296551704407,
0.010424858890473843,
0.01919524557888508,
-0.019988715648651123,
0.0038892740849405527,
-0.029881780967116356,
-0.026944249868392944,
0.019887423142790794,
0.019009539857506752,
0.014940890483558178,
0.010256035253405571,
0.013649390079081059,
0.029290897771716118,
-0.062160857021808624,
-0.04821602627635002,
0.016114214435219765,
-0.013911066576838493,
0.0322115458548069,
-0.02267301268875599,
0.015371390618383884,
0.06813721358776093,
0.008162622340023518,
0.01757453940808773,
0.015683714300394058,
-0.06540226936340332,
-0.11236900091171265,
0.001280949218198657,
-0.03562178462743759,
0.054597560316324234,
0.019448481500148773,
-0.003790090326219797,
0.057062383741140366,
-0.00808665156364441,
-0.003273067995905876,
0.00926841702312231,
-0.03565554693341255,
0.0020301039330661297,
-0.013396154157817364,
0.02267301268875599,
0.038896963000297546,
-0.010230711661279202,
0.09116475284099579,
0.04213837534189224,
0.00831456296145916,
0.03423742949962616,
0.02517160214483738,
-0.008031783625483513,
0.0036824652925133705,
-0.061080384999513626,
0.061519328504800797,
-0.004309223033487797,
-0.025745602324604988,
-0.011505329981446266,
-0.0010910226264968514,
0.03074278123676777,
0.005917267873883247,
0.025340424850583076,
0.00010597638902254403,
-0.019380951300263405,
0.05098473280668259,
0.02258859947323799,
0.013522772118449211,
-0.04737190902233124,
0.025779366493225098,
-0.028851956129074097,
-0.033950429409742355,
0.025492366403341293,
0.0002777675981633365,
-0.02166007086634636,
-0.028446780517697334,
0.009504769928753376,
0.0033617003355175257,
0.035014018416404724,
-0.029527250677347183,
0.04689920321106911,
0.04328637570142746,
-0.010644328780472279,
-0.004397855140268803,
0.005718899890780449,
-0.020799070596694946,
0.0022559056524187326,
0.02765330858528614,
0.002500699833035469,
-0.07907698303461075,
-0.005507870577275753,
0.03764766827225685,
-0.03990990296006203,
-0.03774896264076233,
0.00246060430072248,
0.028396133333444595,
0.00806132797151804,
0.008588901720941067,
0.023348307237029076,
-0.04467073082923889,
0.030354486778378487,
0.03717496246099472,
-0.03788401931524277,
0.02510407194495201,
-0.048553671687841415,
0.01612265594303608,
0.023449601605534554,
-0.06584121286869049,
-0.0196341872215271,
-0.03303878381848335,
0.029966192319989204,
-0.019516009837388992,
0.06314003467559814,
0.008947651833295822,
0.040011197328567505,
0.01283059548586607,
0.00842851959168911,
-0.011167682707309723,
0.04220590367913246,
0.04075402021408081,
-0.056116972118616104,
-0.007061047945171595,
0.02412489429116249,
0.03936966881155968,
0.06908262521028519,
-0.01705118641257286,
0.0361957848072052,
-0.04973543807864189,
-0.0231625996530056,
0.015396714210510254,
0.0025787807535380125,
-0.02458071894943714,
0.008930769748985767,
-0.02268989384174347,
0.09278546273708344,
-0.034946490079164505,
0.008213269524276257,
-0.008491828106343746,
0.04966790974140167,
-0.05871685594320297,
-0.05989861860871315,
0.0038639504928141832,
-0.0034756562672555447,
-0.0410916693508625,
-0.006276017986238003,
-0.018739420920610428,
0.0012218609917908907,
0.03020254522562027,
-0.022369129583239555,
0.0221665408462286,
-0.004731282126158476,
0.015295419842004776,
0.008795710280537605,
0.003059928072616458,
0.001930920174345374,
-0.023972954601049423,
-0.06644897907972336,
0.018266715109348297,
0.03737754747271538,
-0.004380973055958748,
0.0001618332607904449,
-0.01459480170160532,
-0.004950752481818199,
0.014214948751032352,
-0.029476603493094444,
-0.022976893931627274,
0.026842955499887466,
-0.04578496515750885,
-0.002574560232460499,
0.0003352731582708657,
0.003152781166136265,
-0.018519951030611992,
-0.02005624584853649,
0.09730993211269379,
0.02111983485519886,
0.00853403378278017,
0.002471155719831586,
0.03761390224099159,
0.0026631925720721483,
-0.020967893302440643,
0.01538827270269394,
0.016975214704871178,
-0.05685979500412941,
-0.05068084970116615,
0.007428239099681377,
0.030945369973778725,
-0.010247593745589256,
0.04926273226737976,
-0.04264484718441963,
-0.016097331419587135,
-0.03270113468170166,
0.02508718892931938,
-0.04267860949039459,
0.03707366809248924,
0.035993196070194244,
0.00905738677829504,
0.010213828645646572,
0.03812037408351898,
0.06344391405582428,
-0.016637567430734634,
0.010931329801678658,
-0.051524966955184937,
-0.03680354729294777,
0.030877839773893356,
-0.030455781146883965,
-0.012847477570176125,
-0.03109731152653694,
0.04473825916647911,
0.026944249868392944,
-0.0028341265860944986,
0.006204267963767052,
0.018452420830726624,
0.037951551377773285,
-0.0371074303984642,
0.024006718769669533,
-0.0110832704231143,
-0.019397834315896034,
-0.006069208960980177,
0.059020739048719406,
-0.022537952288985252,
-0.058649323880672455,
-0.010770946741104126,
0.03724249079823494,
-0.024935249239206314,
0.0006019617430865765,
0.0015795560320839286,
-0.05328073352575302,
0.005626047030091286,
-0.030911603942513466,
0.027923427522182465,
0.022436659783124924,
-0.02056271769106388,
0.032431017607450485,
-0.006250694394111633,
0.03477766737341881,
0.016933009028434753,
-0.022774307057261467,
0.0317557230591774,
0.020005598664283752,
-0.029358427971601486,
0.015151919797062874,
-0.0027053984813392162,
-0.04122672602534294,
0.07441744953393936,
0.047034259885549545,
0.08231839537620544,
0.022301599383354187,
0.02767019160091877,
-0.018486186861991882,
0.0037668771110475063,
0.0003540020261425525,
-0.010120975784957409,
0.010593682527542114,
-0.05800779536366463,
-0.0071665626019239426,
0.026522191241383553,
0.07326944917440414,
-0.07387721538543701,
-0.023010659962892532,
0.0017251663375645876,
0.0252391304820776
] |
725,862 | osqp.interface | update |
Update OSQP problem arguments
| def update(self, q=None, l=None, u=None,
Px=None, Px_idx=np.array([]), Ax=None, Ax_idx=np.array([])):
"""
Update OSQP problem arguments
"""
# get problem dimensions
(n, m) = self._model.dimensions()
# check consistency of the input arguments
if q is not None and len(q) != n:
raise ValueError("q must have length n")
if l is not None:
if not isinstance(l, np.ndarray):
raise TypeError("l must be numpy.ndarray, not %s" %
type(l).__name__)
elif len(l) != m:
raise ValueError("l must have length m")
# Convert values to -OSQP_INFTY
l = np.maximum(l, -_osqp.constant('OSQP_INFTY'))
if u is not None:
if not isinstance(u, np.ndarray):
raise TypeError("u must be numpy.ndarray, not %s" %
type(u).__name__)
elif len(u) != m:
raise ValueError("u must have length m")
# Convert values to OSQP_INFTY
u = np.minimum(u, _osqp.constant('OSQP_INFTY'))
if Ax is None:
if len(Ax_idx) > 0:
raise ValueError("Vector Ax has not been specified")
else:
if len(Ax_idx) > 0 and len(Ax) != len(Ax_idx):
raise ValueError("Ax and Ax_idx must have the same lengths")
if Px is None:
if len(Px_idx) > 0:
raise ValueError("Vector Px has not been specified")
else:
if len(Px_idx) > 0 and len(Px) != len(Px_idx):
raise ValueError("Px and Px_idx must have the same lengths")
if q is None and l is None and u is None and Px is None and Ax is None:
raise ValueError("No updatable data has been specified")
# update linear cost
if q is not None:
self._model.update_lin_cost(q)
# update lower bound
if l is not None and u is None:
self._model.update_lower_bound(l)
# update upper bound
if u is not None and l is None:
self._model.update_upper_bound(u)
# update bounds
if l is not None and u is not None:
self._model.update_bounds(l, u)
# update matrix P
if Px is not None and Ax is None:
self._model.update_P(Px, Px_idx, len(Px))
# update matrix A
if Ax is not None and Px is None:
self._model.update_A(Ax, Ax_idx, len(Ax))
# update matrices P and A
if Px is not None and Ax is not None:
self._model.update_P_A(Px, Px_idx, len(Px), Ax, Ax_idx, len(Ax))
# TODO(bart): this will be unnecessary when the derivative will be in C
# update problem data in self._derivative_cache
if q is not None:
self._derivative_cache["q"] = q
if l is not None:
self._derivative_cache["l"] = l
if u is not None:
self._derivative_cache["u"] = u
if Px is not None:
if Px_idx.size == 0:
self._derivative_cache["P"].data = Px
else:
self._derivative_cache["P"].data[Px_idx] = Px
if Ax is not None:
if Ax_idx.size == 0:
self._derivative_cache["A"].data = Ax
else:
self._derivative_cache["A"].data[Ax_idx] = Ax
# delete results from self._derivative_cache to prohibit
# taking the derivative of unsolved problems
if "results" in self._derivative_cache.keys():
del self._derivative_cache["results"]
| (self, q=None, l=None, u=None, Px=None, Px_idx=array([], dtype=float64), Ax=None, Ax_idx=array([], dtype=float64)) | [
0.005942539777606726,
-0.021496152505278587,
-0.07164088636636734,
0.03589818626642227,
-0.04544123634696007,
-0.03389628604054451,
-0.04318666458129883,
-0.08816143870353699,
-0.0031850652303546667,
0.02353692799806595,
-0.02102969028055668,
-0.06996939331293106,
-0.013012363575398922,
0.045907698571681976,
-0.07160201668739319,
0.07611115276813507,
0.012050285004079342,
-0.01358572393655777,
0.016491398215293884,
0.004531004466116428,
-0.0019460237817838788,
-0.03251633420586586,
-0.0027404678985476494,
0.11070713400840759,
-0.003913912922143936,
-0.027599038556218147,
0.06759820878505707,
-0.02198205143213272,
0.007181581109762192,
-0.05065006762742996,
0.01567508839070797,
0.035217929631471634,
0.02310933545231819,
0.023187080398201942,
-0.012759696692228317,
-0.010495409369468689,
0.044663798063993454,
-0.03537341579794884,
-0.00028607278363779187,
-0.013644032180309296,
-0.025402776896953583,
-0.019610866904258728,
0.05391530692577362,
-0.027229756116867065,
0.06157306954264641,
0.03389628604054451,
-0.0388718880712986,
0.07786038517951965,
0.0111367953941226,
0.03657844662666321,
0.023809030652046204,
-0.06064014136791229,
0.020796459168195724,
-0.040776610374450684,
-0.018464146181941032,
0.06044578179717064,
0.03376023471355438,
0.05208832770586014,
0.05947398766875267,
-0.0665486678481102,
0.015053138136863708,
0.006992080714553595,
-0.004049964714795351,
-0.012730542570352554,
-0.0020602098666131496,
-0.01826006919145584,
0.01587916538119316,
-0.00836231466382742,
0.0031316163949668407,
0.03840542212128639,
-0.033954594284296036,
0.002004331676289439,
-0.02946488931775093,
-0.026471754536032677,
0.07677197456359863,
0.023342568427324295,
-0.007448825053870678,
0.004560158122330904,
-0.03455710783600807,
-0.030533866956830025,
0.04551897943019867,
0.010981308296322823,
-0.02487800642848015,
-0.040854353457689285,
-0.01789078488945961,
0.03360474482178688,
0.03080596961081028,
0.021126870065927505,
0.07311801612377167,
-0.05321561172604561,
-0.02825986221432686,
-0.020116200670599937,
-0.010612024925649166,
0.03175833076238632,
0.0692308321595192,
-0.0043050614185631275,
-0.020077329128980637,
-0.07879331707954407,
-0.012244644574820995,
-0.00821168627589941,
-0.005233127623796463,
0.013012363575398922,
0.0009736192878335714,
0.0015293657779693604,
0.03146679326891899,
-0.058113470673561096,
-0.006549912970513105,
-0.03288561478257179,
0.029853608459234238,
-0.045324619859457016,
-0.044624924659729004,
0.07043585926294327,
-0.06157306954264641,
0.003007712308317423,
-0.07887105643749237,
0.024178313091397285,
-0.06891985237598419,
-0.005077640060335398,
0.025636009871959686,
0.03988255560398102,
-0.0692308321595192,
0.060329169034957886,
-0.05212720111012459,
-0.00855181459337473,
0.026471754536032677,
-0.018920890986919403,
-0.013682903721928596,
0.0388718880712986,
0.017327142879366875,
-0.07354561239480972,
-0.024605903774499893,
-0.032574642449617386,
-0.02299272082746029,
0.057957980781793594,
0.005412910133600235,
-0.019173558801412582,
-0.01781304180622101,
-0.03436274826526642,
-0.01601521670818329,
0.0043050614185631275,
0.0076820566318929195,
0.05877429246902466,
0.030417250469326973,
0.012361260131001472,
0.017288271337747574,
0.03624803572893143,
0.06876436620950699,
-0.01572367735207081,
-0.06056239828467369,
0.01605408824980259,
-0.054731614887714386,
0.06444958597421646,
0.027190884575247765,
-0.0470738559961319,
-0.005461500026285648,
-0.07012487947940826,
-0.00033709214767441154,
-0.09873458743095398,
0.0083768917247653,
-0.0138966990634799,
-0.048589859157800674,
-0.0636332780122757,
0.02754073217511177,
0.014372879639267921,
-0.012565337121486664,
-0.014742163009941578,
-0.03727813810110092,
-0.0012439003912732005,
0.0018233343726024032,
0.062428250908851624,
0.007890992797911167,
-0.013556570746004581,
-0.028531964868307114,
0.008517801761627197,
-0.043031178414821625,
0.05504259094595909,
-0.018745966255664825,
-0.06748159229755402,
0.04217599704861641,
-0.07486725598573685,
0.028454219922423363,
0.011972540989518166,
-0.012672235257923603,
-0.0334298238158226,
-0.024178313091397285,
0.024508723989129066,
-0.06825903058052063,
0.00540319224819541,
-0.005087357945740223,
-0.015296087600290775,
-0.00838175043463707,
-0.05309899523854256,
0.019844098016619682,
0.0013993879547342658,
-0.033837977796792984,
0.06650979816913605,
0.03727813810110092,
0.00976170226931572,
0.08046480268239975,
0.025480521842837334,
0.0443916954100132,
-0.05776362121105194,
0.02176825702190399,
0.03743362799286842,
-0.06005706265568733,
-0.0347709022462368,
-0.008464353159070015,
-0.001983680995181203,
0.015830576419830322,
0.020252251997590065,
0.03710321709513664,
0.014052187092602253,
-0.05158299207687378,
-0.03622859716415405,
0.014236828312277794,
0.0720684751868248,
0.020427176728844643,
0.00387747073546052,
0.02913447842001915,
-0.00011486945732031018,
0.04481928423047066,
-0.023731285706162453,
-0.016685757786035538,
0.003211789531633258,
-0.0013167851138859987,
0.005631564650684595,
0.025772061198949814,
0.06285583972930908,
0.01618042215704918,
-0.013498262502253056,
0.013809237629175186,
-0.024100570008158684,
0.02699652500450611,
-0.01128256507217884,
0.03657844662666321,
-0.019591430202126503,
-0.08388552814722061,
0.04108758270740509,
-0.02031056024134159,
-0.010981308296322823,
-0.011885079555213451,
-0.03898850083351135,
0.007254465948790312,
0.036131419241428375,
-0.008022185415029526,
-0.02361467108130455,
0.030358942225575447,
0.03265238553285599,
0.014343726448714733,
-0.025130674242973328,
-0.0083768917247653,
-0.01233210600912571,
-0.05504259094595909,
0.03292448818683624,
0.008882226422429085,
0.020913075655698776,
0.05504259094595909,
0.003447450464591384,
0.023595234379172325,
-0.03698660060763359,
-0.03572326526045799,
-0.01596662774682045,
-0.02448928914964199,
0.05228268727660179,
-0.056325364857912064,
0.000763468153309077,
0.01634562760591507,
0.005743321031332016,
-0.0005527096218429506,
0.03704490885138512,
0.01280828658491373,
0.055781155824661255,
-0.022254154086112976,
0.017706144601106644,
0.031952690333127975,
0.062428250908851624,
0.013605160638689995,
0.013818955980241299,
0.032496895641088486,
-0.015179471112787724,
0.05562566965818405,
-0.0065644895657896996,
0.014713008888065815,
0.04606318473815918,
-0.02750185877084732,
0.011010461486876011,
-0.04260358586907387,
-0.03774460032582283,
0.012613927014172077,
-0.005689872428774834,
0.02336200326681137,
0.039066243916749954,
0.02888181060552597,
0.01262364536523819,
0.04443056508898735,
0.03891075775027275,
-0.0305533017963171,
0.03877470642328262,
0.08256388455629349,
0.023517491295933723,
-0.006093168165534735,
0.009844304993748665,
0.026355138048529625,
-0.010923000052571297,
0.05504259094595909,
-0.04882308840751648,
0.06919195502996445,
-0.02616078034043312,
0.00854695588350296,
-0.02031056024134159,
0.007740364409983158,
0.02015507221221924,
-0.013265031389892101,
0.04905632138252258,
0.007954159751534462,
-0.03315771743655205,
0.0011418616631999612,
-0.0034523094072937965,
0.0060834502801299095,
0.04544123634696007,
-0.018697377294301987,
0.02557770162820816,
0.03152510151267052,
-0.021884871646761894,
-0.05554792657494545,
-0.0019265878945589066,
0.02549995668232441,
0.005889090709388256,
0.005782193038612604,
-0.05061119422316551,
0.01629703864455223,
-0.00961107388138771,
0.0005855077761225402,
0.01704532280564308,
-0.01672462932765484,
-0.035081878304481506,
0.008323442190885544,
-0.034459926187992096,
0.05877429246902466,
0.02001902088522911,
0.03657844662666321,
0.0611843504011631,
-0.055275823920965195,
0.031194688752293587,
-0.02034943178296089,
-0.0499115027487278,
0.03821106255054474,
-0.029834171757102013,
0.04656852036714554,
-0.007890992797911167,
-0.0889388769865036,
0.035004135221242905,
-0.0006504967459477484,
-0.019921841099858284,
0.06168968230485916,
0.031836073845624924,
0.005033909343183041,
-0.049134064465761185,
0.02717144787311554,
-0.023556362837553024,
-0.010417665354907513,
-0.0034231555182486773,
-0.05663633719086647,
0.028784632682800293,
-0.035548340529203415,
-0.02796832285821438,
-0.020466048270463943,
-0.03127243369817734,
-0.0052185505628585815,
0.017297988757491112,
-0.011943386867642403,
-0.05286576598882675,
-0.0004688921326305717,
0.02950376085937023,
-0.019698329269886017,
0.05613100528717041,
-0.06040691211819649,
0.04369200021028519,
-0.033876847475767136,
-0.03315771743655205,
0.025266725569963455,
-0.0884724110364914,
-0.020077329128980637,
-0.005685013253241777,
0.01055371668189764,
-0.004120419733226299,
0.034751467406749725,
-0.005913385655730963,
0.018376683816313744,
-0.008974546566605568,
0.011418616399168968,
-0.006870605982840061,
0.030494995415210724,
0.021010255441069603,
-0.03564551845192909,
0.020582662895321846,
0.03026176430284977,
0.011360309086740017,
-0.08271937072277069,
-0.06993052363395691,
-0.015655651688575745,
-0.048628728836774826,
-0.02546108514070511,
0.016899552196264267,
0.009577061049640179,
-0.06853113323450089,
0.02528616227209568,
0.060251422226428986,
-0.03686998412013054,
0.0946919173002243,
0.02938714623451233,
0.009664522483944893,
-0.022895541042089462,
0.0111367953941226,
-0.040815480053424835,
0.0011619050055742264,
0.026743857190012932,
-0.06215614452958107,
0.03547059744596481,
0.0887833908200264,
0.04435282200574875,
0.004788530524820089,
0.0359564945101738,
0.057491518557071686,
0.0014783464139327407,
-0.014489495195448399,
-0.024294929578900337,
-0.008561532944440842,
0.002730750013142824,
0.02524729073047638,
-0.03352700173854828,
-0.003726842114701867,
0.002657865174114704,
0.0047423699870705605,
-0.03432387486100197,
0.005077640060335398,
0.058113470673561096,
0.014917085878551006,
0.00075375015148893,
0.02143784612417221,
0.03912455216050148,
-0.03142791986465454,
0.01095215417444706,
0.0048274025321006775,
-0.03648126497864723,
-0.010563435032963753,
-0.00632154056802392,
-0.05045570805668831,
-0.11583822220563889,
0.014518649317324162,
0.03992142900824547,
0.05333222821354866,
-0.007332209497690201,
-0.012886030599474907,
0.01651083305478096,
-0.033332642167806625,
-0.04905632138252258,
-0.06802579760551453,
-0.025188982486724854,
0.01429513655602932,
-0.0029396864119917154,
0.02989248000085354,
0.011681001633405685,
-0.009290380403399467,
0.003853175789117813,
0.04769580438733101,
0.0417095348238945,
-0.07665535807609558,
-0.02176825702190399,
0.0049901786260306835,
0.018318375572562218,
-0.013653749600052834,
-0.008483788929879665,
-0.014431187883019447,
-0.035334546118974686,
-0.041865020990371704,
0.014411752112209797,
0.07463402301073074,
-0.0020359151531010866,
-0.06036803871393204,
0.018959762528538704,
-0.04384748637676239,
0.024294929578900337,
0.05488710477948189,
0.011982259340584278,
-0.031039200723171234,
0.021224049851298332,
-0.022215282544493675,
0.0031170393340289593,
0.015062855556607246,
-0.020543791353702545,
-0.016248447820544243,
0.053487714380025864,
-0.021243486553430557,
-0.005019332282245159,
-0.014654701575636864,
-0.009183483198285103,
-0.02211810275912285,
0.021379537880420685,
-0.03924116864800453,
0.045208003371953964,
-0.033799104392528534,
-0.011807335540652275,
-0.007293337490409613,
0.036422956734895706,
-0.02487800642848015,
-0.01007753610610962,
0.048667602241039276,
-0.02812380902469158,
0.0076869153417646885,
-0.0835745558142662,
-0.047423701733350754,
0.08209742605686188,
-0.03150566294789314,
0.010155280120670795,
0.02336200326681137,
-0.0277156550437212,
0.018483581021428108,
0.002208409132435918,
-0.029814736917614937,
0.016617732122540474,
0.02590811252593994,
0.00885793101042509,
-0.025383342057466507,
0.001194703159853816,
0.037142086774110794,
-0.012749978341162205,
-0.05776362121105194,
0.03273012861609459,
-0.00917376484721899,
-0.030203456059098244,
0.0035980790853500366,
0.026646677404642105,
0.04551897943019867,
0.036384087055921555,
0.02796832285821438,
0.007084401324391365,
-0.05939624086022377,
-0.07164088636636734,
-0.013614878058433533,
-0.01704532280564308,
0.07447853684425354,
0.022040359675884247,
-0.044158462435007095,
-0.00013255920202936977,
-0.003223937004804611,
-0.0180171187967062,
0.018376683816313744,
0.009970638900995255,
-0.03405177220702171,
-0.0890166163444519,
-0.004280766472220421,
0.05679182708263397,
0.06612107902765274,
0.034595977514982224,
0.007988172583281994,
0.014955958351492882,
0.01038851123303175,
0.019678892567753792,
-0.009431291371583939,
-0.0554313100874424,
-0.053565457463264465,
0.05671408027410507,
-0.010271895676851273,
-0.036384087055921555,
0.025655444711446762,
-0.005534384865313768,
-0.017356297001242638,
0.033332642167806625,
0.03234140947461128,
-0.012895748019218445,
-0.007589735556393862,
-0.0317777656018734,
-0.03924116864800453,
-0.03955214470624924,
-0.07304027676582336,
0.03117525205016136,
-0.058696549385786057,
-0.030164584517478943,
0.0174243226647377,
0.011904515326023102,
0.011593540199100971,
-0.02215697430074215,
-0.022059794515371323,
0.04886196181178093,
0.025130674242973328,
-0.01867794059216976,
0.03401289880275726,
0.04097096994519234,
0.012507029809057713,
-0.026180215179920197,
0.006807439029216766,
-0.01433400809764862,
-0.03926060348749161,
0.01189479697495699,
0.0528268925845623,
-0.0387163981795311,
-0.058113470673561096,
0.04353651404380798,
-0.030572738498449326,
-0.03230253607034683,
0.01672462932765484,
-0.020640971139073372,
-0.005723885260522366,
0.005709308199584484,
-0.005087357945740223,
-0.053643204271793365,
0.05391530692577362,
0.018882019445300102,
-0.018998634070158005,
0.07358448207378387,
-0.014732444658875465,
0.01174902729690075,
0.004834691062569618,
-0.048628728836774826,
-0.0347709022462368,
-0.005529525689780712,
0.02557770162820816,
0.07642212510108948,
0.02161276899278164,
-0.05426515266299248,
0.023847902193665504,
0.005655859597027302,
-0.012633362784981728,
-0.04769580438733101,
-0.0015317952493205667,
0.02448928914964199,
-0.07269042730331421,
-0.021962616592645645,
0.0061903479509055614,
0.0414763018488884,
0.009912330657243729,
0.022137539461255074,
0.0642552301287651,
-0.011360309086740017,
-0.018571043387055397,
-0.025266725569963455,
-0.00163504877127707,
-0.02862914465367794,
0.04275907576084137,
0.043575383722782135,
0.05714167281985283,
0.041359685361385345,
-0.02950376085937023,
0.027482423931360245,
0.05706392973661423,
-0.03535398095846176,
-0.0499892458319664,
0.04031014442443848,
0.014907368458807468,
-0.038385987281799316,
-0.028143245726823807,
-0.04905632138252258,
-0.004927011672407389,
0.0032968218438327312,
0.03999917209148407,
-0.0021610339172184467,
-0.01051484514027834,
0.024061698466539383,
-0.004324497189372778,
-0.023420311510562897,
0.01893060840666294,
0.02423662133514881,
-0.021165741607546806,
-0.011564386077225208,
0.021224049851298332,
0.012001695111393929,
-0.025344470515847206,
0.015062855556607246,
0.026763293892145157,
-0.00933897029608488,
-0.028357040137052536,
-0.004438683390617371,
0.03869696334004402,
-0.0012323602568358183,
-0.03298279643058777,
0.025188982486724854,
-0.024178313091397285,
-0.006525618024170399,
-0.03309941291809082,
0.05403192341327667,
0.013012363575398922,
-0.003751137061044574,
-0.0249168798327446,
0.019921841099858284,
0.02132122963666916,
0.017754733562469482,
0.020466048270463943,
-0.0038094448391348124,
-0.009086303412914276,
-0.0249168798327446,
0.00700179859995842,
-0.001840340904891491,
-0.03572326526045799,
0.05776362121105194,
-0.10098916292190552,
-0.04544123634696007,
-0.031622279435396194,
0.015043419785797596,
0.0035130467731505632,
0.03331320732831955,
0.03966876119375229,
-0.04046563431620598,
0.028765195980668068,
0.023128772154450417,
0.07599453628063202,
-0.07525597512722015,
0.013809237629175186,
-0.06814241409301758,
-0.02190430834889412,
0.027987757697701454,
0.0076869153417646885,
0.008736456744372845,
-0.06926970183849335,
0.07486725598573685,
0.06122322008013725,
0.014052187092602253,
-0.00023596450046170503,
0.013644032180309296,
0.02619965188205242,
-0.026005292311310768,
0.028687452897429466,
-0.00278419884853065,
-0.06818129122257233,
-0.0009256367920897901,
-0.004540722351521254,
-0.023459183052182198,
-0.03945496305823326,
-0.016539987176656723,
0.02419774979352951,
-0.006559630855917931,
0.019367916509509087,
0.01710362918674946,
-0.05900752171874046,
0.034712594002485275,
-0.03933835029602051,
-0.0004476340545807034,
0.008576110005378723,
-0.03815275803208351,
0.0471515990793705,
-0.023303695023059845,
0.05372094735503197,
-0.0011716228909790516,
0.001454051467590034,
0.0014236827846616507,
0.01759924739599228,
-0.04384748637676239,
-0.022429078817367554,
-0.016685757786035538,
-0.026821602135896683,
0.08676204830408096,
0.012895748019218445,
0.010738358832895756,
0.028493093326687813,
0.034459926187992096,
-0.054692745208740234,
0.039765939116477966,
0.007050388492643833,
-0.006525618024170399,
-0.013517698273062706,
-0.009455586783587933,
0.012166900560259819,
0.05667521059513092,
0.11296170204877853,
-0.054109666496515274,
-0.00154394272249192,
-0.0019970431458204985,
0.02561657316982746
] |
725,863 | osqp.interface | update_settings |
Update OSQP solver settings
It is possible to change: 'max_iter', 'eps_abs', 'eps_rel',
'eps_prim_inf', 'eps_dual_inf', 'rho'
'alpha', 'delta', 'polish',
'polish_refine_iter',
'verbose', 'scaled_termination',
'check_termination', 'time_limit',
| def update_settings(self, **kwargs):
"""
Update OSQP solver settings
It is possible to change: 'max_iter', 'eps_abs', 'eps_rel',
'eps_prim_inf', 'eps_dual_inf', 'rho'
'alpha', 'delta', 'polish',
'polish_refine_iter',
'verbose', 'scaled_termination',
'check_termination', 'time_limit',
"""
# get arguments
max_iter = kwargs.pop('max_iter', None)
eps_abs = kwargs.pop('eps_abs', None)
eps_rel = kwargs.pop('eps_rel', None)
eps_prim_inf = kwargs.pop('eps_prim_inf', None)
eps_dual_inf = kwargs.pop('eps_dual_inf', None)
rho = kwargs.pop('rho', None)
alpha = kwargs.pop('alpha', None)
delta = kwargs.pop('delta', None)
polish = kwargs.pop('polish', None)
polish_refine_iter = kwargs.pop('polish_refine_iter', None)
verbose = kwargs.pop('verbose', None)
scaled_termination = kwargs.pop('scaled_termination', None)
check_termination = kwargs.pop('check_termination', None)
warm_start = kwargs.pop('warm_start', None)
time_limit = kwargs.pop('time_limit', None)
# update them
if max_iter is not None:
self._model.update_max_iter(max_iter)
if eps_abs is not None:
self._model.update_eps_abs(eps_abs)
if eps_rel is not None:
self._model.update_eps_rel(eps_rel)
if eps_prim_inf is not None:
self._model.update_eps_prim_inf(eps_prim_inf)
if eps_dual_inf is not None:
self._model.update_eps_dual_inf(eps_dual_inf)
if rho is not None:
self._model.update_rho(rho)
if alpha is not None:
self._model.update_alpha(alpha)
if delta is not None:
self._model.update_delta(delta)
if polish is not None:
self._model.update_polish(polish)
if polish_refine_iter is not None:
self._model.update_polish_refine_iter(polish_refine_iter)
if verbose is not None:
self._model.update_verbose(verbose)
if scaled_termination is not None:
self._model.update_scaled_termination(scaled_termination)
if check_termination is not None:
self._model.update_check_termination(check_termination)
if warm_start is not None:
self._model.update_warm_start(warm_start)
if time_limit is not None:
self._model.update_time_limit(time_limit)
if max_iter is None and \
eps_abs is None and \
eps_rel is None and \
eps_prim_inf is None and \
eps_dual_inf is None and \
rho is None and \
alpha is None and \
delta is None and \
polish is None and \
polish_refine_iter is None and \
verbose is None and \
scaled_termination is None and \
check_termination is None and \
warm_start is None:
raise ValueError("No updatable settings has been specified!")
| (self, **kwargs) | [
0.04814634472131729,
-0.05911871790885925,
-0.05192612484097481,
0.015917284414172173,
-0.03926569223403931,
-0.026293335482478142,
-0.05277015268802643,
-0.03546756133437157,
0.011761358939111233,
-0.021320903673768044,
-0.01771543174982071,
-0.02906395122408867,
0.01932092197239399,
0.06594434380531311,
-0.03922899439930916,
0.05530223995447159,
-0.003919688519090414,
-0.0064953528344631195,
0.023614460602402687,
-0.007293510716408491,
0.010311831720173359,
-0.03581618145108223,
-0.01014669518917799,
0.08880651742219925,
0.024623624980449677,
0.0045481231063604355,
0.028586892411112785,
0.014990687370300293,
-0.013935650698840618,
-0.0260731540620327,
-0.004201795905828476,
0.034990500658750534,
0.009403582662343979,
0.04488031938672066,
0.05721047893166542,
-0.029669450595974922,
0.045761045068502426,
0.031963005661964417,
-0.07383418083190918,
-0.027192408218979836,
-0.032293278723955154,
-0.06220126152038574,
0.039852842688560486,
-0.02405482344329357,
-0.0072568138130009174,
-0.003318776609376073,
-0.009178814478218555,
0.10598067194223404,
0.04429316893219948,
-0.0018681020010262728,
0.0186512041836977,
-0.045247286558151245,
0.022935567423701286,
0.032128144055604935,
-0.029669450595974922,
0.040146417915821075,
-0.002545848023146391,
0.0437794104218483,
0.05438481643795967,
-0.05067843198776245,
0.006188016384840012,
0.0048118820413947105,
0.00621095160022378,
-0.0373758003115654,
0.0016731496434658766,
-0.016853054985404015,
-0.02383464202284813,
0.0005037224036641419,
0.004057302139699459,
0.02915569394826889,
-0.0013142080279067159,
-0.04388950392603874,
-0.032972171902656555,
-0.002326813293620944,
0.012476949021220207,
-0.014339316636323929,
-0.0760359913110733,
0.0073669045232236385,
-0.0635957419872284,
-0.0323299765586853,
0.025632791221141815,
0.03915560245513916,
-0.01443105936050415,
-0.05662332847714424,
-0.01178888138383627,
-0.030403388664126396,
0.036384984850883484,
0.04135741665959358,
0.0815405324101448,
-0.051962822675704956,
-0.02649516798555851,
0.011532003059983253,
0.025174079462885857,
0.017311766743659973,
0.0901276096701622,
0.020605314522981644,
-0.020275041460990906,
-0.0873386412858963,
-0.019889723509550095,
-0.07699011266231537,
-0.049724310636520386,
0.014458581805229187,
0.007027457933872938,
-0.019431013613939285,
0.024660322815179825,
-0.07919193059206009,
-0.009238447062671185,
-0.019247528165578842,
0.03631158918142319,
-0.07295345515012741,
-0.05864166095852852,
0.03717396780848503,
-0.057614147663116455,
-0.009009091183543205,
-0.06143062561750412,
-0.0031995116733014584,
-0.04198126494884491,
0.01624755561351776,
0.08616434037685394,
0.010109998285770416,
-0.1013568639755249,
0.06286180764436722,
-0.041577596217393875,
0.01375216618180275,
0.048072949051856995,
0.02333923429250717,
0.015853064134716988,
0.05379766598343849,
-0.019504407420754433,
-0.03166943043470383,
-0.03779781609773636,
-0.019504407420754433,
-0.01333015225827694,
0.010476967319846153,
0.012137502431869507,
-0.04704543575644493,
-0.025045640766620636,
0.007614608388394117,
-0.008509095758199692,
0.03350427746772766,
0.022495204582810402,
0.05155915766954422,
0.0041811540722846985,
-0.028109831735491753,
0.005724717862904072,
0.02341262809932232,
0.010834761895239353,
-0.04517389461398125,
-0.03289877995848656,
0.030495131388306618,
-0.003325657220557332,
0.03289877995848656,
-0.00655957218259573,
0.008371482603251934,
-0.005577930249273777,
-0.04231153428554535,
0.016091594472527504,
-0.04711883142590523,
-0.029082300141453743,
-0.002940339734777808,
-0.0590820237994194,
-0.021155767142772675,
0.04095374792814255,
-0.04113723337650299,
-0.022348416969180107,
0.021357601508498192,
-0.06392601132392883,
-0.017651213333010674,
0.02623828873038292,
0.08352216333150864,
0.001520628109574318,
-0.011128337122499943,
-0.02763277292251587,
0.001824524370022118,
-0.016183337196707726,
0.0747516006231308,
0.022385114803910255,
-0.04286199063062668,
0.00862836092710495,
-0.018045704811811447,
0.005385271273553371,
-0.014531975612044334,
-0.04902707040309906,
-0.0073577300645411015,
0.004876101855188608,
0.04869679734110832,
-0.030054768547415733,
0.003701800713315606,
-0.05067843198776245,
-0.03577948734164238,
0.04418307915329933,
-0.030990539118647575,
0.050898611545562744,
0.03058687224984169,
-0.04950413107872009,
0.023265840485692024,
0.0577242374420166,
-0.05126558244228363,
0.07816441357135773,
0.06326547265052795,
0.0017740661278367043,
-0.042715203016996384,
0.042715203016996384,
-0.017531948164105415,
-0.009265969507396221,
-0.02513738162815571,
-0.002166264457628131,
-0.036770302802324295,
0.01709158532321453,
0.04620140790939331,
-0.04062347859144211,
-0.00417656684294343,
-0.0033050153870135546,
0.001830258290283382,
0.01911908946931362,
0.026348380371928215,
0.07552223652601242,
0.03926569223403931,
-0.026091501116752625,
0.006967825349420309,
0.006174254696816206,
0.005697194952517748,
0.0039403303526341915,
-0.02961440570652485,
0.039082206785678864,
-0.00029873577295802534,
0.008600837551057339,
0.03671525791287422,
0.016853054985404015,
-0.038164783269166946,
0.011743010953068733,
-0.0020997512619942427,
-0.005816460121423006,
-0.0000259458611253649,
0.011146686039865017,
0.0003933449916075915,
-0.04678855836391449,
0.03203640133142471,
-0.04110053926706314,
-0.04715552553534508,
-0.0005022889235988259,
-0.035962969064712524,
-0.027394242584705353,
0.002442637924104929,
-0.02460527792572975,
-0.0479261614382267,
0.06561407446861267,
-0.003979321103543043,
-0.002844010479748249,
-0.024917200207710266,
0.046091318130493164,
-0.04528398439288139,
-0.020660359412431717,
0.03532077372074127,
-0.01311914436519146,
-0.005628388375043869,
0.03012816235423088,
0.02695387974381447,
0.03557765111327171,
-0.031449250876903534,
-0.008210932835936546,
0.038201481103897095,
-0.033852897584438324,
0.06583425402641296,
-0.002866945927962661,
0.028513498604297638,
-0.011697139590978622,
-0.00008780021744314581,
-0.003727029776200652,
0.037063878029584885,
-0.016504434868693352,
0.02847680076956749,
-0.08476985991001129,
0.05126558244228363,
0.010394399054348469,
0.0422014445066452,
-0.02717406116425991,
-0.0033417122904211283,
-0.029761193320155144,
-0.010495316237211227,
0.04047669097781181,
-0.027192408218979836,
0.039889540523290634,
0.028972208499908447,
-0.0010573297040537,
0.007036632392555475,
-0.06939385086297989,
0.026513516902923584,
0.032972171902656555,
-0.004559590946882963,
-0.02700892463326454,
0.024531884118914604,
0.04399959370493889,
-0.02565113827586174,
0.042384929955005646,
0.0030206143856048584,
-0.006348565220832825,
-0.021192464977502823,
0.05218300223350525,
-0.009678809903562069,
0.05522884801030159,
-0.03148594871163368,
-0.022623643279075623,
0.019596148282289505,
0.06807276606559753,
0.019963117316365242,
0.05699029937386513,
-0.004954082425683737,
0.055632513016462326,
-0.0084586376324296,
-0.023999778553843498,
-0.014458581805229187,
0.020109904929995537,
0.04308217018842697,
0.018706249073147774,
-0.029375875368714333,
-0.0028990558348596096,
-0.022843824699521065,
-0.011265951208770275,
0.044917017221450806,
-0.07049476355314255,
0.02935752645134926,
0.015889761969447136,
-0.02240346185863018,
-0.04759588837623596,
-0.055008664727211,
0.005490774754434824,
0.010816413909196854,
-0.025008942931890488,
-0.06664158403873444,
-0.01906404457986355,
-0.02256859838962555,
0.038751933723688126,
0.03291712701320648,
-0.03864184394478798,
-0.040183115750551224,
0.03517398610711098,
0.023192446678876877,
0.02603645622730255,
-0.004729314241558313,
0.10010916739702225,
0.04113723337650299,
-0.05438481643795967,
0.024146566167473793,
-0.013320977799594402,
-0.03893541917204857,
0.06117374449968338,
-0.04532068222761154,
0.053981151431798935,
-0.04755919426679611,
-0.046935345977544785,
0.04678855836391449,
-0.02071540430188179,
0.048623405396938324,
0.050568338483572006,
0.011743010953068733,
0.003752258839085698,
-0.030054768547415733,
0.032586853951215744,
-0.06080677732825279,
-0.03860514611005783,
0.02370620332658291,
-0.041577596217393875,
0.07566902786493301,
0.005321051925420761,
-0.018366802483797073,
-0.001973605714738369,
0.007885248400270939,
0.05288024619221687,
-0.04201795905828476,
-0.0038669367786496878,
-0.04051338508725166,
0.03568774461746216,
-0.0260731540620327,
-0.010678800754249096,
0.06733882427215576,
-0.10172382742166519,
0.021541085094213486,
-0.00858707632869482,
-0.0211007222533226,
0.06873331218957901,
-0.04855000972747803,
-0.011247602291405201,
-0.014531975612044334,
0.021871358156204224,
-0.023394279181957245,
0.049173858016729355,
-0.012385206297039986,
0.06862322241067886,
-0.011743010953068733,
-0.0077843316830694675,
0.02821992337703705,
0.013495287857949734,
0.0717424526810646,
0.011348518542945385,
0.05137567222118378,
0.04766928404569626,
0.029210738837718964,
-0.04968761280179024,
-0.02214658446609974,
0.0006278611836023629,
-0.04590783268213272,
0.017623690888285637,
0.03515563905239105,
0.0007150163291953504,
-0.07735708355903625,
0.0407702662050724,
0.061320532113313675,
0.02165117673575878,
0.09533856809139252,
-0.010752194561064243,
-0.012614562176167965,
-0.04179777950048447,
0.01280722115188837,
-0.0816139206290245,
-0.0000030819669518677983,
-0.0015642057405784726,
-0.03864184394478798,
0.043632622808218,
0.012862266041338444,
0.06377922743558884,
0.023761248216032982,
0.06300859153270721,
0.06491683423519135,
0.04766928404569626,
-0.02003651112318039,
0.0172567218542099,
-0.010816413909196854,
-0.011843927204608917,
0.00911459419876337,
-0.037614330649375916,
-0.0018417261308059096,
-0.0014942522393539548,
0.010458619333803654,
-0.0009845092426985502,
0.009862294420599937,
0.030146509408950806,
-0.018807165324687958,
-0.017412682995200157,
-0.015596185810863972,
0.03100888803601265,
-0.04957752302289009,
-0.02421995997428894,
-0.008765974082052708,
0.007614608388394117,
-0.03150429576635361,
0.024917200207710266,
-0.033944640308618546,
-0.05889853835105896,
0.0302932970225811,
-0.008509095758199692,
-0.001986220246180892,
0.00042115437099710107,
-0.02412821725010872,
0.04884358495473862,
-0.015504444018006325,
0.007743047550320625,
0.019210832193493843,
-0.03772442042827606,
-0.04572434723377228,
0.02269703708589077,
0.020623663440346718,
-0.0030779531225562096,
0.00260548060759902,
-0.016100767999887466,
0.04950413107872009,
0.03539416939020157,
-0.008527443744242191,
-0.029082300141453743,
-0.0037407909985631704,
0.014192529022693634,
-0.00892193615436554,
0.01886221021413803,
-0.022219978272914886,
-0.036384984850883484,
-0.033357489854097366,
-0.05588939040899277,
0.05379766598343849,
0.010431095957756042,
-0.04902707040309906,
0.058237992227077484,
-0.02763277292251587,
0.06510031223297119,
0.054861877113580704,
-0.0101925665512681,
-0.04594453051686287,
0.04686195030808449,
-0.05108209699392319,
0.012917311862111092,
-0.003637581132352352,
-0.02100897952914238,
-0.029082300141453743,
0.04851331189274788,
0.006408197805285454,
-0.007967816665768623,
-0.010706323198974133,
-0.03058687224984169,
0.0073577300645411015,
0.05335730314254761,
-0.016926448792219162,
0.053394000977277756,
-0.027155712246894836,
0.0013325564796105027,
-0.017476903274655342,
0.03728405758738518,
-0.009669635444879532,
-0.06708195060491562,
0.032807037234306335,
-0.020898889750242233,
0.019229179248213768,
0.018623681738972664,
-0.054494909942150116,
0.03697213530540466,
-0.045504167675971985,
0.04201795905828476,
0.0036467553582042456,
-0.0037866621278226376,
0.02421995997428894,
0.010229263454675674,
-0.025467654690146446,
-0.013064099475741386,
0.02561444230377674,
0.027430938556790352,
-0.0015676460461691022,
-0.00044408993562683463,
0.0049403212033212185,
-0.02513738162815571,
-0.04480692371726036,
0.0635957419872284,
0.04047669097781181,
0.03590792417526245,
-0.02412821725010872,
0.00638067489489913,
0.05743066221475601,
0.03210979327559471,
-0.01941266469657421,
-0.008903587237000465,
-0.04543077200651169,
-0.016843881458044052,
-0.027779560536146164,
-0.04451334848999977,
0.03249511122703552,
0.020440177991986275,
-0.025302518159151077,
0.011330170556902885,
-0.002256859792396426,
0.03088044933974743,
0.024788761511445045,
-0.04601792246103287,
-0.04733901098370552,
-0.051962822675704956,
0.019357619807124138,
0.04939403757452965,
0.0590820237994194,
-0.014642066322267056,
-0.03911890462040901,
0.006963238585740328,
-0.008701754733920097,
0.03266024962067604,
0.0033348314464092255,
-0.044696833938360214,
-0.04455004632472992,
0.06146731972694397,
-0.006660488899797201,
-0.032385021448135376,
0.030990539118647575,
-0.04715552553534508,
0.007032045163214207,
-0.002288969699293375,
0.048623405396938324,
0.033779505640268326,
-0.00689901877194643,
-0.016825532540678978,
-0.03607306256890297,
-0.033852897584438324,
-0.06110035255551338,
0.0012167318491265178,
-0.0013038869947195053,
-0.03245841711759567,
0.0027178646996617317,
0.008632947690784931,
0.008632947690784931,
-0.016678744927048683,
-0.06264162063598633,
0.022623643279075623,
0.029210738837718964,
0.01269713044166565,
0.06168750301003456,
0.0028600653167814016,
0.05023806914687157,
-0.01822918839752674,
0.05438481643795967,
-0.02152273617684841,
-0.06275171041488647,
-0.027027273550629616,
0.018531939014792442,
-0.04950413107872009,
-0.05713708698749542,
0.06289850175380707,
0.031229069456458092,
-0.09064136445522308,
0.014192529022693634,
0.03464188054203987,
-0.00794946774840355,
0.00822469498962164,
-0.0009145557414740324,
-0.03187126666307449,
0.030660266056656837,
0.012541168369352818,
-0.010687974281609058,
0.02075210213661194,
-0.036513425409793854,
0.017146630212664604,
-0.004213263746351004,
-0.051669247448444366,
-0.023045659065246582,
-0.013761340640485287,
0.010119172744452953,
0.07574241608381271,
-0.042128052562475204,
-0.0379813015460968,
0.048072949051856995,
-0.0030206143856048584,
-0.020495222881436348,
-0.057100389152765274,
0.016054896637797356,
0.020935585722327232,
-0.059045325964689255,
-0.05262336507439613,
-0.05188942700624466,
0.022898871451616287,
-0.02071540430188179,
0.028458451852202415,
0.008435701951384544,
-0.034018032252788544,
0.011522829532623291,
-0.016403518617153168,
0.026550212875008583,
-0.016467737033963203,
-0.00301602715626359,
0.08807258307933807,
0.03590792417526245,
0.0190273467451334,
0.004944908432662487,
0.0027889651246368885,
0.06869661062955856,
-0.04895367473363876,
-0.023908035829663277,
0.016825532540678978,
0.04781607165932655,
-0.031963005661964417,
-0.011054943315684795,
-0.06755901128053665,
-0.03546756133437157,
-0.01624755561351776,
-0.0016788835637271404,
-0.0036513423547148705,
-0.0295410118997097,
0.0507885217666626,
-0.057026997208595276,
-0.02244015969336033,
0.012119154445827007,
0.021797964349389076,
-0.02152273617684841,
0.010596232488751411,
0.02779790759086609,
-0.029339177533984184,
0.04231153428554535,
0.03546756133437157,
0.017999833449721336,
0.020917238667607307,
-0.059595778584480286,
-0.032091446220874786,
0.0564398467540741,
-0.015385178849101067,
0.029632752761244774,
-0.02080714702606201,
0.003667397191748023,
-0.051412370055913925,
-0.015788845717906952,
0.051118794828653336,
0.0020068620797246695,
-0.05475178733468056,
0.018513590097427368,
0.02763277292251587,
-0.013302628882229328,
-0.018614506348967552,
0.05911871790885925,
0.008743038401007652,
0.00021631107665598392,
-0.04924724996089935,
0.003243089187890291,
-0.023742899298667908,
0.003816478420048952,
0.039008814841508865,
-0.10047613829374313,
-0.07155897468328476,
-0.05409124121069908,
0.05159585177898407,
-0.05108209699392319,
0.037907905876636505,
0.017146630212664604,
-0.03787120804190636,
-0.013889780268073082,
0.033265747129917145,
0.038715239614248276,
-0.04766928404569626,
0.008573315106332302,
-0.014183355495333672,
-0.03344923257827759,
0.026862137019634247,
0.06818285584449768,
-0.0012098512379452586,
-0.05977926403284073,
0.018706249073147774,
0.029797889292240143,
0.025724532082676888,
-0.012816395610570908,
-0.002990798093378544,
0.012201721780002117,
-0.026311682537198067,
0.03100888803601265,
-0.0024311700835824013,
-0.052843548357486725,
-0.0069907610304653645,
-0.022678690031170845,
-0.06836634129285812,
0.015073254704475403,
0.027449287474155426,
0.0072797490283846855,
-0.012284290045499802,
-0.0274676363915205,
-0.01713745668530464,
-0.027559379115700722,
0.021632827818393707,
-0.02366950549185276,
0.02708231844007969,
0.029632752761244774,
-0.02126585878431797,
0.02785295434296131,
0.008467811159789562,
0.038201481103897095,
-0.050568338483572006,
-0.0002970155910588801,
0.006798102054744959,
0.01644938997924328,
0.030770357698202133,
-0.013825559988617897,
0.006188016384840012,
-0.0022281904239207506,
0.0520729124546051,
0.020183298736810684,
0.06799937039613724,
0.023908035829663277,
0.028752027079463005,
-0.04686195030808449,
-0.00978890061378479,
0.031082281842827797,
-0.021375948563218117,
-0.009371472522616386,
-0.0036696908064186573,
-0.03856845200061798,
0.04425647109746933,
0.09621929377317429,
0.014082438312470913,
0.020275041460990906,
0.014256749302148819,
0.006637553218752146
] |
725,864 | osqp.interface | version | null | def version(self):
return self._model.version()
| (self) | [
0.05338920280337334,
-0.035852354019880295,
-0.0031125361565500498,
0.040456622838974,
0.07360058277845383,
-0.045399442315101624,
-0.012010031379759312,
-0.012111595831811428,
0.023410674184560776,
0.002539118519052863,
-0.038763877004384995,
-0.04641508683562279,
-0.01928037405014038,
0.036698728799819946,
0.03839147463440895,
-0.026830019429326057,
0.019331157207489014,
-0.04286032170057297,
0.03266999125480652,
0.02413855493068695,
0.01448144018650055,
-0.016741255298256874,
0.009470912627875805,
-0.026999294757843018,
0.01779075711965561,
0.0020090776961296797,
0.04990214481949806,
0.012831012718379498,
0.05758721008896828,
-0.024968000128865242,
-0.07407455146312714,
-0.021971840411424637,
0.038797732442617416,
0.005911914631724358,
-0.00796860083937645,
0.022428881376981735,
-0.009267782792448997,
-0.011671481654047966,
-0.013347300700843334,
-0.03043556772172451,
0.03258535638451576,
0.0171644426882267,
-0.0037980983033776283,
-0.013575821183621883,
-0.015387059189379215,
-0.02220882475376129,
-0.0036774901673197746,
-0.018569421023130417,
0.020939264446496964,
-0.025340404361486435,
0.011773047037422657,
0.018569421023130417,
0.0066948095336556435,
-0.00415357481688261,
-0.06913173943758011,
-0.029910817742347717,
0.041032157838344574,
-0.0032627673353999853,
-0.03608933836221695,
0.07847569137811661,
0.008180193603038788,
0.006250463891774416,
0.020499151200056076,
-0.03253457322716713,
0.01676664687693119,
-0.0010960528161376715,
0.05257668346166611,
0.026119066402316093,
0.012636346742510796,
0.03321167081594467,
-0.014210600405931473,
-0.03307625278830528,
0.031315796077251434,
0.04709218814969063,
-0.03988109156489372,
-0.03383798897266388,
-0.047836996614933014,
0.031146522611379623,
0.005806117784231901,
-0.03346558287739754,
0.02462945133447647,
-0.006216608919203281,
0.0031612026505172253,
-0.03835761919617653,
0.006864083930850029,
-0.07400684058666229,
-0.002615292090922594,
-0.031028030440211296,
-0.03744353726506233,
0.04594111815094948,
-0.04187852889299393,
0.07339745759963989,
-0.02346145547926426,
0.04925890266895294,
0.017122123390436172,
-0.05758721008896828,
-0.008078629150986671,
-0.04032120481133461,
0.05474339798092842,
-0.0023338731843978167,
0.0014314281288534403,
0.07332974672317505,
-0.05098550021648407,
0.04296188801527023,
-0.05975392460823059,
0.010884354822337627,
-0.041201431304216385,
-0.010368067771196365,
-0.012348580174148083,
-0.0605325885117054,
0.025780517607927322,
0.05863671377301216,
0.016775110736489296,
0.01826472580432892,
0.03336402028799057,
-0.033601004630327225,
-0.007435385603457689,
0.0034616650082170963,
0.046211957931518555,
0.03771437704563141,
-0.0450608916580677,
0.07603813707828522,
-0.048954207450151443,
0.018095452338457108,
0.010875891894102097,
0.0033812597393989563,
0.00980099756270647,
-0.03581849858164787,
-0.01441373024135828,
-0.06791295856237411,
0.03825605288147926,
-0.025645097717642784,
-0.006407042499631643,
-0.0037727071903645992,
0.009564013220369816,
-0.04052433371543884,
0.055928319692611694,
0.019805125892162323,
-0.031992893666028976,
0.07922050356864929,
-0.04052433371543884,
0.04743073508143425,
0.04885264113545418,
-0.02332603558897972,
-0.03446430340409279,
0.01722368784248829,
-0.008920770138502121,
-0.0062250723131000996,
0.019060317426919937,
-0.03544609621167183,
0.07163699716329575,
-0.006885243114084005,
0.1065075621008873,
-0.02947070263326168,
-0.05602988600730896,
0.00448577618226409,
-0.022411953657865524,
-0.09980428963899612,
0.030317075550556183,
-0.05393087863922119,
0.0002543086011428386,
0.01627575047314167,
0.016707399860024452,
-0.02073613554239273,
0.001221950864419341,
0.017926177009940147,
-0.07190784066915512,
-0.03761281073093414,
-0.020143674686551094,
-0.0004321791639085859,
-0.025814373046159744,
0.022259606048464775,
-0.011536062695086002,
0.0025412344839423895,
-0.03043556772172451,
0.0913405641913414,
0.021396305412054062,
0.057858049869537354,
0.07048593461513519,
0.009606332518160343,
0.045737989246845245,
-0.001694861683063209,
-0.06828536093235016,
0.034582797437906265,
0.009784070774912834,
0.018857188522815704,
0.008125179447233677,
-0.013491183519363403,
0.02979232557117939,
0.005281366873532534,
0.04682134836912155,
-0.0244432482868433,
0.05829816311597824,
0.014337556436657906,
-0.05291523039340973,
-0.04516245797276497,
0.002651263028383255,
-0.0468890555202961,
0.03608933836221695,
0.025357332080602646,
0.0314173623919487,
-0.04763386398553848,
-0.01253478229045868,
0.027067003771662712,
-0.011840756982564926,
-0.03659716248512268,
0.021311668679118156,
-0.03659716248512268,
-0.003180246101692319,
-0.02669460140168667,
-0.0027316685300320387,
0.002763407537713647,
-0.004549254197627306,
0.03470128774642944,
-0.0013012982672080398,
-0.08768422901630402,
0.0026385674718767405,
-0.048514094203710556,
-0.004430762026458979,
0.00040625897236168385,
0.08016844093799591,
0.018535565584897995,
0.03517525643110275,
0.00022270185581874102,
-0.032923903316259384,
-0.05403244495391846,
0.015945665538311005,
0.03581849858164787,
-0.008247903548181057,
-0.041032157838344574,
0.00009270427835872397,
-0.028048796579241753,
0.021159321069717407,
0.0189248975366354,
-0.028539692983031273,
0.03940712288022041,
-0.042487919330596924,
0.07075677067041397,
-0.03659716248512268,
-0.027794884517788887,
-0.010478096082806587,
-0.002520075300708413,
0.04404524341225624,
0.03192518651485443,
0.01843400113284588,
-0.04438379406929016,
-0.000012480693840188906,
-0.041032157838344574,
0.02247966267168522,
-0.08741339296102524,
0.012111595831811428,
-0.055589769035577774,
-0.009098508395254612,
0.03393955156207085,
0.0398472361266613,
-0.015268567018210888,
0.010647370480000973,
-0.010994384065270424,
0.010554269887506962,
0.018891042098402977,
-0.0514933243393898,
-0.0001401805056957528,
-0.04546714946627617,
0.003925054334104061,
-0.024866435676813126,
-0.000043211301090195775,
-0.008273295126855373,
0.03883158788084984,
0.017672264948487282,
0.05856900289654732,
0.11801823228597641,
0.0015932968817651272,
-0.10549191385507584,
-0.04499318078160286,
-0.018366292119026184,
-0.1501803994178772,
-0.025171129032969475,
-0.013423473574221134,
-0.05870442092418671,
0.01465917844325304,
-0.004193777684122324,
-0.018078524619340897,
0.01610647514462471,
0.0075835008174180984,
-0.04262333735823631,
0.010164937935769558,
-0.016741255298256874,
-0.029098300263285637,
-0.017926177009940147,
-0.0299615990370512,
-0.0031485070940107107,
0.01705441251397133,
0.01659737154841423,
-0.022852066904306412,
0.016191113740205765,
-0.02557738870382309,
-0.021006975322961807,
0.034244246780872345,
0.07001196593046188,
0.0424540638923645,
-0.007693529594689608,
-0.017401427030563354,
0.006813301704823971,
0.023105978965759277,
-0.007651210762560368,
0.05040996894240379,
0.0482771098613739,
-0.013355763629078865,
-0.0070502860471606255,
0.005120555870234966,
-0.06710044294595718,
0.04228479042649269,
0.003730388358235359,
0.028116507455706596,
-0.05721480771899223,
-0.0005096751847304404,
-0.05362618714570999,
0.007689297664910555,
-0.016157258301973343,
0.05183187499642372,
-0.026186777278780937,
0.09526772797107697,
0.03405804559588432,
0.024477103725075722,
-0.03615704923868179,
-0.045433297753334045,
0.011129803024232388,
0.007477704435586929,
-0.04756615683436394,
-0.003994879778474569,
0.002192105632275343,
-0.02329218201339245,
0.06320712715387344,
0.06070186197757721,
-0.016216503456234932,
0.0239862073212862,
0.033736422657966614,
0.009860243648290634,
-0.015243175439536572,
0.038797732442617416,
0.04353741928935051,
0.003049058374017477,
-0.0019360779551789165,
-0.018857188522815704,
-0.08985094726085663,
0.02266586571931839,
0.02462945133447647,
-0.008692249655723572,
0.02249659039080143,
-0.06892860680818558,
-0.06781139224767685,
-0.019703561440110207,
-0.03380413353443146,
-0.008036310784518719,
-0.03366871178150177,
-0.05328763648867607,
-0.00688101164996624,
-0.0028818997088819742,
0.015530942007899284,
0.01994054578244686,
-0.07481936365365982,
0.014896162785589695,
0.0017615135293453932,
0.009267782792448997,
-0.03334709256887436,
-0.004291110672056675,
-0.00853567011654377,
0.029199864715337753,
0.02847198396921158,
-0.022293461486697197,
-0.027270134538412094,
0.02154865302145481,
0.031942110508680344,
-0.008726104162633419,
0.02332603558897972,
0.025492750108242035,
-0.04374055191874504,
0.03177283704280853,
0.0020016718190163374,
-0.07346516847610474,
-0.031214231625199318,
0.025509677827358246,
-0.019195737317204475,
-0.034379664808511734,
0.010164937935769558,
0.0019223244162276387,
-0.01327112689614296,
-0.04587341099977493,
-0.042995743453502655,
-0.012196233496069908,
-0.03151892498135567,
-0.002458713250234723,
-0.042792610824108124,
-0.01166301779448986,
-0.008586453273892403,
0.0366310179233551,
0.02170100063085556,
0.003311433829367161,
-0.005370236001908779,
-0.04868336766958237,
0.018535565584897995,
0.017452208325266838,
0.014489904046058655,
0.011806901544332504,
-0.021599436178803444,
-0.050613097846508026,
0.034904416650533676,
0.04699062183499336,
-0.04871722310781479,
-0.057248663157224655,
-0.03366871178150177,
-0.009961809031665325,
-0.03124808706343174,
-0.008112483657896519,
0.04455306753516197,
0.0012970664538443089,
0.06357952952384949,
-0.05020684003829956,
0.03476899862289429,
0.03206060454249382,
0.042995743453502655,
0.10305435955524445,
0.050748515874147415,
0.04340200126171112,
-0.009699433110654354,
0.020922336727380753,
-0.0302662942558527,
0.0660509392619133,
0.023393746465444565,
0.04834481701254845,
-0.029436849057674408,
-0.028116507455706596,
0.04032120481133461,
0.020346803590655327,
-0.0482771098613739,
-0.03336402028799057,
0.05653770640492439,
-0.031959038227796555,
-0.042183224111795425,
0.029843106865882874,
0.02039758674800396,
-0.0077231526374816895,
0.04418066516518593,
0.013795877806842327,
0.02363073080778122,
-0.01926344633102417,
-0.0001467927941121161,
-0.022462736815214157,
-0.01635192334651947,
-0.0022725111339241266,
-0.061108119785785675,
0.013982079923152924,
-0.00691909808665514,
-0.05758721008896828,
-0.020837699994444847,
0.016385778784751892,
-0.04451921209692955,
-0.04495932534337044,
-0.004997831769287586,
-0.03153585270047188,
-0.04211551323533058,
0.07299119979143143,
0.021785637363791466,
0.0020535122603178024,
-0.01383819617331028,
-0.05975392460823059,
0.018366292119026184,
-0.04837867245078087,
-0.03588620945811272,
0.026339123025536537,
0.054709542542696,
-0.0023677281569689512,
0.0005178744322620332,
-0.031942110508680344,
-0.036664873361587524,
0.03771437704563141,
-0.0084679601714015,
-0.004684674087911844,
-0.0003340528055559844,
-0.050274547189474106,
-0.035683080554008484,
0.03906857222318649,
-0.0045958044938743114,
0.06994425505399704,
0.018400145694613457,
0.01287333108484745,
-0.048649512231349945,
-0.010317285545170307,
0.009826389141380787,
-0.033296309411525726,
0.0017477599903941154,
0.030841827392578125,
-0.017122123390436172,
-0.02297055907547474,
0.02171792834997177,
0.02556046098470688,
-0.006026174873113632,
-0.017519919201731682,
-0.0060642617754638195,
0.05230584368109703,
-0.0008982132421806455,
0.018874114379286766,
0.03595392033457756,
-0.052678246051073074,
-0.01125675905495882,
-0.03322859853506088,
0.0119931036606431,
-0.07393913716077805,
0.04150612652301788,
-0.008493351750075817,
-0.01956814154982567,
-0.036326322704553604,
0.009183146059513092,
0.03889929875731468,
0.00546756898984313,
0.020533006638288498,
-0.027625611051917076,
0.01860327646136284,
0.03446430340409279,
0.04333429038524628,
-0.017739975824952126,
-0.020600715652108192,
0.023055197671055794,
-0.06740513443946838,
-0.039914943277835846,
-0.00626739114522934,
-0.050443824380636215,
-0.030503278598189354,
0.03866231441497803,
0.07116302847862244,
0.03900086134672165,
0.027100859209895134,
-0.021430160850286484,
0.07597042620182037,
-0.031214231625199318,
-0.012771766632795334,
-0.04191238433122635,
0.010393459349870682,
-0.04160768911242485,
-0.009005407802760601,
-0.01667354628443718,
-0.0596185065805912,
-0.015014654956758022,
0.01392283383756876,
0.025678953155875206,
0.009978735819458961,
0.023715367540717125,
-0.01377048622816801,
-0.05958465114235878,
-0.008243671618402004,
-0.05582675337791443,
0.012484000064432621,
0.017172906547784805,
-0.0669650211930275,
0.06290243566036224,
0.07380371540784836,
-0.0004774071858264506,
0.010029518976807594,
0.02070228010416031,
0.000307868147501722,
0.009403202682733536,
-0.02701622247695923,
0.06395193189382553,
0.04221707955002785,
0.017892323434352875,
0.06107426807284355,
0.023105978965759277,
-0.01327112689614296,
0.01863713003695011,
0.025797445327043533,
0.01140910666435957,
-0.011612235568463802,
0.07299119979143143,
0.004748151637613773,
0.006373187527060509,
-0.001307646045461297,
-0.03866231441497803,
0.05308450758457184,
-0.013990543782711029,
0.021447088569402695,
0.04164154455065727,
0.008247903548181057,
0.05911068245768547,
0.011476816609501839,
-0.028607403859496117,
0.0005041208351030946,
-0.02136245183646679,
0.06327483803033829,
0.0023740758188068867,
0.00979253463447094,
-0.034904416650533676,
-0.026152921840548515,
-0.004870875738561153,
0.03366871178150177,
-0.0015647318214178085,
-0.0925593376159668,
-0.040219638496637344,
-0.08605919033288956,
0.031959038227796555,
-0.008353699930012226,
0.057045530527830124,
0.014210600405931473,
0.033431727439165115,
-0.001932904007844627,
0.005463337060064077,
-0.005649539176374674,
-0.044756196439266205,
0.03305932506918907,
0.0450608916580677,
-0.005048613995313644,
-0.006034638732671738,
0.00048534193774685264,
-0.07671523839235306,
-0.11253374069929123,
0.0006347796297632158,
-0.003990648314356804,
0.014760742895305157,
0.007202633190900087,
0.0016398474108427763,
-0.0005234287236817181,
0.03272077441215515,
0.06594937294721603,
0.014930017292499542,
0.012915650382637978,
-0.00036684973747469485,
0.04624581336975098,
-0.05007141828536987,
0.00409221276640892,
0.04641508683562279,
-0.040862880647182465,
0.029758470132946968,
-0.029995454475283623,
0.0517980195581913,
-0.0017668033251538873,
0.012043885886669159,
-0.033245526254177094,
-0.050443824380636215,
-0.004820093512535095,
0.020109819248318672,
0.06770983338356018,
0.023546094074845314,
0.042826466262340546,
0.004132415633648634,
0.00393140222877264,
-0.03774822875857353,
0.0011288498062640429,
-0.02625448629260063,
-0.016394242644309998,
0.03930555656552315,
-0.032923903316259384,
-0.036698728799819946,
-0.026525326073169708,
0.012500927783548832,
-0.016385778784751892,
-0.022852066904306412,
-0.041539981961250305,
-0.013931297697126865,
0.010503487661480904,
-0.04032120481133461,
-0.06300399452447891,
-0.035242967307567596,
-0.011933857575058937,
0.021447088569402695,
-0.030994175001978874,
0.06930100917816162,
0.049936000257730484,
-0.0001670264027779922,
0.004532326944172382,
-0.006081189028918743,
-0.01311877928674221,
-0.035039838403463364,
0.022953633219003677,
0.0017699772724881768,
0.006927561946213245,
-0.07251723110675812,
-0.03551380708813667,
0.026000574231147766,
0.06967341154813766,
0.02009289152920246,
0.0044053709134459496,
0.04892035201191902,
0.01748606376349926,
-0.025814373046159744,
-0.0028226536232978106,
0.015082364901900291,
-0.01408364437520504,
-0.06801452487707138,
0.07468394190073013,
0.03808677941560745,
-0.040862880647182465,
-0.0756995901465416,
-0.014862307347357273,
-0.014346020296216011,
0.0057637994177639484,
0.04370669648051262,
-0.02512034773826599,
0.04157383739948273,
0.054167862981557846,
-0.013728167861700058,
-0.014938481152057648,
0.029826181009411812,
0.03030014969408512,
-0.04011807590723038,
0.023207543417811394,
0.01522624772042036,
0.029369138181209564,
-0.0450608916580677,
-0.014049789868295193,
-0.034379664808511734,
-0.03305932506918907,
0.014244455844163895,
0.04309730604290962,
0.020516078919172287,
-0.011451425030827522,
0.06493372470140457,
0.04187852889299393,
-0.017384499311447144,
0.054337140172719955,
-0.014261382631957531,
0.03561536967754364,
-0.05907682701945305,
-0.020025182515382767,
-0.002264047507196665,
0.006491680163890123,
0.02556046098470688,
0.062394607812166214,
0.00000282262044493109,
0.016665082424879074,
-0.014066717587411404,
0.03459972143173218,
0.00012788164895027876,
-0.04868336766958237,
-0.018891042098402977,
-0.07353287190198898,
0.047498445957899094,
0.04892035201191902,
0.019652778282761574,
-0.015175465494394302,
0.03366871178150177,
-0.04661821946501732,
0.03041864186525345,
0.03612319380044937,
-0.04319887235760689,
-0.011840756982564926,
0.029064444825053215,
0.029843106865882874,
-0.023867715150117874,
0.0018175857840105891,
0.00031474491697736084,
-0.03531067818403244,
0.02151479758322239,
-0.018721768632531166,
0.041032157838344574,
-0.07048593461513519,
0.017037486657500267,
-0.008853060193359852,
0.022868994623422623,
0.01875562220811844,
0.029843106865882874,
-0.007985527627170086,
0.040084220468997955,
-0.04861565679311752,
0.01481998898088932,
0.0029178704135119915,
-0.03578464686870575,
0.02750711888074875,
-0.0023846556432545185,
-0.001805948093533516
] |
725,865 | osqp.interface | warm_start |
Warm start primal or dual variables
| def warm_start(self, x=None, y=None):
"""
Warm start primal or dual variables
"""
# get problem dimensions
(n, m) = self._model.dimensions()
if x is not None:
if len(x) != n:
raise ValueError("Wrong dimension for variable x")
if y is None:
self._model.warm_start_x(x)
if y is not None:
if len(y) != m:
raise ValueError("Wrong dimension for variable y")
if x is None:
self._model.warm_start_y(y)
if x is not None and y is not None:
self._model.warm_start(x, y)
if x is None and y is None:
raise ValueError("Unrecognized fields")
| (self, x=None, y=None) | [
0.021523507311940193,
0.025642096996307373,
0.042633432894945145,
0.035533607006073,
0.018904153257608414,
0.020472319796681404,
-0.008142399601638317,
-0.04670032486319542,
-0.037119004875421524,
-0.001172893331386149,
-0.019455596804618835,
0.023643117398023605,
0.003985037095844746,
0.06272663921117783,
-0.022643625736236572,
-0.06269217282533646,
-0.04246110841631889,
0.004601102322340012,
-0.04184073582291603,
-0.017956361174583435,
0.025711027905344963,
0.03787723928689957,
0.017956361174583435,
0.056557368487119675,
-0.006854263599961996,
0.001105039962567389,
-0.008848936296999454,
0.006444989703595638,
-0.006061564199626446,
-0.019317736849188805,
0.024073932319879532,
0.03811849281191826,
-0.027089634910225868,
-0.013880853541195393,
0.037360262125730515,
-0.019317736849188805,
0.02872673235833645,
0.025848887860774994,
-0.030346594750881195,
-0.022678092122077942,
-0.022419603541493416,
-0.023229533806443214,
0.021454578265547752,
0.04473581165075302,
-0.037187933921813965,
-0.0684133917093277,
0.04794107377529144,
0.03527511656284332,
0.01698271930217743,
0.0026796681340783834,
0.024005001410841942,
-0.06775855273008347,
0.03611951321363449,
-0.03234557434916496,
0.024280723184347153,
0.0491473525762558,
0.004937137942761183,
0.031914759427309036,
0.01978301629424095,
-0.0494920052587986,
0.04490813612937927,
0.02117885649204254,
-0.037256862968206406,
0.01936943456530571,
0.009874275885522366,
-0.01967962086200714,
-0.03908351808786392,
0.005626441445201635,
-0.00946069322526455,
0.03339676558971405,
-0.013458654284477234,
0.004881131928414106,
-0.018680131062865257,
0.015578263439238071,
0.026193540543317795,
-0.004872515331953764,
-0.06941287964582443,
-0.03949710354208946,
-0.009960438124835491,
-0.04397757723927498,
-0.004239217843860388,
0.017232593148946762,
-0.10208588093519211,
-0.030829107388854027,
-0.06731050461530685,
0.013811922632157803,
0.0025159583892673254,
0.032087087631225586,
0.05552341416478157,
-0.05290405824780464,
-0.04477027431130409,
0.08671440184116364,
0.00902126170694828,
0.08726584911346436,
0.07954564690589905,
0.04363292455673218,
0.0009208666742779315,
-0.010985777713358402,
-0.0369122140109539,
-0.003801940707489848,
-0.010391253046691418,
0.007883911021053791,
-0.030932502821087837,
0.01783573254942894,
-0.005665214732289314,
0.013794690370559692,
0.021265018731355667,
-0.010735904797911644,
-0.011924954131245613,
-0.009641635231673717,
-0.059107791632413864,
-0.03618844226002693,
-0.07237688452005386,
0.05280066281557083,
-0.08981627225875854,
-0.013475887477397919,
-0.03935924172401428,
0.042805761098861694,
0.03822188824415207,
0.04139268770813942,
-0.028037426993250847,
0.015293926000595093,
-0.037325795739889145,
-0.009253902360796928,
0.031397782266139984,
0.0392213799059391,
0.04663139581680298,
0.006832723040133715,
-0.004997451789677143,
-0.06058979406952858,
0.00609172135591507,
-0.010365404188632965,
-0.018576733767986298,
0.07354870438575745,
-0.06527706235647202,
-0.007457404397428036,
0.006716402713209391,
0.002787371864542365,
0.04625227674841881,
-0.013114002533257008,
0.010287857614457607,
0.010072450153529644,
-0.005699679721146822,
0.0034745214506983757,
-0.02035169117152691,
0.02652096003293991,
0.009529623202979565,
-0.0052559408359229565,
0.02495279349386692,
0.07864955067634583,
-0.01332940999418497,
-0.01712919771671295,
0.02781340479850769,
-0.07034344226121902,
-0.06393291801214218,
0.001063574105501175,
-0.026951774954795837,
-0.026986239477992058,
0.0340343713760376,
-0.015810903161764145,
-0.07272154092788696,
-0.05169777572154999,
0.048423584550619125,
-0.0262452382594347,
-0.004846666473895311,
0.010899614542722702,
-0.06731050461530685,
-0.0007156911306083202,
0.029484964907169342,
0.032793622463941574,
0.01225237362086773,
-0.0215752050280571,
0.03577486053109169,
-0.022919347509741783,
0.05576466768980026,
-0.0014109185431152582,
-0.01432890072464943,
-0.062140729278326035,
0.015147448517382145,
0.04956093430519104,
0.022006019949913025,
-0.0031686429865658283,
-0.018094221130013466,
-0.056764159351587296,
-0.012821048498153687,
0.04135822132229805,
-0.0064966874197125435,
-0.026865610852837563,
0.0015121599426493049,
0.04966432973742485,
0.04473581165075302,
-0.013381107710301876,
-0.020127667114138603,
0.012097279541194439,
-0.018404409289360046,
0.06999879330396652,
0.07968350499868393,
-0.06513919681310654,
0.045976556837558746,
0.00509653938934207,
-0.022419603541493416,
0.034878768026828766,
0.0048035853542387486,
0.030484456568956375,
0.01654328778386116,
0.037429191172122955,
-0.03182859718799591,
0.056522902101278305,
-0.040151938796043396,
0.000912788906134665,
-0.00021231092978268862,
-0.048630375415086746,
-0.011614766903221607,
0.017379069700837135,
0.021764764562249184,
-0.032931484282016754,
0.03798063471913338,
-0.021609671413898468,
0.022936580702662468,
-0.015328390523791313,
0.06365719437599182,
-0.019352201372385025,
-0.04480474069714546,
0.014096261002123356,
0.013967015780508518,
-0.005777226760983467,
-0.016741463914513588,
-0.002856302075088024,
-0.062209658324718475,
-0.03325890377163887,
0.01094269659370184,
-0.0217475313693285,
-0.03522342070937157,
-0.06927502155303955,
0.02869226597249508,
0.04104803502559662,
0.034775372594594955,
0.03482706844806671,
-0.026641588658094406,
-0.06283003091812134,
-0.01572474092245102,
0.002270394004881382,
-0.005479964427649975,
-0.07458265870809555,
-0.04414990171790123,
0.02450474724173546,
0.007345392368733883,
0.014664935879409313,
-0.032224949449300766,
0.03260406479239464,
-0.0024319496005773544,
0.028985220938920975,
-0.002645202912390232,
0.01835271157324314,
0.009788112714886665,
0.01675008051097393,
0.022919347509741783,
0.0026495109777897596,
-0.014751099050045013,
-0.027089634910225868,
-0.02443581633269787,
-0.0027249036356806755,
-0.031707968562841415,
0.04063445329666138,
-0.0033905126620084047,
0.04401203989982605,
-0.06965413689613342,
0.0053377957083284855,
0.006052948068827391,
-0.01967962086200714,
0.00222515850327909,
0.023987768217921257,
0.028106357902288437,
0.01095992885529995,
0.021540740504860878,
-0.0031923376955091953,
-0.05262833833694458,
-0.011476906947791576,
0.029898548498749733,
0.012347152456641197,
0.0014033792540431023,
-0.019110944122076035,
0.018473338335752487,
-0.006440681405365467,
-0.05176670849323273,
-0.06486348062753677,
-0.016551904380321503,
-0.03618844226002693,
0.01895585097372532,
-0.05348996818065643,
-0.029502198100090027,
0.06765516102313995,
0.06086551770567894,
0.007125677075237036,
0.03132885321974754,
-0.001963438466191292,
-0.011347661726176739,
0.006040023639798164,
-0.009202204644680023,
0.01596599631011486,
0.07899420708417892,
-0.02502172440290451,
-0.04125482589006424,
0.00451063085347414,
0.029433267191052437,
-0.004368462134152651,
0.059073325246572495,
0.01220067497342825,
0.01814592070877552,
-0.03636077046394348,
0.0004604333371389657,
0.03060508333146572,
-0.03196645900607109,
-0.01313985139131546,
-0.01912817731499672,
-0.037119004875421524,
0.007832213304936886,
0.02862333506345749,
-0.05338657274842262,
0.045631904155015945,
0.0259005855768919,
-0.03387927636504173,
0.023332929238677025,
0.040151938796043396,
-0.014165190979838371,
0.030346594750881195,
0.05872867628931999,
-0.03434455767273903,
-0.05000898241996765,
-0.03618844226002693,
0.0024233332369476557,
-0.0026322784833610058,
-0.023608651012182236,
0.024073932319879532,
-0.008383655920624733,
-0.047975536435842514,
-0.007229072507470846,
0.006272663827985525,
0.04642460495233536,
-0.0003341507399454713,
0.048320189118385315,
-0.018507804721593857,
-0.03175966814160347,
-0.006100337486714125,
0.08933375775814056,
-0.02198878861963749,
0.06103784218430519,
-0.06768961995840073,
0.06058979406952858,
-0.01191633753478527,
-0.025659330189228058,
0.053558897227048874,
-0.007957149296998978,
-0.059004396200180054,
0.04390864446759224,
0.03043275885283947,
-0.04463241249322891,
0.03543021157383919,
-0.01329494547098875,
0.002066834131255746,
-0.027761707082390785,
0.018404409289360046,
-0.08023495227098465,
0.04473581165075302,
-0.006078796926885843,
-0.019903644919395447,
-0.03308657556772232,
0.01589706726372242,
-0.021092692390084267,
0.024659840390086174,
-0.024832164868712425,
-0.05293852463364601,
-0.07837382704019547,
0.014966506510972977,
-0.03355185687541962,
0.04701051115989685,
0.027210263535380363,
-0.0034185154363512993,
0.04480474069714546,
-0.0014066103613004088,
0.03250066936016083,
-0.04390864446759224,
0.004691573325544596,
-0.0064148325473070145,
-0.07485838234424591,
0.03043275885283947,
0.039807289838790894,
-0.08333681523799896,
0.04159947857260704,
0.014664935879409313,
0.09588214755058289,
-0.01818038523197174,
0.05893546715378761,
0.026641588658094406,
0.05772918462753296,
0.01964515447616577,
0.0883687362074852,
0.02495279349386692,
-0.02467707172036171,
0.009245285764336586,
0.006750868167728186,
-0.012795199640095234,
-0.011752627789974213,
0.04111696407198906,
-0.007970074191689491,
-0.09257348626852036,
0.03217324987053871,
-0.008616296574473381,
-0.00985704269260168,
0.09691610187292099,
-0.012760735116899014,
-0.0249183289706707,
-0.000593447417486459,
0.006970583461225033,
-0.016491590067744255,
-0.04959540069103241,
0.04401203989982605,
0.017318755388259888,
0.0418751984834671,
0.04366739094257355,
0.02181646227836609,
0.01800805889070034,
0.01985194720327854,
0.022884882986545563,
-0.03598165139555931,
0.005859081633388996,
-0.017043033614754677,
-0.06003835052251816,
0.023401860147714615,
0.016767311841249466,
-0.06696585565805435,
0.013932551257312298,
0.006199425086379051,
-0.007767591159790754,
0.020713575184345245,
-0.04869930446147919,
0.01668114960193634,
0.02097206562757492,
0.024229025468230247,
-0.040220871567726135,
0.011700930073857307,
-0.011097789742052555,
0.04962986707687378,
-0.030001943930983543,
-0.04625227674841881,
0.01312261912971735,
-0.005604900885373354,
0.037498120218515396,
-0.05552341416478157,
0.06248537823557854,
0.015500716865062714,
-0.004424468148499727,
0.04873377084732056,
0.0023630191572010517,
0.04763088375329971,
-0.020041504874825478,
-0.08533579856157303,
-0.0035197569523006678,
0.03213878348469734,
-0.0249183289706707,
-0.013355258852243423,
0.001983902184292674,
-0.02600398287177086,
0.0028067585080862045,
-0.028554406017065048,
-0.011511371470987797,
-0.05862528085708618,
0.03849761188030243,
0.0020237525459378958,
-0.011588918045163155,
-0.028106357902288437,
0.018369942903518677,
0.02376374416053295,
-0.0827164426445961,
0.02617630735039711,
0.006703478284180164,
-0.01919710822403431,
0.043219342827796936,
0.111667200922966,
-0.03642969951033592,
-0.003293579211458564,
-0.007052438333630562,
0.04087571054697037,
0.05783258005976677,
0.025004491209983826,
-0.0007313081296160817,
-0.0024147171061486006,
-0.015810903161764145,
0.00018363480921834707,
0.012045581825077534,
0.020679110661149025,
0.013053689152002335,
0.03343122825026512,
0.011304580606520176,
-0.06420864164829254,
-0.014130725525319576,
-0.00846120249480009,
-0.0260729119181633,
0.06934395432472229,
0.06131356209516525,
-0.0029403110966086388,
0.007384165655821562,
-0.031811363995075226,
0.03022596798837185,
0.00890063401311636,
0.07589233666658401,
-0.056626297533512115,
-0.01432890072464943,
-0.06710371375083923,
0.03880779817700386,
0.022678092122077942,
-0.045287251472473145,
-0.009538239799439907,
0.00806485302746296,
0.019662387669086456,
0.0067077865824103355,
0.007646963000297546,
0.06986092776060104,
0.003995807375758886,
-0.061968401074409485,
-0.02195432223379612,
0.03770491108298302,
0.06486348062753677,
-0.004575253464281559,
0.015354239381849766,
0.021454578265547752,
-0.027451518923044205,
-0.040289800614118576,
-0.00947792548686266,
0.05014684423804283,
0.05766025558114052,
-0.06152035668492317,
-0.022247277200222015,
0.04873377084732056,
0.00012991759285796434,
-0.03591272234916687,
-0.005505813285708427,
-0.059349048882722855,
0.0040044235065579414,
-0.05187010392546654,
0.0050534578040242195,
0.004657107871025801,
0.03611951321363449,
0.018904153257608414,
-0.0012019732967019081,
-0.006074488628655672,
-0.05638504400849342,
0.06917162239551544,
-0.10911677777767181,
0.012734885327517986,
-0.028226986527442932,
-0.0265898909419775,
-0.02233343943953514,
0.033724185079336166,
-0.008745540864765644,
-0.0784427598118782,
0.01899031735956669,
0.040014080703258514,
-0.010658358223736286,
0.07230795919895172,
0.025590399280190468,
-0.033034879714250565,
0.10635956376791,
-0.001704949652776122,
-0.0494920052587986,
-0.028485475108027458,
-0.042426642030477524,
0.00973641499876976,
-0.009900124743580818,
-0.0022143882233649492,
0.02205771766602993,
0.03811849281191826,
-0.026917308568954468,
0.05152545124292374,
-0.008478435687720776,
0.022178346291184425,
0.007328160107135773,
-0.004975911229848862,
-0.10194801539182663,
0.0038299437146633863,
0.011993884108960629,
-0.013458654284477234,
0.003412053221836686,
-0.027003472670912743,
0.01671561412513256,
0.045666370540857315,
-0.03563700243830681,
0.02447028085589409,
0.012028349563479424,
-0.012691804207861423,
-0.013648212887346745,
0.033379532396793365,
-0.03642969951033592,
-0.0006149881519377232,
-0.04363292455673218,
0.03898012265563011,
0.023746512830257416,
-0.027089634910225868,
0.07506517320871353,
-0.004566636867821217,
-0.07168758660554886,
-0.015440402552485466,
0.010632509365677834,
-0.018025292083621025,
-0.03193199262022972,
-0.00561782531440258,
-0.019696852192282677,
0.05273173376917839,
-0.014483993873000145,
-0.06393291801214218,
0.012777967378497124,
-0.05803937092423439,
-0.0016209407476708293,
0.026400331407785416,
-0.07892527431249619,
-0.009719181805849075,
0.011451058089733124,
-0.03611951321363449,
0.056316111236810684,
-0.07354870438575745,
-0.023953303694725037,
0.011976651847362518,
0.03043275885283947,
-0.0071127526462078094,
0.05569573864340782,
0.048320189118385315,
0.06606975942850113,
-0.07341084629297256,
0.03475813940167427,
-0.03475813940167427,
-0.006824106443673372,
0.01619863696396351,
-0.020885901525616646,
-0.026538193225860596,
0.021592438220977783,
0.009615786373615265,
0.01038263738155365,
0.0027701391372829676,
-0.026572657749056816,
-0.015561031177639961,
-0.02648649364709854,
0.04459794983267784,
0.03660202771425247,
0.014716633595526218,
-0.0059624770656228065,
-0.02593505196273327,
-0.022798718884587288,
-0.00022496610472444445,
0.06155481934547424,
0.005066382233053446,
-0.018301013857126236,
-0.043495062738657,
-0.028554406017065048,
0.039669428020715714,
0.05255940556526184,
-0.006923194043338299,
-0.0029877007473260164,
-0.07120507210493088,
0.05280066281557083,
-0.04339166730642319,
0.0219198577105999,
0.023643117398023605,
0.025659330189228058,
-0.020162133499979973,
0.01695687137544155,
-0.010279241017997265,
-0.011356278322637081,
-0.06799980998039246,
0.0020603719167411327,
0.04373631998896599,
-0.025848887860774994,
-0.07430693507194519,
-0.0009402533178217709,
0.011330429464578629,
0.02107546105980873,
-0.014337517321109772,
-0.014423679560422897,
-0.014966506510972977,
-0.043184876441955566,
-0.013820539228618145,
0.03401713818311691,
-0.054075874388217926,
0.053903549909591675,
-0.04170287400484085,
-0.01191633753478527,
0.001517545199021697,
-0.03625737503170967,
-0.006979200057685375,
0.03560253605246544,
0.06455329060554504,
-0.025487003847956657,
-0.005518737714737654,
0.022609161213040352,
0.008349191397428513,
-0.03063954971730709,
-0.05597145855426788,
-0.03251790255308151,
-0.03315550833940506,
0.04184073582291603,
-0.025004491209983826,
-0.018731828778982162,
0.03377588093280792,
-0.04976772516965866,
0.0247460026293993,
-0.030691247433423996,
0.0501813106238842,
-0.03860100731253624,
0.03036382794380188,
0.027382589876651764,
-0.059900492429733276,
0.04873377084732056,
-0.03263853117823601,
0.01657775416970253,
-0.005902162753045559,
0.04111696407198906,
-0.01162338349968195,
-0.014690784737467766,
0.014483993873000145,
0.013320794329047203,
0.03908351808786392,
0.018611200153827667,
0.008375040255486965,
-0.03332783281803131,
-0.0026581273414194584,
0.013088153675198555,
0.023195069283246994,
0.011735395528376102,
-0.05803937092423439,
0.016146939247846603,
-0.02031722664833069,
-0.014509842731058598,
0.009365914389491081,
0.007332467939704657,
-0.0012945984490215778,
0.03660202771425247,
-0.027089634910225868,
-0.03653309494256973,
0.013269096612930298,
0.026917308568954468,
-0.01885245554149151,
-0.029777919873595238,
-0.03953156620264053,
0.019110944122076035,
-0.03158734366297722,
0.00902126170694828,
0.03458581119775772,
0.030243199318647385,
-0.015535182319581509,
-0.030243199318647385,
0.03315550833940506,
0.016345113515853882,
0.029192011803388596,
0.019490061327815056,
0.010218927636742592,
0.0044373925775289536,
0.001284905127249658,
-0.034706439822912216,
0.009340065531432629,
0.00524301640689373,
-0.05610932037234306,
-0.04215092211961746,
-0.07306618988513947,
0.013562050648033619,
0.05755686014890671,
-0.008577522821724415,
0.037256862968206406,
0.06858571618795395,
0.06458775699138641
] |
725,871 | qsm_forward.qsm_forward | ReconParams |
A class used to represent reconstruction parameters.
Attributes
----------
subject : str
The ID of the subject.
session : str
The ID of the session.
acq : str
The acquisition name.
run : int
The run number.
TR : float
Repetition time (in seconds).
TEs : np.array
Echo times (in seconds).
flip_angle : int
Flip angle (in degrees).
B0 : int
Magnetic field strength (in Tesla).
B0_dir : np.array
B0 field direction.
phase_offset : int
Phase offset (in radians).
generate_phase_offset : bool
Boolean to control phase offset generation.
generate_shim_field : bool
Boolean to control shim field generation.
voxel_size : np.array
Voxel size (in mm).
peak_snr : float
Peak signal-to-noise ratio.
random_seed : int
Random seed to use for noise.
suffix : string
The BIDS-compliant suffix that defines the weighting of the images (e.g. T1w, T2starw, PD).
save_phase : bool
Boolean to control whether phase images are saved.
| class ReconParams:
"""
A class used to represent reconstruction parameters.
Attributes
----------
subject : str
The ID of the subject.
session : str
The ID of the session.
acq : str
The acquisition name.
run : int
The run number.
TR : float
Repetition time (in seconds).
TEs : np.array
Echo times (in seconds).
flip_angle : int
Flip angle (in degrees).
B0 : int
Magnetic field strength (in Tesla).
B0_dir : np.array
B0 field direction.
phase_offset : int
Phase offset (in radians).
generate_phase_offset : bool
Boolean to control phase offset generation.
generate_shim_field : bool
Boolean to control shim field generation.
voxel_size : np.array
Voxel size (in mm).
peak_snr : float
Peak signal-to-noise ratio.
random_seed : int
Random seed to use for noise.
suffix : string
The BIDS-compliant suffix that defines the weighting of the images (e.g. T1w, T2starw, PD).
save_phase : bool
Boolean to control whether phase images are saved.
"""
def __init__(
self,
subject="1",
session=None,
acq=None,
run=None,
TR=50e-3,
TEs=np.array([ 4e-3, 12e-3, 20e-3, 28e-3 ]),
flip_angle=15,
B0=7,
B0_dir=np.array([0, 0, 1]),
phase_offset=0,
generate_phase_offset=True,
generate_shim_field=True,
voxel_size=np.array([1.0, 1.0, 1.0]),
peak_snr=np.inf,
random_seed=None,
suffix="T2starw",
save_phase=True
):
self.subject = subject
self.session = session
self.acq = acq
self.run = run
self.TR = TR
self.TEs = TEs
self.flip_angle = flip_angle
self.B0 = B0
self.B0_dir = B0_dir
self.phase_offset = phase_offset
self.generate_phase_offset = generate_phase_offset
self.generate_shim_field = generate_shim_field
self.voxel_size = voxel_size
self.peak_snr = peak_snr
self.random_seed = random_seed
self.suffix = suffix
self.save_phase = save_phase
| (subject='1', session=None, acq=None, run=None, TR=0.05, TEs=array([0.004, 0.012, 0.02 , 0.028]), flip_angle=15, B0=7, B0_dir=array([0, 0, 1]), phase_offset=0, generate_phase_offset=True, generate_shim_field=True, voxel_size=array([1., 1., 1.]), peak_snr=inf, random_seed=None, suffix='T2starw', save_phase=True) | [
0.04129919037222862,
-0.06452304124832153,
-0.07963521033525467,
0.008264468051493168,
-0.03418758139014244,
-0.04385492578148842,
-0.06085611879825592,
-0.040743596851825714,
0.04822560399770737,
-0.011658224277198315,
-0.03352086991071701,
0.04948494955897331,
0.009695123881101608,
0.08793208748102188,
-0.019427288323640823,
0.013806523755192757,
0.034002382308244705,
0.023760924115777016,
-0.018204979598522186,
-0.007398666813969612,
0.002960855606943369,
0.03381718695163727,
-0.026279618963599205,
0.07644980400800705,
0.005796702578663826,
0.026112942025065422,
0.019649526104331017,
-0.04011392220854759,
-0.04596618562936783,
0.01138042751699686,
-0.01101929135620594,
-0.019019851461052895,
0.00754219526425004,
0.029613187536597252,
-0.017954962328076363,
-0.035132091492414474,
0.02774268575012684,
0.047744087874889374,
-0.10534071922302246,
0.032668955624103546,
-0.0010232198983430862,
-0.044966116547584534,
0.07163465023040771,
-0.07407926768064499,
-0.01492697186768055,
0.036576636135578156,
-0.019334688782691956,
0.0411880724132061,
-0.0432252511382103,
-0.012028620578348637,
0.05385562777519226,
-0.06678245961666107,
-0.006241178140044212,
0.012269378639757633,
-0.03739150986075401,
0.035761766135692596,
0.002562679583206773,
0.07126425206661224,
0.05018870159983635,
-0.03522469103336334,
-0.005014240276068449,
-0.023705365136265755,
0.04207702353596687,
0.022575655952095985,
-0.007236618548631668,
0.01579740270972252,
-0.06326369196176529,
0.0083015076816082,
0.038113784044981,
0.023279409855604172,
0.06656022369861603,
-0.03226152062416077,
-0.006773623172193766,
0.0026668536011129618,
-0.009982180781662464,
-0.017593825235962868,
-0.1050444021821022,
-0.02759452722966671,
-0.016149280592799187,
-0.032983794808387756,
0.031076252460479736,
0.04907751455903053,
0.013519465923309326,
-0.06400448828935623,
0.0316503681242466,
-0.036261800676584244,
-0.018677234649658203,
-0.017047490924596786,
0.034724656492471695,
-0.07485710084438324,
-0.041151031851768494,
-0.010028480552136898,
0.030039142817258835,
0.03381718695163727,
0.020686635747551918,
0.008537635207176208,
-0.031946685165166855,
-0.06763437390327454,
-0.010760013945400715,
-0.08363549411296844,
-0.050114624202251434,
-0.026853734627366066,
-0.026390738785266876,
0.01508439052850008,
-0.0074310763739049435,
-0.010297018103301525,
-0.043891966342926025,
0.00778758293017745,
0.011898982338607311,
-0.047447770833969116,
-0.011611925438046455,
0.08170942962169647,
-0.06911595910787582,
0.024538757279515266,
-0.0024214659351855516,
-0.046151384711265564,
-0.026020342484116554,
0.013621325604617596,
-0.03716927021741867,
0.011750823818147182,
0.02348312735557556,
0.011519325897097588,
-0.0628192201256752,
0.07326439768075943,
0.013732444494962692,
0.008815432898700237,
0.022353418171405792,
0.05152212828397751,
0.0011794808087870479,
-0.10867428779602051,
0.0051716589368879795,
0.0018647140823304653,
-0.050225742161273956,
-0.0036067343316972256,
0.03692851588129997,
-0.015899263322353363,
0.04781816527247429,
0.013436127454042435,
-0.037706345319747925,
0.025205470621585846,
0.052337002009153366,
0.026372218504548073,
0.005505015607923269,
-0.006597684696316719,
0.026594456285238266,
-0.017278989776968956,
0.03639144077897072,
-0.08096864074468613,
-0.02296457253396511,
0.03027990087866783,
-0.006398596800863743,
0.009426586329936981,
0.00569021375849843,
0.025316588580608368,
0.026835214346647263,
-0.07441262155771255,
0.04385492578148842,
-0.0015336723299697042,
-0.04807744547724724,
0.011241529136896133,
-0.01353798620402813,
0.0035604347940534353,
-0.020834794268012047,
-0.03270599618554115,
0.005588354542851448,
0.01839943788945675,
0.012167519889771938,
0.0005026393919251859,
0.001704980619251728,
0.018177200108766556,
0.02192746289074421,
-0.0679306909441948,
-0.07904257625341415,
-0.014806593768298626,
-0.044817958027124405,
0.09482146054506302,
-0.020149560645222664,
-0.0070190103724598885,
-0.031372569501399994,
-0.0071254996582865715,
0.016102980822324753,
-0.013121290132403374,
-0.02209414169192314,
-0.03252079710364342,
0.02079775370657444,
0.052114762365818024,
0.03907681256532669,
0.021334828808903694,
0.07404222339391708,
-0.03594696521759033,
0.04537355154752731,
0.011334127746522427,
-0.007014380767941475,
0.040188003331422806,
0.012611995451152325,
-0.03453945741057396,
0.019390247762203217,
-0.016065940260887146,
0.06207842379808426,
0.08370956778526306,
0.006810662802308798,
-0.003444685833528638,
0.0002543581067584455,
-0.030705856159329414,
0.004083619453012943,
-0.027631565928459167,
0.017593825235962868,
-0.019742123782634735,
0.0028242720291018486,
0.026575936004519463,
-0.012482356280088425,
-0.027872323989868164,
0.06222658231854439,
-0.04189182445406914,
0.05726327374577522,
-0.0648563951253891,
0.02192746289074421,
0.04163254797458649,
-0.008426516316831112,
0.0035650646314024925,
0.07748690992593765,
0.015741843730211258,
-0.0033567168284207582,
0.004319747444242239,
-0.028335319831967354,
0.02053847722709179,
0.0032178182154893875,
0.004560505039989948,
-0.016797473654150963,
-0.024427637457847595,
0.016149280592799187,
0.0013450017431750894,
-0.0396324060857296,
-0.005884671583771706,
0.015862222760915756,
0.015658505260944366,
-0.022316379472613335,
0.01790866255760193,
-0.031020693480968475,
-0.024205399677157402,
0.003328937105834484,
0.0031807785853743553,
-0.004155383910983801,
0.013704664073884487,
-0.019168009981513023,
-0.04011392220854759,
0.05844854190945625,
0.04278077557682991,
-0.0628192201256752,
0.009292317554354668,
0.009954401291906834,
-0.045484669506549835,
-0.033020831644535065,
0.04355860874056816,
0.008454296737909317,
-0.016640055924654007,
-0.018964292481541634,
-0.004706348292529583,
0.05322595313191414,
-0.022168220952153206,
0.03537284955382347,
-0.03390978276729584,
-0.012037880718708038,
0.057226233184337616,
-0.022149700671434402,
0.053670428693294525,
-0.037298910319805145,
-0.005694843828678131,
-0.0370766744017601,
-0.01006552018225193,
0.015362188220024109,
0.06867147982120514,
-0.06511567533016205,
-0.01310276985168457,
-0.018242020159959793,
-0.009713644161820412,
0.00267611350864172,
0.003173833480104804,
-0.0011360750067979097,
0.025298070162534714,
0.020519956946372986,
-0.06467120349407196,
0.037558186799287796,
-0.0036692386493086815,
0.016445597633719444,
-0.006319887470453978,
-0.035187650471925735,
0.0684862807393074,
0.0597078874707222,
0.018056821078062057,
-0.01987176388502121,
0.0012859697453677654,
0.05281851813197136,
0.014667694456875324,
0.053818587213754654,
-0.006241178140044212,
-0.04881823807954788,
-0.019168009981513023,
0.03265043720602989,
-0.02163114584982395,
-0.00635692710056901,
0.016649315133690834,
0.02244601771235466,
-0.014964011497795582,
-0.030761415138840675,
0.005963380914181471,
0.026946334168314934,
-0.023038651794195175,
0.0432622916996479,
0.019112451002001762,
0.012260118499398232,
0.019371727481484413,
0.03635440021753311,
0.03370606526732445,
0.03174296393990517,
-0.05452233925461769,
0.03531729057431221,
-0.028279760852456093,
0.023538686335086823,
0.07556085288524628,
-0.00372711312957108,
0.018825393170118332,
-0.0437808483839035,
-0.01747344620525837,
0.02363128587603569,
-0.056707680225372314,
-0.008796912617981434,
0.019853243604302406,
-0.0011135039385408163,
0.002764082746580243,
-0.07859810441732407,
0.014047280885279179,
-0.007144019473344088,
0.049707189202308655,
-0.0029816904570907354,
-0.02255713753402233,
0.010121080093085766,
0.010139599442481995,
0.032613396644592285,
-0.03726186975836754,
0.0530407540500164,
-0.04544762894511223,
-0.054188985377550125,
0.05185548588633537,
-0.01538996770977974,
-0.04422532394528389,
-0.012371237389743328,
-0.02100147120654583,
0.05033686012029648,
-0.00937102735042572,
0.008773762732744217,
0.025705505162477493,
0.03970648720860481,
0.10059964656829834,
0.06259697675704956,
0.02311273105442524,
-0.02990950457751751,
-0.010278497822582722,
0.019334688782691956,
-0.030724376440048218,
0.026890773326158524,
0.013556505553424358,
-0.02152002789080143,
0.004706348292529583,
0.013658365234732628,
0.018038300797343254,
-0.05641136318445206,
-0.011593405157327652,
0.024538757279515266,
-0.03381718695163727,
-0.007241248153150082,
-0.027372289448976517,
-0.04804040491580963,
-0.02496471256017685,
0.006250438280403614,
0.026446297764778137,
-0.04763296991586685,
0.005120729096233845,
0.008032970130443573,
-0.035446930676698685,
0.02429799921810627,
0.003717853222042322,
0.017343807965517044,
0.021797824651002884,
-0.030409539118409157,
-0.03077993541955948,
0.011676744557917118,
0.03531729057431221,
0.08200574666261673,
-0.001221150392666459,
-0.04041023924946785,
0.011648965068161488,
0.003495615441352129,
-0.020297719165682793,
-0.04504019394516945,
-0.008482076227664948,
0.003250227775424719,
0.04915159195661545,
-0.04700329527258873,
-0.043114133179187775,
-0.02192746289074421,
-0.06974563002586365,
-0.028298279270529747,
0.05622616410255432,
0.0391138531267643,
-0.04344749078154564,
0.09015446901321411,
0.0591893345117569,
0.01576036401093006,
-0.008421886712312698,
-0.011861942708492279,
-0.022205259650945663,
-0.005972641054540873,
0.011213748715817928,
-0.043484531342983246,
-0.027150051668286324,
-0.035539526492357254,
-0.0176401250064373,
0.03594696521759033,
0.009695123881101608,
-0.0006140476907603443,
0.07896849513053894,
0.058559659868478775,
0.05944861099123955,
0.01628817804157734,
0.06137467175722122,
0.032613396644592285,
0.01274163369089365,
-0.016964152455329895,
-0.0026460187509655952,
-0.076227568089962,
0.02516843006014824,
-0.05792998522520065,
-0.014769554138183594,
0.012667554430663586,
-0.0011499648680910468,
-0.011260048486292362,
0.022983092814683914,
0.016538197174668312,
0.025298070162534714,
0.019834723323583603,
-0.0003394335217308253,
-0.01810312084853649,
-0.045892104506492615,
-0.028187161311507225,
-0.02877979539334774,
-0.0290946327149868,
0.010213678702712059,
-0.00794037152081728,
0.012547175399959087,
0.04355860874056816,
0.03653959929943085,
-0.028094561770558357,
-0.04107695445418358,
0.008060750551521778,
-0.00009042879537446424,
0.02846495807170868,
-0.0027432478964328766,
-0.027927882969379425,
-0.11319311708211899,
0.03428018093109131,
0.014713994227349758,
-0.0030603997875005007,
0.03685443475842476,
0.010445176623761654,
0.03948424756526947,
0.08296877890825272,
-0.00030702384538017213,
-0.0411880724132061,
-0.01940876804292202,
-0.003657663706690073,
0.019427288323640823,
0.010963731445372105,
-0.0035534899216145277,
0.02609442174434662,
0.009417327120900154,
-0.02496471256017685,
0.018556855618953705,
-0.07252360135316849,
-0.05807814374566078,
-0.009602525271475315,
-0.04370676726102829,
0.0008414941839873791,
0.026075901463627815,
0.0053800069727003574,
-0.04281781613826752,
-0.01851055584847927,
0.01914948970079422,
-0.010445176623761654,
-0.01929764822125435,
-0.07270880043506622,
0.004317432176321745,
-0.01243605650961399,
0.09815502911806107,
-0.022723814472556114,
0.06267105787992477,
-0.010445176623761654,
0.0005793230375275016,
-0.021686704829335213,
-0.032557837665081024,
0.053151872009038925,
-0.028816834092140198,
-0.028242720291018486,
-0.023186810314655304,
0.006153209134936333,
-0.08356141299009323,
-0.10497032105922699,
-0.02203858271241188,
-0.015038090758025646,
0.01929764822125435,
-0.017140090465545654,
-0.03057621791958809,
-0.012630514800548553,
-0.022686775773763657,
0.0032131881453096867,
0.015399227850139141,
-0.05237404257059097,
0.006657874211668968,
-0.03833601996302605,
-0.008759872987866402,
0.005301297642290592,
0.04063247889280319,
0.029872464016079903,
0.03440982103347778,
0.0072690281085669994,
0.04103991389274597,
-0.004657733719795942,
-0.05837446078658104,
0.07326439768075943,
0.03833601996302605,
-0.05385562777519226,
-0.044447559863328934,
0.009972921572625637,
0.07748690992593765,
0.04763296991586685,
0.003951665945351124,
0.04241038113832474,
-0.0442623607814312,
0.0039262012578547,
-0.034150540828704834,
-0.011648965068161488,
0.036484040319919586,
0.03037249855697155,
-0.04885527491569519,
-0.011102629825472832,
0.04504019394516945,
0.05344819277524948,
0.06063387915492058,
0.006208768580108881,
-0.0452994704246521,
0.004977200645953417,
-0.022983092814683914,
0.004792002495378256,
-0.022223779931664467,
0.006787512917071581,
0.013084250502288342,
0.021427428349852562,
-0.010417397134006023,
0.0332060307264328,
0.006616204511374235,
0.0006910206866450608,
-0.005074429791420698,
-0.00046820411807857454,
-0.019945843145251274,
-0.022723814472556114,
0.02255713753402233,
0.030539177358150482,
0.019482847303152084,
0.0023311818949878216,
0.010824833065271378,
0.03016878105700016,
-0.018362397328019142,
0.028650157153606415,
-0.0014399157371371984,
-0.07574605196714401,
-0.02152002789080143,
-0.003215503180399537,
0.027816765010356903,
-0.023149771615862846,
-0.04263261705636978,
0.07548677176237106,
-0.0028752016369253397,
0.022631216794252396,
-0.059078216552734375,
-0.007833882234990597,
0.02785380370914936,
-0.0023346543312072754,
-0.002764082746580243,
0.00070317427162081,
-0.00788018200546503,
-0.007051420398056507,
0.05826334282755852,
-0.01068593468517065,
-0.025261029601097107,
0.009417327120900154,
0.0406695157289505,
0.03970648720860481,
-0.012454576790332794,
0.013315748423337936,
0.004972570575773716,
-0.009509925730526447,
-0.045484669506549835,
0.014315818436443806,
0.01389912236481905,
-0.036724794656038284,
-0.023909082636237144,
-0.02290901355445385,
0.051559168845415115,
0.03213188052177429,
0.02152002789080143,
0.026242580264806747,
0.0004838301974814385,
0.02863163687288761,
-0.045743945986032486,
-0.0072042085230350494,
-0.028446437790989876,
-0.06193026527762413,
0.045632828027009964,
0.02487211301922798,
-0.02100147120654583,
0.010602595284581184,
0.028279760852456093,
-0.03607660159468651,
0.013167589902877808,
-0.07189393043518066,
-0.0043706768192350864,
-0.008713574148714542,
-0.13408347964286804,
-0.00038515430060215294,
-0.06837516278028488,
0.08067232370376587,
-0.016908593475818634,
0.06033756211400032,
-0.03666923567652702,
0.00033190983231179416,
0.011435986496508121,
0.02290901355445385,
0.0360395647585392,
-0.025372149422764778,
0.03841010108590126,
0.04448460042476654,
-0.029798384755849838,
-0.03202076256275177,
0.03566916659474373,
-0.026835214346647263,
-0.022946052253246307,
-0.011565625667572021,
-0.03490985557436943,
0.01057481486350298,
0.01070445403456688,
-0.017362328246235847,
0.046336580067873,
-0.003423851216211915,
-0.03350234776735306,
-0.0036784985568374395,
-0.01605668105185032,
0.028594596311450005,
0.03666923567652702,
0.021038511767983437,
0.004245668184012175,
-0.0024168360978364944,
-0.02707597240805626,
0.024316519498825073,
-0.06418968737125397,
-0.014612135477364063,
-0.02640925906598568,
0.007241248153150082,
0.0004913538577966392,
-0.004595229402184486,
0.02039031870663166,
-0.005819852463901043,
-0.05522609502077103,
-0.019038371741771698,
-0.01590852253139019,
0.012843492440879345,
0.020297719165682793,
-0.018380917608737946,
-0.03131701052188873,
0.04189182445406914,
0.00022368466306943446,
0.037243351340293884,
0.06578239053487778,
-0.003428481053560972,
-0.014223218895494938,
0.09141381829977036,
-0.018556855618953705,
-0.003627569181844592,
0.0198162030428648,
-0.031020693480968475,
-0.04248445853590965,
-0.005194808356463909,
0.037039633840322495,
0.041410308331251144,
-0.029427988454699516,
0.036521077156066895,
0.002458505565300584,
-0.029835425317287445,
-0.018288318067789078,
0.004724868107587099,
-0.05837446078658104,
-0.0010498421033844352,
-0.02100147120654583,
-0.009366397745907307,
0.013093510642647743,
-0.028390878811478615,
0.059078216552734375,
-0.0011025078129023314,
-0.00788018200546503,
0.013149069622159004,
-0.022001542150974274,
0.01088965218514204,
0.07889442145824432,
0.05159620940685272,
-0.03226152062416077,
-0.02183486334979534,
0.0319281630218029,
0.032465238124132156,
0.03918793052434921,
-0.05826334282755852,
0.012463836930692196,
-0.0406695157289505,
0.02166818641126156,
0.05415194481611252,
0.006880111992359161,
0.011639704927802086,
-0.014667694456875324,
0.032205961644649506,
-0.01158414501696825,
0.03526173159480095,
-0.030261380597949028,
0.04818856343626976,
0.0597078874707222,
-0.03792858496308327,
-0.007282917853444815,
-0.02198302187025547,
-0.06367112696170807,
0.0357988066971302,
-0.06152283027768135,
-0.011963801458477974,
0.08304286003112793,
-0.0070375301875174046,
0.03103921189904213,
-0.02394612319767475,
0.014667694456875324,
-0.0339653454720974,
0.032150402665138245,
0.02553882636129856,
0.0157048050314188,
0.044966116547584534,
-0.06304145604372025,
0.049447908997535706,
-0.00039325671968981624,
0.0003677919739857316,
-0.0016447912203148007,
0.015482566319406033,
-0.06937523186206818,
0.02203858271241188,
0.0007182216504588723,
-0.01998288184404373,
-0.0803019255399704,
-0.03818786144256592,
-0.059596769511699677,
0.05504089593887329,
0.05370746925473213,
-0.01068593468517065,
0.060152363032102585,
-0.01191750168800354,
-0.029372429475188255
] |
725,872 | qsm_forward.qsm_forward | __init__ | null | def __init__(
self,
subject="1",
session=None,
acq=None,
run=None,
TR=50e-3,
TEs=np.array([ 4e-3, 12e-3, 20e-3, 28e-3 ]),
flip_angle=15,
B0=7,
B0_dir=np.array([0, 0, 1]),
phase_offset=0,
generate_phase_offset=True,
generate_shim_field=True,
voxel_size=np.array([1.0, 1.0, 1.0]),
peak_snr=np.inf,
random_seed=None,
suffix="T2starw",
save_phase=True
):
self.subject = subject
self.session = session
self.acq = acq
self.run = run
self.TR = TR
self.TEs = TEs
self.flip_angle = flip_angle
self.B0 = B0
self.B0_dir = B0_dir
self.phase_offset = phase_offset
self.generate_phase_offset = generate_phase_offset
self.generate_shim_field = generate_shim_field
self.voxel_size = voxel_size
self.peak_snr = peak_snr
self.random_seed = random_seed
self.suffix = suffix
self.save_phase = save_phase
| (self, subject='1', session=None, acq=None, run=None, TR=0.05, TEs=array([0.004, 0.012, 0.02 , 0.028]), flip_angle=15, B0=7, B0_dir=array([0, 0, 1]), phase_offset=0, generate_phase_offset=True, generate_shim_field=True, voxel_size=array([1., 1., 1.]), peak_snr=inf, random_seed=None, suffix='T2starw', save_phase=True) | [
0.03465718775987625,
0.0458800345659256,
-0.03277145326137543,
-0.031306806951761246,
-0.009556815028190613,
-0.055546700954437256,
-0.10062117874622345,
0.012248102575540543,
0.0057853516191244125,
-0.00744680967181921,
0.00021740839292760938,
0.09102775156497955,
-0.006192706525325775,
0.08641411364078522,
-0.053532812744379044,
0.020505044609308243,
0.0585126094520092,
0.024111734703183174,
-0.027388880029320717,
0.009831435978412628,
0.002067668130621314,
0.019296711310744286,
-0.02511867880821228,
0.1011338084936142,
-0.02546653151512146,
-0.000945154344663024,
-0.0140697555616498,
-0.06210099160671234,
-0.005712119396775961,
0.00038446957478299737,
0.02030365541577339,
-0.06265023350715637,
-0.0054786913096904755,
-0.017786294221878052,
-0.001497829332947731,
-0.033998094499111176,
-0.021749993786215782,
-0.016065334901213646,
-0.0681060403585434,
0.06305301189422607,
0.06133205071091652,
-0.03753155469894409,
0.058768920600414276,
-0.040094684809446335,
-0.03224052116274834,
0.04375629872083664,
0.013850058428943157,
0.025942541658878326,
-0.0074971565045416355,
0.018390461802482605,
-0.011964326724410057,
-0.03753155469894409,
0.026308704167604446,
-0.01193686481565237,
-0.0766742154955864,
0.033302389085292816,
0.0024487050250172615,
0.03555428236722946,
0.015177394263446331,
0.03317423164844513,
0.0202853474766016,
0.017456749454140663,
0.04675882309675217,
0.0674835667014122,
0.018875624984502792,
-0.003304607467725873,
-0.03086741454899311,
-0.01040814071893692,
0.00030837664962746203,
0.028432440012693405,
0.061441898345947266,
-0.0014795212773606181,
-0.028029663488268852,
0.014866156503558159,
0.01156154926866293,
-0.0008341616485267878,
-0.09432320296764374,
-0.02619885466992855,
0.004815023858100176,
-0.021621836349368095,
0.0703396275639534,
0.0689115971326828,
-0.015168240293860435,
-0.005419190041720867,
0.00985889881849289,
0.030006935819983482,
0.03939897567033768,
-0.026290396228432655,
0.012458644807338715,
-0.01005113311111927,
-0.056425485759973526,
-0.047820691019296646,
0.040643926709890366,
-0.0016843428602442145,
0.02402019500732422,
-0.022500624880194664,
-0.014573227614164352,
-0.0677032619714737,
-0.057157810777425766,
-0.029732313007116318,
-0.018912240862846375,
-0.012046713382005692,
-0.0509696789085865,
0.03441918268799782,
-0.019662871956825256,
0.03304607421159744,
-0.024001887068152428,
-0.01633995771408081,
-0.0029201379511505365,
-0.022354159504175186,
0.008970956318080425,
0.12874238193035126,
-0.04148609936237335,
0.04291412606835365,
-0.03571905568242073,
-0.03216728940606117,
-0.008321019820868969,
-0.009300502017140388,
-0.016294186934828758,
-0.006105742882937193,
0.06290654838085175,
0.02563130483031273,
-0.061624981462955475,
0.06982699781656265,
0.013776826672255993,
-0.03408963605761528,
0.01238541305065155,
-0.0044030919671058655,
0.044232308864593506,
-0.07356184720993042,
0.04126640036702156,
-0.058036599308252335,
0.010014517232775688,
0.00907165091484785,
-0.0036982311867177486,
-0.015452015213668346,
0.04723483324050903,
-0.005744158755987883,
-0.02383711375296116,
0.01737436279654503,
0.01579071395099163,
-0.022354159504175186,
0.008092168718576431,
-0.06243053451180458,
0.02980554662644863,
0.03939897567033768,
-0.012238947674632072,
-0.0662752315402031,
0.001982993446290493,
-0.006522251758724451,
-0.002245027804747224,
-0.027004411444067955,
-0.025246836245059967,
0.02187814936041832,
0.01900378242135048,
-0.0462828129529953,
0.04060731083154678,
-0.02030365541577339,
-0.007423924282193184,
0.028121203184127808,
0.012174869887530804,
-0.006243053358048201,
-0.041010089218616486,
0.013575437478721142,
0.01427114475518465,
0.027041027322411537,
-0.04071715846657753,
0.01140593085438013,
-0.013795134611427784,
-0.03707385063171387,
-0.017484212294220924,
-0.05005427822470665,
-0.05880553647875786,
-0.027517037466168404,
-0.03808079659938812,
0.03745832294225693,
0.009950438514351845,
0.03390655666589737,
-0.01346558891236782,
-0.03050125204026699,
-0.016651194542646408,
-0.00047086080303415656,
-0.016294186934828758,
0.03317423164844513,
0.012147407978773117,
0.060013871639966965,
0.0462828129529953,
0.04049746319651604,
0.0782853290438652,
-0.008764990605413914,
0.010984844528138638,
0.013346586376428604,
-0.043536603450775146,
0.046722207218408585,
0.0022232867777347565,
0.02010226622223854,
0.03383332118391991,
-0.021457063034176826,
-0.010096902959048748,
0.05510730668902397,
0.006700755562633276,
-0.011625627987086773,
-0.0018136437283828855,
-0.016294186934828758,
-0.0060096257366240025,
-0.016642039641737938,
0.025173602625727654,
0.04489139840006828,
-0.012357950210571289,
0.007309498731046915,
-0.005835698917508125,
-0.030958954244852066,
0.039582058787345886,
-0.01757575199007988,
0.025576381012797356,
-0.06316285580396652,
0.021237367764115334,
0.04639266058802605,
0.02546653151512146,
0.028029663488268852,
0.0785050243139267,
0.03581059351563454,
-0.048003774136304855,
-0.02978723868727684,
-0.009639201685786247,
0.027187490835785866,
0.06609214842319489,
-0.03500504046678543,
-0.07110856473445892,
-0.035224735736846924,
0.037751249969005585,
0.024130042642354965,
-0.004988950211554766,
-0.018784085288643837,
-0.009749050252139568,
0.04218180477619171,
-0.02729734033346176,
0.003709673648700118,
-0.07121840864419937,
-0.021402139216661453,
0.012989578768610954,
0.007547503802925348,
0.007703122682869434,
0.06041664630174637,
0.006188129540532827,
-0.004014045465737581,
0.03637814521789551,
0.0319109745323658,
-0.05170200392603874,
-0.009639201685786247,
-0.02799304574728012,
-0.00797774363309145,
-0.04090023785829544,
0.020559968426823616,
-0.019626256078481674,
-0.0008742105565033853,
0.028615521267056465,
-0.02438635565340519,
0.020321963354945183,
-0.0004845918738283217,
0.005945547483861446,
-0.026839638128876686,
-0.04877271130681038,
0.007726007606834173,
-0.006462750490754843,
0.02764519304037094,
-0.05697472766041756,
0.017346901819109917,
-0.007689391262829304,
0.00799605157226324,
0.046209581196308136,
0.038483574986457825,
-0.03841033950448036,
0.009401196613907814,
-0.02369064837694168,
-0.04049746319651604,
-0.012660034000873566,
0.023269563913345337,
0.008906878530979156,
0.012522723525762558,
0.013236737810075283,
-0.019644564017653465,
0.05367927625775337,
0.017282823100686073,
-0.033082690089941025,
-0.03355870023369789,
-0.02204292267560959,
0.02848736383020878,
0.02385542169213295,
-0.04130301624536514,
-0.0654330626130104,
0.017182128503918648,
0.061441898345947266,
0.028816910460591316,
0.10611360520124435,
-0.009703279472887516,
-0.07967673987150192,
-0.004828754812479019,
0.08831815421581268,
0.028212742879986763,
0.028212742879986763,
0.01755744405090809,
-0.014133834280073643,
0.0181433018296957,
-0.033998094499111176,
0.017072279006242752,
-0.006833489052951336,
0.022518932819366455,
0.0660555362701416,
-0.015122469514608383,
0.026583325117826462,
0.02550314925611019,
0.04705175384879112,
0.04111993685364723,
0.02114582620561123,
0.030757565051317215,
-0.006476481445133686,
-0.05009089410305023,
0.0023502991534769535,
0.07304921746253967,
-0.0172278992831707,
0.0008181420853361487,
0.03125188499689102,
-0.026583325117826462,
0.016587115824222565,
-0.05287371948361397,
-0.008421714417636395,
-0.0018342402763664722,
-0.015021775849163532,
0.00654513668268919,
-0.07425755262374878,
0.06839896738529205,
0.030702641233801842,
0.00641240319237113,
-0.049981046468019485,
0.004810446873307228,
-0.002842328744009137,
-0.007561234757304192,
-0.0028697906527668238,
-0.04053407907485962,
0.04031438007950783,
-0.054777760058641434,
-0.014207066036760807,
0.04536740854382515,
0.0166695024818182,
-0.07374492287635803,
-0.053349729627370834,
-0.03745832294225693,
0.03804418072104454,
-0.01612026058137417,
0.013071965426206589,
0.03729354962706566,
0.03282637894153595,
0.07813886553049088,
0.050310589373111725,
0.036524608731269836,
-0.02116413414478302,
-0.03826387599110603,
-0.01453661173582077,
-0.021383831277489662,
0.011881940998136997,
0.051042914390563965,
-0.042255036532878876,
0.03429102525115013,
-0.033796705305576324,
-0.026327012106776237,
-0.053422961384058,
0.010453910566866398,
0.027407187968492508,
0.006343747954815626,
0.020175497978925705,
-0.029640773311257362,
-0.03744001314043999,
0.019296711310744286,
0.00984974391758442,
-0.006668716203421354,
-0.01938825100660324,
-0.010453910566866398,
0.014435917139053345,
-0.07872471958398819,
0.014188758097589016,
-0.011717167682945728,
-0.028029663488268852,
0.037238623946905136,
-0.04562372341752052,
-0.005464960355311632,
0.01741097867488861,
0.03718370199203491,
0.0954216867685318,
0.003927082289010286,
-0.02350756898522377,
0.02603408321738243,
0.05206816643476486,
-0.06546967476606369,
-0.0064490195363759995,
0.034913498908281326,
-0.03601198270916939,
0.01904039829969406,
-0.05609594285488129,
0.007190496660768986,
-0.010993999429047108,
-0.0409734733402729,
-0.010087748989462852,
0.04734468087553978,
0.028816910460591316,
-0.0581098310649395,
0.08223987370729446,
-0.026766406372189522,
0.024825749918818474,
-0.0001167139780591242,
-0.001660313573665917,
0.006682447157800198,
-0.039179280400276184,
-0.009913822636008263,
-0.03582890331745148,
-0.0247708261013031,
-0.02204292267560959,
-0.02456943690776825,
0.023361103609204292,
0.02674809843301773,
-0.03267991542816162,
0.06030679866671562,
0.018390461802482605,
0.03207574784755707,
0.06411487609148026,
0.05540023371577263,
-0.004268069751560688,
0.028066279366612434,
-0.00309177627786994,
-0.008856531232595444,
-0.07085224986076355,
0.04390276223421097,
-0.0685088187456131,
-0.006343747954815626,
0.044928014278411865,
-0.001016670255921781,
-0.042584583163261414,
-0.038849733769893646,
0.007254574913531542,
0.00906707439571619,
0.011039769276976585,
-0.013136044144630432,
0.008943494409322739,
-0.03013509139418602,
-0.018628466874361038,
-0.05107953026890755,
-0.027169182896614075,
-0.01969948783516884,
-0.02958584949374199,
0.02118244208395481,
0.07173103839159012,
0.06426133960485458,
0.002434974070638418,
0.0030368519946932793,
-0.0019406559877097607,
-0.03718370199203491,
0.049431800842285156,
-0.03015339933335781,
-0.024972213432192802,
-0.10120704025030136,
-0.017475057393312454,
0.012357950210571289,
-0.03084910660982132,
0.03282637894153595,
0.026949485763907433,
0.06221083924174309,
0.03192928433418274,
0.018875624984502792,
-0.020010726526379585,
-0.015049237757921219,
-0.03511488810181618,
0.02943938411772251,
-0.01774052530527115,
-0.009035035036504269,
0.03745832294225693,
-0.01704481802880764,
-0.05232447758316994,
-0.0444520078599453,
-0.07202396541833878,
-0.021823225542902946,
-0.03425440937280655,
-0.037403397262096405,
0.0012151984265074134,
0.04972473159432411,
0.011076385155320168,
-0.02242739126086235,
-0.015662558376789093,
-0.044561855494976044,
-0.001755286706611514,
-0.0022896535228937864,
-0.047088369727134705,
0.016751889139413834,
-0.026638248935341835,
0.09329795092344284,
-0.0000327721681969706,
0.06869189441204071,
0.0011351006105542183,
0.03322915732860565,
-0.04866286367177963,
0.0022221426479518414,
0.026235470548272133,
-0.018573541194200516,
-0.021768301725387573,
-0.016724426299333572,
-0.01533301267772913,
-0.04701513797044754,
-0.09212623536586761,
-0.061991140246391296,
-0.011515779420733452,
0.016211800277233124,
0.02638193592429161,
-0.016449805349111557,
-0.024514513090252876,
-0.024459587410092354,
0.029329536482691765,
0.015250626020133495,
-0.04364645108580589,
-0.0022175656631588936,
-0.04642927646636963,
0.03586551919579506,
-0.006476481445133686,
-0.009021303616464138,
0.02207953855395317,
0.0071035330183804035,
0.007845009677112103,
-0.005712119396775961,
0.02493559755384922,
-0.007941127754747868,
0.1076514795422554,
0.024459587410092354,
-0.04013130068778992,
-0.03480365127325058,
-0.01353882160037756,
0.05181185156106949,
0.03617675602436066,
0.04111993685364723,
-0.00824321061372757,
-0.03495011478662491,
0.02799304574728012,
-0.0756489634513855,
-0.024075118824839592,
-0.009108267724514008,
0.03694569692015648,
-0.04675882309675217,
-0.03198420628905296,
0.04972473159432411,
0.009007573127746582,
0.011552395299077034,
0.003691365709528327,
-0.012888885103166103,
-0.0036181332543492317,
-0.07165780663490295,
-0.0021889591589570045,
-0.05331311374902725,
0.0035265928599983454,
0.022152770310640335,
0.022116154432296753,
0.005249840673059225,
0.02618054673075676,
0.007185919210314751,
-0.02204292267560959,
-0.003874446265399456,
-0.021749993786215782,
0.0013868366368114948,
0.027846582233905792,
0.002340000821277499,
0.08963633328676224,
-0.02780996635556221,
-0.003366397228091955,
0.039032816886901855,
0.02347095124423504,
0.0038172337226569653,
-0.006728217471390963,
0.04346337169408798,
-0.06719063222408295,
-0.03419948369264603,
-0.013392357155680656,
0.04562372341752052,
-0.04090023785829544,
-0.017328593879938126,
0.043499987572431564,
0.039032816886901855,
0.005254417657852173,
0.00037731797783635557,
-0.006426134146749973,
0.006082857958972454,
-0.009021303616464138,
-0.0240568108856678,
-0.034345947206020355,
-0.03385163098573685,
-0.006723640486598015,
0.007240843493491411,
-0.016220955178141594,
-0.0010281128343194723,
-0.009886360727250576,
-0.00520407035946846,
0.0281395111232996,
-0.015561863780021667,
-0.00950189121067524,
-0.007533772848546505,
-0.019241787493228912,
0.01935163512825966,
0.027755042538046837,
0.012779036536812782,
0.024111734703183174,
-0.0491388738155365,
-0.04481816664338112,
0.04533079266548157,
-0.026217162609100342,
0.026143930852413177,
0.030391404405236244,
0.015397091396152973,
0.046575743705034256,
-0.04503786563873291,
0.010344062000513077,
-0.06092927232384682,
-0.045843418687582016,
-0.00905334297567606,
0.013877521269023418,
-0.023928653448820114,
-0.01373105589300394,
0.0045655760914087296,
-0.07165780663490295,
0.055510085076093674,
-0.023544184863567352,
-0.0114700086414814,
0.03086741454899311,
-0.11094693094491959,
0.0233427956700325,
-0.023361103609204292,
0.038483574986457825,
-0.0383371077477932,
0.06191790848970413,
-0.0766742154955864,
0.002146621700376272,
0.013932445086538792,
-0.051409073173999786,
0.03282637894153595,
0.04192548990249634,
0.07535603642463684,
-0.013483896851539612,
0.0327165313065052,
0.02975062094628811,
-0.004551845137029886,
-0.029201379045844078,
-0.05829291045665741,
-0.022482316941022873,
-0.021109210327267647,
-0.006915875244885683,
0.029018299654126167,
-0.0013582303654402494,
0.04507448151707649,
-0.003139834851026535,
0.022738629952073097,
-0.02473421022295952,
0.012751574628055096,
0.0326249897480011,
0.017255360260605812,
0.03819064423441887,
0.007460540626198053,
0.0005669781821779907,
-0.014316914603114128,
0.024166658520698547,
-0.03712877631187439,
0.025796078145503998,
-0.015561863780021667,
0.03939897567033768,
0.007533772848546505,
-0.020395195111632347,
-0.02601577527821064,
-0.011927710846066475,
-0.0012632571160793304,
-0.009886360727250576,
-0.0027462111320346594,
-0.01813414879143238,
-0.01866508275270462,
0.02332448773086071,
-0.04430554062128067,
0.04705175384879112,
-0.003991160541772842,
0.0004748656938318163,
0.02114582620561123,
-0.014051447622478008,
-0.09835097938776016,
0.039582058787345886,
0.00154588813893497,
0.015461169183254242,
0.036689382046461105,
-0.08802522718906403,
-0.10362370312213898,
-0.006705332547426224,
0.03939897567033768,
0.0015287242131307721,
-0.005620579235255718,
0.04613634943962097,
-0.006389518268406391,
-0.009639201685786247,
-0.04401261359453201,
0.008755836635828018,
-0.04005806893110275,
0.011067231185734272,
-0.006870104931294918,
0.017886988818645477,
0.05203155055642128,
-0.030043551698327065,
0.019461484625935555,
-0.05364266037940979,
-0.009950438514351845,
0.006311709061264992,
-0.054448213428258896,
0.011534087359905243,
0.06488382071256638,
0.04573357105255127,
0.023196330294013023,
-0.043170440942049026,
0.024093426764011383,
-0.0042062802240252495,
0.07696714997291565,
-0.05093306303024292,
-0.016541345044970512,
-0.017475057393312454,
-0.024898981675505638,
0.03965529054403305,
0.0326249897480011,
0.04899241030216217,
0.0033114731777459383,
-0.010270830243825912,
0.012431182898581028,
0.041705794632434845,
-0.0430239774286747,
0.014737999998033047,
0.044378772377967834,
-0.029988626018166542,
0.018692543730139732,
-0.009977900423109531,
-0.05789013206958771,
-0.005538192577660084,
-0.038300491869449615,
0.017447594553232193,
0.08385097980499268,
0.01720959134399891,
-0.00824321061372757,
0.0383371077477932,
-0.015406245365738869,
-0.03211236372590065,
0.03520642966032028,
-0.0005898632807657123,
0.009259308688342571,
0.049981046468019485,
-0.04866286367177963,
0.02975062094628811,
-0.028981681913137436,
0.024898981675505638,
0.019974110648036003,
-0.0025974581949412823,
-0.04335352033376694,
0.03782448172569275,
-0.006961645558476448,
-0.01318181399255991,
-0.06964391469955444,
-0.0664583146572113,
-0.037037234753370285,
0.06012371927499771,
0.052104782313108444,
-0.008806183934211731,
0.04862624779343605,
0.021109210327267647,
0.010279984213411808
] |
725,873 | qsm_forward.qsm_forward | TissueParams |
A class used to represent tissue parameters.
Attributes
----------
root_dir : str or None
The path to the root directory containing the tissue parameter files.
chi_path : str or ndarray
The path to the Chi file or a 3D numpy array containing Chi values.
M0_path : str or ndarray
The path to the M0 file or a 3D numpy array containing M0 values.
R1_path : str or ndarray
The path to the R1 file or a 3D numpy array containing R1 values.
R2star_path : str or ndarray
The path to the R2* file or a 3D numpy array containing R2* values.
mask_path : str or ndarray
The path to the brain mask file or a 3D numpy array containing brain mask values.
seg_path : str or ndarray
The path to the segmentation file or a 3D numpy array containing segmentation values.
| class TissueParams:
"""
A class used to represent tissue parameters.
Attributes
----------
root_dir : str or None
The path to the root directory containing the tissue parameter files.
chi_path : str or ndarray
The path to the Chi file or a 3D numpy array containing Chi values.
M0_path : str or ndarray
The path to the M0 file or a 3D numpy array containing M0 values.
R1_path : str or ndarray
The path to the R1 file or a 3D numpy array containing R1 values.
R2star_path : str or ndarray
The path to the R2* file or a 3D numpy array containing R2* values.
mask_path : str or ndarray
The path to the brain mask file or a 3D numpy array containing brain mask values.
seg_path : str or ndarray
The path to the segmentation file or a 3D numpy array containing segmentation values.
"""
def __init__(
self,
root_dir = "",
chi = "chimodel/ChiModelMIX.nii",
M0 = "maps/M0.nii.gz",
R1 = "maps/R1.nii.gz",
R2star = "maps/R2star.nii.gz",
mask = "masks/BrainMask.nii.gz",
seg = "masks/SegmentedModel.nii.gz",
apply_mask = False
):
if isinstance(chi, str) and not os.path.exists(os.path.join(root_dir, chi)):
raise ValueError(f"Path to chi is invalid! ({os.path.join(root_dir, chi)})")
self._chi = os.path.join(root_dir, chi) if isinstance(chi, str) and os.path.exists(os.path.join(root_dir, chi)) else chi if not isinstance(chi, str) else None
self._M0 = os.path.join(root_dir, M0) if isinstance(M0, str) and os.path.exists(os.path.join(root_dir, M0)) else M0 if not isinstance(M0, str) else None
self._R1 = os.path.join(root_dir, R1) if isinstance(R1, str) and os.path.exists(os.path.join(root_dir, R1)) else R1 if not isinstance(R1, str) else None
self._R2star = os.path.join(root_dir, R2star) if isinstance(R2star, str) and os.path.exists(os.path.join(root_dir, R2star)) else R2star if not isinstance(R2star, str) else None
self._mask = os.path.join(root_dir, mask) if isinstance(mask, str) and os.path.exists(os.path.join(root_dir, mask)) else mask if not isinstance(mask, str) else None
self._seg = os.path.join(root_dir, seg) if isinstance(seg, str) and os.path.exists(os.path.join(root_dir, seg)) else seg if not isinstance(seg, str) else None
self._apply_mask = apply_mask
self._affine = None
def set_affine(self, affine):
self._affine = affine
def _load(self, nii_path):
nii = nib.load(nii_path)
if self._affine is not None:
nii = nib.Nifti1Image(dataobj=nii.get_fdata(), affine=self._affine, header=nii.header)
return nii
@property
def voxel_size(self):
zooms = self.nii_header.get_zooms()
return zooms if len(zooms) == 3 else np.array([zooms[0] for i in range(3)])
@property
def nii_header(self):
if isinstance(self._chi, str):
return self._load(self._chi).header
header = nib.Nifti1Header()
header.set_data_shape(self._chi.shape)
return header
@property
def nii_affine(self):
if self._affine is not None:
return self._affine
if isinstance(self._chi, str):
return self._load(self._chi).affine
return np.eye(4)
def _do_apply_mask(self, nii): return nib.Nifti1Image(dataobj=nii.get_fdata() * self.mask.get_fdata(), affine=self.nii_affine, header=nii.header) if self._apply_mask else nii
@property
def chi(self): return self._do_apply_mask(self._load(self._chi) if isinstance(self._chi, str) else nib.Nifti1Image(self._chi, affine=self.nii_affine, header=self.nii_header))
@property
def mask(self): return self._load(self._mask) if isinstance(self._mask, str) else nib.Nifti1Image(self._mask or np.array(self._chi != 0), affine=self.nii_affine, header=self.nii_header)
@property
def M0(self): return self._do_apply_mask(self._load(self._M0) if isinstance(self._M0, str) else nib.Nifti1Image(self._M0 or np.array(self.mask.get_fdata() * 1), affine=self.nii_affine, header=self.nii_header))
@property
def R1(self): return self._do_apply_mask(self._load(self._R1) if isinstance(self._R1, str) else nib.Nifti1Image(self._R1 or np.array(self.mask.get_fdata() * 1), affine=self.nii_affine, header=self.nii_header))
@property
def R2star(self): return self._do_apply_mask(self._load(self._R2star) if isinstance(self._R2star, str) else nib.Nifti1Image(self._R2star or np.array(self.mask.get_fdata() * 50), affine=self.nii_affine, header=self.nii_header))
@property
def seg(self): return self._load(self._seg) if isinstance(self._seg, str) else nib.Nifti1Image(self._seg or self.mask.get_fdata(), affine=self.nii_affine, header=self.nii_header)
| (root_dir='', chi='chimodel/ChiModelMIX.nii', M0='maps/M0.nii.gz', R1='maps/R1.nii.gz', R2star='maps/R2star.nii.gz', mask='masks/BrainMask.nii.gz', seg='masks/SegmentedModel.nii.gz', apply_mask=False) | [
0.02633948065340519,
-0.034332435578107834,
0.00606719171628356,
0.032344549894332886,
-0.02393745258450508,
-0.0742972120642662,
-0.06787800043821335,
0.014733129180967808,
0.00802401639521122,
-0.01630687154829502,
-0.0007668112521059811,
0.0413314513862133,
-0.015354343689978123,
0.06092040240764618,
-0.04406479373574257,
0.02638089470565319,
0.0007234556833282113,
0.05566079169511795,
-0.022798560559749603,
-0.008733236230909824,
-0.0493658185005188,
-0.021307645365595818,
0.024185938760638237,
0.0617486871778965,
0.011109380051493645,
0.009064550511538982,
0.029776865616440773,
-0.06700830161571503,
0.025697559118270874,
-0.03789406269788742,
-0.053631491959095,
-0.02845160849392414,
-0.01360459066927433,
0.014795251190662384,
0.0022544898092746735,
-0.06419213116168976,
0.0165035892277956,
0.05860120430588722,
-0.0575658455491066,
0.036920830607414246,
0.00509654451161623,
-0.061086058616638184,
0.048868849873542786,
-0.061210304498672485,
-0.010664176195859909,
0.015923790633678436,
-0.019299054518342018,
0.01813945360481739,
-0.01892632432281971,
0.019071275368332863,
0.011057612486183643,
-0.07500125467777252,
-0.020510422065854073,
-0.005135370418429375,
-0.07450428605079651,
0.06870628893375397,
0.021576838567852974,
0.05524664744734764,
0.02836878038942814,
-0.04572136327624321,
-0.013086912222206593,
0.013449287042021751,
0.06845780462026596,
-0.010317332111299038,
-0.048786018043756485,
0.004604749847203493,
-0.062369901686906815,
0.012444990687072277,
0.02221876010298729,
0.06738103181123734,
-0.004242375027388334,
-0.02184603177011013,
0.04750217869877815,
0.019889207556843758,
0.04994561895728111,
-0.010275918059051037,
-0.07073558866977692,
-0.02638089470565319,
0.03385617211461067,
-0.020965978503227234,
-0.005937772337347269,
0.029072823002934456,
0.013221507892012596,
-0.05938807502388954,
0.007884243503212929,
0.003942121751606464,
0.05984363332390785,
0.0038385859224945307,
0.032365258783102036,
-0.05160219222307205,
-0.04369206354022026,
0.017518239095807076,
0.009411394596099854,
-0.0055236294865608215,
0.029072823002934456,
0.043443579226732254,
-0.005596104543656111,
-0.07968106865882874,
-0.019174810498952866,
-0.09690941125154495,
-0.04650823399424553,
-0.04327791929244995,
-0.0036082190927118063,
0.022508660331368446,
-0.009090433828532696,
-0.003794583259150386,
-0.03582334890961647,
0.035202138125896454,
-0.022550074383616447,
-0.018843496218323708,
-0.07587096095085144,
0.03874305635690689,
-0.053010277450084686,
-0.014132622629404068,
0.004180253483355045,
-0.05636483430862427,
-0.03298647329211235,
0.02383391745388508,
-0.011150794103741646,
0.021090220659971237,
-0.005554690025746822,
0.04650823399424553,
-0.07048710435628891,
0.047999147325754166,
0.02304704673588276,
0.021928859874606133,
0.009100787341594696,
0.05719311907887459,
0.051312290132045746,
-0.08953767269849777,
-0.025262709707021713,
-0.004415797535330057,
-0.03159909322857857,
0.060754746198654175,
0.00006127209780970588,
-0.001841641147620976,
-0.03217889368534088,
-0.03375263512134552,
-0.0027799333911389112,
0.04023396968841553,
0.04418903589248657,
-0.03041878715157509,
0.014142976142466068,
-0.0061189597472548485,
-0.0050396001897752285,
0.018087685108184814,
0.06800224632024765,
-0.048744603991508484,
-0.007754823658615351,
-0.023295531049370766,
-0.024206645786762238,
-0.002673809416592121,
-0.036858707666397095,
0.02265360951423645,
0.032261721789836884,
-0.023564724251627922,
0.04895167797803879,
-0.01776672527194023,
-0.00029038527281954885,
-0.009939426556229591,
-0.06042343005537987,
-0.047543592751026154,
-0.0123621616512537,
0.016182629391551018,
-0.016513943672180176,
-0.002490033395588398,
-0.01772531121969223,
-0.027064230293035507,
0.017197279259562492,
0.03251020982861519,
-0.017932383343577385,
-0.06009211763739586,
-0.08920635282993317,
0.01661747880280018,
0.009390687569975853,
0.07533257454633713,
-0.05151936039328575,
-0.028596559539437294,
-0.025718266144394875,
0.02389603853225708,
0.008505457080900669,
-0.017870260402560234,
-0.01855359598994255,
0.012486404739320278,
-0.02555260993540287,
0.0906144380569458,
0.07380024343729019,
-0.00841745175421238,
0.029155651107430458,
0.012030847370624542,
0.04439610615372658,
0.032365258783102036,
-0.01217579748481512,
0.07968106865882874,
0.04688096418976784,
-0.031578388065099716,
0.05553654581308365,
-0.00392917962744832,
0.03050161525607109,
0.017828846350312233,
-0.01999274268746376,
0.0007564576808363199,
0.023751089349389076,
0.022011687979102135,
-0.03872235119342804,
-0.054915331304073334,
-0.02393745258450508,
0.05313451960682869,
-0.0011880721431225538,
0.07065276056528091,
-0.00577211519703269,
-0.022053103893995285,
0.014494997449219227,
0.004188018850982189,
0.060754746198654175,
-0.04621833562850952,
0.0032251370139420033,
0.06696689128875732,
-0.04319509118795395,
0.011057612486183643,
0.05064966157078743,
0.034332435578107834,
-0.0247243233025074,
0.015395757742226124,
-0.04410620778799057,
0.028617266565561295,
0.030750101432204247,
0.018387939780950546,
0.05135370418429375,
0.020375825464725494,
0.007449393160641193,
-0.05814564600586891,
-0.03184758126735687,
0.01214473694562912,
0.01766319014132023,
0.003196664620190859,
0.004175076726824045,
0.012838426046073437,
-0.01890561729669571,
-0.008277678862214088,
-0.04733651876449585,
-0.027271302416920662,
-0.012672768905758858,
-0.03760416433215141,
0.017497532069683075,
-0.046839550137519836,
0.041020844131708145,
0.039322856813669205,
-0.02714706026017666,
0.005461507942527533,
0.0576486736536026,
-0.01837758533656597,
-0.06336384266614914,
0.03209606558084488,
-0.02476573921740055,
-0.03342132270336151,
-0.022964216768741608,
-0.0113578662276268,
0.07032144069671631,
-0.02077961340546608,
0.026567259803414345,
-0.060382016003131866,
0.04485166445374489,
0.04155922681093216,
-0.038515277206897736,
0.03818396478891373,
-0.010860894806683064,
-0.0017626952612772584,
-0.018367232754826546,
-0.03617537021636963,
0.005533982999622822,
0.09806901216506958,
-0.06009211763739586,
0.028927873820066452,
-0.02180461771786213,
0.00587047403678298,
0.006336384452879429,
0.00402236171066761,
-0.012786658480763435,
-0.003729873336851597,
0.0036470447666943073,
-0.003900707233697176,
0.008955837227404118,
-0.03373192995786667,
0.007511514704674482,
-0.030294544994831085,
-0.025614731013774872,
0.01215509045869112,
0.0071232556365430355,
-0.00626908615231514,
0.005368325859308243,
0.03410465642809868,
-0.008707351982593536,
-0.009706471115350723,
0.06431637704372406,
-0.009152555838227272,
-0.10767712444067001,
0.0018662308575585485,
0.015685657039284706,
-0.03228243067860603,
-0.026587966829538345,
-0.02346118912100792,
0.032344549894332886,
-0.059098176658153534,
-0.0025728619657456875,
0.01438110787421465,
0.029093530029058456,
0.023357652127742767,
0.039260733872652054,
0.046673890203237534,
0.06957598775625229,
-0.024123817682266235,
0.021307645365595818,
-0.020458653569221497,
0.07761035859584808,
-0.025034930557012558,
0.04770924896001816,
0.059098176658153534,
0.04068952798843384,
0.07918410003185272,
-0.010933369398117065,
0.016710661351680756,
-0.04452034831047058,
-0.01213438343256712,
0.05483250319957733,
-0.048454705625772476,
0.049697134643793106,
0.007190553937107325,
-0.057068876922130585,
0.03422890231013298,
-0.014981615357100964,
0.028203124180436134,
-0.01737328991293907,
0.022757146507501602,
-0.008500280790030956,
-0.0012430754723027349,
0.0019814143888652325,
0.00500336242839694,
0.034435972571372986,
-0.011409633792936802,
0.05069107562303543,
-0.004379559773951769,
-0.04294660687446594,
0.007754823658615351,
0.034829407930374146,
-0.059098176658153534,
0.016555357724428177,
-0.010332862846553326,
-0.029942523688077927,
0.07040427625179291,
0.0039058842230588198,
0.041434984654188156,
0.03201323747634888,
0.034767284989356995,
0.025469781830906868,
0.046673890203237534,
-0.018201574683189392,
-0.04460317641496658,
0.04369206354022026,
-0.04365064948797226,
0.03087434358894825,
-0.0019814143888652325,
-0.020137691870331764,
-0.005114663392305374,
0.01912304386496544,
-0.04625974968075752,
-0.01726975478231907,
0.020241228863596916,
0.02346118912100792,
-0.049200162291526794,
-0.007511514704674482,
-0.03594759479165077,
-0.06348808854818344,
-0.07330327481031418,
0.05325876176357269,
-0.002110834000632167,
-0.031205657869577408,
-0.007594343274831772,
-0.046756718307733536,
-0.02186673879623413,
0.02016875334084034,
0.0371071919798851,
-0.0022130755241960287,
0.04493449255824089,
-0.0287829227745533,
-0.030998587608337402,
0.06406788527965546,
0.054584018886089325,
0.0195371862500906,
-0.008841948583722115,
0.02117305062711239,
0.010555463843047619,
0.05901534482836723,
-0.0453486330807209,
0.0024149701930582523,
0.0005623282631859183,
0.010141321457922459,
0.07620227336883545,
-0.0247243233025074,
-0.04122791439294815,
-0.015250807628035545,
-0.09533566981554031,
0.011005843989551067,
0.0822073444724083,
0.04605267569422722,
-0.014598533511161804,
0.0780244991183281,
0.010415690951049328,
-0.006828179117292166,
-0.0288243368268013,
-0.020054863765835762,
0.019485417753458023,
0.0492829903960228,
0.0015025617321953177,
-0.0370657779276371,
-0.0005730053526349366,
-0.024393009021878242,
-0.00009399099508300424,
0.022964216768741608,
0.024082403630018234,
-0.03422890231013298,
0.007615050300955772,
0.048786018043756485,
0.059512317180633545,
-0.013242215849459171,
-0.02099703811109066,
-0.0025210941676050425,
0.01018273551017046,
-0.028596559539437294,
0.041807714849710464,
-0.07686489820480347,
0.043443579226732254,
-0.006745350547134876,
-0.020375825464725494,
-0.005518452730029821,
-0.06054767593741417,
-0.0268364530056715,
-0.05193350464105606,
0.05098097771406174,
0.0113578662276268,
0.031930409371852875,
0.03052232228219509,
0.04151781275868416,
-0.045928433537483215,
-0.05516381934285164,
-0.0010243563447147608,
-0.052471891045570374,
0.05884968861937523,
-0.053797148168087006,
-0.012797011993825436,
-0.01173059456050396,
0.00830873940140009,
-0.022135931998491287,
-0.02139047533273697,
0.0059533026069402695,
0.009742708876729012,
-0.01401873305439949,
0.010099907405674458,
-0.022425832226872444,
-0.029072823002934456,
-0.015085150487720966,
0.02886575274169445,
-0.014370754361152649,
0.008634877391159534,
0.0005610340740531683,
-0.02886575274169445,
0.0658487007021904,
-0.008029193617403507,
-0.046715304255485535,
-0.027043523266911507,
-0.03286223113536835,
-0.033193543553352356,
-0.0053320880979299545,
-0.018719254061579704,
0.03132990002632141,
0.038494572043418884,
0.016182629391551018,
0.04023396968841553,
-0.03739709407091141,
-0.05682038888335228,
0.004519333131611347,
-0.06646991521120071,
0.0022130755241960287,
0.00793601106852293,
-0.00986695196479559,
-0.04704662039875984,
0.02549048885703087,
0.005306204315274954,
0.015095504000782967,
-0.08150330185890198,
-0.04613550752401352,
0.016576064750552177,
-0.025801096111536026,
0.05889110267162323,
-0.0016708072507753968,
0.06485475599765778,
-0.024455131962895393,
-0.03592688590288162,
-0.0036625752691179514,
-0.0576486736536026,
0.010286271572113037,
0.012010140344500542,
-0.03385617211461067,
0.009121494367718697,
0.005176784936338663,
0.002650513779371977,
-0.06862346082925797,
-0.035657692700624466,
-0.009432101622223854,
-0.04766783490777016,
-0.03785264864563942,
-0.044644590467214584,
0.03948851302266121,
-0.014163683168590069,
-0.0016721014399081469,
0.011047258973121643,
-0.030584445223212242,
0.01215509045869112,
-0.032820817083120346,
0.022343002259731293,
0.006626284681260586,
-0.051685020327568054,
0.018584657460451126,
-0.01378060132265091,
0.0069213612005114555,
0.05077390372753143,
0.033172838389873505,
-0.03451880067586899,
0.03004605881869793,
0.007340680807828903,
-0.04191124811768532,
-0.055785033851861954,
0.041062258183956146,
0.045100148767232895,
0.05180926248431206,
0.017580360174179077,
0.06953456997871399,
-0.05843554809689522,
0.00836050696671009,
0.004338145721703768,
-0.011989433318376541,
-0.001950353616848588,
0.013894489966332912,
-0.015954850241541862,
0.03793548047542572,
0.01816016063094139,
-0.007656464818865061,
0.016886672005057335,
0.034829407930374146,
-0.009727178141474724,
0.02675362303853035,
-0.008810888044536114,
0.008215557783842087,
0.012186150997877121,
0.06671839952468872,
0.050525419414043427,
0.028078880161046982,
-0.02766473777592182,
0.013304336927831173,
0.03416677936911583,
-0.04601126164197922,
0.007273382507264614,
0.007506337948143482,
-0.059926461428403854,
-0.04779207706451416,
0.007754823658615351,
-0.03290364518761635,
0.004353675991296768,
-0.007961895316839218,
0.015250807628035545,
0.0032924350816756487,
0.02598745934665203,
0.02228088118135929,
-0.008039547130465508,
-0.06319818645715714,
0.007014543283730745,
-0.004721227567642927,
-0.008707351982593536,
-0.023357652127742767,
-0.04253246262669563,
0.02766473777592182,
0.031516265124082565,
0.05884968861937523,
-0.03323495760560036,
0.013356104493141174,
0.015499293804168701,
-0.047626420855522156,
0.04775066301226616,
-0.006564163137227297,
-0.0052285525016486645,
0.006662521976977587,
-0.00971164833754301,
0.019257638603448868,
-0.005352795589715242,
-0.004788525868207216,
0.060713332146406174,
0.013190447352826595,
-0.051767848432064056,
0.048454705625772476,
-0.04253246262669563,
-0.014505350962281227,
-0.057068876922130585,
-0.04131074249744415,
0.02712635137140751,
-0.0008043429115787148,
0.002562508452683687,
0.005709993652999401,
0.018843496218323708,
-0.003051714738830924,
0.011668472550809383,
0.06539314240217209,
0.012589940801262856,
0.06787800043821335,
-0.021763203665614128,
-0.05060824751853943,
-0.016472529619932175,
-0.04911733418703079,
0.057068876922130585,
0.005218198988586664,
-0.031184950843453407,
-0.04331933334469795,
-0.025697559118270874,
-0.04452034831047058,
-0.02631877362728119,
-0.03470516577363014,
-0.009913543239235878,
0.010860894806683064,
-0.051767848432064056,
0.007470100652426481,
-0.03050161525607109,
0.04617692157626152,
-0.02088315039873123,
0.019909914582967758,
-0.011306097730994225,
-0.007568459492176771,
-0.011119733564555645,
0.040151141583919525,
0.013107619248330593,
-0.06704971939325333,
0.09169121086597443,
0.013325043953955173,
-0.04977996274828911,
-0.008065430447459221,
0.019216224551200867,
-0.029362723231315613,
-0.024144524708390236,
-0.003742815461009741,
-0.02598745934665203,
0.03427031636238098,
0.02886575274169445,
-0.042573876678943634,
0.0492829903960228,
-0.04750217869877815,
-0.036071836948394775,
-0.01715586520731449,
0.0036599868908524513,
-0.007071488071233034,
0.008981721475720406,
-0.01833617128431797,
-0.0027307539712637663,
-0.031205657869577408,
0.008733236230909824,
-0.0037195198237895966,
-0.030273837968707085,
-0.004232021514326334,
-0.01687631756067276,
0.05508099123835564,
-0.0288243368268013,
0.05566079169511795,
0.04410620778799057,
0.003486564615741372,
-0.02971474453806877,
-0.012279333546757698,
0.007361387833952904,
0.023336945101618767,
-0.02038617804646492,
0.02385462448000908,
0.01695914752781391,
0.004043068736791611,
0.0047988793812692165,
0.027292009443044662,
0.042180441319942474,
-0.00520008010789752,
0.013490701094269753,
0.06932750344276428,
0.002540507121011615,
0.03327637165784836,
-0.04031680151820183,
0.00498265540227294,
0.017828846350312233,
-0.01212402991950512,
0.038059722632169724,
0.0656830444931984,
0.04770924896001816,
0.03656880930066109,
-0.0071491398848593235,
-0.04804056137800217,
0.006942068226635456,
-0.03369051590561867,
-0.04443752020597458,
0.010079200379550457,
-0.06303253024816513,
-0.054998163133859634,
-0.008060254156589508,
-0.01458817906677723,
0.05976080521941185,
-0.049200162291526794,
0.01173059456050396,
-0.017714956775307655,
-0.012444990687072277,
-0.005575397051870823,
0.08096491545438766,
0.04609409347176552,
-0.04077235609292984,
-0.04151781275868416,
0.03839103505015373,
0.010079200379550457,
0.015561414882540703,
-0.012662415392696857,
-0.034332435578107834,
0.028161708265542984,
-0.002764403121545911,
0.026235945522785187,
0.037190020084381104,
-0.020986685529351234,
0.015302576124668121,
-0.028223831206560135,
-0.05682038888335228,
-0.010902308858931065,
0.010306978598237038,
0.02088315039873123,
0.06754668802022934,
-0.036858707666397095,
-0.010514049790799618,
0.0015944497426971793,
-0.08928918093442917,
0.07214367389678955,
-0.009173262864351273,
-0.05069107562303543,
0.062328487634658813,
-0.002002121414989233,
-0.0454728789627552,
-0.03184758126735687,
0.029880402609705925,
-0.022757146507501602,
0.04994561895728111,
0.052513305097818375,
0.01215509045869112,
0.010798772796988487,
0.010633115656673908,
0.0822073444724083,
-0.0008839360089041293,
0.006481334567070007,
-0.0073147970251739025,
0.06746385991573334,
-0.026691501960158348,
0.047170862555503845,
0.00041608407627791166,
0.022508660331368446,
-0.0268364530056715,
-0.020872795954346657,
-0.07537398487329483,
0.04410620778799057,
0.05189209058880806,
0.014101562090218067,
0.05110521987080574,
-0.015840960666537285,
0.0053579723462462425
] |
725,874 | qsm_forward.qsm_forward | __init__ | null | def __init__(
self,
root_dir = "",
chi = "chimodel/ChiModelMIX.nii",
M0 = "maps/M0.nii.gz",
R1 = "maps/R1.nii.gz",
R2star = "maps/R2star.nii.gz",
mask = "masks/BrainMask.nii.gz",
seg = "masks/SegmentedModel.nii.gz",
apply_mask = False
):
if isinstance(chi, str) and not os.path.exists(os.path.join(root_dir, chi)):
raise ValueError(f"Path to chi is invalid! ({os.path.join(root_dir, chi)})")
self._chi = os.path.join(root_dir, chi) if isinstance(chi, str) and os.path.exists(os.path.join(root_dir, chi)) else chi if not isinstance(chi, str) else None
self._M0 = os.path.join(root_dir, M0) if isinstance(M0, str) and os.path.exists(os.path.join(root_dir, M0)) else M0 if not isinstance(M0, str) else None
self._R1 = os.path.join(root_dir, R1) if isinstance(R1, str) and os.path.exists(os.path.join(root_dir, R1)) else R1 if not isinstance(R1, str) else None
self._R2star = os.path.join(root_dir, R2star) if isinstance(R2star, str) and os.path.exists(os.path.join(root_dir, R2star)) else R2star if not isinstance(R2star, str) else None
self._mask = os.path.join(root_dir, mask) if isinstance(mask, str) and os.path.exists(os.path.join(root_dir, mask)) else mask if not isinstance(mask, str) else None
self._seg = os.path.join(root_dir, seg) if isinstance(seg, str) and os.path.exists(os.path.join(root_dir, seg)) else seg if not isinstance(seg, str) else None
self._apply_mask = apply_mask
self._affine = None
| (self, root_dir='', chi='chimodel/ChiModelMIX.nii', M0='maps/M0.nii.gz', R1='maps/R1.nii.gz', R2star='maps/R2star.nii.gz', mask='masks/BrainMask.nii.gz', seg='masks/SegmentedModel.nii.gz', apply_mask=False) | [
0.015424393117427826,
0.002340269275009632,
0.03620883449912071,
0.02742747962474823,
-0.020394792780280113,
-0.05820023640990257,
-0.03432711586356163,
0.06743776798248291,
0.01995762623846531,
0.027237407863140106,
0.02790266089141369,
0.0900944247841835,
-0.015433897264301777,
0.0860648825764656,
-0.028358835726976395,
0.03447917476296425,
0.015776026993989944,
0.04748014360666275,
-0.02085096761584282,
-0.00476607121527195,
-0.05698377266526222,
0.006357929203659296,
0.02360701933503151,
0.07405229657888412,
-0.0018056900007650256,
0.04124575853347778,
-0.0050844429060816765,
-0.046377722173929214,
0.0519278421998024,
-0.06694357842206955,
-0.042310167104005814,
0.021763315424323082,
0.01678341254591942,
0.026401087641716003,
-0.003758686129003763,
-0.05747796222567558,
0.03236936777830124,
0.01789533719420433,
-0.08241549134254456,
-0.012677843682467937,
0.038014523684978485,
-0.04892469197511673,
0.05778208002448082,
0.005816222168505192,
-0.0024828235618770123,
0.04436295107007027,
-0.023759078234434128,
0.039573121815919876,
-0.015452904626727104,
0.038166582584381104,
-0.05656561255455017,
-0.03660798817873001,
-0.03033559024333954,
-0.016593340784311295,
-0.054322756826877594,
0.036874089390039444,
0.0016025498043745756,
0.052384015172719955,
0.029499271884560585,
-0.02142118476331234,
-0.019425421953201294,
0.01854158379137516,
0.05934067443013191,
0.0003421307192184031,
-0.016935471445322037,
0.0063009075820446014,
-0.06538498401641846,
-0.014359986409544945,
0.0021810834296047688,
0.08538062125444412,
-0.007721700239926577,
-0.024538375437259674,
0.047860287129879,
0.05956875905394554,
0.09359175711870193,
-0.016897456720471382,
-0.0762571394443512,
-0.014017855748534203,
0.022903751581907272,
0.009389587678015232,
-0.010872154496610165,
-0.02174430899322033,
-0.03499237075448036,
-0.06044309586286545,
-0.01687844842672348,
0.0026705204509198666,
0.07728353142738342,
-0.0551970899105072,
0.04341258853673935,
-0.007094460539519787,
-0.06793195754289627,
-0.0019850709941238165,
-0.008187378756701946,
0.003005523467436433,
0.020489828661084175,
0.05265011638402939,
0.0035139676183462143,
-0.029575301334261894,
0.02484249137341976,
-0.047442127019166946,
-0.06998474150896072,
-0.0029247424099594355,
-0.010777117684483528,
0.0006628782721236348,
-0.025849876925349236,
0.018208958208560944,
-0.031095881015062332,
-0.0004460766795091331,
-0.027636559680104256,
-0.03520144894719124,
-0.08979030698537827,
0.05930265784263611,
0.009014193899929523,
0.0020824831444770098,
-0.04926682636141777,
-0.07591500878334045,
-0.03212227299809456,
-0.006201119627803564,
-0.017876330763101578,
0.009289799258112907,
-0.013732747174799442,
0.04189200699329376,
-0.07409030944108963,
0.04983704164624214,
0.026496123522520065,
-0.007265526335686445,
0.0227326862514019,
0.016650361940264702,
0.057896122336387634,
-0.0543987862765789,
0.01749618537724018,
-0.02052784338593483,
0.0010311439400538802,
-0.01416041050106287,
-0.007788226008415222,
-0.009921791031956673,
-0.0186651311814785,
-0.038090553134679794,
-0.011660955846309662,
0.08347989618778229,
0.04421089217066765,
-0.009228025563061237,
0.04812638834118843,
-0.016175180673599243,
-0.026077963411808014,
0.047670215368270874,
0.050521302968263626,
-0.06143147125840187,
-0.011432868428528309,
-0.015376875177025795,
-0.023340918123722076,
-0.007175241596996784,
-0.037368278950452805,
0.03474527597427368,
-0.006875877268612385,
-0.04375471919775009,
0.030316583812236786,
-0.03601876273751259,
0.028700966387987137,
-0.021136075258255005,
-0.04177796468138695,
-0.03598074987530708,
-0.005279267206788063,
0.00963192991912365,
-0.015443400479853153,
-0.012649333104491234,
-0.062191762030124664,
-0.03155205398797989,
0.0053790551610291,
0.022276511415839195,
-0.02613498643040657,
-0.052384015172719955,
-0.09427602589130402,
0.0017320368206128478,
-0.008016313426196575,
-0.013827783055603504,
-0.02149721421301365,
-0.015747517347335815,
-0.016935471445322037,
0.0074698543176054955,
0.03263546898961067,
0.011908049695193768,
0.0017736151348799467,
0.029119126498699188,
-0.02913813292980194,
0.04907675087451935,
0.02548873983323574,
0.041359804570674896,
0.0454653725028038,
-0.015823546797037125,
0.032977599650621414,
0.024405324831604958,
0.00010639612446539104,
0.03983922302722931,
0.026515131816267967,
0.004153086803853512,
0.07504067569971085,
-0.010197396390140057,
-0.012630325742065907,
-0.0005090382765047252,
-0.018113920465111732,
-0.0054693398997187614,
0.03472626954317093,
-0.013846790418028831,
-0.0421961210668087,
-0.03174212947487831,
-0.060253024101257324,
0.07815786451101303,
-0.03198922425508499,
0.051813796162605286,
0.055463191121816635,
-0.05736391991376877,
0.022010410204529762,
0.029404236003756523,
0.039573121815919876,
-0.015842553228139877,
0.024937529116868973,
0.05671767145395279,
-0.006714315619319677,
0.012810895219445229,
0.035676632076501846,
0.03419406712055206,
-0.01690695993602276,
0.023721063509583473,
-0.0697946697473526,
0.018104417249560356,
0.035676632076501846,
0.023759078234434128,
-0.00922327395528555,
-0.005279267206788063,
0.009940798394382,
-0.08317577838897705,
-0.013561681844294071,
-0.010387469083070755,
-0.052536074072122574,
-0.01747717708349228,
0.024367310106754303,
0.05565326660871506,
-0.028263799846172333,
-0.027617553249001503,
-0.02377808466553688,
-0.02814975567162037,
0.0018484563333913684,
-0.02613498643040657,
0.038166582584381104,
-0.03560060262680054,
0.037615373730659485,
-0.025621790438890457,
-0.019425421953201294,
0.0215162206441164,
0.06238183751702309,
0.004305144771933556,
-0.06660144776105881,
0.0215162206441164,
-0.004751815460622311,
-0.031856171786785126,
-0.05226997286081314,
-0.027769610285758972,
0.056527599692344666,
-0.020584864541888237,
-0.035676632076501846,
-0.010330446995794773,
0.015623969957232475,
0.048088375478982925,
-0.04721403867006302,
-0.008505750447511673,
-0.007460350636392832,
-0.010729599744081497,
0.0018140056636184454,
-0.032103266566991806,
0.03227433189749718,
0.06907239556312561,
-0.06314212828874588,
0.05766803398728371,
-0.04679587855935097,
-0.0017498561646789312,
-0.020831959322094917,
-0.021554235368967056,
-0.05835229530930519,
0.037615373730659485,
0.03170411288738251,
-0.0009699643705971539,
0.01059654913842678,
0.004305144771933556,
-0.015063256025314331,
-0.014293461106717587,
-0.018475059419870377,
-0.03594273328781128,
-0.01606113649904728,
-0.03345278277993202,
0.02362602762877941,
0.041663918644189835,
-0.060747209936380386,
-0.02516561560332775,
0.06401646137237549,
-0.049799028784036636,
-0.08127505332231522,
-0.015072759240865707,
0.03708316758275032,
-0.047670215368270874,
-0.039649151265621185,
-0.04204406589269638,
0.04485714063048363,
-0.009931294247508049,
-0.02102203294634819,
0.024956535547971725,
-0.026971304789185524,
-0.00025615256163291633,
0.0239301435649395,
0.0600629486143589,
0.06914842128753662,
-0.016089648008346558,
0.07488861680030823,
-0.015519429929554462,
0.04679587855935097,
0.03949709236621857,
0.046529777348041534,
0.037691403180360794,
0.035334501415491104,
0.057325903326272964,
-0.016336742788553238,
0.050749391317367554,
-0.018798181787133217,
0.0021109941881150007,
0.0328635573387146,
-0.01310550794005394,
0.02522263675928116,
0.01387530192732811,
-0.06454866379499435,
0.0020290252286940813,
-0.03888886049389839,
0.044096849858760834,
0.0015075134579092264,
-0.023321911692619324,
-0.021155083552002907,
0.03345278277993202,
0.0058257258497178555,
-0.009603419341146946,
0.035334501415491104,
-0.003592372639104724,
0.08211137354373932,
0.016099151223897934,
-0.03864176571369171,
0.012183655053377151,
0.01278238371014595,
-0.034460168331861496,
-0.0014041615650057793,
-0.024861499667167664,
-0.048316460102796555,
0.025355687364935875,
-0.03352881222963333,
0.020888982340693474,
0.010501512326300144,
0.01302947849035263,
0.027522515505552292,
0.06279999762773514,
-0.0495329275727272,
-0.011147759854793549,
0.03341476619243622,
-0.04614963382482529,
0.057744063436985016,
-0.0013637710362672806,
-0.03953510522842407,
-0.009679448790848255,
-0.018056899309158325,
-0.09024648368358612,
0.01213613711297512,
-0.0095321424305439,
0.04189200699329376,
-0.009190011769533157,
0.02343595400452614,
-0.03337675333023071,
-0.06838813424110413,
-0.05455084517598152,
0.06854018568992615,
0.011185773648321629,
-0.004630644340068102,
0.0015300846425816417,
-0.03799551725387573,
-0.014759139157831669,
-0.015034744516015053,
0.04569346085190773,
0.011822517029941082,
0.015443400479853153,
-0.0075316280126571655,
-0.03888886049389839,
0.06390241533517838,
0.060405079275369644,
0.0123832318931818,
0.00612984225153923,
0.04234817996621132,
0.01658383570611477,
0.05135762318968773,
-0.06124139949679375,
0.025602782145142555,
-0.01221216656267643,
0.036550965160131454,
0.04607360437512398,
-0.028339829295873642,
-0.0028534652665257454,
-0.0060253022238612175,
-0.08005858957767487,
-0.02077493816614151,
0.0737861916422844,
0.025621790438890457,
-0.03352881222963333,
0.07044091820716858,
0.010206899605691433,
-0.019368400797247887,
-0.039383046329021454,
0.01221216656267643,
-0.0024056066758930683,
0.020337771624326706,
0.01895974390208721,
-0.06348425894975662,
0.008619793690741062,
0.004107944667339325,
-0.04238619655370712,
0.012506778351962566,
0.017163557931780815,
-0.021972395479679108,
0.014949211850762367,
0.053600478917360306,
0.003905992489308119,
0.0377294160425663,
0.030126512050628662,
-0.007351059000939131,
-0.01314352173358202,
0.0032193551305681467,
0.0030625450890511274,
-0.07656125724315643,
0.03480229899287224,
-0.01131882518529892,
-0.010691585019230843,
0.012069611810147762,
-0.032331354916095734,
-0.04002929478883743,
-0.029955444857478142,
0.00021576213475782424,
-0.0056689162738621235,
-0.02929019182920456,
-0.03668401762843132,
0.032749515026807785,
-0.007964042946696281,
-0.0551970899105072,
0.016089648008346558,
-0.01935889758169651,
0.07496464252471924,
-0.03871779516339302,
0.005721185822039843,
-0.008192130364477634,
0.015139284543693066,
-0.017211075872182846,
-0.014255447313189507,
0.049304839223623276,
-0.004488090053200722,
-0.00870057474821806,
0.03442215174436569,
-0.015072759240865707,
0.017182566225528717,
-0.018075907602906227,
0.02020472101867199,
0.048012346029281616,
-0.0109481830149889,
-0.009351572953164577,
0.028929052874445915,
0.07618110626935959,
0.006595520302653313,
-0.020565858110785484,
-0.05333437770605087,
-0.045655444264411926,
-0.0035092157777398825,
0.015433897264301777,
0.010263921692967415,
0.007954539731144905,
0.015766523778438568,
-0.0016536317998543382,
-0.01273486576974392,
-0.041169729083776474,
-0.042728327214717865,
0.01399884931743145,
-0.042158108204603195,
-0.012753873132169247,
0.027123363688588142,
-0.02653413824737072,
-0.06747578084468842,
0.002005266258493066,
-0.02790266089141369,
0.013533171266317368,
-0.08393607288599014,
-0.011043219827115536,
0.04683389514684677,
-0.03402300179004669,
0.002311758231371641,
0.013172033242881298,
0.05698377266526222,
-0.026762226596474648,
0.005017917137593031,
-0.019501451402902603,
-0.040789585560560226,
0.021288134157657623,
-0.009351572953164577,
-0.06557505577802658,
-0.005963528528809547,
-0.03333873674273491,
0.06553704291582108,
-0.07192347943782806,
-0.054892975836992264,
0.008529509417712688,
-0.041169729083776474,
-0.009099726565182209,
-0.04732808470726013,
-0.010853147134184837,
-0.03837566450238228,
0.01690695993602276,
0.021535228937864304,
-0.029575301334261894,
0.025013556703925133,
-0.029157141223549843,
0.03050665557384491,
0.014084381982684135,
-0.05743994563817978,
0.02296077273786068,
-0.002658640965819359,
0.0035971244797110558,
0.039763193577528,
0.01350465975701809,
-0.007232263218611479,
0.06390241533517838,
0.010130871087312698,
-0.03377590700984001,
-0.04862057790160179,
0.003252617781981826,
0.06774188578128815,
0.034612223505973816,
0.021326148882508278,
0.07439442723989487,
-0.034764282405376434,
-0.009969308972358704,
-0.03791948780417442,
-0.02814975567162037,
0.0031219429802149534,
0.024196244776248932,
-0.026629174128174782,
0.06994672864675522,
0.0079070208594203,
-0.02442433312535286,
0.0042409952729940414,
0.044096849858760834,
0.01971053145825863,
-0.004328904207795858,
-0.01095768716186285,
-0.04968498274683952,
0.04455302283167839,
0.09830556064844131,
0.03991525247693062,
0.007964042946696281,
-0.0296323224902153,
-0.028225785121321678,
0.03945907577872276,
-0.04960895702242851,
0.002102678408846259,
0.01225018035620451,
-0.016222698614001274,
-0.014778146520256996,
0.012924938462674618,
-0.03831864148378372,
-0.04877263680100441,
0.027408473193645477,
-0.010815132409334183,
-0.016004115343093872,
0.042728327214717865,
0.020641887560486794,
0.03343377634882927,
-0.08005858957767487,
0.01690695993602276,
0.002794067608192563,
0.023797092959284782,
-0.0022345413453876972,
-0.017657747492194176,
0.0511295348405838,
0.022998787462711334,
0.059758834540843964,
0.021573243662714958,
0.022124454379081726,
-0.023169852793216705,
-0.02571682631969452,
0.04835447669029236,
0.006348425522446632,
-0.009432354010641575,
0.04090362787246704,
-0.04048546776175499,
-0.008643552660942078,
0.013590192422270775,
-0.015015737153589725,
-0.015234321355819702,
-0.022865736857056618,
-0.08386003971099854,
0.04687190800905228,
-0.039763193577528,
-0.03487832844257355,
-0.03561960905790329,
-0.0308297798037529,
0.013305083848536015,
-0.0033381504472345114,
0.0052222455851733685,
-0.004435820039361715,
0.05607142299413681,
-0.0511295348405838,
0.0320652537047863,
0.03848970681428909,
0.009052208624780178,
0.050521302968263626,
-0.032673485577106476,
-0.010900665074586868,
-0.052878204733133316,
-0.012753873132169247,
0.01578553207218647,
0.0013233806239441037,
0.006433958187699318,
-0.03579067438840866,
-0.045427355915308,
-0.05329636484384537,
0.010653570294380188,
-0.04398280382156372,
0.005763952154666185,
0.00851525366306305,
-0.0007377193542197347,
0.0014896942302584648,
-0.017543703317642212,
0.04729006811976433,
-0.035752661526203156,
-0.00002448298801027704,
-0.005787711590528488,
-0.014255447313189507,
-0.0005586353363469243,
0.0385657362639904,
0.011832021176815033,
-0.011166767217218876,
0.08340387046337128,
0.015852056443691254,
-0.03430810943245888,
0.02944224886596203,
-0.014540555886924267,
-0.04018135368824005,
-0.015918582677841187,
-0.027237407863140106,
0.017144551500678062,
0.006932898890227079,
0.002214346081018448,
-0.01861761324107647,
0.013096003793179989,
-0.05420871451497078,
-0.01789533719420433,
0.0027726844418793917,
-0.010339951142668724,
-0.0033761649392545223,
-0.005317281931638718,
-0.007094460539519787,
0.017562709748744965,
-0.04307045787572861,
0.011870035901665688,
0.03968716412782669,
-0.013742250390350819,
-0.005226997192949057,
-0.0010465873638167977,
0.046377722173929214,
-0.06371234357357025,
-0.013219551183283329,
0.024538375437259674,
-0.008472487330436707,
0.011157263070344925,
-0.03487832844257355,
-0.018978752195835114,
-0.04561743140220642,
0.012155144475400448,
0.02638208121061325,
0.0000037030749808764085,
0.06637336313724518,
0.003701664274558425,
0.038014523684978485,
0.04398280382156372,
0.034118037670850754,
-0.0038180837873369455,
0.06310410797595978,
0.039078932255506516,
0.006110834889113903,
0.0006123902276158333,
0.029252177104353905,
-0.034688252955675125,
-0.04470508173108101,
0.05778208002448082,
0.036493945866823196,
-0.009370580315589905,
0.025184622034430504,
0.006096579600125551,
-0.04538934305310249,
-0.02432929538190365,
-0.04614963382482529,
-0.01707802526652813,
0.04900072142481804,
-0.011955568566918373,
-0.060899268835783005,
-0.01618468388915062,
-0.03018353320658207,
0.017705265432596207,
-0.05892251431941986,
0.04227215051651001,
-0.02077493816614151,
-0.00696140993386507,
0.04371670261025429,
0.06295205652713776,
0.011176270432770252,
-0.03255943953990936,
-0.023759078234434128,
0.019225846976041794,
0.023492977023124695,
0.04512324184179306,
0.00910923071205616,
-0.07317796349525452,
0.05223195627331734,
-0.06435859203338623,
0.014958715997636318,
0.026230022311210632,
0.009883776307106018,
-0.03683607652783394,
-0.02278970740735531,
-0.027370458468794823,
0.039801206439733505,
0.022409562021493912,
0.003454569960013032,
0.03531549498438835,
-0.03092481568455696,
0.00713722687214613,
-0.016621850430965424,
-0.07192347943782806,
0.03377590700984001,
-0.00843922421336174,
-0.0048254686407744884,
0.05249805748462677,
0.0024851995985955,
-0.021877359598875046,
0.01809491403400898,
0.027142370119690895,
-0.03723522648215294,
0.04862057790160179,
0.05341040715575218,
-0.005849484819918871,
0.00758864963427186,
0.050521302968263626,
0.06287602335214615,
0.00331676728092134,
0.029518278315663338,
0.03181815892457962,
0.037596363574266434,
-0.044591039419174194,
0.016982989385724068,
-0.010511016473174095,
0.04090362787246704,
-0.025279659777879715,
-0.0025445972569286823,
-0.1338871568441391,
0.05622348189353943,
0.0035044639371335506,
0.05143365263938904,
0.05705980211496353,
0.024196244776248932,
-0.0027417975943535566
] |
725,875 | qsm_forward.qsm_forward | _do_apply_mask | null | def _do_apply_mask(self, nii): return nib.Nifti1Image(dataobj=nii.get_fdata() * self.mask.get_fdata(), affine=self.nii_affine, header=nii.header) if self._apply_mask else nii
| (self, nii) | [
0.02547929249703884,
-0.0382540337741375,
0.08366753906011581,
-0.007817510515451431,
-0.01991666480898857,
-0.05169558897614479,
-0.019934212788939476,
-0.01672297902405262,
0.031094564124941826,
-0.00419829273596406,
0.030164534226059914,
0.02277694270014763,
-0.034709393978118896,
-0.0077736410312354565,
-0.018302274867892265,
0.0002244189236080274,
-0.05152011290192604,
0.07524463534355164,
-0.016880908980965614,
-0.03200704604387283,
-0.019864020869135857,
-0.030603228136897087,
0.0010879588080570102,
0.023899998515844345,
0.04141262546181679,
0.032147426158189774,
-0.0039197225123643875,
-0.07356005162000656,
0.04120205342769623,
-0.02416321262717247,
-0.016152678057551384,
-0.02826938033103943,
0.056924812495708466,
-0.0065102051012218,
0.015731532126665115,
-0.02611101046204567,
-0.003138848813250661,
0.07840321958065033,
0.012608038261532784,
0.0003451966040302068,
0.010905909352004528,
-0.05980263650417328,
0.04716827720403671,
0.021092362701892853,
-0.02193465270102024,
-0.001868832390755415,
-0.0020881788805127144,
0.010835718363523483,
0.019899116829037666,
0.019004182890057564,
-0.0361483097076416,
-0.03577980399131775,
0.004117134492844343,
-0.011125256307423115,
-0.053064312785863876,
0.03244573995471001,
-0.007896474562585354,
0.026479512453079224,
-0.008291298523545265,
-0.031936854124069214,
-0.06864669173955917,
-0.006457561627030373,
0.042430393397808075,
-0.03270895406603813,
-0.018828706815838814,
0.0068699331022799015,
-0.07699940353631973,
-0.00298530631698668,
-0.006874320097267628,
0.06643567979335785,
-0.019583258777856827,
0.03448127582669258,
0.04141262546181679,
0.012362370267510414,
-0.033603888005018234,
-0.05267826095223427,
0.016924777999520302,
0.006953285075724125,
0.014880468137562275,
0.001293047796934843,
-0.024724740535020828,
0.011318281292915344,
0.009466996416449547,
-0.0077955755405128,
-0.015082267113029957,
-0.012958993203938007,
0.02798861637711525,
-0.019723640754818916,
-0.005501211155205965,
-0.061557408422231674,
0.0033362607937306166,
-0.027163874357938766,
0.014678670093417168,
-0.007124375086277723,
0.01884625293314457,
0.06822554767131805,
0.0008719024481251836,
0.010958552360534668,
0.034709393978118896,
-0.021952200680971146,
-0.05194125697016716,
-0.003452514298260212,
-0.003810049267485738,
-0.028427310287952423,
0.057275764644145966,
0.03635888174176216,
0.021197648718953133,
-0.0017810937715694308,
-0.07029617577791214,
0.00933538842946291,
0.004667694214731455,
0.021127456799149513,
-0.03195440396666527,
-0.026374226436018944,
-0.01495065912604332,
-0.028409762308001518,
-0.016916004940867424,
0.018793610855937004,
0.005689849145710468,
0.04723846912384033,
-0.04362363740801811,
0.039026133716106415,
-0.005492437165230513,
-0.006764647085219622,
-0.030234726145863533,
0.039201609790325165,
0.024777384474873543,
0.008076339028775692,
0.07082260400056839,
-0.030919086188077927,
-0.05236240476369858,
-0.019899116829037666,
-0.017389792948961258,
0.07566577941179276,
-0.04737884923815727,
0.039096325635910034,
-0.0037727602757513523,
-0.0295854602009058,
-0.01981137879192829,
0.08738765865564346,
0.009186232462525368,
-0.010756753385066986,
0.05885506048798561,
0.05657385662198067,
-0.01100242231041193,
0.019337590783834457,
0.04348325729370117,
0.0278131403028965,
0.04365873336791992,
-0.049519672989845276,
0.006159250624477863,
0.042290009558200836,
-0.007400752045214176,
0.08366753906011581,
0.010616372339427471,
0.04116695746779442,
0.07363024353981018,
-0.03270895406603813,
-0.011476210318505764,
-0.022127678617835045,
-0.04836152121424675,
0.03274405002593994,
-0.023198088631033897,
0.021320482715964317,
-0.01727573201060295,
-0.03220007196068764,
0.028585240244865417,
-0.0207238607108593,
0.03976313769817352,
0.020881788805127144,
-0.04014918953180313,
-0.039236705750226974,
-0.0014816857874393463,
0.025742508471012115,
-0.013695997186005116,
0.09861820191144943,
-0.05794258043169975,
-0.04846680909395218,
-0.02590043842792511,
0.04334287345409393,
-0.016626466065645218,
0.004654533229768276,
-0.01981137879192829,
0.011028743349015713,
-0.04836152121424675,
0.05267826095223427,
0.03439353406429291,
0.01454706210643053,
0.003910948522388935,
-0.05931130051612854,
0.028251832351088524,
0.04204434156417847,
0.00032353613642044365,
-0.0009832207579165697,
0.0028164093382656574,
-0.05148501694202423,
0.007756093051284552,
0.014687443152070045,
0.009896915405988693,
-0.07022598385810852,
-0.009791629388928413,
-0.023320922628045082,
-0.005974999628961086,
0.06991012394428253,
-0.020636120811104774,
-0.03678002581000328,
-0.03274405002593994,
0.09075681865215302,
-0.0038758532609790564,
0.013292399235069752,
0.03514808788895607,
-0.013055505231022835,
-0.018512846902012825,
0.057170480489730835,
-0.001840317388996482,
0.015161232091486454,
0.0090370774269104,
0.03142797201871872,
-0.02242598868906498,
0.02203993871808052,
-0.05787238851189613,
0.010475990362465382,
-0.012809837237000465,
0.008879147469997406,
-0.007852605544030666,
0.030743610113859177,
0.042430393397808075,
0.01909192092716694,
0.07917532324790955,
0.018372464925050735,
-0.03737664967775345,
-0.02986622415482998,
-0.05274845287203789,
-0.0018863801378756762,
0.015950879082083702,
0.02367187663912773,
0.02211013063788414,
-0.028655430302023888,
-0.0026913818437606096,
0.049695149064064026,
-0.019425328820943832,
-0.020179880782961845,
0.0066330390982329845,
-0.012265858240425587,
0.009221328422427177,
-0.027585020288825035,
0.00516341719776392,
0.04376401752233505,
0.011783295311033726,
0.022408440709114075,
0.024935312569141388,
-0.015450769104063511,
-0.04000880569219589,
0.02847995236515999,
-0.0019653448835015297,
0.021671436727046967,
-0.041903961449861526,
-0.028672978281974792,
0.014090821146965027,
0.01465234812349081,
0.03783288970589638,
-0.027935974299907684,
0.009879367426037788,
-0.04400968924164772,
-0.03425315394997597,
0.01263436023145914,
-0.03014698624610901,
0.026374226436018944,
-0.0035907027777284384,
0.00656284810975194,
0.07468310743570328,
0.024724740535020828,
0.02526872046291828,
0.013836379162967205,
-0.004413252230733633,
-0.004952844697982073,
0.027935974299907684,
0.060680024325847626,
-0.022513728588819504,
-0.03758722171187401,
0.0372011698782444,
0.026935754343867302,
-0.04337796941399574,
-0.05432774871587753,
-0.009186232462525368,
-0.016459763050079346,
0.06643567979335785,
0.06429485231637955,
-0.014029404148459435,
-0.038534797728061676,
0.016714205965399742,
0.08528193086385727,
-0.015231423079967499,
-0.032831788063049316,
-0.053064312785863876,
0.004068878013640642,
-0.0683659240603447,
-0.015161232091486454,
-0.011134029366075993,
0.011985094286501408,
-0.057100288569927216,
-0.054222460836172104,
-0.09889896214008331,
-0.04709808528423309,
0.03574471175670624,
0.011151577346026897,
0.018898896872997284,
0.06429485231637955,
0.0000934964555199258,
0.0701557919383049,
0.05187106877565384,
-0.05488927662372589,
-0.025426650419831276,
-0.09616151452064514,
0.042746249586343765,
-0.04295682534575462,
0.07671864330768585,
0.06531262397766113,
0.029111670330166817,
0.05825843662023544,
0.001979602500796318,
-0.015871914103627205,
-0.053731124848127365,
-0.031305138021707535,
0.0012228569248691201,
-0.019302494823932648,
0.028357118368148804,
-0.003395484294742346,
-0.05502965673804283,
0.04081600159406662,
-0.006084672641009092,
0.03762231767177582,
-0.02997151017189026,
0.02572496049106121,
-0.01977628283202648,
-0.01273964624851942,
0.07341966778039932,
-0.011827165260910988,
-0.01121299434453249,
-0.0019785056356340647,
-0.053309980779886246,
0.012046511285007,
-0.005496824160218239,
0.004332093987613916,
0.04025447368621826,
-0.011063839308917522,
-0.053134504705667496,
-0.01387147419154644,
-0.03237554803490639,
0.030304916203022003,
0.005733718164265156,
-0.0016440022736787796,
0.0178986769169569,
-0.02951526828110218,
0.04583464935421944,
0.07882437109947205,
-0.01776706799864769,
-0.010247869417071342,
0.03183156996965408,
-0.048186045140028,
-0.00855451449751854,
-0.013406460173428059,
0.057135384529829025,
-0.021109910681843758,
0.05274845287203789,
-0.014222429133951664,
-0.01500330213457346,
0.025602126494050026,
-0.0030050473287701607,
-0.03184911608695984,
-0.011037517338991165,
-0.02186446264386177,
-0.08865109086036682,
-0.07636768370866776,
0.02175917476415634,
-0.04895814508199692,
-0.05867958441376686,
-0.04397459328174591,
-0.04057033360004425,
0.008975659497082233,
-0.04390440136194229,
0.027795592322945595,
-0.027216516435146332,
0.01727573201060295,
-0.033568792045116425,
0.03706078976392746,
0.017609139904379845,
0.03370917588472366,
0.002270236611366272,
-0.053766220808029175,
0.026514608412981033,
-0.033779364079236984,
0.05250278487801552,
-0.09665285050868988,
0.015898237004876137,
-0.0002289429394295439,
-0.015652569010853767,
0.032831788063049316,
0.0074358475394546986,
-0.038850657641887665,
-0.04158810153603554,
-0.023794710636138916,
0.02558457851409912,
0.06225932016968727,
0.04071071743965149,
-0.0027857008390128613,
0.005115161184221506,
0.0038144360296428204,
0.02360168658196926,
-0.05460851266980171,
-0.02718142233788967,
0.0256898645311594,
0.04200924560427666,
0.0015529734082520008,
0.0006212990265339613,
0.05653876066207886,
0.03000660426914692,
-0.020951980724930763,
-0.04471159726381302,
0.00790963601320982,
0.021952200680971146,
0.004132488742470741,
0.026532156392931938,
0.0021737241186201572,
-0.023005064576864243,
-0.06531262397766113,
0.025075694546103477,
0.00499671371653676,
-0.0410967655479908,
0.01849529892206192,
-0.0581180565059185,
-0.0027308643329888582,
0.02416321262717247,
0.05485418066382408,
0.0061417026445269585,
-0.0719456598162651,
-0.02367187663912773,
-0.031410422176122665,
0.030778704211115837,
0.014994529075920582,
0.05166049301624298,
0.008107047528028488,
0.061803076416254044,
-0.061592504382133484,
-0.05050234496593475,
0.020987076684832573,
-0.019583258777856827,
0.06692701578140259,
-0.09061643481254578,
-0.017337149009108543,
0.06327708810567856,
-0.00949331745505333,
-0.007405138574540615,
0.007887701503932476,
-0.002024568384513259,
-0.001770126516930759,
-0.039201609790325165,
-0.028532596305012703,
0.0015979394083842635,
0.020179880782961845,
-0.029778484255075455,
-0.0026913818437606096,
-0.06924331188201904,
-0.0010199613170698285,
0.0012952412944287062,
-0.05302921682596207,
0.01800396293401718,
-0.03428824990987778,
-0.0026716405991464853,
-0.002980919321998954,
-0.026058368384838104,
-0.03986842557787895,
0.01390657015144825,
-0.04099147766828537,
0.05411717668175697,
0.06194346025586128,
0.023057706654071808,
0.025145886465907097,
0.03678002581000328,
-0.00594429112970829,
-0.028251832351088524,
0.02402283251285553,
-0.008107047528028488,
-0.007264757063239813,
-0.03779779374599457,
-0.049660053104162216,
0.0021287580020725727,
0.02002195082604885,
0.0019302495056763291,
-0.04565917328000069,
0.0207238607108593,
0.0513797290623188,
-0.0026891883462667465,
0.01273964624851942,
0.0047071767039597034,
-0.009853046387434006,
-0.024286048486828804,
-0.025531936436891556,
0.025602126494050026,
-0.04165829345583916,
-0.04123714566230774,
0.017047611996531487,
-0.04397459328174591,
0.03369162604212761,
-0.03653435781598091,
-0.026725180447101593,
-0.06036416441202164,
-0.030883992090821266,
0.024110570549964905,
-0.053941696882247925,
-0.03100682608783245,
-0.007979827001690865,
-0.0032375548034906387,
0.01101996935904026,
0.01495065912604332,
-0.02635667845606804,
-0.02798861637711525,
0.008975659497082233,
-0.010125035420060158,
-0.02002195082604885,
0.016056165099143982,
-0.04541350528597832,
0.0019554742611944675,
0.0056723011657595634,
0.01543322205543518,
0.018477750942111015,
0.04541350528597832,
-0.017653008922934532,
0.008927403949201107,
-0.05320469290018082,
-0.050221581012010574,
-0.07222642749547958,
0.07148942351341248,
-0.00030489166965708137,
-0.004755432717502117,
-0.053696028888225555,
0.017459983006119728,
-0.020846694707870483,
-0.0345514640212059,
-0.031059468165040016,
-0.016494859009981155,
-0.02725161239504814,
0.019249850884079933,
-0.005264316685497761,
0.025356458500027657,
0.06640058010816574,
-0.042886633425951004,
0.012274631299078465,
0.038920849561691284,
0.007185792084783316,
0.001137311803176999,
0.013204661197960377,
0.017609139904379845,
0.03212988004088402,
0.06369823217391968,
0.09307312220335007,
0.002169337123632431,
0.02058347873389721,
-0.06917311996221542,
0.021057266741991043,
-0.05439794063568115,
-0.012493978254497051,
0.07398119568824768,
-0.04916871711611748,
-0.054082080721855164,
-0.03253347799181938,
-0.009019529446959496,
-0.0006574912113137543,
0.02009214274585247,
0.011414793320000172,
-0.04506254941225052,
0.009607378393411636,
0.017951318994164467,
-0.005492437165230513,
-0.011151577346026897,
0.03216497600078583,
0.02614610642194748,
-0.07285813987255096,
0.020074594765901566,
-0.03504280000925064,
-0.04765961319208145,
-0.04123714566230774,
0.07812245935201645,
-0.021022170782089233,
-0.01898663491010666,
-0.030497942119836807,
-0.06882216781377792,
0.0453433133661747,
0.004667694214731455,
-0.01411714218556881,
0.0400439016520977,
-0.0010901521891355515,
0.0031191075686365366,
0.022794490680098534,
-0.030497942119836807,
0.03448127582669258,
-0.020864242687821388,
-0.08064933121204376,
0.03251592814922333,
-0.028655430302023888,
0.03979823365807533,
-0.019688544794917107,
-0.04755432903766632,
0.04148281365633011,
-0.013757414184510708,
0.05081820487976074,
-0.035902637988328934,
-0.005382763687521219,
-0.009405579417943954,
-0.042360201478004456,
0.04116695746779442,
0.032112330198287964,
0.008295685984194279,
0.004474669229239225,
-0.030322464182972908,
-0.011221768334507942,
0.007427073549479246,
0.04762451723217964,
-0.03625359386205673,
0.013292399235069752,
-0.03097173012793064,
-0.0029348565731197596,
-0.032937075942754745,
-0.03398993983864784,
0.020214976742863655,
-0.007286691572517157,
0.025251172482967377,
0.041974153369665146,
-0.00023566042364109308,
0.04874757304787636,
0.003127881558611989,
0.06183817237615585,
-0.020636120811104774,
0.006957672070711851,
0.0020256652496755123,
0.009414353407919407,
0.020144784823060036,
0.046325985342264175,
-0.07222642749547958,
0.04744904115796089,
0.0008104854496195912,
-0.05450322479009628,
0.04025447368621826,
-0.024075474590063095,
0.022934872657060623,
-0.04446592926979065,
0.012441335245966911,
-0.038394417613744736,
-0.050256676971912384,
-0.019565710797905922,
-0.04555388540029526,
-0.0028624720871448517,
-0.024970408529043198,
-0.00999342743307352,
0.014661122113466263,
0.003481029300019145,
-0.0023470078594982624,
0.03990352153778076,
-0.0026475125923752785,
-0.03200704604387283,
-0.02597062848508358,
-0.0006207506521604955,
-0.008620318956673145,
-0.032147426158189774,
0.04734375327825546,
0.012230762280523777,
0.03504280000925064,
-0.08142143487930298,
0.046255797147750854,
-0.010607598349452019,
0.00874315295368433,
0.02990131825208664,
-0.06769911199808121,
0.04562407732009888,
0.017196767032146454,
-0.0025093243457376957,
-0.014494418166577816,
0.019513066858053207,
0.030340012162923813,
0.017091481015086174,
0.00811582151800394,
-0.0804387554526329,
0.020864242687821388,
0.04295682534575462,
0.01835491694509983,
-0.04320249333977699,
0.045975033193826675,
-0.06713758409023285,
-0.0034327730536460876,
0.01371354516595602,
0.0008340651984326541,
0.01867077685892582,
0.05232730880379677,
0.07243699580430984,
0.06443523615598679,
0.00860277097672224,
-0.04474669322371483,
0.046501465141773224,
-0.03660454973578453,
0.04895814508199692,
0.008523805998265743,
-0.04839661717414856,
-0.03370917588472366,
-0.050642725080251694,
-0.011388471350073814,
0.053099408745765686,
-0.03270895406603813,
-0.0063478886149823666,
-0.023233184590935707,
0.02433869056403637,
-0.04709808528423309,
0.04815094918012619,
-0.005685462150722742,
0.056889716535806656,
-0.029041480273008347,
0.046712037175893784,
-0.042640965431928635,
-0.02165388874709606,
0.008892307989299297,
-0.041974153369665146,
0.04794037714600563,
-0.01121299434453249,
-0.038429513573646545,
0.026567252352833748,
0.0008104854496195912,
-0.006325954105705023,
-0.03320029005408287,
-0.026233844459056854,
-0.05260807275772095,
0.027374446392059326,
0.07292833179235458,
-0.000609234964940697,
-0.008133369497954845,
-0.0003879691648762673,
0.022689204663038254,
-0.004838784225285053,
0.08310601115226746,
-0.00890108197927475,
-0.06882216781377792,
-0.03577980399131775,
-0.001707612769678235,
-0.05257297679781914,
0.019899116829037666,
0.06004830449819565,
0.015371805056929588,
0.05506475269794464,
0.03607811778783798,
-0.042605869472026825,
0.05601232871413231,
0.04057033360004425,
0.04099147766828537,
0.06317179650068283,
0.03583244979381561,
0.02165388874709606,
0.0903356745839119,
-0.019074374809861183,
0.057030096650123596,
0.030497942119836807,
0.03779779374599457,
0.03741174563765526,
0.025040600448846817,
-0.038815561681985855,
0.024496620520949364,
-0.0018205761443823576,
0.008677348494529724,
-0.030269820243120193,
0.015047172084450722,
-0.02270675264298916
] |
725,876 | qsm_forward.qsm_forward | _load | null | def _load(self, nii_path):
nii = nib.load(nii_path)
if self._affine is not None:
nii = nib.Nifti1Image(dataobj=nii.get_fdata(), affine=self._affine, header=nii.header)
return nii
| (self, nii_path) | [
0.00371344480663538,
-0.024128245189785957,
0.041780825704336166,
-0.02453068643808365,
-0.009832397103309631,
-0.04053691402077675,
-0.004147899337112904,
0.048878446221351624,
0.01795441471040249,
-0.017817217856645584,
0.028152666985988617,
0.05345165356993675,
-0.055610205978155136,
0.06124439835548401,
-0.02615874819457531,
-0.005826266948133707,
-0.026103870943188667,
0.040975943207740784,
-0.07726892083883286,
-0.039329588413238525,
-0.05282969772815704,
-0.01587817817926407,
0.03958568722009659,
0.010618988424539566,
0.016710501164197922,
-0.01808246411383152,
0.02751241810619831,
-0.02853681705892086,
0.046756476163864136,
-0.05337848141789436,
-0.028427060693502426,
-0.03943934291601181,
0.0020728064700961113,
0.04613452032208443,
0.018512345850467682,
0.02253676764667034,
-0.0009575153817422688,
-0.017341604456305504,
0.014679997228085995,
0.03128074109554291,
0.02253676764667034,
-0.08085431158542633,
0.032524652779102325,
-0.02173188328742981,
-0.02811608277261257,
0.012933031655848026,
0.009987886063754559,
-0.03568931296467781,
0.00696499552577734,
0.08400068432092667,
-0.00708389887586236,
-0.03274416923522949,
-0.011186066083610058,
-0.00016706499445717782,
-0.06175659969449043,
0.041707657277584076,
-0.012082415632903576,
0.0299636572599411,
0.004266803152859211,
0.018896494060754776,
-0.06018341705203056,
-0.05893950164318085,
0.05304921045899391,
-0.026524605229496956,
0.023177018389105797,
0.012082415632903576,
-0.019061129540205002,
-0.009384222328662872,
-0.010875088162720203,
-0.0020510838367044926,
0.025390449911355972,
0.04595159366726875,
0.03481125831604004,
0.018100757151842117,
0.017762338742613792,
-0.0009215013706125319,
-0.053305309265851974,
0.0014954389771446586,
0.00014477061631623656,
0.021969690918922424,
-0.02030504308640957,
-0.021128220483660698,
-0.0031692329794168472,
-0.008172322064638138,
-0.0042942422442138195,
-0.037975918501615524,
0.11019601672887802,
-0.01853063888847828,
-0.02233554795384407,
-0.04419548064470291,
0.009411661885678768,
-0.010939112864434719,
-0.013710477389395237,
-0.0006654017488472164,
0.040353987365961075,
-0.0021334015764296055,
0.029579509049654007,
-0.015018414705991745,
0.015384271740913391,
-0.05875657498836517,
-0.08407385647296906,
-0.060110244899988174,
-0.044854022562503815,
-0.01508243940770626,
0.008391836658120155,
0.03651249036192894,
0.0289392601698637,
0.05959804356098175,
-0.01495439000427723,
-0.01955503597855568,
-0.03724420443177223,
0.001889878185465932,
-0.008876596577465534,
0.02990878000855446,
-0.0063201733864843845,
-0.0517687126994133,
0.037427134811878204,
0.02105504833161831,
0.04964674636721611,
0.05696387588977814,
-0.06702493131160736,
0.03411613032221794,
-0.046902820467948914,
0.03984178602695465,
0.019244058057665825,
0.011972658336162567,
-0.00342304608784616,
-0.002716485410928726,
0.04671989008784294,
-0.06826885044574738,
0.013655598275363445,
-0.05484190955758095,
-0.045329637825489044,
0.03503077104687691,
-0.019591622054576874,
0.008368970826268196,
0.007715001702308655,
0.0024032206274569035,
0.01436901930719614,
0.11026918888092041,
0.014899510890245438,
-0.01725928671658039,
0.03848811611533165,
0.04229302704334259,
0.030475856736302376,
0.04529305174946785,
0.04284181073307991,
0.023048967123031616,
-0.046902820467948914,
-0.047707702964544296,
0.001807560445740819,
-0.02641484886407852,
-0.02811608277261257,
0.04606134817004204,
0.04419548064470291,
-0.0469759926199913,
0.022646525874733925,
-0.02070748433470726,
-0.001318227150477469,
-0.04514670744538307,
-0.038524702191352844,
0.05985414609313011,
-0.003926098812371492,
-0.002778223715722561,
-0.06120781600475311,
-0.005035101901739836,
-0.00556559395045042,
-0.01870441995561123,
-0.0013799654552713037,
0.0022385851480066776,
-0.07953722774982452,
-0.09029341489076614,
-0.08970804512500763,
0.0027004792355000973,
-0.025097765028476715,
0.03206733241677284,
-0.043280839920043945,
-0.03874421864748001,
0.007957382127642632,
0.05557362362742424,
-0.025555085390806198,
-0.009850690141320229,
-0.004271375946700573,
0.007001581136137247,
-0.016975747421383858,
0.09014707058668137,
0.07258595526218414,
0.022701403126120567,
0.08458605408668518,
-0.03203074634075165,
0.11107407510280609,
0.09563492238521576,
0.007253107614815235,
0.0388173870742321,
0.0231587253510952,
-0.03889055922627449,
0.008881169371306896,
0.027805102989077568,
-0.05593947693705559,
-0.010628134943544865,
0.037280790507793427,
-0.0017503952840343118,
0.041451554745435715,
0.03038439340889454,
-0.04884186014533043,
-0.01753367856144905,
-0.07328107953071594,
0.04346376657485962,
0.012795835733413696,
0.049683328717947006,
0.021603833884000778,
-0.01900625228881836,
-0.000049376354581909254,
0.02207944728434086,
-0.0016509280540049076,
0.006086939480155706,
-0.06252489984035492,
0.034555159509181976,
-0.014762314967811108,
-0.00790250301361084,
0.023213602602481842,
0.08268360048532486,
-0.018539784476161003,
-0.01747880131006241,
-0.06387856602668762,
-0.00465095229446888,
0.011990951374173164,
0.004488603677600622,
0.02908560261130333,
0.043427180498838425,
-0.003029750194400549,
-0.05864681676030159,
-0.031097814440727234,
0.008899462409317493,
0.027018511667847633,
0.05067114159464836,
-0.012064122594892979,
0.015713542699813843,
0.0008140309946611524,
0.03486613556742668,
-0.04521987959742546,
-0.02641484886407852,
-0.04108569771051407,
-0.06215904280543327,
-0.003498503938317299,
0.01055496372282505,
-0.0010272568324580789,
-0.0028765478637069464,
-0.04284181073307991,
-0.004449731204658747,
0.05191505700349808,
-0.007193656172603369,
0.0064527965150773525,
0.03515882045030594,
-0.0047607095912098885,
0.022427011281251907,
-0.07481767982244492,
-0.0960739478468895,
0.03031122125685215,
-0.006393344607204199,
0.019500158727169037,
-0.048329662531614304,
-0.007618964184075594,
0.012283636257052422,
-0.026817290112376213,
0.02908560261130333,
-0.027000218629837036,
0.019628208130598068,
0.0613175705075264,
-0.05136626958847046,
0.08070797473192215,
0.059488289058208466,
0.0041090273298323154,
-0.0057896813377738,
0.049427229911088943,
-0.04393938183784485,
0.041927170008420944,
-0.03338441625237465,
-0.004568634554743767,
0.01773490011692047,
-0.006160111166536808,
0.02303067408502102,
-0.0014645698247477412,
-0.05143944174051285,
-0.0006391057977452874,
-0.041780825704336166,
0.008268360048532486,
-0.012201318517327309,
-0.04039057344198227,
-0.03482954949140549,
0.03804909065365791,
0.04569549486041069,
-0.05293945595622063,
0.007372010964900255,
-0.028042910620570183,
0.007097618654370308,
-0.1504402458667755,
0.05396385118365288,
-0.010920820757746696,
-0.001414264552295208,
-0.047158919274806976,
-0.04639061912894249,
-0.021292855963110924,
-0.0490247868001461,
0.037079568952322006,
-0.01960991509258747,
-0.017670875415205956,
0.03625639155507088,
-0.045878421515226364,
0.06080537289381027,
0.03914665803313255,
-0.03786616027355194,
0.004369700327515602,
-0.007275973912328482,
0.035652726888656616,
-0.035597849637269974,
0.027567297220230103,
0.03043927252292633,
0.05985414609313011,
-0.02281116135418415,
0.002716485410928726,
0.03594541549682617,
-0.07529329508543015,
-0.011323262937366962,
0.026744119822978973,
-0.0046395193785429,
0.047232091426849365,
0.026945341378450394,
-0.046427205204963684,
0.023451410233974457,
0.0153293926268816,
0.003967257682234049,
-0.03764664754271507,
-0.007756160572171211,
0.004120460245758295,
-0.008835437707602978,
0.0497199147939682,
-0.00510827312245965,
0.0006025201291777194,
0.013070228509604931,
-0.005968036130070686,
-0.02431117370724678,
-0.008652509190142155,
-0.013600720092654228,
0.027695346623659134,
-0.04302474111318588,
-0.03413442522287369,
-0.03889055922627449,
-0.025427035987377167,
0.006288161035627127,
-0.04792721942067146,
-0.005318640731275082,
0.009612882509827614,
-0.004984796512871981,
-0.046427205204963684,
0.03248807042837143,
-0.006311026867479086,
0.010097643360495567,
0.010490939021110535,
-0.04364669695496559,
-0.03051244281232357,
0.00929275806993246,
-0.02663436345756054,
-0.03338441625237465,
0.015539760701358318,
-0.017588557675480843,
-0.007861344143748283,
0.015494028106331825,
0.014561093412339687,
0.03724420443177223,
-0.012558029033243656,
-0.012384247034788132,
-0.07726892083883286,
0.0015823299763724208,
0.08129334449768066,
-0.052354082465171814,
-0.0021791334729641676,
-0.007797319442033768,
-0.042658884078264236,
-0.017039772123098373,
-0.006891824305057526,
0.02228066883981228,
-0.0014977256068959832,
0.019353816285729408,
-0.025116058066487312,
0.035378336906433105,
0.05700046196579933,
0.04708574712276459,
-0.028097789734601974,
-0.09117147326469421,
-0.020048942416906357,
0.005657058209180832,
0.03413442522287369,
-0.0005190590745769441,
0.01065557450056076,
-0.005487849470227957,
0.02581118606030941,
0.028042910620570183,
0.04741501808166504,
-0.030750250443816185,
-0.026103870943188667,
-0.000697414216119796,
0.01615257002413273,
0.047232091426849365,
0.004248510114848614,
0.011506191454827785,
0.023817267268896103,
-0.01504585426300764,
0.014762314967811108,
-0.10756184905767441,
-0.010061057284474373,
0.04829307645559311,
0.024622151628136635,
-0.041853997856378555,
0.026323383674025536,
0.05264676734805107,
0.0012461991282179952,
-0.03965885937213898,
-0.015695249661803246,
-0.0019161740783602,
-0.0517687126994133,
0.038524702191352844,
-0.004580067470669746,
-0.029396580532193184,
-0.016774525865912437,
-0.025975821539759636,
0.021603833884000778,
0.009160134941339493,
0.013783648610115051,
0.024128245189785957,
-0.0850982517004013,
0.024548979476094246,
0.03126244992017746,
0.003800335805863142,
0.011231798678636551,
-0.10024471580982208,
-0.03214050456881523,
-0.029323408380150795,
0.01273181103169918,
0.04748819023370743,
0.03386003151535988,
0.02431117370724678,
0.05048821493983269,
-0.022792868316173553,
-0.06007365882396698,
-0.0055335815995931625,
-0.04931747540831566,
0.0817323699593544,
-0.0014897225191816688,
-0.04254912585020065,
0.011250091716647148,
-0.06548833847045898,
0.02125626988708973,
-0.018823323771357536,
0.0031212144531309605,
-0.0026844730600714684,
0.005515288561582565,
-0.012109854258596897,
0.039732031524181366,
0.03841494768857956,
-0.05784193426370621,
0.02635996975004673,
-0.003576248651370406,
-0.031701475381851196,
0.024475809186697006,
-0.04071984440088272,
-0.003987837117165327,
0.021677006036043167,
0.00041330367093905807,
0.04134180024266243,
-0.035177115350961685,
0.0037088715471327305,
0.04507353529334068,
-0.06965909898281097,
0.046427205204963684,
0.04101252928376198,
0.03521370142698288,
0.022829454392194748,
0.009768372401595116,
-0.027494125068187714,
0.033475883305072784,
-0.035597849637269974,
-0.033475883305072784,
-0.0014028315199539065,
-0.021823348477482796,
-0.007728721480816603,
-0.003697438631206751,
0.04748819023370743,
0.005309494212269783,
-0.07609818130731583,
0.024896543473005295,
0.0817323699593544,
-0.07982991635799408,
0.013143399730324745,
0.04884186014533043,
0.0036105476319789886,
-0.02056114189326763,
-0.025225814431905746,
0.011743998154997826,
0.01249400433152914,
-0.03464662283658981,
-0.003779756370931864,
0.01610683836042881,
0.009759225882589817,
-0.03689664229750633,
0.031427085399627686,
-0.056561436504125595,
-0.017451360821723938,
0.05667119100689888,
-0.050561387091875076,
-0.038378361612558365,
0.012128147296607494,
0.02453068643808365,
0.0017972707282751799,
-0.00850159302353859,
0.009814104065299034,
-0.038524702191352844,
0.047634534537792206,
-0.005876572337001562,
0.03148196265101433,
0.059890732169151306,
-0.02901243045926094,
0.01583244651556015,
0.007852197624742985,
-0.011606801301240921,
-0.010618988424539566,
0.007650977000594139,
-0.020762363448739052,
-0.00488875899463892,
0.015612931922078133,
-0.01406718697398901,
-0.055134594440460205,
0.06530541181564331,
-0.01773490011692047,
-0.015247074887156487,
-0.030530735850334167,
0.026616070419549942,
0.005583886988461018,
0.025372156873345375,
-0.057037048041820526,
-0.014561093412339687,
-0.029323408380150795,
-0.0024695321917533875,
0.07448840886354446,
0.040427155792713165,
0.03823201730847359,
-0.035853948444128036,
0.02771363966166973,
0.01606110669672489,
0.016591597348451614,
-0.0415613129734993,
-0.020176993682980537,
0.00718450965359807,
-0.03737225383520126,
0.045256465673446655,
0.020122114568948746,
-0.00904123205691576,
-0.022646525874733925,
-0.01885990984737873,
0.025701427832245827,
-0.017067212611436844,
-0.005181444343179464,
0.01623488776385784,
-0.008122017607092857,
-0.001192463911138475,
0.025500206276774406,
-0.02696363441646099,
-0.03804909065365791,
0.003242404432967305,
0.04163448512554169,
-0.010500085540115833,
-0.016262326389551163,
0.023817267268896103,
0.022024570032954216,
-0.027073390781879425,
0.03128074109554291,
0.02533557079732418,
-0.008236347697675228,
0.03991495817899704,
-0.0442686527967453,
-0.009868982248008251,
0.020268457010388374,
0.04741501808166504,
-0.005693643819540739,
0.0153293926268816,
0.004875039681792259,
-0.06289075314998627,
0.03448198735713959,
0.018494052812457085,
-0.02063431404531002,
0.04895161837339401,
-0.06413466483354568,
0.002947432454675436,
0.026780705899000168,
0.008195188827812672,
0.04543939232826233,
0.004266803152859211,
-0.02370750904083252,
0.02588435634970665,
-0.06530541181564331,
0.01812819577753544,
-0.01760685071349144,
-0.03698810562491417,
0.058463890105485916,
-0.004454304464161396,
0.05290286988019943,
-0.016344644129276276,
0.0024809653405100107,
0.00020193570526316762,
-0.02057943493127823,
0.04734184965491295,
0.00950312614440918,
0.0178812425583601,
-0.014250115491449833,
-0.038927145302295685,
0.0014714295975863934,
0.02151237055659294,
0.0003987265517935157,
-0.0919031873345375,
-0.003779756370931864,
-0.06651273369789124,
-0.04602476581931114,
-0.01406718697398901,
0.008497020229697227,
0.016161717474460602,
0.0038323481567204,
0.0010135371703654528,
0.05864681676030159,
0.058061446994543076,
0.005154005251824856,
0.0415613129734993,
-0.02635996975004673,
-0.02798803150653839,
0.013865966349840164,
0.011158627457916737,
-0.021475784480571747,
0.04467109590768814,
0.027622176334261894,
-0.029670972377061844,
0.0967324897646904,
-0.0036219805479049683,
-0.04719550535082817,
-0.025280693545937538,
0.006425356958061457,
-0.0026981926057487726,
-0.032652705907821655,
-0.022994089871644974,
-0.018914787098765373,
-0.0017012333264574409,
0.00650310143828392,
-0.004934491124004126,
-0.0021985697094351053,
0.006219562608748674,
-0.012384247034788132,
-0.012777542695403099,
-0.008323238231241703,
0.05619557946920395,
0.02030504308640957,
-0.019866015762090683,
-0.03364051878452301,
-0.003066335804760456,
0.01743306778371334,
-0.022225789725780487,
0.014350726269185543,
0.07982991635799408,
0.039878372102975845,
0.020176993682980537,
-0.01960991509258747,
0.01331718172878027,
-0.04276863858103752,
-0.014698290266096592,
0.05103699862957001,
-0.017341604456305504,
0.00801683310419321,
0.008963487111032009,
-0.015274514444172382,
-0.031573425978422165,
-0.019170887768268585,
0.038524702191352844,
0.05198822543025017,
-0.03594541549682617,
-0.018786737695336342,
0.019189180806279182,
-0.02963438630104065,
-0.02185993455350399,
-0.018914787098765373,
0.03521370142698288,
-0.039000317454338074,
-0.00053535116603598,
-0.021896518766880035,
-0.03698810562491417,
0.05740290507674217,
0.024951422587037086,
0.04503695294260979,
0.05396385118365288,
-0.021439198404550552,
0.02226237580180168,
0.02989048697054386,
-0.07624451816082001,
0.013838526792824268,
0.02030504308640957,
-0.07339084148406982,
-0.0017275292193517089,
-0.006553406827151775,
-0.008890315890312195,
0.05191505700349808,
-0.036951519548892975,
0.019719671458005905,
-0.05604923516511917,
0.042732056230306625,
0.004291955381631851,
0.01995747908949852,
-0.007829331792891026,
-0.000571936834603548,
0.028317302465438843,
0.09139098972082138,
-0.0289392601698637,
0.01860380917787552,
-0.0749274343252182,
-0.026067284867167473,
0.02935999445617199,
-0.026103870943188667,
-0.006356758996844292,
0.06731761991977692,
-0.014579386450350285,
0.02158554084599018,
-0.010737892240285873,
-0.04576866328716278,
-0.03962227329611778,
0.03625639155507088,
0.02138431929051876,
-0.0052820551209151745,
-0.04115886986255646,
-0.020524557679891586,
0.003205818822607398,
-0.056488264352083206,
0.032195381820201874,
0.020213577896356583,
-0.00232547614723444,
-0.02935999445617199,
-0.0037431707605719566,
-0.00007860201003495604,
0.027567297220230103,
0.09175684303045273,
-0.03411613032221794,
0.01553061418235302,
0.04686623439192772,
-0.03823201730847359,
0.030805127695202827,
0.10273253917694092,
0.02860998921096325,
0.05824437364935875,
0.017497092485427856,
0.03318319469690323,
0.03153683990240097,
-0.05374433845281601,
0.022445304319262505,
0.005195164121687412,
0.03373198211193085,
-0.041451554745435715,
-0.000024330895030288957,
-0.0660737082362175,
0.032524652779102325,
-0.01495439000427723,
-0.006896397564560175,
0.0038780802860856056,
0.0004593215708155185,
-0.016692208126187325
] |
725,877 | qsm_forward.qsm_forward | set_affine | null | def set_affine(self, affine):
self._affine = affine
| (self, affine) | [
0.026036612689495087,
0.04896583780646324,
0.09734290838241577,
0.09021227806806564,
-0.03833531215786934,
-0.04304545372724533,
-0.02474459446966648,
-0.03066498041152954,
-0.0016661306144669652,
0.031090199947357178,
0.013615250587463379,
-0.006173882633447647,
0.020917605608701706,
0.08811888843774796,
-0.03512980043888092,
-0.013116434216499329,
-0.022373169660568237,
0.020263418555259705,
-0.02834261767566204,
-0.011734465137124062,
-0.002761892508715391,
-0.04638180509209633,
0.06142808869481087,
-0.019609231501817703,
-0.013181852176785469,
0.022912872955203056,
0.0028170894365757704,
-0.012233282439410686,
0.0672503411769867,
-0.04942376911640167,
-0.04490988329052925,
-0.03315088897943497,
-0.03545689210295677,
-0.024270309135317802,
0.041082896292209625,
0.014621062204241753,
0.014948155730962753,
-0.016469137743115425,
0.060054294764995575,
0.045956581830978394,
-0.02548055350780487,
0.024711884558200836,
0.04801727086305618,
0.020672284066677094,
0.017286870628595352,
0.027966462075710297,
-0.009085011668503284,
0.035031672567129135,
0.023534350097179413,
0.040363289415836334,
-0.029503799974918365,
-0.05979262292385101,
0.03185886889696121,
0.019004110246896744,
-0.04091934859752655,
0.054395586252212524,
0.043209001421928406,
0.033756010234355927,
0.030256113037467003,
-0.007572205737233162,
0.019740069285035133,
-0.04638180509209633,
-0.010998506098985672,
-0.05841882899403572,
0.040428709238767624,
0.023109128698706627,
-0.05956365540623665,
0.041017476469278336,
0.017793865874409676,
0.030043503269553185,
0.022798391059041023,
0.03272566571831703,
-0.015994854271411896,
-0.050666723400354385,
0.03584940731525421,
0.01862795278429985,
-0.1284167617559433,
0.03266024589538574,
-0.03807364031672478,
0.01723780669271946,
0.03777925670146942,
-0.004685608670115471,
-0.0002145270846085623,
0.04098476842045784,
0.011391017585992813,
-0.05161529406905174,
0.01722145266830921,
-0.03424664959311485,
-0.023043710738420486,
-0.018398987129330635,
0.04549865424633026,
-0.028637003153562546,
0.00590403052046895,
0.0372559055685997,
0.05547499284148216,
0.04019974544644356,
-0.008218214847147465,
-0.008295899257063866,
0.0041213734075427055,
0.015643227845430374,
0.014555643312633038,
-0.0050903866067528725,
0.037419453263282776,
-0.05861508473753929,
0.03388684615492821,
0.028522519394755363,
0.024368437007069588,
-0.020198000594973564,
-0.017352290451526642,
0.002688296604901552,
-0.013664314523339272,
0.06329251825809479,
-0.061787888407707214,
0.02409040741622448,
0.004669254180043936,
-0.024270309135317802,
0.03408310189843178,
-0.04785372316837311,
0.019380267709493637,
0.0711754634976387,
0.005658710841089487,
0.01702519692480564,
-0.025055332109332085,
0.05436287447810173,
0.002649454167112708,
-0.05364327132701874,
0.009085011668503284,
0.04644722118973732,
0.03771383687853813,
-0.09773541986942291,
-0.023583414033055305,
-0.04451737180352211,
-0.05249844491481781,
0.03328172490000725,
-0.005069943144917488,
-0.04582574591040611,
0.05289095640182495,
-0.010229837149381638,
-0.0452369786798954,
0.07156797498464584,
-0.05727400630712509,
0.044484663754701614,
0.05861508473753929,
0.038629695773124695,
0.04271836206316948,
0.0269524734467268,
-0.012772985734045506,
0.021326471120119095,
-0.010090822353959084,
-0.023926861584186554,
0.027394048869609833,
0.0016998620703816414,
-0.050862979143857956,
-0.030288822948932648,
0.010704122483730316,
-0.01682894118130207,
-0.02741040289402008,
0.031106555834412575,
0.030108921229839325,
0.07496973872184753,
-0.010761363431811333,
0.03372329846024513,
-0.03637275472283363,
0.04304545372724533,
0.010794072411954403,
-0.014449338428676128,
-0.034900836646556854,
0.010704122483730316,
0.002708739833906293,
-0.04065767303109169,
-0.023190902546048164,
-0.125145822763443,
-0.10493147373199463,
0.02368154190480709,
0.0891655832529068,
0.0239595714956522,
0.004289008677005768,
0.0632271021604538,
-0.040821220725774765,
0.05681607499718666,
0.06764286011457443,
0.010655058547854424,
0.01910223811864853,
0.00578954815864563,
0.0206232201308012,
-0.02155543677508831,
-0.00011473813356133178,
0.05269470065832138,
0.026592670008540154,
-0.03562043979763985,
0.056063760071992874,
0.03213689848780632,
-0.050405047833919525,
-0.007155161816626787,
-0.004910485353320837,
-0.01936391182243824,
-0.01843169704079628,
-0.05642356351017952,
-0.010344319976866245,
0.02467917650938034,
-0.041475407779216766,
-0.039153046905994415,
0.048998549580574036,
-0.0014279659371823072,
0.03362517058849335,
-0.04317628964781761,
-0.007130629848688841,
-0.02315819263458252,
0.010385206900537014,
-0.02775385044515133,
0.027377692982554436,
-0.002126105362549424,
-0.03565314784646034,
-0.03647088259458542,
0.02188253030180931,
-0.06365232169628143,
-0.015152588486671448,
0.00449344189837575,
0.044353827834129333,
0.04850791022181511,
0.02853887528181076,
0.030926654115319252,
0.01606844924390316,
-0.062376655638217926,
0.04772288724780083,
-0.004939105827361345,
0.04742850363254547,
-0.05017608404159546,
-0.02881690301001072,
0.01367249246686697,
-0.0034753642976284027,
-0.04638180509209633,
-0.05567124858498573,
-0.015078992582857609,
0.06842788308858871,
-0.02283109910786152,
0.020999377593398094,
0.005928562954068184,
-0.05756838992238045,
0.0013983231037855148,
-0.0033056847751140594,
0.056848783046007156,
0.0022998733911663294,
-0.022127849981188774,
-0.03512980043888092,
0.0519096776843071,
-0.004321717657148838,
0.02302735485136509,
-0.09740833193063736,
-0.003512162249535322,
0.04219501093029976,
0.0026003902312368155,
-0.01433485560119152,
0.02476094849407673,
-0.02675621770322323,
0.05946552753448486,
-0.04948918893933296,
0.0006311875185929239,
0.019265783950686455,
0.044222988188266754,
0.04343796521425247,
-0.03306911513209343,
-0.02742675691843033,
-0.0023959570098668337,
0.052661992609500885,
0.030632270500063896,
-0.022602133452892303,
0.01908588409423828,
-0.003371103433892131,
-0.025120751932263374,
0.010720476508140564,
0.015234362334012985,
0.0007446479285135865,
0.03149906545877457,
0.00855348538607359,
0.006574571598321199,
-0.04134456813335419,
-0.010368851944804192,
-0.027099665254354477,
0.02768843248486519,
0.07379220426082611,
-0.03519522026181221,
0.0022385434713214636,
0.037092357873916626,
-0.03306911513209343,
-0.042947325855493546,
0.01777750998735428,
0.08923099935054779,
-0.03424664959311485,
-0.00444437749683857,
0.0023836910258978605,
0.03493354469537735,
0.03372329846024513,
-0.025840356945991516,
0.026118384674191475,
-0.04736308380961418,
-0.03087759017944336,
0.005965360905975103,
0.013876925222575665,
0.02853887528181076,
0.03378871828317642,
-0.009804615750908852,
-0.04039600118994713,
-0.032970987260341644,
-0.004775559529662132,
-0.02369789592921734,
-0.08079200237989426,
0.0499144084751606,
0.010671412572264671,
0.0325784757733345,
0.056979622691869736,
-0.015111701563000679,
-0.07797899842262268,
0.00948570016771555,
0.035227928310632706,
0.004951372276991606,
0.031580839306116104,
-0.007429102435708046,
0.014097712934017181,
0.0176303181797266,
0.031041136011481285,
-0.03558773174881935,
-0.03146635740995407,
-0.02673986181616783,
0.01373791042715311,
-0.024793658405542374,
0.021195633336901665,
0.04746121168136597,
0.0028273111674934626,
0.025693165138363838,
-0.011063924990594387,
-0.004168393090367317,
-0.008259100839495659,
-0.018873272463679314,
-0.04396131634712219,
-0.010417915880680084,
-0.00019727803010027856,
0.001369702396914363,
0.002964281477034092,
0.023305384442210197,
-0.03014163114130497,
0.025971192866563797,
-0.016011208295822144,
-0.012200573459267616,
-0.021195633336901665,
-0.01617475412786007,
-0.0904739573597908,
-0.021310117095708847,
0.008013781160116196,
-0.08255830407142639,
-0.06594197452068329,
0.001346192555502057,
0.019919971004128456,
-0.0309430081397295,
-0.039610978215932846,
0.07006334513425827,
-0.015545099973678589,
-0.0010099000064656138,
-0.003009256673976779,
-0.04111560434103012,
0.05115736275911331,
-0.07732481509447098,
-0.04536781460046768,
-0.054199330508708954,
-0.052007805556058884,
0.008790627121925354,
-0.017384998500347137,
-0.0325784757733345,
0.10107177495956421,
0.007294176612049341,
0.0419333390891552,
-0.04369964078068733,
-0.01817002333700657,
0.04553136229515076,
0.01591308042407036,
-0.00878245010972023,
-0.0148091409355402,
0.04520426690578461,
0.006742206867784262,
-0.0029458822682499886,
0.04625096544623375,
-0.030092567205429077,
0.03755028918385506,
0.02754124067723751,
-0.033363498747348785,
0.028964094817638397,
0.07065211236476898,
0.01669810339808464,
0.04572761803865433,
0.002547237556427717,
-0.010295256040990353,
0.008320431225001812,
0.05154987424612045,
-0.06482985615730286,
0.05207322537899017,
0.008173239417374134,
-0.006721763405948877,
-0.0014371654251590371,
0.010794072411954403,
-0.03951284661889076,
-0.012658503837883472,
0.05563854053616524,
0.015520568005740643,
0.0216372087597847,
0.04039600118994713,
0.006116641219705343,
0.004894130863249302,
0.010417915880680084,
0.019265783950686455,
0.003469231305643916,
0.007653979118913412,
-0.009747374802827835,
0.006321074441075325,
-0.036896102130413055,
-0.016640862450003624,
-0.00888875499367714,
-0.06142808869481087,
-0.07529683411121368,
0.02322361059486866,
-0.014498402364552021,
-0.01220875047147274,
0.05135361850261688,
-0.07909111678600311,
0.0027128285728394985,
-0.0026310551911592484,
-0.030305176973342896,
0.006092109251767397,
-0.062049563974142075,
0.0452369786798954,
0.002688296604901552,
-0.06214769184589386,
-0.0032934187911450863,
0.029569217935204506,
0.018284505233168602,
0.02135918103158474,
-0.02788468822836876,
0.02348528616130352,
0.005372504238039255,
-0.017352290451526642,
-0.024041343480348587,
0.05181154981255531,
0.011121165938675404,
-0.022847454994916916,
-0.06901665031909943,
-0.019069528207182884,
-0.00316871446557343,
-0.027099665254354477,
0.07869860529899597,
-0.006010335870087147,
0.042096883058547974,
0.05017608404159546,
0.017074260860681534,
-0.0034814972896128893,
-0.035031672567129135,
0.05380681902170181,
0.00894599687308073,
0.020443320274353027,
-0.04219501093029976,
0.054199330508708954,
0.013329044915735722,
-0.04569490998983383,
-0.04971815273165703,
-0.008218214847147465,
0.0060716657899320126,
0.023060064762830734,
0.0014330766862258315,
0.007964717224240303,
0.04952189698815346,
-0.015594163909554482,
0.004505707882344723,
-0.03830260410904884,
-0.036634430289268494,
-0.023403512313961983,
-0.044942595064640045,
-0.001448409166187048,
0.009518410079181194,
0.035424184054136276,
0.016313768923282623,
-0.02068863995373249,
-0.013198207132518291,
-0.031711678951978683,
-0.03535876423120499,
-0.0025431490503251553,
0.0028191336896270514,
0.03372329846024513,
0.011726288124918938,
-0.012233282439410686,
-0.04997982829809189,
-0.009354863315820694,
0.010646880604326725,
-0.01849711500108242,
0.03434477746486664,
-0.04379776865243912,
0.08896932750940323,
-0.0039823586121201515,
-0.015610518865287304,
-0.02109750546514988,
-0.06679241359233856,
-0.005859055556356907,
0.020770413801074028,
-0.006856689229607582,
-0.02467917650938034,
-0.014351210556924343,
-0.02760665863752365,
0.040821220725774765,
0.03771383687853813,
-0.06447005271911621,
-0.007355506531894207,
0.01869337074458599,
-0.003397679654881358,
0.034900836646556854,
-0.00023305384092964232,
-0.03467186912894249,
-0.0035448716953396797,
-0.005809991620481014,
-0.0052334899082779884,
0.016362832859158516,
0.024728240445256233,
0.019053174182772636,
0.016191110014915466,
0.0036041573621332645,
0.01715603470802307,
-0.007964717224240303,
0.004182703327387571,
0.02647818811237812,
0.022782035171985626,
-0.05096110701560974,
-0.023992279544472694,
0.018546178936958313,
0.023714251816272736,
0.006913930643349886,
-0.05109194293618202,
0.038956791162490845,
0.024662820622324944,
0.0028906853403896093,
0.10087551921606064,
0.017548546195030212,
-0.06574571877717972,
-0.025693165138363838,
-0.06836245954036713,
-0.0259384848177433,
-0.021048441529273987,
0.03617649897933006,
0.029307542368769646,
0.04160624369978905,
-0.0179574117064476,
-0.06836245954036713,
-0.020050808787345886,
0.024646466597914696,
0.02760665863752365,
-0.05037233978509903,
-0.03607837110757828,
-0.022176913917064667,
-0.003385413670912385,
-0.03738674148917198,
-0.021669918671250343,
0.05380681902170181,
0.017074260860681534,
-0.042947325855493546,
0.04160624369978905,
-0.031106555834412575,
0.006680876947939396,
0.06427379697561264,
0.06028326228260994,
0.03692881390452385,
-0.010663235560059547,
0.006239301059395075,
0.0032504878472536802,
0.02840803749859333,
-0.021980658173561096,
-0.02222597785294056,
0.02875148504972458,
0.012053381651639938,
0.027704786509275436,
-0.07647436857223511,
0.019445685669779778,
-0.016084803268313408,
0.02708330936729908,
0.0018828297033905983,
-0.013819684274494648,
0.015316135250031948,
-0.00032198228291235864,
-0.04618554934859276,
0.013729733414947987,
0.00685260072350502,
-0.02647818811237812,
0.010720476508140564,
0.054591841995716095,
-0.09171690791845322,
-0.04818081483244896,
-0.033756010234355927,
-0.06643261015415192,
-0.012887468561530113,
0.05835341289639473,
-0.03912033513188362,
-0.003373147686943412,
0.05292366445064545,
-0.006382404360920191,
-0.00017223496979568154,
-0.012037026695907116,
-0.0002379091311013326,
-0.00830407626926899,
0.018120959401130676,
0.022193267941474915,
-0.0076212696731090546,
0.03784467279911041,
0.002880463842302561,
0.03532605618238449,
-0.0572412945330143,
0.03598024323582649,
-0.003538738703355193,
0.06960541754961014,
-0.010638703592121601,
-0.022929226979613304,
-0.006623635534197092,
-0.050928398966789246,
-0.028358973562717438,
0.062376655638217926,
-0.08327791094779968,
0.02441750094294548,
-0.03558773174881935,
0.00981279369443655,
-0.059923458844423294,
-0.0019053174182772636,
-0.02042696438729763,
-0.03826989606022835,
0.046937860548496246,
-0.021113861352205276,
0.027655722573399544,
-0.034573741257190704,
0.008872400969266891,
-0.020983023568987846,
-0.01817002333700657,
-0.02209514006972313,
0.06247478350996971,
0.007294176612049341,
-0.03179344907402992,
0.051124654710292816,
-0.004086619708687067,
-0.01220875047147274,
-0.03997077792882919,
0.004415757022798061,
0.038891371339559555,
-0.02036154642701149,
0.023370802402496338,
0.012298701331019402,
-0.07909111678600311,
-0.012257814407348633,
-0.030632270500063896,
-0.008488066494464874,
-0.005082209128886461,
0.031384583562612534,
0.03581669554114342,
0.012715744785964489,
0.008831514045596123,
-0.032235026359558105,
-0.050339631736278534,
0.030305176973342896,
0.0003069053345825523,
-0.022994646802544594,
-0.022716617211699486,
-0.0022548981942236423,
-0.0004857843741774559,
0.024139471352100372,
0.08007239550352097,
-0.02714872919023037,
-0.011448259465396404,
0.021522726863622665,
-0.08412835001945496,
0.04543323442339897,
0.0027148728258907795,
-0.01923307590186596,
0.011767175048589706,
-0.012257814407348633,
0.06440463662147522,
-0.05400307476520538,
0.020181644707918167,
-0.10054842382669449,
0.06568029522895813,
0.028113653883337975,
-0.02382873371243477,
-0.02667444385588169,
-0.018448051065206528,
-0.014195840805768967,
-0.04690515249967575,
-0.01723780669271946,
0.018317215144634247,
0.030436014756560326,
-0.026265576481819153,
-0.038564279675483704,
0.007997427135705948,
-0.04212959483265877,
-0.01983819715678692,
-0.008651613257825375,
0.04438653588294983,
-0.003371103433892131,
-0.027116019278764725,
-0.007216491736471653,
0.03418122977018356,
0.03334714472293854,
-0.014686481095850468,
0.032970987260341644,
-0.02534971572458744,
-0.0169597789645195,
-0.009600182995200157,
0.00847988948225975,
0.008896932937204838,
0.01587219350039959,
-0.007743929512798786,
-0.07137171924114227,
0.050797559320926666,
0.0034508323296904564,
-0.01689435914158821,
0.01193889882415533,
0.050274211913347244,
0.013729733414947987,
-0.008042401634156704,
0.022144204005599022,
-0.03705964982509613,
-0.0452696867287159,
0.001962558599188924,
-0.0061943260952830315,
0.012928355485200882,
-0.019936325028538704,
0.04490988329052925,
-0.03282379359006882,
-0.028898676857352257,
0.00130121735855937,
0.002735316287726164,
0.006443734280765057,
0.016191110014915466,
0.0877917930483818,
0.013991408050060272,
0.02168627269566059,
-0.058320701122283936,
-0.028637003153562546,
-0.03804092854261398,
-0.04170437157154083,
-0.06476444005966187,
0.03951284661889076,
-0.00645600026473403,
-0.01970735937356949,
-0.01090855523943901,
-0.018382633104920387,
-0.04490988329052925,
0.035489603877067566,
-0.04628367722034454,
-0.014670126140117645,
0.014163131825625896,
0.03941471874713898,
-0.041082896292209625,
0.06162434443831444,
-0.01190618984401226,
0.03519522026181221,
0.054657258093357086,
-0.02268390730023384,
0.026985181495547295,
0.0612318329513073,
0.034639161080121994,
-0.02654360607266426,
-0.050666723400354385,
0.004967726767063141,
-0.023763315752148628,
-0.028440745547413826,
0.028031880035996437,
0.022536715492606163,
0.013288157992064953,
0.016313768923282623
] |
725,878 | qsm_forward.qsm_forward | add_noise |
Add complex Gaussian noise to a signal.
Parameters
----------
sig : numpy.ndarray
The input signal to which noise will be added.
peak_snr : float, optional
The peak signal-to-noise ratio, by default np.inf
rng : numpy.random.Generator, optional
A random number Generator. If None, a new Generator will be created.
Returns
-------
numpy.ndarray
The input signal with added noise.
| def add_noise(sig, peak_snr=np.inf, rng=None):
"""
Add complex Gaussian noise to a signal.
Parameters
----------
sig : numpy.ndarray
The input signal to which noise will be added.
peak_snr : float, optional
The peak signal-to-noise ratio, by default np.inf
rng : numpy.random.Generator, optional
A random number Generator. If None, a new Generator will be created.
Returns
-------
numpy.ndarray
The input signal with added noise.
"""
# Create a new RNG if one was not provided
if rng is None:
rng = np.random.default_rng()
noise = rng.standard_normal(sig.shape) + 1j * rng.standard_normal(sig.shape)
sig_noisy = sig + (noise * np.max(np.abs(sig))) / peak_snr
return sig_noisy
| (sig, peak_snr=inf, rng=None) | [
0.005385720636695623,
-0.017124522477388382,
0.09063488990068436,
0.08825922757387161,
-0.026078226044774055,
-0.008008841425180435,
-0.022694716230034828,
0.008818724192678928,
0.059679366648197174,
-0.00006587328243767843,
-0.0015590244438499212,
0.01731349527835846,
0.003799700178205967,
0.021812843158841133,
-0.07530110329389572,
-0.0022069306578487158,
-0.02006709575653076,
-0.014361921697854996,
-0.021308917552232742,
-0.012571181170642376,
-0.044165611267089844,
-0.0024071517400443554,
0.0020888226572424173,
0.047729093581438065,
0.012211233377456665,
0.08142022043466568,
-0.00019586228881962597,
0.002232801867648959,
-0.023972531780600548,
0.0004235012165736407,
0.013696018606424332,
-0.09596211463212967,
0.07623697072267532,
-0.0431937500834465,
0.02973169833421707,
0.030865533277392387,
0.011878280900418758,
0.009250661358237267,
-0.06122714281082153,
-0.017637448385357857,
0.02974969521164894,
0.008215811103582382,
0.006672534625977278,
0.017511466518044472,
0.010096538811922073,
0.031243478879332542,
0.02951573021709919,
0.06435868889093399,
-0.049996767193078995,
0.0004968968569301069,
0.024260489270091057,
-0.005754667334258556,
0.014037968590855598,
-0.028453882783651352,
-0.010357500985264778,
-0.0038896871265023947,
0.006794016808271408,
0.015576746314764023,
0.028867824003100395,
0.030937524512410164,
0.023108655586838722,
0.026114221662282944,
0.002321664011105895,
-0.07054979354143143,
-0.017745433375239372,
0.02748202346265316,
-0.07990843802690506,
0.014334925450384617,
0.037290602922439575,
-0.006200103089213371,
0.027122076600790024,
-0.019923117011785507,
0.016863560304045677,
0.03833445534110069,
0.054856061935424805,
-0.016395628452301025,
-0.06032727286219597,
0.019923117011785507,
-0.05834755674004555,
-0.015099815092980862,
0.07206157594919205,
-0.004548841621726751,
0.010654458776116371,
0.026078226044774055,
0.013911986723542213,
0.03847843408584595,
-0.037002645432949066,
-0.0015860205749049783,
0.038262464106082916,
0.02368457242846489,
0.03250329568982124,
-0.019383195787668228,
0.024764416739344597,
-0.011995264329016209,
0.03439302369952202,
0.04301377758383751,
0.01528878789395094,
-0.011878280900418758,
0.07918854057788849,
-0.021254925057291985,
0.008463275618851185,
0.009021194651722908,
-0.022010814398527145,
0.009871571324765682,
-0.02163287065923214,
0.03923432156443596,
0.021038955077528954,
0.014550894498825073,
0.051256582140922546,
0.03793850913643837,
0.02085898257791996,
-0.00819331407546997,
-0.04168196767568588,
-0.03079354390501976,
-0.04906089976429939,
-0.033727120608091354,
0.02039104886353016,
0.04042215272784233,
0.045641396194696426,
-0.034249044954776764,
-0.005871650297194719,
-0.018915263935923576,
-0.07573304325342178,
0.06612243503332138,
0.0006029127398505807,
-0.038262464106082916,
0.06277491897344589,
-0.021722856909036636,
-0.006380076985806227,
0.0023171647917479277,
-0.02039104886353016,
0.023702571168541908,
0.08581158518791199,
-0.023342622444033623,
-0.01682756468653679,
-0.04675723612308502,
-0.004679323174059391,
-0.04168196767568588,
0.023594586178660393,
-0.03736259415745735,
-0.018735289573669434,
0.04348170757293701,
-0.018933260813355446,
0.039306312799453735,
-0.011536330915987492,
0.034483011811971664,
-0.03149544447660446,
-0.027644000947475433,
0.005012274719774723,
-0.055827923119068146,
-0.02645617164671421,
0.03567083925008774,
0.04445356875658035,
0.06299088895320892,
0.04574938118457794,
-0.0029133285861462355,
0.049528833478689194,
0.011122390627861023,
-0.041609980165958405,
0.03207135945558548,
-0.0031675416976213455,
-0.002762600313872099,
-0.0009246162371709943,
-0.03669669106602669,
-0.04988878220319748,
-0.028831828385591507,
-0.007527410984039307,
0.06954193860292435,
-0.004458854906260967,
-0.010474484413862228,
-0.05258839204907417,
-0.016548605635762215,
-0.01657560095191002,
-0.009322650730609894,
0.018519319593906403,
0.04481351748108864,
-0.04294178634881973,
0.047945063561201096,
-0.021308917552232742,
-0.008782729506492615,
0.03711063042283058,
0.011095394380390644,
0.009223665110766888,
0.05111260339617729,
0.02033705823123455,
-0.022064806893467903,
-0.033205196261405945,
-0.03336717188358307,
0.021578878164291382,
-0.049024906009435654,
0.044633541256189346,
0.06061523035168648,
-0.030109643936157227,
-0.02390054240822792,
-0.0069334967993199825,
-0.0008396910270676017,
0.017745433375239372,
0.015495757572352886,
-0.038262464106082916,
0.035742826759815216,
0.0242064967751503,
-0.006357579957693815,
-0.018699293956160545,
-0.03732660040259361,
0.028651854023337364,
-0.05388420447707176,
0.0030528083443641663,
-0.03970225527882576,
-0.03333117812871933,
0.048520978540182114,
0.054064176976680756,
0.01551375538110733,
0.049204882234334946,
-0.013839997351169586,
0.0498167909681797,
0.05017673969268799,
-0.00040775351226329803,
0.007333938963711262,
-0.052552394568920135,
-0.039594270288944244,
-0.04996076971292496,
-0.02825591154396534,
-0.035994790494441986,
0.027895964682102203,
0.061947036534547806,
0.06392674893140793,
0.014658879488706589,
-0.0033610137179493904,
0.053056322038173676,
-0.032143350690603256,
0.0024071517400443554,
0.03923432156443596,
0.014046967960894108,
-0.07623697072267532,
-0.05946339666843414,
0.013075108639895916,
0.04880893975496292,
-0.018447330221533775,
0.047225166112184525,
-0.04675723612308502,
-0.012913132086396217,
-0.00004175958383711986,
-0.02237076312303543,
0.029317758977413177,
0.00089874496916309,
-0.0211289431899786,
0.01004254724830389,
0.05212045833468437,
-0.01554075162857771,
0.019509177654981613,
0.020157083868980408,
-0.026816120371222496,
-0.0036737185437232256,
0.03259328380227089,
0.023036666214466095,
0.007518412079662085,
-0.0021484391763806343,
0.05859952047467232,
0.0021428149193525314,
-0.016368631273508072,
0.0071359677240252495,
0.027428030967712402,
-0.004877294413745403,
0.018681297078728676,
-0.04531744495034218,
0.05730370804667473,
-0.031153492629528046,
0.009979556314647198,
0.004265382885932922,
0.03565284237265587,
0.09214666485786438,
-0.016593599691987038,
0.017376486212015152,
-0.043157756328582764,
0.05571993812918663,
0.02033705823123455,
-0.002584876026958227,
0.013192091137170792,
0.03261128067970276,
0.0068840039893984795,
-0.003700714558362961,
-0.01791640743613243,
0.05323629826307297,
0.0354008786380291,
0.04956482723355293,
-0.012427201494574547,
-0.020768994465470314,
0.002956072334200144,
-0.023054664954543114,
-0.0472971573472023,
-0.028561867773532867,
-0.0020427044946700335,
0.03315120190382004,
0.026042232289910316,
0.010717449709773064,
0.018096381798386574,
-0.03135146200656891,
0.038298457860946655,
-0.0010331630473956466,
0.01003354787826538,
0.08869116753339767,
0.08372388780117035,
-0.025880254805088043,
0.015198800712823868,
0.045893359929323196,
-0.0015556499129161239,
-0.07767675817012787,
-0.012310218997299671,
0.0003287336730863899,
0.030163636431097984,
-0.10935217887163162,
0.013192091137170792,
0.021254925057291985,
0.014091961085796356,
-0.04574938118457794,
0.03819047287106514,
0.03912634029984474,
0.005633185151964426,
0.0017558709951117635,
0.0312974713742733,
0.03891037032008171,
-0.06493460386991501,
-0.03351115062832832,
-0.016863560304045677,
0.01696254499256611,
-0.024890398606657982,
-0.07652492821216583,
0.03547286614775658,
-0.08480373024940491,
-0.013597032986581326,
-0.04960082471370697,
-0.005583692342042923,
0.012733157724142075,
0.051292579621076584,
-0.014613885432481766,
0.006488061044365168,
-0.018249358981847763,
-0.08257205039262772,
-0.04232987388968468,
-0.04812503606081009,
-0.10791238397359848,
-0.04481351748108864,
-0.06122714281082153,
0.018645301461219788,
0.01770043931901455,
-0.029641712084412575,
0.012895134277641773,
-0.1169830709695816,
-0.021758852526545525,
0.0002161093580070883,
0.05744768679141998,
0.022568734362721443,
-0.006119114812463522,
-0.0036152268294245005,
0.038298457860946655,
0.047693099826574326,
-0.016629593446850777,
0.012751155532896519,
-0.0032327822409570217,
-0.02517835609614849,
0.003451000666245818,
0.03077554702758789,
0.04409362003207207,
-0.035490866750478745,
0.01805138774216175,
0.05492805317044258,
-0.05086063966155052,
0.06540253758430481,
-0.007149465382099152,
-0.015810713171958923,
-0.023306628689169884,
-0.023882543668150902,
-0.04402162879705429,
-0.0065645501017570496,
-0.02287469059228897,
-0.05374022573232651,
-0.047153178602457047,
-0.018627304583787918,
-0.008706239983439445,
0.006479062605649233,
-0.04938485473394394,
-0.0004533094179350883,
0.007486916612833738,
-0.015108813531696796,
0.04628930240869522,
-0.008485772646963596,
0.0014971584314480424,
0.038262464106082916,
-0.029137784615159035,
-0.03419505059719086,
-0.013830998912453651,
0.010402495041489601,
0.030649565160274506,
0.025610294193029404,
-0.044921498745679855,
-0.036786679178476334,
-0.018294353038072586,
0.03583281487226486,
-0.08854718506336212,
0.03462699055671692,
-0.05068066716194153,
0.01601768285036087,
-0.07292544841766357,
-0.029191777110099792,
0.03030761517584324,
-0.003754706820473075,
-0.0778927281498909,
-0.03415905684232712,
0.0625949427485466,
0.032143350690603256,
0.03919832780957222,
-0.03743458539247513,
0.017268501222133636,
-0.018645301461219788,
0.038298457860946655,
0.011536330915987492,
0.028867824003100395,
-0.08617153018712997,
-0.02368457242846489,
0.006294589024037123,
0.014334925450384617,
-0.08077231049537659,
-0.03594079986214638,
0.050284724682569504,
-0.003298022784292698,
0.00008295675070257857,
0.005628685466945171,
-0.04956482723355293,
-0.06191104277968407,
0.014883846044540405,
-0.007284446153789759,
-0.004416110925376415,
0.01904124580323696,
0.04143000394105911,
0.014199945144355297,
-0.019185224547982216,
-0.01766444370150566,
-0.024998383596539497,
-0.053056322038173676,
-0.018465328961610794,
0.028687849640846252,
0.031387459486722946,
-0.0523364283144474,
-0.036768678575754166,
-0.021326914429664612,
-0.014910842292010784,
0.08178016543388367,
0.0002065482403850183,
0.05751967802643776,
-0.010051545687019825,
0.04017018899321556,
-0.019995106384158134,
-0.0018503572791814804,
0.009709594771265984,
-0.008679244667291641,
-0.016071675345301628,
0.10676055401563644,
-0.03280925378203392,
-0.008296799845993519,
0.008805225603282452,
-0.024242492392659187,
0.027895964682102203,
-0.05625985935330391,
-0.032683271914720535,
0.0345190055668354,
0.08905111253261566,
0.07346536964178085,
-0.010789439082145691,
-0.03401507809758186,
-0.04096207395195961,
0.061443109065294266,
0.023198643699288368,
-0.005997632164508104,
-0.03212535008788109,
-0.013129100203514099,
-0.04117804020643234,
-0.042653828859329224,
0.052768364548683167,
0.003666969481855631,
0.016512610018253326,
-0.009007696993649006,
-0.020517030730843544,
-0.0172595027834177,
0.011671311222016811,
0.022226784378290176,
0.010870426893234253,
-0.00384919298812747,
-0.07054979354143143,
0.021272921934723854,
0.007837865501642227,
0.03410506621003151,
-0.05320030078291893,
-0.015738721936941147,
0.051544543355703354,
-0.01806938648223877,
-0.01958116702735424,
0.01473986729979515,
0.01797039993107319,
0.014541896060109138,
-0.010915420949459076,
-0.0651145800948143,
-0.03693065792322159,
-0.040278173983097076,
-0.050248730927705765,
0.005439713131636381,
0.024314481765031815,
-0.040602125227451324,
0.023774560540914536,
-0.022946679964661598,
0.022694716230034828,
0.02267671935260296,
0.037506572902202606,
-0.018501322716474533,
-0.04276181384921074,
0.010996408760547638,
-0.011617318727076054,
0.005867151077836752,
-0.016818566247820854,
-0.002827840857207775,
-0.007558906450867653,
0.02337861806154251,
-0.01756545901298523,
-0.008895212784409523,
-0.007194458972662687,
0.07522911578416824,
-0.015621739439666271,
-0.017286498099565506,
-0.0015702728414908051,
0.005390220321714878,
0.06234297901391983,
-0.004724316298961639,
0.010843430645763874,
-0.014190946705639362,
0.010258515365421772,
0.01564873568713665,
-0.04834100604057312,
0.047693099826574326,
-0.006335083395242691,
0.023738564923405647,
-0.0372186154127121,
-0.05006875470280647,
-0.001030913321301341,
0.0317654050886631,
0.047225166112184525,
0.00597513560205698,
0.05809559300541878,
-0.009961558505892754,
-0.01778142713010311,
-0.002436397597193718,
-0.028651854023337364,
-0.003246280364692211,
0.009646603837609291,
-0.013300075195729733,
0.0028368395287543535,
0.04146600142121315,
-0.0031945377122610807,
0.006798516493290663,
-0.02800394780933857,
-0.04499348998069763,
0.006258594337850809,
-0.03919832780957222,
0.01617066003382206,
0.05327229201793671,
-0.06025528162717819,
-0.061695072799921036,
0.013345069251954556,
-0.027949955314397812,
0.0003236719057895243,
0.02062501572072506,
-0.005102261900901794,
-0.011320361867547035,
-0.014919841662049294,
0.00448810076341033,
0.013669022358953953,
-0.06151510030031204,
0.04434558376669884,
0.015837708488106728,
0.00035094920895062387,
-0.022208787500858307,
-0.03149544447660446,
-0.007329439744353294,
-0.00046062085311859846,
-0.03181939572095871,
-0.007441923022270203,
-0.025538304820656776,
-0.04711718112230301,
-0.055647946894168854,
-0.03352914750576019,
-0.07357335835695267,
0.06266693025827408,
0.06360279768705368,
0.02546631544828415,
-0.04196992889046669,
-0.055359989404678345,
-0.0328812412917614,
-0.0029763192869722843,
-0.0074194264598190784,
0.0002966758329421282,
0.014154952019453049,
-0.005993132945150137,
-0.053056322038173676,
-0.014802858233451843,
0.012112247757613659,
-0.06529455631971359,
0.016953546553850174,
0.05514402315020561,
-0.038550421595573425,
-0.09293854981660843,
-0.02008509449660778,
-0.014541896060109138,
-0.02899380587041378,
0.10359301418066025,
-0.040818095207214355,
0.022478748112916946,
-0.03480696305632591,
0.024260489270091057,
-0.04153798893094063,
-0.018771283328533173,
0.05827556923031807,
0.018627304583787918,
-0.013561038300395012,
-0.01258017960935831,
0.02620420791208744,
-0.029389748349785805,
-0.032971229404211044,
-0.056583814322948456,
-0.012940127402544022,
0.004179895389825106,
-0.046145323663949966,
-0.003831195645034313,
-0.017088526859879494,
-0.027661997824907303,
0.057087741792201996,
-0.054568104445934296,
-0.01260717585682869,
-0.01805138774216175,
-0.08473174273967743,
0.012364211492240429,
-0.03459099680185318,
0.06594245880842209,
0.04322974383831024,
-0.006200103089213371,
-0.0701538473367691,
-0.0698658898472786,
-0.024872401729226112,
0.05697975680232048,
-0.0000855579346534796,
-0.03050558641552925,
-0.07450921833515167,
-0.05975135415792465,
0.025592297315597534,
-0.011023405008018017,
-0.024638434872031212,
-0.00093698943965137,
0.0728534609079361,
-0.009385641664266586,
-0.047513123601675034,
0.04484951123595238,
0.040854088962078094,
-0.027895964682102203,
0.08415582031011581,
-0.02595224417746067,
0.024818409234285355,
-0.009727592580020428,
0.0504646971821785,
0.04942084848880768,
-0.01744847558438778,
-0.05733970180153847,
0.03558085113763809,
-0.016071675345301628,
0.004620831459760666,
-0.010690453462302685,
-0.011320361867547035,
-0.005898646544665098,
0.04700919985771179,
-0.0049492837861180305,
-0.01095141563564539,
0.017016537487506866,
-0.07292544841766357,
0.0031675416976213455,
0.04268982261419296,
-0.016584601253271103,
0.046973202377557755,
0.012058255262672901,
-0.003626475343480706,
0.020319059491157532,
0.036282751709222794,
0.00043053145054727793,
0.0051922486163675785,
0.040818095207214355,
-0.01554075162857771,
-0.0488809272646904,
0.003869440173730254,
0.00442061061039567,
0.053848206996917725,
-0.008868216536939144,
-0.006753522902727127,
0.04355369880795479,
-0.0021034455858170986,
-0.053056322038173676,
0.06230698525905609,
0.07652492821216583,
-0.01120337937027216,
0.0468292236328125,
-0.014415914192795753,
0.008953704498708248,
0.0075859022326767445,
0.013822000473737717,
0.03333117812871933,
0.003693965496495366,
-0.056403838098049164,
0.034213051199913025,
0.003939180169254541,
-0.01663859188556671,
-0.05010475218296051,
0.0193112064152956,
0.05600789561867714,
0.01183328777551651,
0.024062518030405045,
-0.002899830462411046,
0.01374101173132658,
0.033439163118600845,
0.010609464719891548,
0.0017671192763373256,
-0.055323995649814606,
-0.02674413099884987,
0.019167227670550346,
0.007873861119151115,
0.0452454537153244,
-0.01959916390478611,
0.006528555415570736,
0.02719406597316265,
0.016089672222733498,
0.03873039782047272,
-0.03684066981077194,
0.024728422984480858,
-0.06536654382944107,
0.014280933886766434,
-0.013435056433081627,
-0.02260472998023033,
-0.010096538811922073,
0.017745433375239372,
0.026906106621026993,
0.00819331407546997,
0.022316770628094673,
-0.009691597893834114,
0.06140711531043053,
0.018969254568219185,
-0.004436358343809843,
-0.022460749372839928,
0.01564873568713665,
0.04358969256281853,
0.0035364883951842785,
0.04258183762431145,
-0.054568104445934296,
-0.0012159490725025535,
-0.018519319593906403,
0.014541896060109138,
0.010051545687019825,
-0.000184754520887509,
0.032719265669584274,
0.018951257690787315,
0.045641396194696426,
0.003131547011435032,
-0.02899380587041378,
0.03480696305632591,
-0.028345897793769836,
0.02337861806154251
] |
725,879 | qsm_forward.qsm_forward | crop_imagespace |
Crop a nD matrix around its center.
Parameters
----------
x : numpy.ndarray
The input n-dimensional matrix.
shape : tuple of int
The desired shape after cropping.
Returns
-------
numpy.ndarray
The cropped matrix.
| def crop_imagespace(x, shape):
"""
Crop a nD matrix around its center.
Parameters
----------
x : numpy.ndarray
The input n-dimensional matrix.
shape : tuple of int
The desired shape after cropping.
Returns
-------
numpy.ndarray
The cropped matrix.
"""
if np.array_equal(x.shape, np.array(shape)):
return x
m = np.array(x.shape)
s = np.array(shape)
if s.size < m.size:
s = np.concatenate((s, np.ones(m.size - s.size, dtype=int)))
if np.array_equal(m, s):
res = x
return res
idx = []
for n in range(s.size):
start = np.floor_divide(m[n], 2) + np.ceil(-s[n] / 2)
end = np.floor_divide(m[n], 2) + np.ceil(s[n] / 2)
idx.append(slice(int(start), int(end)))
res = x[tuple(idx)]
return res
| (x, shape) | [
-0.017988523468375206,
-0.024950647726655006,
-0.01445278525352478,
0.015108902007341385,
0.036979448050260544,
-0.03258711099624634,
0.016229767352342606,
0.013341032899916172,
0.06411714851856232,
-0.024203402921557426,
-0.0054949745535850525,
0.010944385081529617,
-0.036195751279592514,
0.03572189062833786,
0.015847032889723778,
-0.01325901784002781,
0.07523467391729355,
0.031511809676885605,
0.00749977445229888,
-0.008807450532913208,
0.037799593061208725,
-0.020394284278154373,
0.003720270935446024,
-0.04027825593948364,
-0.009932872839272022,
0.02797607332468033,
0.015683002769947052,
-0.0016995236510410905,
0.014735279604792595,
-0.0621487982571125,
-0.03714347630739212,
0.04071566462516785,
0.05937853083014488,
0.03275114297866821,
-0.018252791836857796,
-0.0003568202373571694,
0.04290271922945976,
0.04304852336645126,
0.0006703549879603088,
0.0010513808811083436,
-0.07406824827194214,
-0.03276936709880829,
-0.032824043184518814,
0.011782756075263023,
-0.00155599822755903,
0.02318277768790722,
0.02055831253528595,
0.014051825739443302,
-0.08369128406047821,
0.06182074174284935,
-0.003590414533391595,
0.01379666943103075,
0.010361170396208763,
0.028705090284347534,
-0.021688289940357208,
-0.012110814452171326,
-0.011946785263717175,
0.00634701456874609,
0.03849215805530548,
-0.03461013734340668,
-0.013231679797172546,
-0.008470280095934868,
0.031438909471035004,
-0.016083963215351105,
0.019009148702025414,
-0.05274446681141853,
-0.06856416165828705,
-0.0004428215906955302,
-0.013131439685821533,
0.0004197550006210804,
-0.03830990567803383,
0.029215402901172638,
0.06331522762775421,
-0.01693144626915455,
0.062294602394104004,
0.012092589400708675,
0.016384683549404144,
0.024659039452672005,
0.03464658930897713,
-0.010434072464704514,
-0.01469882857054472,
0.034956421703100204,
0.019227854907512665,
0.05190609395503998,
0.025606762617826462,
-0.01643935963511467,
0.03366241604089737,
0.035138677805662155,
-0.013933359645307064,
-0.054166048765182495,
0.03823700174689293,
0.032076798379421234,
-0.011472923681139946,
0.04709457606077194,
-0.07603659480810165,
0.044615913182497025,
-0.0038296235725283623,
0.03380821645259857,
-0.048880670219659805,
-0.045891694724559784,
-0.03632333129644394,
0.008976036682724953,
-0.059815943241119385,
-0.034318529069423676,
0.023000523447990417,
0.1098630428314209,
0.03860151395201683,
0.04261111095547676,
-0.05190609395503998,
0.04676651582121849,
-0.01920962892472744,
0.025406284257769585,
-0.02890557050704956,
0.0035425727255642414,
-0.0057592433877289295,
-0.06378909200429916,
-0.044652365148067474,
-0.009226636029779911,
-0.029962647706270218,
-0.036979448050260544,
-0.0241122767329216,
-0.046037498861551285,
-0.01134534552693367,
0.031511809676885605,
-0.0034127163235098124,
0.047568436712026596,
0.03896602243185043,
0.00832903292030096,
0.0036815418861806393,
-0.012566450983285904,
-0.05609794706106186,
-0.030910370871424675,
-0.05081256851553917,
-0.03809120133519173,
0.003118830965831876,
0.004103005398064852,
-0.0006589640979655087,
-0.01722305454313755,
-0.005248930770903826,
-0.0011846545385196805,
0.013295468874275684,
-0.00448573986068368,
0.03298807144165039,
0.057118576020002365,
0.03216792643070221,
-0.01816166564822197,
0.059925295412540436,
0.014161177910864353,
0.10548893362283707,
-0.008392821997404099,
-0.02905137464404106,
0.009153734892606735,
0.07902557402849197,
-0.04567299038171768,
0.02939765714108944,
0.01486285775899887,
0.03657848760485649,
-0.07344858348369598,
-0.029069600626826286,
0.030873918905854225,
-0.01970171555876732,
0.008201454766094685,
-0.03710702434182167,
-0.06535647809505463,
-0.05063031241297722,
-0.016001949086785316,
0.061091724783182144,
-0.029835069552063942,
-0.039111826568841934,
0.01613863930106163,
-0.000866278656758368,
-0.0018829172477126122,
-0.022380858659744263,
-0.045891694724559784,
-0.05063031241297722,
0.07516177743673325,
-0.05398379638791084,
-0.019227854907512665,
0.0067889816127717495,
0.000847483635880053,
0.01636645756661892,
-0.0029434110037982464,
0.0008412186289206147,
0.03550318628549576,
-0.03355306014418602,
0.055514734238386154,
0.01276693120598793,
0.0032646346371620893,
0.04224660247564316,
-0.004326267167925835,
-0.03245953470468521,
0.030801018700003624,
-0.00742231635376811,
-0.01606573723256588,
0.014234079979360104,
-0.019610589370131493,
0.004232861567288637,
0.04403269663453102,
0.008515843190252781,
0.0071762725710868835,
-0.043485935777425766,
-0.02219860441982746,
0.018918022513389587,
0.027010124176740646,
0.013678203336894512,
-0.029634589329361916,
0.006069076247513294,
0.03149358555674553,
0.010160691104829311,
0.049974195659160614,
0.026080625131726265,
0.02269069105386734,
0.026153527200222015,
-0.02901492267847061,
0.03176696598529816,
0.022380858659744263,
-0.0008583050221204758,
-0.00006371789640979841,
0.02680964395403862,
0.05624375119805336,
-0.03340725973248482,
-0.0069074472412467,
-0.02269069105386734,
0.01294007245451212,
-0.00034770750789903104,
0.0009511408861726522,
0.008679872378706932,
-0.05861306190490723,
0.04352238401770592,
-0.05303607136011124,
0.02321922965347767,
-0.06426294893026352,
-0.005996174644678831,
-0.005039338022470474,
0.03728928044438362,
-0.04574589058756828,
-0.01695878617465496,
-0.06349748373031616,
0.018972698599100113,
-0.017405308783054352,
-0.05646245926618576,
-0.007012243382632732,
-0.014908421784639359,
0.01706813834607601,
-0.007759487256407738,
-0.0029639145359396935,
-0.031621161848306656,
0.03163938969373703,
0.03342548385262489,
0.01992042176425457,
-0.01595638506114483,
-0.02471371553838253,
-0.012119927443563938,
0.006779869087040424,
0.06776224076747894,
-0.012949185445904732,
-0.02219860441982746,
-0.010825919918715954,
0.0013270409544929862,
0.0072992946952581406,
0.044725265353918076,
-0.04290271922945976,
0.013268130831420422,
-0.04662071168422699,
0.005326388869434595,
-0.03608639910817146,
0.016749192029237747,
0.01065277773886919,
0.02407582476735115,
0.014498349279165268,
0.06696031987667084,
0.08689896762371063,
0.011263330467045307,
-0.04392334446310997,
-0.0012552781263366342,
0.020831694826483727,
-0.038929570466279984,
0.00583214545622468,
0.012010574340820312,
-0.04902647063136101,
0.03313387557864189,
-0.03484706953167915,
-0.05507732182741165,
0.05321832746267319,
-0.006132865324616432,
-0.04519912600517273,
0.04643845930695534,
-0.05376509204506874,
0.006629508920013905,
0.07472436130046844,
-0.017551112920045853,
0.008579632267355919,
-0.01999332383275032,
-0.0009380413684993982,
-0.09207499772310257,
0.015063337981700897,
-0.0310014970600605,
-0.017159264534711838,
-0.0481516495347023,
-0.00698490533977747,
0.028504610061645508,
0.023237453773617744,
-0.016302669420838356,
0.005112240090966225,
0.08500351756811142,
0.03732573240995407,
-0.035175126045942307,
0.0014329763362184167,
-0.018116101622581482,
0.0691109225153923,
-0.006921116262674332,
-0.10293736308813095,
-0.058212101459503174,
-0.04508977383375168,
0.0028249453753232956,
0.010297381319105625,
0.048516158014535904,
0.007600014563649893,
0.05515022575855255,
0.03657848760485649,
0.04920872673392296,
-0.042064350098371506,
-0.06360683590173721,
0.055806342512369156,
-0.01070745475590229,
-0.06335167586803436,
-0.06907447427511215,
0.037726689130067825,
-0.01413383986800909,
0.06473681330680847,
-0.02389357052743435,
0.055186677724123,
-0.06466390937566757,
0.03925762698054314,
0.024950647726655006,
-0.05340057983994484,
0.015509861521422863,
-0.008807450532913208,
0.008547738194465637,
0.010962611064314842,
-0.03801829740405083,
-0.006779869087040424,
0.004706723615527153,
-0.047276828438043594,
0.030655214563012123,
0.01580146886408329,
-0.048734866082668304,
-0.01437988318502903,
0.009431672282516956,
0.0003955493157263845,
0.056936319917440414,
-0.010643665678799152,
0.012457097880542278,
-0.05205189809203148,
-0.04272046685218811,
0.05657181143760681,
-0.0172959566116333,
0.0011248522205278277,
0.001180098159238696,
0.010424959473311901,
0.07016799598932266,
0.040496960282325745,
0.04246531054377556,
-0.058321453630924225,
0.018116101622581482,
0.013304581865668297,
-0.06834545731544495,
-0.0004126356798224151,
0.0023214672692120075,
0.0026404126547276974,
-0.0683090016245842,
-0.059779491275548935,
-0.04221015423536301,
-0.0064290291629731655,
-0.0203396063297987,
0.047604888677597046,
-0.07975459098815918,
-0.01546429842710495,
-0.024841293692588806,
0.05055741220712662,
-0.009750617668032646,
-0.006483705248683691,
0.03543028235435486,
-0.008802894502878189,
-0.04009599983692169,
0.020612988620996475,
-0.08011909574270248,
0.04399624839425087,
-0.06353393197059631,
-0.026864320039749146,
-0.04782359302043915,
-0.006310563534498215,
0.0066614034585654736,
0.014571250416338444,
-0.007613683585077524,
-0.0010838450398296118,
-0.0070076873525977135,
0.054129600524902344,
0.017131926491856575,
-0.002421707147732377,
-0.0029570800252258778,
0.0021711073350161314,
-0.014224966987967491,
0.0049801054410636425,
-0.0017598954727873206,
-0.0010377118596807122,
-0.03750798478722572,
-0.013094988651573658,
-0.0016334563260897994,
-0.009559250436723232,
0.07924427837133408,
0.014543912373483181,
0.06065431237220764,
0.028613964095711708,
0.05781114101409912,
-0.022362632676959038,
-0.004975548945367336,
0.06455455720424652,
-0.03125665336847305,
0.007290181703865528,
0.0002161424927180633,
-0.03003554977476597,
0.0004656033997889608,
-0.02265423908829689,
-0.05117707699537277,
-0.06491906940937042,
-0.010251818224787712,
-0.03362596407532692,
0.01606573723256588,
0.015427847392857075,
-0.046001046895980835,
0.014498349279165268,
-0.04359528794884682,
0.029907971620559692,
-0.032331954687833786,
-0.03014490194618702,
-0.019865745678544044,
0.030272480100393295,
-0.03987729549407959,
0.05033870413899422,
0.012657578103244305,
0.0411166250705719,
0.0206312146037817,
-0.001726861810311675,
0.04115307703614235,
0.05361928790807724,
-0.017104588449001312,
0.03739863261580467,
-0.07166248559951782,
0.03369886428117752,
0.031147301197052002,
-0.037872493267059326,
-0.005417516455054283,
-0.048880670219659805,
-0.01816166564822197,
-0.051614485681056976,
-0.04144468158483505,
-0.00883478857576847,
0.000005152606718183961,
-0.004911759868264198,
0.009951097890734673,
0.004219192545861006,
-0.05183319374918938,
-0.05999819561839104,
0.023346807807683945,
0.0007620517862960696,
-0.016457585617899895,
0.048771314322948456,
0.017551112920045853,
-0.01763312704861164,
0.03572189062833786,
-0.012639353051781654,
-0.0544576570391655,
0.005864039994776249,
0.07388599216938019,
0.008174116723239422,
-0.010188029147684574,
0.0411166250705719,
0.05489506945014,
0.0016733244992792606,
-0.05114062502980232,
0.03747153282165527,
-0.06615839898586273,
-0.04268401488661766,
-0.056863415986299515,
0.001070745405741036,
-0.040496960282325745,
0.011381796561181545,
0.010853257961571217,
-0.013860458508133888,
0.009960210882127285,
0.027684465050697327,
-0.048953570425510406,
0.031238429248332977,
0.0029342982452362776,
-0.040752116590738297,
-0.03025425411760807,
0.02183409407734871,
0.0241487268358469,
0.007809607312083244,
-0.0030049218330532312,
0.04217370226979256,
0.05485861748456955,
0.0027383745182305574,
-0.031584713608026505,
0.0617113895714283,
-0.04417850077152252,
0.02123265527188778,
0.03568543866276741,
-0.047276828438043594,
-0.047422632575035095,
0.027538660913705826,
-0.03995019569993019,
-0.012047025375068188,
-0.0005985922762192786,
-0.031129077076911926,
-0.017213942483067513,
0.017760705202817917,
0.008160446770489216,
-0.024659039452672005,
-0.027247054502367973,
0.006643177941441536,
-0.03798184543848038,
0.1228395625948906,
-0.03747153282165527,
0.0341545008122921,
0.05737373232841492,
-0.0019478454487398267,
-0.023036973550915718,
0.010643665678799152,
-0.04381399229168892,
0.017624014988541603,
0.00832903292030096,
0.050265803933143616,
0.03003554977476597,
0.07093346863985062,
-0.03253243491053581,
0.0019056990277022123,
0.05875886604189873,
0.043194327503442764,
0.011190429329872131,
0.012839832343161106,
0.008998817764222622,
0.04950033500790596,
-0.08398289233446121,
0.068163201212883,
-0.023656640201807022,
0.018772218376398087,
-0.022909395396709442,
0.0015286599518731236,
0.023875344544649124,
0.01228395663201809,
0.06922027468681335,
-0.051505133509635925,
0.09207499772310257,
0.004394612740725279,
0.019118500873446465,
-0.04538138210773468,
-0.016074851155281067,
-0.02287294529378414,
0.0021073182579129934,
-0.019009148702025414,
0.07756753265857697,
0.041626937687397,
-0.03699767217040062,
0.0241122767329216,
-0.020284930244088173,
0.024057600647211075,
0.0013441272312775254,
0.02176119200885296,
0.011636952869594097,
0.006606727372854948,
-0.0204854104667902,
0.03743508458137512,
-0.0037384964525699615,
0.015345832332968712,
0.02620820328593254,
-0.042064350098371506,
-0.004879865329712629,
0.016220655292272568,
0.05248931050300598,
-0.09754262864589691,
0.08128552883863449,
-0.04523557797074318,
-0.05347348377108574,
0.029907971620559692,
-0.09003374725580215,
0.003098327200859785,
0.01244798582047224,
-0.03457368537783623,
0.08952343463897705,
0.08529512584209442,
0.05340057983994484,
0.01065277773886919,
-0.020977498963475227,
-0.029889745637774467,
-0.034227404743433,
-0.027064800262451172,
0.018662866204977036,
-0.01065277773886919,
0.013960697688162327,
0.02699189819395542,
0.0544576570391655,
0.05854015797376633,
-0.01613863930106163,
-0.030618762597441673,
-0.047495532780885696,
0.016676289960741997,
0.03003554977476597,
0.00512135261669755,
-0.04359528794884682,
0.015118014067411423,
0.020758792757987976,
-0.003754443721845746,
-0.07829654961824417,
0.023784218356013298,
-0.03189454600214958,
0.008319919928908348,
-0.008688985370099545,
-0.01514535304158926,
-0.016712741926312447,
-0.0023419708013534546,
-0.004563197959214449,
-0.026262879371643066,
0.00801008753478527,
0.041991446167230606,
0.0010115127079188824,
-0.003882021876052022,
-0.016047513112425804,
0.016156865283846855,
0.006342458073049784,
-0.03632333129644394,
0.02804897353053093,
-0.013541512191295624,
-0.05117707699537277,
0.011126640252768993,
0.004622431006282568,
0.05084901675581932,
-0.04683941602706909,
0.06218525022268295,
0.07399534434080124,
-0.06841835379600525,
0.03085569478571415,
-0.009190184995532036,
-0.02119620330631733,
-0.06499197334051132,
-0.00958658941090107,
0.03827345371246338,
0.003216792596504092,
0.03284226730465889,
-0.03032715618610382,
0.004508521873503923,
0.0308192428201437,
-0.0036906544119119644,
0.07705722004175186,
0.0008827954297885299,
-0.023419708013534546,
0.001024042721837759,
-0.011263330467045307,
-0.03519335389137268,
0.01602017506957054,
-0.02318277768790722,
-0.04268401488661766,
0.021706515923142433,
0.05132288113236427,
-0.02269069105386734,
0.0041895764879882336,
-0.005144134629517794,
-0.025369832292199135,
0.033571287989616394,
0.044652365148067474,
-0.019501235336065292,
-0.03393579646945,
-0.003601805539801717,
0.003948089201003313,
-0.042064350098371506,
0.02254488691687584,
-0.02542450837790966,
-0.031548261642456055,
0.007595458067953587,
0.03167583793401718,
-0.024330981075763702,
0.018553512170910835,
-0.015026886947453022,
0.03597704693675041,
0.030509410426020622,
-0.009431672282516956,
0.008629752323031425,
-0.09499106556177139,
-0.00047927250852808356,
0.020576538518071175,
-0.005444854497909546,
0.08084811270236969,
0.01102640014141798,
-0.020831694826483727,
0.03991374373435974,
0.006324232555925846,
0.08092101663351059,
-0.003909360151737928,
0.015774130821228027,
-0.013094988651573658,
-0.013468611054122448,
-0.039075374603271484,
0.008707210421562195,
-0.03220437839627266,
0.025716116651892662,
-0.03103794902563095,
0.025479184463620186,
0.020248480141162872,
0.031438909471035004,
0.014197628945112228,
-0.02598949708044529,
0.032222602516412735,
-0.06174783781170845,
0.006643177941441536,
0.013988036662340164,
-0.08631575107574463,
-0.013997148722410202,
-0.012675803154706955,
0.006182985380291939,
0.0005259752506390214,
0.010115127079188824,
-0.006611283402889967,
0.007203611079603434,
-0.029780391603708267,
0.024804843589663506,
0.017232166603207588,
-0.05536893010139465,
-0.013587076216936111,
-0.002906959969550371,
-0.0023738653399050236,
0.002660916419699788,
-0.007654690649360418,
0.06470036506652832,
0.04293917119503021,
0.04968258738517761,
0.01868109032511711,
-0.09520977735519409,
-0.015582763589918613,
-0.013113214634358883,
0.0009089945233426988,
-0.04950033500790596,
0.0482974536716938,
-0.00722639262676239,
-0.015664778649806976,
0.020303156226873398,
-0.01868109032511711,
-0.04654781147837639,
-0.01935543306171894,
-0.003991374745965004,
0.014817294664680958,
0.01722305454313755,
0.02872331626713276,
-0.031657613813877106,
-0.04505332186818123,
-0.037763141095638275,
-0.010716566815972328,
-0.009768843650817871,
-0.011163091287016869,
-0.0020993445068597794,
-0.04100727289915085,
-0.03820055350661278,
-0.055587634444236755,
0.06225815415382385,
0.006255887448787689,
0.013186116702854633,
0.052671562880277634,
-0.007595458067953587
] |
725,880 | qsm_forward.qsm_forward | crop_kspace |
Crop a 3D volume in k-space and apply optional scaling and Gibbs ringing correction.
Parameters
----------
volume : numpy.ndarray
The input 3D volume.
dims : tuple of int
The desired dimensions after cropping.
scaling : bool, optional
Whether to scale the cropped volume to maintain the total energy. Default is True.
gibbs_correction : bool, optional
Whether to apply Gibbs ringing correction. Default is True.
Returns
-------
numpy.ndarray
The cropped volume.
| def crop_kspace(volume, dims, scaling=True, gibbs_correction=True):
"""
Crop a 3D volume in k-space and apply optional scaling and Gibbs ringing correction.
Parameters
----------
volume : numpy.ndarray
The input 3D volume.
dims : tuple of int
The desired dimensions after cropping.
scaling : bool, optional
Whether to scale the cropped volume to maintain the total energy. Default is True.
gibbs_correction : bool, optional
Whether to apply Gibbs ringing correction. Default is True.
Returns
-------
numpy.ndarray
The cropped volume.
"""
if np.array_equal(volume.shape, dims):
return volume
working_volume = np.fft.ifftn(np.fft.ifftshift(crop_imagespace(np.fft.fftshift(np.fft.fftn(volume)), dims)))
# gibbs correction is only needed for non-complex volumes
if not np.iscomplexobj(volume):
working_volume = np.real(working_volume)
if gibbs_correction:
working_volume = gibbs_removal(gibbs_removal(working_volume, slice_axis=2), slice_axis=1)
if scaling:
working_volume *= np.prod(dims) / np.prod(volume.shape)
return working_volume
| (volume, dims, scaling=True, gibbs_correction=True) | [
0.0211639404296875,
-0.012941524386405945,
-0.06855315715074539,
0.04063476622104645,
0.001293477020226419,
0.0428682379424572,
0.003170088166370988,
-0.010735071264207363,
0.09265302866697311,
-0.0024316017515957355,
-0.016633957624435425,
-0.06444644927978516,
-0.043876901268959045,
0.0008735754527151585,
-0.0407068133354187,
0.030836312100291252,
0.01753455027937889,
-0.0033614642452448606,
0.06271731108427048,
-0.030368003994226456,
0.04294028505682945,
-0.07622621208429337,
0.017813734710216522,
0.07903606444597244,
-0.019344743341207504,
0.0016559658106416464,
0.011941866017878056,
0.03629390522837639,
-0.022442782297730446,
-0.03717648983001709,
0.020713644102215767,
0.009267103858292103,
0.08631285279989243,
0.08206205815076828,
-0.011302445083856583,
0.039265863597393036,
0.06603149324655533,
-0.029539458453655243,
-0.009258097968995571,
-0.0083845229819417,
-0.06873327493667603,
0.025648895651102066,
0.01757957972586155,
-0.030187884345650673,
0.04866805672645569,
0.07006615400314331,
0.06502283364534378,
0.002288632560521364,
-0.009001429192721844,
0.0878978967666626,
0.0018214498413726687,
0.019092576578259468,
-0.015508214943110943,
-0.010356822051107883,
-0.05302692949771881,
-0.031718894839286804,
0.024622218683362007,
-0.008069314993917942,
0.013607963919639587,
-0.02844073437154293,
0.02696376107633114,
-0.00471910834312439,
-0.00797475315630436,
-0.05439583212137222,
-0.025360705330967903,
0.0195428729057312,
-0.017138289287686348,
-0.01524704322218895,
0.019524861127138138,
-0.01672401651740074,
-0.047947581857442856,
-0.006830999627709389,
0.010347816161811352,
-0.0335380919277668,
0.01430142018944025,
-0.022478807717561722,
0.010176703333854675,
-0.0037667311262339354,
-0.013256732374429703,
-0.03065619245171547,
0.036762215197086334,
0.02202850952744484,
-0.035735540091991425,
0.04337257146835327,
0.053747404366731644,
0.03315984085202217,
-0.05562063679099083,
0.017552562057971954,
0.07089469581842422,
-0.06149250641465187,
-0.010005590505897999,
0.016183659434318542,
0.039157792925834656,
0.03559144586324692,
0.02213658206164837,
0.028692899271845818,
-0.02930530346930027,
-0.07201143354177475,
-0.020263347774744034,
-0.04650663584470749,
-0.01500388327986002,
0.026297321543097496,
0.0013846621150150895,
-0.018047887831926346,
0.0401664562523365,
0.05605292320251465,
-0.04801962897181511,
0.015445173718035221,
0.023325365036725998,
0.024766312912106514,
0.004144980106502771,
0.01704823039472103,
-0.017552562057971954,
0.016624951735138893,
-0.03380826860666275,
-0.04063476622104645,
-0.011239403858780861,
0.025973107665777206,
-0.02316325716674328,
-0.017192324623465538,
0.02208254672586918,
-0.09906525164842606,
-0.0081638777628541,
0.027161892503499985,
0.01779572293162346,
0.03152076154947281,
0.020335394889116287,
0.04510170966386795,
-0.005475606769323349,
0.02615322731435299,
-0.017138289287686348,
-0.029377350583672523,
-0.03721251338720322,
-0.0532790943980217,
0.060483839362859726,
-0.0015929242363199592,
0.03674420341849327,
0.047191083431243896,
0.015012889169156551,
0.052666690200567245,
0.037464678287506104,
-0.002321279142051935,
-0.02680165506899357,
0.051910191774368286,
-0.013022578321397305,
0.00009498443978372961,
0.06613956391811371,
-0.04092295467853546,
0.03951803222298622,
0.012266079895198345,
-0.01774168573319912,
0.0758659765124321,
0.08984317630529404,
-0.007884693332016468,
0.022280676290392876,
-0.009942549280822277,
-0.000350105605321005,
-0.04683084785938263,
0.0020578554831445217,
0.018750350922346115,
-0.06084407866001129,
-0.011275427415966988,
-0.04809167981147766,
-0.039049722254276276,
-0.0010930950520560145,
-0.048812150955200195,
0.028044473379850388,
0.012185025960206985,
-0.029053136706352234,
0.0622129812836647,
0.009050961583852768,
0.019885098561644554,
-0.03847334161400795,
-0.024135898798704147,
0.005534145515412092,
0.052018266171216965,
-0.06408621370792389,
-0.03343002125620842,
-0.030313968658447266,
-0.03919381648302078,
0.021902427077293396,
0.010933201760053635,
-0.005043322220444679,
0.07809944450855255,
-0.021506166085600853,
0.033303938806056976,
0.015391138382256031,
0.031772930175065994,
-0.00652479799464345,
-0.04661470651626587,
0.0461103729903698,
0.017867770045995712,
0.03424055501818657,
0.03940995782613754,
0.018966494128108025,
-0.016859104856848717,
0.0335380919277668,
0.012194031849503517,
-0.04427316412329674,
0.02078569121658802,
-0.009420204907655716,
-0.03847334161400795,
0.03596969321370125,
-0.013887147419154644,
0.0014398234197869897,
-0.0473351813852787,
-0.0255588348954916,
0.03933791071176529,
0.031989071518182755,
0.024946432560682297,
-0.035573434084653854,
-0.006727431435137987,
0.07118289172649384,
-0.02437005192041397,
0.0319170244038105,
0.047083012759685516,
-0.03591565787792206,
-0.016183659434318542,
0.007821652106940746,
0.01567932777106762,
-0.05176609754562378,
-0.002420344389975071,
-0.04229185730218887,
0.06455451995134354,
-0.0434085950255394,
0.03431260213255882,
0.030566133558750153,
0.006290643475949764,
0.04553399235010147,
0.00010821190517162904,
0.01871432736515999,
0.0049982923083007336,
-0.026243286207318306,
-0.05345921218395233,
-0.008398031815886497,
-0.07211950421333313,
-0.03260147571563721,
0.017183318734169006,
0.12579485774040222,
-0.034600790590047836,
0.020425453782081604,
-0.05104562267661095,
-0.02690972574055195,
0.04928046092391014,
-0.0038612934295088053,
-0.01802087016403675,
-0.003982873633503914,
0.03065619245171547,
0.044741470366716385,
0.024820350110530853,
-0.022712960839271545,
-0.021956462413072586,
-0.035357289016246796,
0.06559921056032181,
0.06257321685552597,
-0.0036879293620586395,
-0.06912953406572342,
-0.015670321881771088,
0.023235304281115532,
-0.00982547178864479,
0.012581286951899529,
0.017678644508123398,
0.01229309756308794,
0.01857023313641548,
-0.01860625669360161,
0.006245614029467106,
0.05904289335012436,
-0.012185025960206985,
0.02366759069263935,
0.03326791524887085,
0.016561908647418022,
0.0900593250989914,
0.007614515721797943,
-0.016958169639110565,
0.00531800277531147,
0.02372162602841854,
0.004559253342449665,
0.026333345100283623,
0.008933885022997856,
0.003080028807744384,
0.01513897255063057,
0.020641596987843513,
-0.03119654953479767,
0.04337257146835327,
0.026675570756196976,
-0.029449397698044777,
-0.029971743002533913,
-0.05237850174307823,
0.04737120494246483,
0.028909042477607727,
-0.06012360379099846,
-0.00569625198841095,
0.024442100897431374,
-0.032745569944381714,
-0.019795039668679237,
0.0014826016267761588,
-0.056737374514341354,
-0.0649147629737854,
-0.015724357217550278,
-0.03750070184469223,
0.025955095887184143,
0.019362755119800568,
0.01368001103401184,
0.06527499854564667,
0.06444644927978516,
0.07089469581842422,
-0.0005268470267765224,
-0.04254402220249176,
0.004764138255268335,
-0.002681516343727708,
-0.03850936517119408,
-0.09056365489959717,
0.008852831088006496,
0.03153877332806587,
0.03577156364917755,
0.004487205762416124,
0.05853855982422829,
-0.008118848316371441,
-0.0018056894186884165,
0.023487471044063568,
0.03326791524887085,
-0.02593708410859108,
-0.009001429192721844,
0.11246608197689056,
0.0012732136528939009,
-0.05046924576163292,
-0.02768423594534397,
0.06019565090537071,
0.008654700592160225,
0.024514148011803627,
-0.07954039424657822,
0.06689606606960297,
-0.0010373707627877593,
0.02208254672586918,
-0.050397198647260666,
-0.07449707388877869,
0.025973107665777206,
-0.018209995701909065,
0.02539672888815403,
0.009492252953350544,
0.03321387991309166,
-0.05529642477631569,
0.025000467896461487,
-0.02707183174788952,
-0.010230738669633865,
0.051369838416576385,
0.01590447686612606,
-0.0688413456082344,
0.0010480653727427125,
-0.004349865484982729,
0.06649980694055557,
-0.010924195870757103,
-0.010482905432581902,
0.029647529125213623,
-0.0428682379424572,
-0.03278159350156784,
0.044201117008924484,
0.0036879293620586395,
-0.0035483373794704676,
-0.0181199349462986,
0.06549113988876343,
0.027143878862261772,
-0.022604890167713165,
-0.01172572374343872,
0.019614920020103455,
0.049892865121364594,
-0.04567808657884598,
-0.0473351813852787,
-0.019200647249817848,
0.021416107192635536,
0.01574236899614334,
-0.07021024823188782,
0.024279993027448654,
-0.00180456368252635,
0.002262740395963192,
0.02750411629676819,
-0.058682654052972794,
-0.052774764597415924,
0.0006698162178508937,
0.06033974513411522,
-0.012356138788163662,
0.010789106599986553,
-0.06296947598457336,
0.01643582619726658,
-0.006205087527632713,
0.013562933541834354,
-0.07294805347919464,
-0.006322164554148912,
0.010356822051107883,
0.0037419649306684732,
-0.029665540903806686,
0.016354773193597794,
0.09539083391427994,
0.04211173951625824,
-0.05338716506958008,
0.028296638280153275,
-0.06289742887020111,
-0.012094967067241669,
0.00892938207834959,
-0.015418156050145626,
-0.044093042612075806,
-0.005975435953587294,
-0.06603149324655533,
0.00996056105941534,
0.009177044965326786,
0.028909042477607727,
-0.031286608427762985,
0.0024293502792716026,
0.03614981099963188,
0.026333345100283623,
0.04546194523572922,
-0.003262398997321725,
0.019885098561644554,
-0.005322505719959736,
-0.0013891650596633554,
-0.007578492164611816,
-0.059943486005067825,
-0.03315984085202217,
-0.023415423929691315,
0.0035325768403708935,
-0.023973790928721428,
-0.018858421593904495,
0.019362755119800568,
-0.011365486308932304,
-0.01992112211883068,
-0.025756966322660446,
0.021848391741514206,
0.00963634718209505,
0.02078569121658802,
0.0011426276760175824,
-0.05843048915266991,
0.0007159716333262622,
0.005597186740487814,
-0.0326555110514164,
-0.025702930986881256,
0.0242079459130764,
-0.0033231889829039574,
0.03175491839647293,
-0.02181236818432808,
0.04906431958079338,
0.018642280250787735,
0.018516195937991142,
-0.04362473636865616,
-0.01449054479598999,
-0.0052144345827400684,
-0.004250800237059593,
-0.05317102372646332,
0.03287165239453316,
-0.03391633927822113,
0.03222322463989258,
0.033826280385255814,
-0.01802087016403675,
0.012977547943592072,
-0.04809167981147766,
0.04855998605489731,
-0.008735754527151585,
-0.09553492814302444,
0.002325782086700201,
-0.02523462288081646,
-0.04095897823572159,
-0.002933682408183813,
0.012815441936254501,
-0.025000467896461487,
-0.023577529937028885,
0.028909042477607727,
0.08580852299928665,
0.004266560543328524,
-0.013905159197747707,
-0.02046147733926773,
-0.0075559769757092,
0.005781808402389288,
-0.0001735049154376611,
-0.02224465273320675,
0.02701779641211033,
-0.008159374818205833,
-0.0030957891140133142,
-0.03728456050157547,
0.07781125605106354,
0.020065216347575188,
0.02224465273320675,
-0.03847334161400795,
0.0010334306862205267,
-0.054575949907302856,
0.03699636831879616,
-0.047947581857442856,
0.016300737857818604,
-0.001101538073271513,
0.0455700159072876,
-0.0056197019293904305,
-0.007641533389687538,
-0.017183318734169006,
-0.00889786146581173,
-0.021398095414042473,
0.05713363364338875,
-0.01590447686612606,
-0.014967859722673893,
-0.0093301460146904,
0.015931494534015656,
0.02707183174788952,
0.0024270988069474697,
-0.006916556041687727,
0.03580758720636368,
-0.006628366187214851,
-0.014319431968033314,
0.005880873650312424,
-0.009735412895679474,
-0.03966212645173073,
0.012230056338012218,
0.028891030699014664,
-0.07096674293279648,
-0.02442408911883831,
0.011374492198228836,
0.007979256100952625,
-0.00586286187171936,
-0.029485421255230904,
-0.0006889537908136845,
-0.02316325716674328,
0.022604890167713165,
-0.026189250871539116,
-0.012833453714847565,
-0.003958107437938452,
-0.005826838314533234,
-0.0016390796517953277,
0.043768830597400665,
0.02501847967505455,
0.031448714435100555,
0.03359212726354599,
-0.013734046369791031,
-0.03832924738526344,
0.007763113360852003,
-0.040130432695150375,
0.030458062887191772,
0.023325365036725998,
0.05291885882616043,
0.0002485074510332197,
0.011266421526670456,
-0.02518058568239212,
-0.0593671053647995,
0.04110307618975639,
-0.030890347436070442,
-0.009519270621240139,
0.04095897823572159,
0.06448247283697128,
0.02854880504310131,
-0.014346449635922909,
0.05295488238334656,
0.027612188830971718,
-0.07867582142353058,
-0.01600354164838791,
0.003116052597761154,
-0.03251141682267189,
0.00023471711028832942,
0.044525329023599625,
0.010437875054776669,
0.06783267855644226,
-0.000675444898661226,
0.018002858385443687,
-0.03227725997567177,
-0.018372101709246635,
-0.07773920893669128,
0.03930188715457916,
-0.016886122524738312,
0.07809944450855255,
0.014256390742957592,
-0.030368003994226456,
-0.02246079407632351,
-0.04971274733543396,
0.007988261990249157,
0.017183318734169006,
0.011464552022516727,
0.004566007759422064,
-0.013472874648869038,
0.050505269318819046,
0.04236390441656113,
-0.04996491223573685,
0.006943573709577322,
0.05947517603635788,
-0.054071616381406784,
-0.020155277103185654,
-0.06473463773727417,
0.04185957461595535,
-0.06268128752708435,
-0.0004956077318638563,
-0.026981772854924202,
-0.039265863597393036,
-0.016886122524738312,
-0.024388063699007034,
-0.006749946158379316,
-0.01039284560829401,
0.01683208718895912,
0.09928140044212341,
0.06660787761211395,
0.027594177052378654,
-0.010924195870757103,
0.0005144638707861304,
-0.09740816056728363,
-0.03200708329677582,
0.014400485903024673,
0.004120213910937309,
-0.030097825452685356,
-0.028026461601257324,
-0.039590079337358475,
0.04960467293858528,
0.0643744021654129,
-0.07338033616542816,
0.021362071856856346,
-0.014094283804297447,
0.032475393265485764,
0.044417258352041245,
-0.02474830113351345,
-0.07990062981843948,
0.01590447686612606,
-0.027089843526482582,
0.004203518852591515,
-0.036708179861307144,
0.0020173287484794855,
-0.02094779908657074,
-0.020641596987843513,
0.06613956391811371,
0.02224465273320675,
-0.07078662514686584,
-0.029719576239585876,
-0.00569625198841095,
0.023847708478569984,
-0.013166672550141811,
-0.030638180673122406,
0.007546971086412668,
0.017300395295023918,
-0.038401294499635696,
-0.054287757724523544,
-0.009222074411809444,
-0.05875470116734505,
0.07190336287021637,
-0.0031565793324261904,
-0.044093042612075806,
0.04225583374500275,
-0.038725510239601135,
0.012446198612451553,
-0.016255708411335945,
0.033772245049476624,
0.09611131250858307,
-0.03366417437791824,
0.021578213199973106,
0.01562529243528843,
-0.003235381096601486,
-0.03315984085202217,
0.028350675478577614,
0.02523462288081646,
-0.019831063225865364,
0.002746809273958206,
-0.0561249703168869,
0.009456228464841843,
0.024946432560682297,
-0.0643744021654129,
-0.02040744200348854,
0.0024788829032331705,
0.06577932834625244,
-0.03006180189549923,
-0.03995031490921974,
-0.052234407514333725,
0.021614236757159233,
0.010113662108778954,
-0.05367535725235939,
0.018002858385443687,
0.049568649381399155,
-0.05605292320251465,
0.0291431974619627,
-0.03060215711593628,
-0.04261607304215431,
0.046650730073451996,
0.02690972574055195,
-0.06559921056032181,
-0.044741470366716385,
0.012221050448715687,
-0.024081863462924957,
-0.006646377965807915,
0.040562719106674194,
0.028584828600287437,
-0.05763796716928482,
0.008465575985610485,
-0.009834477677941322,
-0.0008144740131683648,
0.003780239960178733,
0.010311792604625225,
0.04221981018781662,
0.046542659401893616,
-0.03724853694438934,
-0.026999784633517265,
-0.020983822643756866,
-0.012518245726823807,
0.029863670468330383,
0.023127233609557152,
0.03287165239453316,
0.003989628050476313,
-0.04221981018781662,
-0.032367318868637085,
0.021416107192635536,
0.05025310069322586,
0.024279993027448654,
-0.009762430563569069,
0.04780348762869835,
-0.014157325029373169,
-0.01893046870827675,
-0.041535358875989914,
-0.03876153379678726,
-0.03886960446834564,
-0.0494966022670269,
0.022748984396457672,
-0.01790379360318184,
0.032475393265485764,
0.06631968170404434,
0.022821031510829926,
0.0326555110514164,
-0.06430235505104065,
0.007146207150071859,
0.007700072135776281,
-0.07172324508428574,
0.007105680648237467,
0.01009565033018589,
-0.004818173591047525,
-0.01757957972586155,
0.037572748959064484,
0.009879508055746555,
0.0014128056354820728,
-0.017237354069948196,
0.0049442569725215435,
-0.019831063225865364,
0.019290706142783165,
-0.0113925039768219,
-0.0031363158486783504,
0.027287974953651428,
-0.009294122457504272,
-0.024928420782089233,
-0.031160525977611542,
0.014670663513243198,
0.005556660238653421,
-0.003818515222519636,
-0.06783267855644226,
0.004899227060377598,
0.015319090336561203,
0.0360417403280735,
0.02213658206164837,
-0.023325365036725998,
-0.0333399623632431,
-0.03456476703286171,
-0.010059625841677189,
-0.013418839313089848,
-0.011221391148865223,
0.014976865611970425,
0.0028503774665296078,
0.04992888867855072,
0.029017113149166107,
0.005817832425236702,
-0.014337443746626377,
-0.00787118449807167,
-0.0020049456506967545,
-0.04459737613797188,
0.00712369242683053,
-0.012022919952869415,
-0.03998633846640587,
-0.04211173951625824,
-0.08991523087024689,
-0.021938450634479523,
0.08054906129837036,
0.0017325162189081311,
-0.0017190072685480118,
0.010861154645681381,
-0.0060159629210829735
] |
725,881 | qsm_forward.qsm_forward | generate_bids |
Simulate T2*-weighted magnitude and phase images and save the outputs in the BIDS-compliant format.
This function simulates a T2*-weighted MRI signal based on a ground truth susceptibility map,
and saves the outputs (images, JSON headers) in the BIDS-compliant format in the specified
directory.
Parameters
----------
tissue_params : TissueParams
Provides paths to different tissue parameter files or the 3D numpy arrays themselves.
recon_params : ReconParams
Provides parameters for the simulated reconstruction.
bids_dir : str
The directory where the BIDS-formatted outputs will be saved.
save_chi : bool
Whether to save the cropped chi map to the BIDS directory. Default is True.
save_mask : bool
Whether to save the cropped mask to the BIDS directory. Default is True.
save_segmentation : bool
Whether to save the cropped segmentation to the BIDS directory. Default is True.
save_field : bool
Whether to save the cropped field map to the BIDS directory. Default is False.
save_shimmed_field : bool
Whether to save the cropped and shimmed field map to the BIDS directory. Default is False.
save_shimmed_offset_field : bool
Whether to save the cropped, shimmed and offset field map to the BIDS directory. Default is False.
Returns
-------
None
Outputs are saved as files in the bids_dir directory.
| def generate_bids(tissue_params: TissueParams, recon_params: ReconParams, bids_dir, save_chi=True, save_mask=True, save_segmentation=True, save_field=False, save_shimmed_field=False, save_shimmed_offset_field=False):
"""
Simulate T2*-weighted magnitude and phase images and save the outputs in the BIDS-compliant format.
This function simulates a T2*-weighted MRI signal based on a ground truth susceptibility map,
and saves the outputs (images, JSON headers) in the BIDS-compliant format in the specified
directory.
Parameters
----------
tissue_params : TissueParams
Provides paths to different tissue parameter files or the 3D numpy arrays themselves.
recon_params : ReconParams
Provides parameters for the simulated reconstruction.
bids_dir : str
The directory where the BIDS-formatted outputs will be saved.
save_chi : bool
Whether to save the cropped chi map to the BIDS directory. Default is True.
save_mask : bool
Whether to save the cropped mask to the BIDS directory. Default is True.
save_segmentation : bool
Whether to save the cropped segmentation to the BIDS directory. Default is True.
save_field : bool
Whether to save the cropped field map to the BIDS directory. Default is False.
save_shimmed_field : bool
Whether to save the cropped and shimmed field map to the BIDS directory. Default is False.
save_shimmed_offset_field : bool
Whether to save the cropped, shimmed and offset field map to the BIDS directory. Default is False.
Returns
-------
None
Outputs are saved as files in the bids_dir directory.
"""
# create output directories
print("Creating output directory...")
os.makedirs(bids_dir, exist_ok=True)
# recon name
recon_name = f"sub-{recon_params.subject}"
if recon_params.session: recon_name += f"_ses-{recon_params.session}"
if recon_params.acq: recon_name += f"_acq-{recon_params.acq}"
if recon_params.run: recon_name += f"_run-{recon_params.run}"
# subject directory
subject_dir = os.path.join(bids_dir, f"sub-{recon_params.subject}")
if recon_params.session: subject_dir = os.path.join(subject_dir, f"ses-{recon_params.session}")
# derivatives directory
subject_dir_deriv = os.path.join(bids_dir, "derivatives", "qsm-forward", f"sub-{recon_params.subject}")
if recon_params.session: subject_dir_deriv = os.path.join(subject_dir_deriv, f"ses-{recon_params.session}")
os.makedirs(os.path.join(subject_dir, 'anat'), exist_ok=True)
os.makedirs(os.path.join(subject_dir_deriv, 'anat'), exist_ok=True)
# random number generator for noise etc.
rng = np.random.default_rng(recon_params.random_seed)
# adjust affine for B0 direction
affine = adjust_affine_for_B0_direction(tissue_params.nii_affine.copy(), recon_params.B0_dir)
tissue_params.set_affine(affine)
# image-space resizing
print("Image-space resizing of chi...")
chi_downsampled_nii = resize(tissue_params.chi, recon_params.voxel_size)
if save_chi: nib.save(chi_downsampled_nii, filename=os.path.join(subject_dir_deriv, "anat", f"{recon_name}_Chimap.nii"))
print("Image-space cropping of mask...")
if save_mask: nib.save(resize(tissue_params.mask, recon_params.voxel_size, 'nearest'), filename=os.path.join(subject_dir_deriv, "anat", f"{recon_name}_mask.nii"))
print("Image-space cropping of segmentation...")
if save_segmentation: nib.save(resize(tissue_params.seg, recon_params.voxel_size, 'nearest'), filename=os.path.join(subject_dir_deriv, "anat", f"{recon_name}_dseg.nii"))
# calculate field
print("Computing field model...")
field = generate_field(tissue_params.chi.get_fdata(), voxel_size=tissue_params.voxel_size, B0_dir=recon_params.B0_dir)
if save_field: nib.save(resize(nib.Nifti1Image(dataobj=np.array(field, dtype=np.float32), affine=tissue_params.nii_affine, header=tissue_params.nii_header), recon_params.voxel_size), filename=os.path.join(subject_dir_deriv, "anat", f"{recon_name}_fieldmap.nii"))
# simulate shim field
if recon_params.generate_shim_field:
print("Computing shim fields...")
_, field, _ = generate_shimmed_field(field, tissue_params.mask.get_fdata(), order=2)
if save_shimmed_field: nib.save(resize(nib.Nifti1Image(dataobj=np.array(field, dtype=np.float32), affine=tissue_params.nii_affine, header=tissue_params.nii_header), recon_params.voxel_size), filename=os.path.join(subject_dir_deriv, "anat", f"{recon_name}_desc-shimmed_fieldmap.nii"))
# phase offset
phase_offset = recon_params.phase_offset
if recon_params.generate_phase_offset:
print("Computing phase offset...")
phase_offset = recon_params.phase_offset + generate_phase_offset(tissue_params.M0.get_fdata(), tissue_params.mask.get_fdata(), tissue_params.M0.get_fdata().shape)
if save_shimmed_offset_field: nib.save(resize(nib.Nifti1Image(dataobj=np.array(field, dtype=np.float32), affine=tissue_params.nii_affine, header=tissue_params.nii_header), recon_params.voxel_size), filename=os.path.join(subject_dir_deriv, "anat", f"{recon_name}_desc-shimmed-offset_fieldmap.nii"))
# signal model
multiecho = len(recon_params.TEs) > 1
for i in range(len(recon_params.TEs)):
print(f"Computing MR signal for echo {i+1}...")
recon_name_i = f"{recon_name}_echo-{i+1}" if multiecho else recon_name
sigHR = generate_signal(
field=field,
B0=recon_params.B0,
TR=recon_params.TR,
TE=recon_params.TEs[i],
flip_angle=recon_params.flip_angle,
phase_offset=phase_offset,
R1=tissue_params.R1.get_fdata(),
R2star=tissue_params.R2star.get_fdata(),
M0=tissue_params.M0.get_fdata()
)
# k-space cropping of sigHR
print(f"k-space cropping of MR signal for echo {i+1}...")
resolution = np.array(np.round((np.array(tissue_params.voxel_size) / recon_params.voxel_size) * np.array(tissue_params.nii_header.get_data_shape())), dtype=int)
sigHR_cropped = crop_kspace(sigHR, resolution)
del sigHR
# noise
print(f"Simulating noise for echo {i+1}...")
sigHR_cropped_noisy = add_noise(sigHR_cropped, peak_snr=recon_params.peak_snr, rng=rng)
del sigHR_cropped
# save nifti images
mag_filename = f"{recon_name_i}" + ("_part-mag" if recon_params.save_phase else "") + f"_{recon_params.suffix}"
phs_filename = f"{recon_name_i}" + ("_part-phase" if recon_params.save_phase else "") + f"_{recon_params.suffix}"
nib.save(nib.Nifti1Image(dataobj=np.abs(sigHR_cropped_noisy), affine=chi_downsampled_nii.affine, header=chi_downsampled_nii.header), filename=os.path.join(subject_dir, "anat", f"{mag_filename}.nii"))
if recon_params.save_phase: nib.save(nib.Nifti1Image(dataobj=np.angle(sigHR_cropped_noisy), affine=chi_downsampled_nii.affine, header=chi_downsampled_nii.header), filename=os.path.join(subject_dir, "anat", f"{phs_filename}.nii"))
# json header
print(f"Creating JSON headers...")
json_dict = {
'EchoTime': recon_params.TEs[i],
'MagneticFieldStrength': recon_params.B0,
'EchoNumber': i+1,
'ProtocolName': recon_params.suffix,
'ConversionSoftware': 'qsm-forward',
'RepetitionTime': recon_params.TR,
'FlipAngle': recon_params.flip_angle,
'B0_dir': recon_params.B0_dir.tolist(),
'PhaseOffset': recon_params.generate_phase_offset or phase_offset != 0,
'ShimmField': recon_params.generate_shim_field,
'VoxelSize': recon_params.voxel_size.tolist(),
'PeakSNR': recon_params.peak_snr if recon_params.peak_snr != np.inf else "inf"
}
json_dict_phs = json_dict.copy()
json_dict_phs['ImageType'] = ['P', 'PHASE']
json_dict_mag = json_dict.copy()
json_dict_mag['ImageType'] = ['M', 'MAGNITUDE']
with open(os.path.join(subject_dir, "anat", f"{mag_filename}.json"), 'w') as mag_json_file:
| (tissue_params: qsm_forward.qsm_forward.TissueParams, recon_params: qsm_forward.qsm_forward.ReconParams, bids_dir, save_chi=True, save_mask=True, save_segmentation=True, save_field=False, save_shimmed_field=False, save_shimmed_offset_field=False) | [
0.018622297793626785,
-0.041642483323812485,
-0.05185840651392937,
0.03632837161421776,
-0.03889380395412445,
-0.06752587109804153,
-0.0968451127409935,
-0.010290365666151047,
-0.02581467479467392,
-0.018759731203317642,
0.006831611972302198,
0.07540541887283325,
0.009150809608399868,
0.06715938448905945,
-0.005706371273845434,
0.0225391648709774,
0.04338331148028374,
0.05020919814705849,
-0.0029290607199072838,
-0.047139838337898254,
-0.0542864054441452,
-0.01122377160936594,
-0.006161621306091547,
0.06963319331407547,
0.01948126032948494,
-0.007805102039128542,
-0.013903733342885971,
-0.03396908938884735,
-0.008223130367696285,
0.018473410978913307,
-0.015152091160416603,
-0.0606541782617569,
0.023890599608421326,
-0.030624860897660255,
-0.023054542019963264,
-0.02959410659968853,
0.013674676418304443,
0.009053460322320461,
-0.09075220674276352,
0.03511437028646469,
0.018965883180499077,
-0.0376339927315712,
0.06912926584482193,
-0.058501046150922775,
-0.03442719951272011,
0.06340285390615463,
-0.007822281681001186,
0.050438255071640015,
-0.012071280740201473,
0.05195002630352974,
0.0006163052748888731,
-0.0679381787776947,
-0.031128786504268646,
0.03836697340011597,
-0.0011080610565841198,
0.04544482007622719,
-0.027395164594054222,
0.025997919961810112,
0.04441406577825546,
-0.07586353272199631,
0.00114098796620965,
0.02489844709634781,
0.039993274956941605,
0.026295693591237068,
0.0038710557855665684,
0.023329410701990128,
-0.014018261805176735,
-0.006917507853358984,
-0.013056224212050438,
-0.014247317798435688,
0.025379465892910957,
-0.031380750238895416,
0.032777994871139526,
0.044345349073410034,
0.008830130100250244,
-0.023386674001812935,
-0.023203428834676743,
-0.03007512539625168,
-0.014751242473721504,
-0.012540846131742,
0.04576550051569939,
0.04285648092627525,
0.002161721233278513,
-0.029800258576869965,
-0.015678921714425087,
0.025035882368683815,
0.073664590716362,
0.027395164594054222,
-0.017648808658123016,
-0.09249303489923477,
-0.04077206552028656,
-0.021428240463137627,
0.0425587072968483,
0.007140838075429201,
0.008045611903071404,
0.008784319274127483,
-0.045994557440280914,
-0.07242768257856369,
-0.026616372168064117,
-0.07668813318014145,
-0.04631523787975311,
-0.02581467479467392,
-0.03431267291307449,
0.010759931989014149,
-0.008091422729194164,
0.022791126742959023,
-0.04943040385842323,
0.03742784261703491,
-0.02105029858648777,
-0.04594874382019043,
-0.051171235740184784,
0.049613650888204575,
-0.05020919814705849,
-0.047552142292261124,
0.015426958911120892,
-0.05987538397312164,
0.008366290479898453,
0.01932092010974884,
0.01106343138962984,
0.02892984263598919,
0.00031423696782439947,
-0.02975444681942463,
-0.07041198760271072,
0.0095287524163723,
0.03007512539625168,
0.01776333525776863,
0.024073844775557518,
0.055935610085725784,
0.039924558252096176,
-0.07467243820428848,
-0.05391991510987282,
-0.0035990511532872915,
-0.00874996092170477,
0.019091865047812462,
-0.03248022124171257,
-0.00011381247895769775,
0.01570182666182518,
-0.05698927119374275,
0.02441742829978466,
-0.004420791752636433,
0.03032708913087845,
-0.010668309405446053,
0.03454172983765602,
-0.007301177829504013,
0.010845827870070934,
-0.0005579674616456032,
0.03245731443166733,
-0.06642640382051468,
-0.02721191942691803,
-0.021096108481287956,
-0.0010171543108299375,
0.0019856339786201715,
-0.029296332970261574,
0.012059827335178852,
0.03944353759288788,
-0.02876950427889824,
0.04471183940768242,
0.02450905181467533,
-0.06505206227302551,
0.010502243414521217,
0.0065109324641525745,
-0.04938459396362305,
0.0409553125500679,
0.009683365933597088,
-0.03154108673334122,
0.004787282086908817,
-0.027921995148062706,
0.05213327333331108,
0.037130068987607956,
0.06642640382051468,
-0.0021345207933336496,
-0.008830130100250244,
-0.09185168147087097,
-0.04773538559675217,
-0.037107162177562714,
0.08213967829942703,
-0.03032708913087845,
-0.04022233188152313,
-0.05689764767885208,
0.0252420324832201,
-0.026776712387800217,
-0.01525516714900732,
0.011888035573065281,
0.050163384526968,
-0.023455390706658363,
0.032846711575984955,
0.05579817667603493,
0.013995355926454067,
0.10179273784160614,
-0.006854517385363579,
0.04782700911164284,
0.05506519600749016,
-0.019836297258734703,
0.006505206227302551,
0.039924558252096176,
-0.01914912834763527,
0.07064104080200195,
-0.027921995148062706,
0.03948935121297836,
0.0008424986735917628,
-0.03706135228276253,
-0.004117291420698166,
-0.02482973039150238,
-0.05785968527197838,
-0.01422441191971302,
-0.04088659584522247,
-0.015117732807993889,
0.007953989319503307,
0.008606799878180027,
0.041390519589185715,
0.007581772282719612,
-0.005248258356004953,
0.009133630432188511,
-0.013835015706717968,
0.05543168634176254,
-0.024486146867275238,
-0.010101393796503544,
0.06248662993311882,
-0.034816596657037735,
-0.013193657621741295,
-0.033510975539684296,
0.044368255883455276,
-0.08530066162347794,
-0.00339003698900342,
-0.05511100962758064,
0.06326542049646378,
0.04423082247376442,
0.04993433132767677,
0.05657697096467018,
-0.02753259800374508,
0.015552939847111702,
0.057676441967487335,
0.008990470319986343,
-0.00887594185769558,
0.00047815556172281504,
0.0008911732002161443,
-0.014831412583589554,
-0.015323883853852749,
-0.013147846795618534,
-0.019687410444021225,
-0.027990711852908134,
-0.031861767172813416,
-0.01007276214659214,
-0.017144883051514626,
-0.01060531847178936,
-0.03387746587395668,
0.058821722865104675,
0.02803652361035347,
-0.04120727628469467,
0.015404053963720798,
0.0552484430372715,
-0.04248999059200287,
-0.024600673466920853,
0.00961464922875166,
-0.002598360413685441,
-0.05153772607445717,
0.022298656404018402,
-0.04833093285560608,
0.08140669763088226,
-0.008538083173334599,
0.057676441967487335,
-0.04070334881544113,
-0.03140365332365036,
-0.0059440177865326405,
-0.06234919652342796,
0.04998014122247696,
-0.03344225883483887,
0.011573082767426968,
-0.05341598764061928,
-0.028334295377135277,
0.01455654390156269,
0.049292970448732376,
-0.06839628517627716,
-0.01645771414041519,
-0.03994746506214142,
0.010026950389146805,
0.0070549421943724155,
0.008772865869104862,
-0.01476269494742155,
-0.0027071621734648943,
0.0073698945343494415,
-0.01725941151380539,
0.07861220836639404,
-0.004606899805366993,
-0.006321961060166359,
-0.006551017519086599,
-0.025929203256964684,
0.038275349885225296,
0.010318998247385025,
-0.02086705155670643,
-0.03225116431713104,
0.03871055692434311,
-0.008532356470823288,
-0.010834375396370888,
0.0073698945343494415,
0.002038603415712714,
-0.08268941938877106,
-0.022825485095381737,
0.013021864928305149,
-0.013479978777468204,
-0.043864332139492035,
0.06656383723020554,
0.07476405799388885,
-0.03781723603606224,
-0.047872819006443024,
0.029731541872024536,
0.05217908322811127,
-0.025700146332383156,
0.008188772015273571,
0.0075760455802083015,
0.0030235466547310352,
0.0055460319854319096,
0.04718565195798874,
0.020454751327633858,
0.07348134368658066,
-0.01997373253107071,
0.0596921406686306,
0.056851837784051895,
0.06473138183355331,
0.05543168634176254,
0.011240950785577297,
-0.025745956227183342,
-0.0050277914851903915,
0.00138292892370373,
0.08791190385818481,
-0.08328496664762497,
0.01768316701054573,
0.0314265601336956,
-0.03387746587395668,
-0.020935770124197006,
-0.011074884794652462,
0.02851754240691662,
-0.019962279126048088,
0.007238187361508608,
0.008961837738752365,
-0.017969487234950066,
-0.014533638954162598,
-0.051675159484148026,
0.029456673189997673,
-0.02679961733520031,
-0.0037221689708530903,
-0.0404742956161499,
-0.018713921308517456,
0.06459394842386246,
0.023890599608421326,
-0.028746597468852997,
0.032434407621622086,
-0.02860916405916214,
-0.02169165574014187,
0.02867788076400757,
0.025677239522337914,
0.06784655153751373,
0.050346631556749344,
0.08882813155651093,
0.04003908485174179,
0.033991992473602295,
-0.05130866914987564,
-0.034724973142147064,
-0.012643922120332718,
0.004246136173605919,
0.004363527521491051,
0.0252420324832201,
-0.016514977440238,
0.025677239522337914,
0.013376902788877487,
-0.024623580276966095,
-0.029571201652288437,
0.009826526045799255,
0.023363769054412842,
-0.017637355253100395,
-0.0005164509639143944,
-0.00925388466566801,
-0.05515681952238083,
-0.01669822260737419,
0.024348711594939232,
0.027601314708590508,
-0.01816418580710888,
-0.005898206494748592,
-0.04642976447939873,
0.012964601628482342,
-0.029960596933960915,
0.02086705155670643,
-0.06885439902544022,
0.003169570118188858,
0.002997777657583356,
-0.01443056296557188,
0.05506519600749016,
0.017121978104114532,
0.0026599192060530186,
-0.07925356924533844,
0.037107162177562714,
0.007879545912146568,
0.06496044248342514,
-0.015163544565439224,
-0.017053261399269104,
-0.01669822260737419,
-0.016343185678124428,
0.061203911900520325,
-0.041069839149713516,
-0.008503724820911884,
-0.02359282597899437,
-0.07719206064939499,
0.00874996092170477,
0.0360305979847908,
0.037198785692453384,
-0.048056066036224365,
0.04546772688627243,
-0.013640318065881729,
0.02054637297987938,
-0.017133429646492004,
-0.0032812352292239666,
0.006276149768382311,
-0.034816596657037735,
-0.008303300477564335,
-0.05960051715373993,
0.004930442199110985,
-0.039099954068660736,
-0.014109884388744831,
0.0037193058524280787,
0.03387746587395668,
-0.006081451661884785,
0.036946821957826614,
0.05708089470863342,
0.07288579642772675,
0.0046441215090453625,
0.03543505072593689,
0.010788563638925552,
0.04855998978018761,
-0.027074486017227173,
0.030876824632287025,
-0.025929203256964684,
0.045994557440280914,
-0.0468420647084713,
-0.006367772351950407,
0.03353387862443924,
-0.021325165405869484,
-0.005417187698185444,
-0.04629233106970787,
0.03800048306584358,
0.04462021589279175,
0.02771584317088127,
0.015816355124115944,
0.005379965994507074,
-0.07348134368658066,
0.03245731443166733,
0.004269041586667299,
-0.028494635596871376,
0.035641200840473175,
-0.00762185687199235,
0.024302901700139046,
0.04308553785085678,
0.013079129159450531,
-0.0012097049038857222,
-0.040909502655267715,
0.015896525233983994,
0.0047185649164021015,
0.07572609931230545,
0.010662582702934742,
-0.04022233188152313,
-0.09941054880619049,
-0.045925840735435486,
0.044368255883455276,
0.004223230294883251,
0.037679802626371384,
0.07128240168094635,
0.03362550213932991,
0.013697582297027111,
-0.013628865592181683,
-0.03845859691500664,
0.0034243955742567778,
-0.015209355391561985,
0.012105639092624187,
0.011166507378220558,
-0.0011667568469420075,
0.048789046704769135,
-0.005113687831908464,
-0.012174355797469616,
0.01751137338578701,
-0.0365116149187088,
-0.02161148563027382,
0.03829825669527054,
-0.07251930981874466,
-0.02654765546321869,
-0.004784418735653162,
0.0032125182915478945,
-0.052499763667583466,
-0.0005540305282920599,
-0.03877927362918854,
0.012014016509056091,
-0.08181900531053543,
-0.045330293476581573,
-0.027005767449736595,
-0.0022819759324193,
0.03873346373438835,
-0.007272545713931322,
0.05382829159498215,
-0.014155695214867592,
-0.007839460857212543,
-0.011601714417338371,
-0.08497998118400574,
0.023776071146130562,
0.003043588949367404,
-0.05671440437436104,
-0.025081692263484,
-0.03740493580698967,
-0.019779033958911896,
-0.02163439244031906,
-0.058501046150922775,
-0.01376629900187254,
-0.014648166485130787,
-0.024440335109829903,
-0.02375316433608532,
0.0066140079870820045,
-0.05895915627479553,
-0.013147846795618534,
0.018942978233098984,
-0.009815073572099209,
0.013056224212050438,
-0.04581131041049957,
0.01653788425028324,
0.01451073307543993,
-0.04833093285560608,
0.006264696829020977,
0.03041871078312397,
0.040726255625486374,
0.024119654670357704,
0.004546772688627243,
-0.0009377002716064453,
0.05859266594052315,
0.009511573240160942,
-0.05657697096467018,
-0.006499479990452528,
0.05135447904467583,
0.03518308699131012,
0.050438255071640015,
-0.010244554840028286,
0.03536633402109146,
-0.0730232298374176,
0.019996637478470802,
-0.042375463992357254,
-0.04029104858636856,
0.002392209367826581,
0.0033585417550057173,
-0.04496380314230919,
-0.012048374861478806,
0.05327855423092842,
0.008228857070207596,
0.017076166346669197,
0.034335579723119736,
-0.03348806872963905,
-0.012850073166191578,
-0.003664904972538352,
0.06532692909240723,
-0.020030995830893517,
0.045582253485918045,
0.021760372444987297,
0.07508473843336105,
-0.0105595076456666,
0.008406375534832478,
0.014086978510022163,
-0.012678280472755432,
0.008606799878180027,
0.013228015974164009,
-0.06766330450773239,
-0.0025711599737405777,
0.029662825167179108,
-0.005334154702723026,
0.05712670460343361,
-0.01889716647565365,
-0.024531956762075424,
0.005726413801312447,
0.04915553703904152,
0.05822617560625076,
0.0002922260609921068,
-0.06702195107936859,
-0.04242127388715744,
-0.019962279126048088,
-0.004632669035345316,
-0.01643480733036995,
-0.04029104858636856,
0.05992119386792183,
0.027326447889208794,
0.04746051877737045,
-0.012426318600773811,
0.009832252748310566,
-0.0001763556501828134,
0.011212318204343319,
0.04349784180521965,
-0.004549636039882898,
0.02991478703916073,
-0.014407657086849213,
0.039329010993242264,
0.0012862957082688808,
-0.013102035038173199,
-0.012002564035356045,
0.07819990813732147,
0.04601746425032616,
-0.01015293225646019,
-0.00793108344078064,
-0.01425877120345831,
0.02950248494744301,
-0.020443297922611237,
0.01586216688156128,
-0.015507129020988941,
-0.0008976153912954032,
-0.0025196222122758627,
-0.013835015706717968,
0.027349352836608887,
0.014270223677158356,
0.019939374178647995,
0.039260294288396835,
0.035457953810691833,
0.056027233600616455,
-0.04551353678107262,
-0.023065995424985886,
-0.03225116431713104,
-0.026272786781191826,
0.04901810362935066,
0.03891671076416969,
-0.026204070076346397,
-0.0032755087595432997,
0.0002388988359598443,
-0.0377943329513073,
-0.003779433201998472,
-0.026753805577754974,
-0.01687001623213291,
-0.005454409401863813,
-0.03756527602672577,
-0.0006807274767197669,
-0.031289126724004745,
0.010290365666151047,
-0.027830371633172035,
0.04924716055393219,
-0.04010780155658722,
0.005703508388251066,
0.05295787751674652,
-0.008744234219193459,
0.02867788076400757,
-0.05950889363884926,
0.07655069977045059,
0.06903764605522156,
-0.03754236921668053,
-0.042054783552885056,
-0.0018281576922163367,
-0.02416546642780304,
-0.008303300477564335,
-0.027097390964627266,
-0.05107961222529411,
-0.0225391648709774,
0.01604541204869747,
-0.021084656938910484,
0.028746597468852997,
-0.05703508481383324,
-0.043039727956056595,
0.007163743954151869,
-0.006167348008602858,
0.0009312580805271864,
0.009391319006681442,
-0.01848486438393593,
-0.009895243681967258,
0.02721191942691803,
-0.013903733342885971,
0.024142561480402946,
-0.03944353759288788,
-0.026089541614055634,
-0.031289126724004745,
0.05566074326634407,
-0.06660964339971542,
0.030052220448851585,
0.016400448977947235,
0.025997919961810112,
-0.06468557566404343,
0.0012777061201632023,
-0.014739789068698883,
0.0012018311535939574,
0.025081692263484,
0.019687410444021225,
0.04274195432662964,
0.04113855957984924,
0.008028432726860046,
0.029662825167179108,
0.021004486829042435,
0.002246185904368758,
-0.019962279126048088,
0.08475092798471451,
-0.01922929845750332,
0.0404742956161499,
0.0006116525619290769,
-0.04704821854829788,
-0.004100112244486809,
-0.0036334097385406494,
0.050025951117277145,
0.010954629629850388,
0.018450506031513214,
0.0323885977268219,
0.011601714417338371,
-0.01791222207248211,
0.037198785692453384,
-0.0360305979847908,
-0.011498639360070229,
0.008142960257828236,
-0.036946821957826614,
0.016011053696274757,
-0.015300977975130081,
-0.04416210576891899,
0.07540541887283325,
-0.0552484430372715,
0.006562470458447933,
-0.00892175268381834,
-0.04006199166178703,
-0.010616771876811981,
0.0755886659026146,
0.03032708913087845,
0.0003965541545767337,
-0.061616215854883194,
-0.0022805442567914724,
-0.03209082409739494,
0.06931251287460327,
-0.004071480128914118,
-0.021393882110714912,
-0.011796412989497185,
0.026570560410618782,
0.03403780609369278,
0.032846711575984955,
-0.015907978639006615,
-0.013731940649449825,
0.014109884388744831,
-0.025883391499519348,
0.02819686196744442,
0.0013557284837588668,
0.029135994613170624,
0.034724973142147064,
-0.05227070674300194,
-0.00912217702716589,
0.0007487286347895861,
-0.07343553006649017,
0.02638731524348259,
-0.039099954068660736,
-0.026204070076346397,
0.03344225883483887,
0.002011402975767851,
-0.05465289577841759,
-0.048147689551115036,
0.0043291691690683365,
-0.017854958772659302,
0.049292970448732376,
0.05130866914987564,
0.0037966123782098293,
-0.012598110362887383,
-0.00561188580468297,
0.073664590716362,
-0.0065681966952979565,
-0.025837579742074013,
0.0001546131825307384,
-0.005251121707260609,
0.038344066590070724,
0.02771584317088127,
0.040726255625486374,
0.008681243285536766,
0.0059440177865326405,
0.0033585417550057173,
-0.054881952702999115,
0.04042848199605942,
0.03742784261703491,
0.027440976351499557,
0.04924716055393219,
-0.03034999407827854,
-0.023123258724808693
] |
725,882 | qsm_forward.qsm_forward | generate_field |
Perform the forward convolution operation.
This function performs the forward convolution step of the QSM simulation.
Parameters
----------
chi : numpy.ndarray
The susceptibility distribution array.
Returns
-------
numpy.ndarray
The resulting magnetic field array after the forward convolution operation.
| def generate_field(chi, voxel_size=[1, 1, 1], B0_dir=[0, 0, 1]):
"""
Perform the forward convolution operation.
This function performs the forward convolution step of the QSM simulation.
Parameters
----------
chi : numpy.ndarray
The susceptibility distribution array.
Returns
-------
numpy.ndarray
The resulting magnetic field array after the forward convolution operation.
"""
dims = np.array(chi.shape)
D = _generate_3d_dipole_kernel(data_shape=dims, voxel_size=voxel_size, B0_dir=B0_dir)
chitemp = np.ones(2 * dims) * chi[-1, -1, -1]
chitemp[:dims[0], :dims[1], :dims[2]] = chi
field = np.real(np.fft.ifftn(np.fft.fftn(chitemp) * D))
field = field[:dims[0], :dims[1], :dims[2]]
return field
| (chi, voxel_size=[1, 1, 1], B0_dir=[0, 0, 1]) | [
0.021391719579696655,
0.012619511224329472,
-0.04335340857505798,
0.01193376537412405,
-0.012975743040442467,
0.024971850216388702,
0.0016041563358157873,
-0.016493532806634903,
-0.018452808260917664,
0.029424747452139854,
0.03305831179022789,
0.023030385375022888,
-0.012192033231258392,
0.026200849562883377,
0.00664817588403821,
0.0633736401796341,
-0.0003239483048673719,
0.00143049331381917,
-0.004223573487251997,
-0.012031729333102703,
-0.007146900519728661,
-0.03711935505270958,
0.0392567440867424,
0.027625776827335358,
0.01977086439728737,
0.015006264671683311,
-0.03336110711097717,
0.015442648902535439,
-0.03211429715156555,
-0.006398813799023628,
-0.012067352421581745,
-0.006710516754537821,
0.012984649278223515,
0.01815001107752323,
0.03783181682229042,
-0.04025419428944588,
0.0691445916891098,
-0.0020683708135038614,
-0.12297122180461884,
0.013046990148723125,
0.027269544079899788,
-0.024562181904911995,
0.01577216386795044,
0.009894338436424732,
-0.04805567115545273,
-0.011924859136343002,
0.029602862894535065,
0.07089012861251831,
-0.025363704189658165,
0.0316690057516098,
-0.0005271117552183568,
-0.06875273585319519,
0.002527019241824746,
-0.004346027970314026,
0.05461033433675766,
-0.032808948308229446,
0.005383552983403206,
-0.03489290550351143,
0.02190825529396534,
0.006363190710544586,
-0.034946341067552567,
-0.006621458567678928,
0.0571039579808712,
-0.02694893628358841,
-0.008620809763669968,
0.017686909064650536,
0.019485879689455032,
0.04260532185435295,
0.0179629884660244,
-0.010295098647475243,
-0.05361288785934448,
0.017393017187714577,
0.03850865736603737,
0.030885297805070877,
0.0017488754820078611,
0.013064801692962646,
0.00041105810669250786,
-0.00008550954953534529,
0.03444761410355568,
-0.02570212446153164,
0.021658893674612045,
0.01378617063164711,
-0.05781641975045204,
-0.04470708966255188,
-0.06771966814994812,
0.031526513397693634,
0.04242720827460289,
0.01213859859853983,
0.02401002310216427,
-0.03982671722769737,
-0.010161512531340122,
-0.05528717488050461,
-0.035712238401174545,
0.05632024630904198,
-0.008050838485360146,
0.02401002310216427,
-0.005873371846973896,
0.01737520657479763,
-0.029905660077929497,
0.09019789099693298,
-0.025399327278137207,
0.04388775676488876,
0.03220335394144058,
0.038473036140203476,
-0.02226448804140091,
-0.005664085503667593,
-0.07381123304367065,
-0.01788283698260784,
0.02101767621934414,
-0.062126826494932175,
-0.035712238401174545,
0.03679874539375305,
0.015692010521888733,
0.03448323905467987,
-0.02155202440917492,
-0.03095654398202896,
0.008344730362296104,
0.0019225385040044785,
0.055607784539461136,
0.03462573140859604,
0.04050355777144432,
-0.09461516886949539,
-0.037048108875751495,
-0.040396686643362045,
-0.02573774755001068,
0.03161557391285896,
0.015077510848641396,
-0.035320382565259933,
0.012904496863484383,
-0.03947048261761665,
0.015692010521888733,
-0.014614409767091274,
0.015335778705775738,
-0.0003033536486327648,
-0.0037782834842801094,
-0.021534211933612823,
0.008643073961138725,
-0.07106824219226837,
0.019966792315244675,
0.035943787544965744,
-0.02636115252971649,
0.04442210495471954,
0.00675949826836586,
0.04403024911880493,
0.025898052379488945,
0.06750592589378357,
0.03907863050699234,
0.042890310287475586,
-0.022959139198064804,
-0.012735286727547646,
-0.06992830336093903,
0.03122371807694435,
0.03029751405119896,
0.016965540125966072,
-0.022585095837712288,
0.03327205032110214,
0.006385454908013344,
-0.03822367265820503,
-0.005802125670015812,
0.00004919060302199796,
-0.009457954205572605,
-0.013875228352844715,
-0.06031004339456558,
0.06319551914930344,
0.0029789884574711323,
0.02181919850409031,
0.00001464585784560768,
-0.033254239708185196,
0.004372745286673307,
0.08798925578594208,
0.015362496487796307,
-0.018684357404708862,
-0.059098854660987854,
0.016564778983592987,
0.019111836329102516,
0.005646273959428072,
-0.04983682930469513,
-0.05332789942622185,
0.003099216613918543,
-0.0365850068628788,
-0.021088922396302223,
0.013991003856062889,
0.06080877035856247,
-0.027073616161942482,
0.006714969407767057,
0.028890399262309074,
0.008620809763669968,
0.02498966082930565,
0.07324125617742538,
-0.03109903633594513,
0.03343235328793526,
-0.008928059600293636,
0.01671617664396763,
-0.06921584159135818,
0.01722380705177784,
0.0013681527925655246,
0.017072409391403198,
-0.02605835720896721,
0.019379010424017906,
0.03257739916443825,
0.022941328585147858,
-0.01766909658908844,
-0.020020227879285812,
-0.05179610475897789,
-0.06786216050386429,
0.01905840076506138,
-0.001708799391053617,
0.029068514704704285,
-0.017072409391403198,
0.018069857731461525,
0.04894625023007393,
-0.0001708799391053617,
0.0008221162133850157,
-0.012396866455674171,
0.019966792315244675,
-0.04848314821720123,
0.03466135263442993,
-0.017179278656840324,
-0.05336352437734604,
0.0057709552347660065,
0.008781113661825657,
0.04050355777144432,
-0.031152471899986267,
-0.015941374003887177,
-0.014712373726069927,
0.016226358711719513,
-0.06323114782571793,
-0.024437502026557922,
-0.06251867860555649,
-0.0874192863702774,
0.003063593525439501,
0.06568914651870728,
-0.02502528391778469,
-0.02712705172598362,
0.03694123774766922,
0.0136080551892519,
0.02881915308535099,
0.016653837636113167,
-0.02021615393459797,
0.00952920038253069,
-0.003693678416311741,
0.003700357861816883,
0.009707316756248474,
0.04317529499530792,
0.01286887377500534,
-0.026129603385925293,
-0.0007358413422480226,
-0.009867620654404163,
-0.040895409882068634,
0.04755694419145584,
-0.05229482799768448,
-0.04670199006795883,
-0.04524143785238266,
0.024526558816432953,
0.03113465942442417,
-0.06714969128370285,
-0.00234222412109375,
0.03590816631913185,
0.027643587440252304,
-0.018933720886707306,
0.012005011551082134,
-0.04484958574175835,
0.04403024911880493,
0.014365047216415405,
-0.05282917618751526,
0.007276034448295832,
-0.03216773271560669,
0.009181874804198742,
0.008798925206065178,
0.03715497627854347,
0.05282917618751526,
0.028890399262309074,
0.04125164449214935,
-0.04388775676488876,
-0.015024076215922832,
-0.05767392739653587,
0.004085533320903778,
0.044813960790634155,
-0.026663949713110924,
0.02529245801270008,
-0.03711935505270958,
-0.05393349379301071,
-0.01654696650803089,
0.05763830617070198,
-0.04538393020629883,
0.08100711554288864,
-0.008785567246377468,
0.045526422560214996,
0.06394360959529877,
-0.026076167821884155,
-0.011835801415145397,
0.010642425157129765,
0.004800223745405674,
-0.01117677241563797,
-0.018755603581666946,
-0.018256880342960358,
-0.03957735374569893,
-0.0012345658615231514,
0.012922308407723904,
-0.015611859038472176,
0.00297230901196599,
0.0504067987203598,
-0.036656253039836884,
0.04866126552224159,
-0.004666636697947979,
0.02846292033791542,
0.013777265325188637,
-0.033254239708185196,
-0.02730516716837883,
-0.05482407286763191,
-0.04695134982466698,
0.010517744347453117,
-0.021071111783385277,
-0.004991698078811169,
0.04574016481637955,
0.009270932525396347,
0.004613202065229416,
0.03065374679863453,
0.054859697818756104,
0.025221211835741997,
0.05671210214495659,
0.01882685162127018,
0.006082658190280199,
0.009734033606946468,
-0.02066144533455372,
-0.010072453878819942,
-0.028623225167393684,
-0.030190644785761833,
-0.04695134982466698,
0.014062250033020973,
-0.006848556455224752,
0.06729219108819962,
-0.0023711679968982935,
0.061236247420310974,
-0.006737234070897102,
-0.03957735374569893,
0.02703799307346344,
-0.046844482421875,
-0.027590153738856316,
-0.051154885441064835,
0.006670440547168255,
0.004764600191265345,
-0.023172879591584206,
-0.019646184518933296,
0.018007516860961914,
-0.04855439439415932,
-0.0006022544112056494,
-0.01311823632568121,
0.019040590152144432,
0.012459207326173782,
0.06771966814994812,
-0.041785988956689835,
0.024473125115036964,
0.04299717769026756,
0.007681248243898153,
0.06999954581260681,
-0.037404339760541916,
-0.013234011828899384,
-0.02926444262266159,
0.02173013985157013,
0.0073606395162642,
0.0459539033472538,
-0.0065991939045488834,
-0.009279838763177395,
0.01269075833261013,
-0.014169120229780674,
-0.04474271461367607,
0.012067352421581745,
0.035266947001218796,
0.06618786603212357,
0.01633322797715664,
0.02609398029744625,
-0.008580733090639114,
0.012218751013278961,
0.0028476279694586992,
-0.007748041767627001,
-0.0490887425839901,
0.043246541172266006,
-0.03765370324254036,
-0.007405168376863003,
-0.018844662234187126,
-0.0013614734634757042,
-0.04385213553905487,
-0.01601262018084526,
0.02016272023320198,
0.0001476413890486583,
0.023261936381459236,
0.07010641694068909,
0.0220863725990057,
-0.041607875376939774,
-0.052579812705516815,
-0.01760675758123398,
-0.027732646092772484,
0.007427433039993048,
0.013536808080971241,
-0.027554530650377274,
0.0316690057516098,
0.01959274895489216,
-0.031205905601382256,
-0.05674772709608078,
0.006278585642576218,
-0.05247294530272484,
-0.07039140164852142,
0.037546832114458084,
-0.06447795778512955,
-0.052936047315597534,
-0.046060770750045776,
-0.0020115964580327272,
0.015095322392880917,
-0.012307808734476566,
0.06041691452264786,
0.07039140164852142,
-0.025274645537137985,
-0.0068619148805737495,
-0.051724858582019806,
-0.027447659522294998,
-0.03797430917620659,
-0.06519041955471039,
-0.009070551954209805,
0.08464067429304123,
0.036869991570711136,
-0.024027835577726364,
-0.015994807705283165,
-0.00598914735019207,
-0.022602908313274384,
0.04809129238128662,
0.0100368307903409,
0.09076786041259766,
0.031918369233608246,
0.028747906908392906,
-0.028587602078914642,
0.04346027970314026,
-0.0006840763962827623,
0.014801431447267532,
-0.04335340857505798,
-0.041073527187108994,
-0.009956679306924343,
0.021872632205486298,
-0.010784917511045933,
0.04545517638325691,
0.006612552795559168,
-0.035320382565259933,
0.03448323905467987,
-0.08086461573839188,
-0.04748569801449776,
0.022424792870879173,
-0.0144986342638731,
0.023440051823854446,
-0.03904300555586815,
0.01240577269345522,
0.08243203908205032,
0.010784917511045933,
0.006964331958442926,
0.0023644885513931513,
0.07195882499217987,
0.0406104251742363,
0.009048287756741047,
-0.013643678277730942,
0.016912104561924934,
-0.03270208090543747,
0.018898097798228264,
0.024651240557432175,
-0.0028721189592033625,
-0.03628220781683922,
-0.01220093946903944,
0.022905705496668816,
0.019343387335538864,
-0.01197829470038414,
0.0038027744740247726,
-0.037404339760541916,
0.046844482421875,
0.025630878284573555,
0.026699572801589966,
-0.06754154711961746,
0.05938384309411049,
-0.013153859414160252,
-0.054539088159799576,
0.0267708208411932,
0.0075832842849195,
-0.06273242086172104,
-0.0025515102315694094,
-0.04855439439415932,
-0.0006673780153505504,
-0.018328126519918442,
-0.017330676317214966,
-0.008148802444338799,
-0.009912149980664253,
0.0005905655561946332,
0.03195399418473244,
-0.02516777627170086,
-0.015585141256451607,
0.011728932149708271,
0.015451554208993912,
-0.046844482421875,
0.022763211280107498,
0.017063504084944725,
0.033218614757061005,
0.04028981551527977,
0.01708131469786167,
0.051368627697229385,
-0.029032891616225243,
0.029460370540618896,
-0.101739801466465,
-0.03423387557268143,
-0.06323114782571793,
-0.06351613253355026,
0.046417005360126495,
-0.015335778705775738,
0.006621458567678928,
-0.04082416370511055,
0.04210659861564636,
-0.07516490668058395,
-0.05268668383359909,
-0.051012393087148666,
0.00029750922112725675,
-0.018417183309793472,
-0.023725038394331932,
0.016921009868383408,
-0.07309876382350922,
-0.016876481473445892,
0.00029750922112725675,
0.0026138508692383766,
-0.04538393020629883,
0.05461033433675766,
-0.008460504934191704,
0.0406104251742363,
-0.02155202440917492,
-0.05792329087853432,
0.032719891518354416,
0.005085208918899298,
0.010838352143764496,
-0.017802683636546135,
0.06223369762301445,
0.07438120245933533,
0.035088833421468735,
-0.01927214115858078,
0.041287265717983246,
-0.027857327833771706,
-0.06372986733913422,
-0.059811320155858994,
-0.04395900294184685,
0.017588945105671883,
0.012770909816026688,
-0.006527947727590799,
0.04139413684606552,
-0.025185588747262955,
0.005837748758494854,
-0.044956453144550323,
0.018666546791791916,
-0.07787226885557175,
-0.053826626390218735,
0.011737837456166744,
-0.020055850967764854,
-0.0521879605948925,
0.08428444713354111,
0.027607964351773262,
0.009805280715227127,
-0.012922308407723904,
-0.02078612521290779,
-0.02333318255841732,
-0.02288789302110672,
-0.036389078944921494,
0.05140424892306328,
0.019663995131850243,
-0.001839046715758741,
-0.007436338812112808,
0.019432444125413895,
-0.007921705022454262,
-0.004346027970314026,
-0.007325016427785158,
0.023261936381459236,
0.025149965658783913,
0.010223852470517159,
0.07580612599849701,
-0.000686859420966357,
-0.009716222062706947,
-0.04068167135119438,
-0.06572476774454117,
0.06625911593437195,
-0.07730229943990707,
-0.010277287103235722,
-0.03613971546292305,
0.01514875702559948,
-0.005632915534079075,
-0.020180530846118927,
-0.0019492559367790818,
0.006527947727590799,
0.034643542021512985,
-0.0056195566430687904,
0.007894987240433693,
0.02092861756682396,
0.023083820939064026,
-0.05183172598481178,
0.030012529343366623,
-0.01097193919122219,
0.00016865349607542157,
-0.04228471592068672,
0.0182925034314394,
0.035266947001218796,
0.013545714318752289,
-0.0374755859375,
-0.0037960950285196304,
0.009867620654404163,
0.00023920409148558974,
-0.027376413345336914,
-0.04538393020629883,
-0.02698455937206745,
0.02445531263947487,
0.038793642073869705,
-0.002043880056589842,
0.0336817167699337,
-0.006786216050386429,
0.035979412496089935,
0.06910897046327591,
-0.04064605012536049,
-0.015870125964283943,
-0.00670161098241806,
-0.04224909096956253,
0.0521879605948925,
0.032595209777355194,
-0.006429984234273434,
-0.013144953176379204,
-0.015513895079493523,
-0.025096530094742775,
0.003626885125413537,
-0.05286480113863945,
0.033307675272226334,
-0.04399462789297104,
-0.020269589498639107,
0.04794880002737045,
0.014623315073549747,
0.027109239250421524,
0.011844707652926445,
0.040040455758571625,
-0.08228954672813416,
0.020554574206471443,
-0.03601503372192383,
0.03435855731368065,
-0.025666501373052597,
0.0048091295175254345,
0.017419734969735146,
0.06836088001728058,
0.024526558816432953,
-0.03186493366956711,
-0.03435855731368065,
-0.015932466834783554,
0.025755560025572777,
-0.07523615658283234,
-0.020447704941034317,
-0.008963682688772678,
-0.044457729905843735,
-0.009164063259959221,
-0.02739422582089901,
-0.02377847209572792,
0.03608627989888191,
-0.10002989321947098,
-0.0015095322160050273,
-0.007547661196440458,
-0.011417229659855366,
-0.010660236701369286,
0.03779619559645653,
0.04071729630231857,
0.07594861835241318,
-0.11534785479307175,
-0.058778248727321625,
-0.007195882499217987,
0.11670153588056564,
-0.012432489544153214,
-0.09390269964933395,
0.0014238139847293496,
-0.0009228630224242806,
-0.03711935505270958,
-0.01681414060294628,
-0.050834279507398605,
0.01651134341955185,
0.040931034833192825,
0.03608627989888191,
0.05140424892306328,
-0.007191429380327463,
0.02066144533455372,
0.08998415619134903,
0.043389033526182175,
0.020376458764076233,
0.0597756952047348,
0.046773236244916916,
-0.005147549323737621,
0.010695859789848328,
-0.004152326844632626,
-0.02846292033791542,
-0.022335734218358994,
-0.021747952327132225,
0.015496083535254002,
0.0327911376953125,
-0.057531435042619705,
0.01692991703748703,
0.008157708682119846,
0.001579665346071124,
0.019129646942019463,
0.0036135262344032526,
0.058243900537490845,
0.03400232642889023,
0.031241528689861298,
0.017179278656840324,
0.030137211084365845,
-0.02949599362909794,
-0.05778079852461815,
0.03711935505270958,
0.023368805646896362,
-0.019663995131850243,
0.05233045294880867,
0.04274781793355942,
0.02516777627170086,
-0.05956195667386055,
0.027180487290024757,
-0.015522800385951996,
0.05461033433675766,
-0.07936844229698181,
0.09896119683980942,
0.010927410796284676,
-0.011417229659855366,
0.05603526160120964,
-0.028124500066041946,
0.021979501470923424,
0.014445199631154537,
-0.017678003758192062,
-0.057032711803913116,
0.010535555891692638,
0.030814051628112793,
-0.020144907757639885,
-0.02922881953418255,
0.044101495295763016,
-0.011915953829884529,
-0.004179044160991907,
0.042355962097644806,
0.002362262224778533,
0.0026093979831784964,
0.008264577947556973,
0.000019916280507459305,
-0.03430512174963951,
0.027429848909378052,
-0.0579945370554924,
0.061449985951185226,
0.06832525879144669,
-0.007837099954485893,
0.005383552983403206,
0.04894625023007393,
0.03989796340465546,
-0.01838156022131443,
-0.019165270030498505,
-0.015585141256451607,
0.027892950922250748,
0.03389545530080795,
0.02552400901913643,
0.0024045647587627172,
-0.01197829470038414,
-0.02588023990392685,
-0.014409576542675495,
-0.014872677624225616,
-0.04837627708911896,
-0.03231022506952286,
-0.020501140505075455,
-0.04848314821720123,
0.027269544079899788,
0.03605065867304802,
-0.03854428231716156,
0.026485834270715714,
0.042676571756601334,
-0.0014705694047734141
] |
725,883 | qsm_forward.qsm_forward | generate_phase_offset |
Generate a suitable phase offset.
Parameters
----------
M0 : numpy.ndarray
The initial magnetization.
mask : numpy.ndarray
A binary mask that indicates the internal region of interest.
dims : tuple of int
The dimensions of the input image.
Returns
-------
numpy.ndarray
The phase offset of the input image.
| def generate_phase_offset(M0, mask, dims):
"""
Generate a suitable phase offset.
Parameters
----------
M0 : numpy.ndarray
The initial magnetization.
mask : numpy.ndarray
A binary mask that indicates the internal region of interest.
dims : tuple of int
The dimensions of the input image.
Returns
-------
numpy.ndarray
The phase offset of the input image.
"""
c, w = _center_of_mass(M0)
x, y, z = np.meshgrid(
np.arange(1, dims[1]+1)-c[1],
np.arange(1, dims[0]+1)-c[0],
np.arange(1, dims[2]+1)-c[2]
)
temp = (x/w[1])**2 + (y/w[0])**2 + (z/w[2])**2
max_temp = np.max(temp[mask != 0])
min_temp = np.min(temp[mask != 0])
phase_offset = -temp / (max_temp - min_temp) * np.pi
return phase_offset
| (M0, mask, dims) | [
0.05280458927154541,
0.010809175670146942,
-0.016163930296897888,
-0.020766664296388626,
0.011180656030774117,
-0.0064782570116221905,
0.005236968398094177,
0.019117653369903564,
-0.05613885447382927,
0.057443562895059586,
0.049216631799936295,
-0.002453130204230547,
0.00645560584962368,
0.03383190557360649,
-0.04214944317936897,
0.062444958835840225,
0.06190133094787598,
0.013835382647812366,
-0.004670687485486269,
-0.06092279776930809,
0.06625036895275116,
-0.029084201902151108,
-0.0015380197437480092,
0.029809042811393738,
-0.04196823388338089,
-0.012304157949984074,
-0.037329256534576416,
-0.02895735576748848,
-0.03241846710443497,
-0.1027098149061203,
0.009975609369575977,
0.004956093151122332,
0.017858244478702545,
0.038271550089120865,
-0.007470381446182728,
0.009730976074934006,
0.09553389996290207,
0.050158921629190445,
-0.07070813328027725,
0.010963204316794872,
0.10655146837234497,
-0.025985511019825935,
0.05842209979891777,
-0.004285615868866444,
0.02779761143028736,
-0.014813915826380253,
-0.05247841030359268,
-0.013409539125859737,
0.02375662885606289,
0.08516868948936462,
-0.00217338721267879,
-0.03975747153162956,
0.021437140181660652,
-0.0142159229144454,
-0.015683723613619804,
0.02020491287112236,
0.04095345735549927,
-0.038054097443819046,
-0.01707904040813446,
0.019498193636536598,
-0.03729301318526268,
0.006682117935270071,
0.048383064568042755,
-0.015973659232258797,
0.011289382353425026,
0.00386656797491014,
0.013019937090575695,
-0.006673057563602924,
0.009486342780292034,
0.030370792374014854,
-0.017559247091412544,
0.031077511608600616,
0.04200447350740433,
0.0005603352328762412,
0.0654892846941948,
-0.019443830475211143,
-0.0026479309890419245,
-0.03571648895740509,
0.037546709179878235,
-0.018093816936016083,
-0.015864934772253036,
-0.008906470611691475,
0.00041734924889169633,
0.05168108642101288,
-0.0026773775462061167,
-0.004342244006693363,
0.020241154357790947,
-0.049107905477285385,
-0.0043784864246845245,
-0.06661278754472733,
0.05414554104208946,
-0.028359362855553627,
-0.0015561407199129462,
0.004720520228147507,
-0.002385176485404372,
-0.00518260570243001,
-0.016526350751519203,
0.02301366813480854,
-0.032563433051109314,
0.01374477706849575,
-0.032853368669748306,
0.0640033632516861,
0.025025099515914917,
0.026384172961115837,
0.032237257808446884,
0.0640033632516861,
-0.011570257134735584,
-0.028613056987524033,
0.028812387958168983,
-0.014025652781128883,
0.02384723350405693,
0.028178151696920395,
-0.04809312894940376,
-0.06168387830257416,
0.023593539372086525,
-0.037655435502529144,
0.06527183949947357,
0.06947590410709381,
0.007307292427867651,
-0.00911939237266779,
0.04667969048023224,
-0.04559243097901344,
-0.04990522935986519,
-0.01342765986919403,
0.019226379692554474,
-0.01768609508872032,
0.03419432416558266,
-0.0017690624808892608,
-0.007040007971227169,
-0.07965990900993347,
0.0034293988719582558,
0.024100927636027336,
0.01727837137877941,
-0.03520910069346428,
-0.004000210203230381,
-0.021110963076353073,
0.08132704347372055,
-0.04189574718475342,
-0.0335419662296772,
0.045048803091049194,
0.0048383064568042755,
0.03787288814783096,
-0.03455674275755882,
0.02279621548950672,
-0.012403823435306549,
0.05925566330552101,
0.09031505882740021,
0.025550607591867447,
0.09923058748245239,
-0.007995890453457832,
-0.004684278275817633,
-0.06940342485904694,
-0.0016614689957350492,
0.10256484895944595,
0.028594935312867165,
-0.030135219916701317,
0.02500697784125805,
-0.02948286384344101,
-0.049724020063877106,
-0.0024916373658925295,
-0.009504463523626328,
0.03147617354989052,
-0.06190133094787598,
0.004774882923811674,
0.017260251566767693,
0.010546420700848103,
0.017749518156051636,
0.004353569820523262,
-0.023158635944128036,
-0.01958879828453064,
0.03114999644458294,
0.0003026773047167808,
-0.0029423970263451338,
-0.034303050488233566,
0.10444943606853485,
-0.012376641854643822,
-0.05200726538896561,
0.009830641560256481,
-0.05356566980481148,
-0.027562038972973824,
0.029609711840748787,
0.08625595271587372,
-0.0014236309798434377,
0.005273210350424051,
-0.019824372604489326,
0.05947311595082283,
0.023702265694737434,
0.013681354001164436,
0.034737952053546906,
-0.030986906960606575,
-0.028921112418174744,
0.035553399473428726,
0.03415808081626892,
0.04200447350740433,
0.010926961898803711,
-0.002096372889354825,
0.02551436610519886,
0.025133823975920677,
0.02125593088567257,
0.007986829616129398,
0.019933098927140236,
-0.005141833331435919,
-0.01823878474533558,
0.0007033212459646165,
0.0012922537280246615,
-0.014234044589102268,
0.0522972010076046,
0.03448425978422165,
-0.03018958307802677,
0.02040424384176731,
-0.027779489755630493,
0.003968498669564724,
-0.0033591799437999725,
-0.0069041005335748196,
-0.0023285483475774527,
0.04378033056855202,
0.03158489987254143,
0.023684144020080566,
0.007597228512167931,
0.0766155794262886,
-0.01646292768418789,
0.02948286384344101,
0.008503278717398643,
0.034321170300245285,
0.055232804268598557,
0.02531503513455391,
-0.010954143479466438,
-0.012666577473282814,
-0.010908841155469418,
0.012240733951330185,
0.05131866782903671,
0.03448425978422165,
-0.0739336758852005,
-0.04146084561944008,
0.033179547637701035,
0.07813774794340134,
0.002274185186251998,
-0.07828271389007568,
-0.02759828045964241,
0.012820606119930744,
-0.024517711251974106,
0.011941737495362759,
0.02178144082427025,
0.07741290330886841,
-0.016073325648903847,
0.0026139540132135153,
-0.025858664885163307,
-0.024608315899968147,
-0.007076249923557043,
0.02665598876774311,
-0.05374687910079956,
0.015393787994980812,
-0.005087470170110464,
0.054218027740716934,
0.021419020369648933,
0.03863396868109703,
0.02779761143028736,
0.05117369815707207,
-0.005622039549052715,
0.01104474812746048,
-0.02625732682645321,
-0.09937555342912674,
0.010066214948892593,
-0.04928911477327347,
-0.009984670206904411,
0.0023308133240789175,
0.026384172961115837,
0.009178285486996174,
-0.06320603936910629,
0.020875390619039536,
0.10466688871383667,
0.04001116380095482,
-0.030986906960606575,
-0.0655980110168457,
0.06240871921181679,
0.013790079392492771,
0.0633147656917572,
-0.007157794199883938,
-0.04613606259226799,
0.025170067325234413,
-0.0039843544363975525,
-0.0572623535990715,
-0.029247291386127472,
0.023502934724092484,
-0.035046011209487915,
0.0074477302841842175,
0.03301645815372467,
0.0470421127974987,
0.06820743530988693,
-0.0002395369519945234,
0.029935888946056366,
-0.01730555295944214,
0.014469617046415806,
0.0027679824270308018,
0.046933386474847794,
-0.002214159583672881,
-0.02772512659430504,
-0.019534436985850334,
-0.07371622323989868,
-0.05153612047433853,
0.01130750309675932,
0.027616402134299278,
-0.005078409798443317,
-0.013173965737223625,
-0.007674242835491896,
0.042946767061948776,
-0.03772791847586632,
0.01318302657455206,
0.08908282965421677,
-0.046208545565605164,
-0.013826321810483932,
-0.050448860973119736,
-0.012820606119930744,
-0.03772791847586632,
0.0383077897131443,
0.047948163002729416,
0.02488012984395027,
0.03700307756662369,
0.09082244336605072,
0.02417341247200966,
0.03903263062238693,
0.014460556209087372,
0.02314051426947117,
-0.02738082781434059,
-0.009241709485650063,
-0.04595485329627991,
-0.024427106603980064,
0.031023148447275162,
0.0154572119936347,
-0.009137513116002083,
-0.07610819488763809,
0.024245895445346832,
-0.02893923409283161,
0.02999025210738182,
-0.01709716208279133,
-0.12083081901073456,
0.03040703572332859,
-0.05157236009836197,
-0.05262337997555733,
-0.004661626648157835,
0.03747422620654106,
-0.04276555776596069,
0.017767637968063354,
0.03513661399483681,
-0.018148180097341537,
-0.007080779876559973,
-0.022325070574879646,
0.015873994678258896,
-0.03386814519762993,
0.059436872601509094,
0.08618346601724625,
0.03638696298003197,
0.0270908921957016,
-0.04957905039191246,
0.019335106015205383,
0.011062869802117348,
-0.0013081096112728119,
-0.033777542412281036,
-0.00974003691226244,
0.027779489755630493,
0.012014222331345081,
-0.004679747857153416,
-0.004185950383543968,
-0.06110400706529617,
-0.0312587209045887,
-0.03011709824204445,
-0.034846678376197815,
0.01385350339114666,
0.05128242447972298,
-0.017160585150122643,
-0.030026493594050407,
-0.023394208401441574,
-0.012884030118584633,
0.021400898694992065,
-0.00489719957113266,
0.03392250835895538,
-0.027471434324979782,
-0.0008596148691140115,
-0.03450237959623337,
0.0027815732173621655,
0.007221217732876539,
-0.04591860994696617,
-0.02428213693201542,
0.01967940479516983,
-0.008684488013386726,
-0.001689783064648509,
0.03658629581332207,
0.016299838200211525,
0.010972264222800732,
-0.00979439914226532,
0.042656831443309784,
-0.035988301038742065,
0.04392530024051666,
-0.04367160424590111,
0.0072166877798736095,
0.055885158479213715,
-0.07886258512735367,
0.020223034545779228,
-0.011833012104034424,
-0.0339406281709671,
0.003977559041231871,
-0.03388626500964165,
-0.015248820185661316,
0.02063981629908085,
0.03375941887497902,
-0.10800115019083023,
0.0032617796678096056,
-0.011842072010040283,
0.06621412932872772,
0.04378033056855202,
-0.0466434508562088,
0.04175078123807907,
0.048165611922740936,
-0.03450237959623337,
-0.009241709485650063,
-0.047658223658800125,
-0.05903821066021919,
-0.05809592083096504,
-0.03718428686261177,
0.006369530688971281,
0.0021326150745153427,
-0.03386814519762993,
0.017251189798116684,
-0.042548105120658875,
0.0072166877798736095,
-0.02553248591721058,
-0.01400753203779459,
0.040880970656871796,
-0.04957905039191246,
0.05331197753548622,
-0.0034293988719582558,
0.0335419662296772,
-0.01822066307067871,
-0.004725050181150436,
-0.02821439504623413,
0.08379149436950684,
0.050267647951841354,
-0.018519660457968712,
0.0354265533387661,
0.04465014114975929,
0.05030389130115509,
0.037981610745191574,
-0.01463270653039217,
-0.0126031544059515,
0.01280248537659645,
-0.02603987418115139,
-0.016517290845513344,
-0.024608315899968147,
0.03624199703335762,
0.012974634766578674,
0.02435462176799774,
0.0011223693145439029,
-0.022252585738897324,
-0.03533594682812691,
0.05552273988723755,
-0.020875390619039536,
-0.004446439910680056,
0.01635420136153698,
-0.08161697536706924,
-0.059726811945438385,
-0.014777674339711666,
0.06382215768098831,
0.023557297885417938,
-0.006093185860663652,
0.06356846541166306,
0.018809596076607704,
0.00868901889771223,
0.012150129303336143,
-0.012675638310611248,
0.0023783810902386904,
-0.002031816868111491,
-0.041098423302173615,
-0.016607895493507385,
0.012929332442581654,
0.011497773230075836,
-0.03964874520897865,
-0.01484109740704298,
0.053275734186172485,
-0.027580158784985542,
0.000303526729112491,
0.012041402980685234,
-0.02094787359237671,
0.00044538016663864255,
0.019135775044560432,
-0.04280179738998413,
0.037329256534576416,
-0.029138565063476562,
0.018184421584010124,
-0.006799904629588127,
-0.06722890585660934,
0.01623641513288021,
-0.009305132552981377,
-0.036405086517333984,
-0.02011430822312832,
-0.00011714942229446024,
-0.03845275938510895,
0.04675217717885971,
0.028268758207559586,
0.04204071685671806,
0.002591302851215005,
-0.004124792292714119,
-0.00008989714115159586,
0.010075274854898453,
-0.04080848768353462,
-0.07994984090328217,
-0.0005099362460896373,
-0.027018409222364426,
-0.03772791847586632,
0.005060288589447737,
0.018256906419992447,
0.017541127279400826,
-0.018592143431305885,
-0.08545862883329391,
0.003685357980430126,
0.009658492170274258,
0.08661837130784988,
-0.028613056987524033,
0.0019570677541196346,
-0.011851132847368717,
-0.00030862324638292193,
-0.050267647951841354,
-0.005921036005020142,
-0.08096461743116379,
-0.028504330664873123,
-0.046099819242954254,
0.03298021852970123,
-0.052877072244882584,
-0.04465014114975929,
-0.008471566252410412,
0.009033317677676678,
-0.007814680226147175,
-0.03428492695093155,
0.004783943761140108,
0.055160317569971085,
0.01862838678061962,
0.00044198246905580163,
0.00994842778891325,
-0.1126401275396347,
-0.05371063947677612,
0.008933652192354202,
0.0013420864706858993,
0.008598413318395615,
0.01603708416223526,
-0.05291331559419632,
0.049216631799936295,
0.023267362266778946,
-0.005241498816758394,
-0.006210972089320421,
0.025278791785240173,
0.010999445803463459,
-0.036296360194683075,
-0.02071230113506317,
-0.037764161825180054,
-0.02729022316634655,
0.02571369707584381,
0.02167271450161934,
0.0034316640812903643,
-0.04533873870968819,
-0.05845833942294121,
0.02040424384176731,
0.003889219369739294,
-0.0006489582592621446,
-0.02314051426947117,
-0.005200726445764303,
-0.09995542466640472,
-0.01687064953148365,
-0.016580713912844658,
-0.009187346324324608,
0.0012877234257757664,
0.06277114152908325,
-0.007058128714561462,
-0.04530249536037445,
-0.002086180029436946,
0.010537360794842243,
-0.011434350162744522,
-0.013246449641883373,
0.038706451654434204,
-0.08690831065177917,
0.08669085800647736,
-0.0057760681957006454,
0.0477307103574276,
-0.03613327071070671,
0.01645386591553688,
-0.023285482078790665,
-0.015167275443673134,
-0.016100507229566574,
-0.018374692648649216,
-0.007248399313539267,
0.03486480191349983,
-0.03517285734415054,
-0.059219423681497574,
-0.02102035842835903,
-0.007406957913190126,
0.01244912575930357,
-0.03961250185966492,
-0.015076670795679092,
-0.006654936820268631,
0.005680933129042387,
0.004312797449529171,
0.007529274560511112,
0.017577368766069412,
0.018293147906661034,
0.005694523919373751,
0.03417620435357094,
-0.016943132504820824,
-0.02250627987086773,
-0.014668948017060757,
0.011144413612782955,
-0.04729580506682396,
-0.024300258606672287,
-0.004815655294805765,
-0.02333984524011612,
0.02250627987086773,
0.010537360794842243,
-0.020802905783057213,
-0.055885158479213715,
-0.00004965578409610316,
0.029609711840748787,
0.05095624551177025,
0.06907724589109421,
-0.05323949456214905,
-0.013491082936525345,
-0.030153341591358185,
-0.022216344252228737,
0.007234808523207903,
-0.0015957803698256612,
0.033705055713653564,
-0.039105113595724106,
0.00630157720297575,
-0.0026864379178732634,
-0.004154238849878311,
0.061720121651887894,
-0.027054650709033012,
-0.035553399473428726,
-0.026819078251719475,
0.0412796325981617,
-0.03834403306245804,
0.005218847654759884,
-0.009558826684951782,
-0.004564226604998112,
-0.02573181688785553,
0.005218847654759884,
-0.02239755354821682,
0.012349460273981094,
-0.014542100951075554,
0.0026728473603725433,
-0.022325070574879646,
0.026492899283766747,
0.005005925893783569,
0.016644136980175972,
0.016825346276164055,
-0.047658223658800125,
0.03841651603579521,
0.014623645693063736,
-0.0016909156693145633,
-0.032762765884399414,
-0.008906470611691475,
0.008104616776108742,
0.02970031648874283,
-0.04320045933127403,
-0.021636471152305603,
-0.01886395923793316,
-0.05987177789211273,
-0.0416782945394516,
-0.024807646870613098,
-0.08016729354858398,
0.026076115667819977,
-0.04762198403477669,
-0.01762267015874386,
-0.033487603068351746,
0.04135211929678917,
-0.018900200724601746,
-0.03241846710443497,
0.0030035555828362703,
0.04131587594747543,
-0.017767637968063354,
0.06490941345691681,
-0.009287011809647083,
0.00926889106631279,
0.040482308715581894,
0.017948849126696587,
-0.015964599326252937,
0.0057805986143648624,
0.06041540950536728,
0.020041823387145996,
0.031294964253902435,
0.03975747153162956,
-0.010800114832818508,
-0.037039320915937424,
0.024862010031938553,
0.02301366813480854,
-0.03917759656906128,
0.05363815650343895,
0.052659619599580765,
0.05019516497850418,
0.022995546460151672,
-0.01405283436179161,
0.030153341591358185,
-0.02000558190047741,
0.010075274854898453,
0.010310848243534565,
-0.047223322093486786,
-0.005173544865101576,
-0.03303458169102669,
-0.10169504582881927,
-0.03303458169102669,
-0.006410303059965372,
0.025133823975920677,
-0.058277130126953125,
0.057443562895059586,
0.017749518156051636,
0.016426684334874153,
0.031095633283257484,
-0.027217740193009377,
0.059219423681497574,
-0.0443602055311203,
-0.04965153709053993,
0.04280179738998413,
0.012159190140664577,
-0.0439615435898304,
-0.010627965442836285,
-0.021002236753702164,
-0.00708531029522419,
0.030479518696665764,
-0.051391150802373886,
-0.03310706466436386,
-0.05958184227347374,
0.01772233657538891,
-0.06704769283533096,
0.0010045828530564904,
-0.01727837137877941,
-0.015366606414318085,
-0.017631731927394867,
-0.0034679060336202383,
0.027543917298316956,
0.00834018923342228,
-0.032436586916446686,
-0.04465014114975929,
-0.06432954221963882,
0.04214944317936897,
0.0029967601876705885,
0.04407026618719101,
0.017033739015460014,
0.021183447912335396,
0.04497631639242172,
0.004247108940035105,
0.02738082781434059,
-0.024318380281329155,
0.031294964253902435,
0.006392182316631079,
0.012222613207995892,
0.0031530538108199835,
0.005975399166345596,
-0.00849874783307314,
0.007234808523207903,
-0.02279621548950672,
0.010582663118839264,
-0.011923616752028465,
-0.005993520375341177,
-0.016580713912844658,
-0.05617509409785271,
-0.039829954504966736,
0.0030647139064967632,
0.01886395923793316,
0.017731396481394768,
0.006940342485904694,
-0.046933386474847794,
-0.025768060237169266
] |
725,884 | qsm_forward.qsm_forward | generate_shimmed_field |
Simulate field shimming by fitting the field with second- and third-order Legendre polynomials.
Parameters
----------
field : numpy.ndarray
3D array representing the magnetic field to fit.
mask : numpy.ndarray
3D binary array. Must be the same shape as `field`. A True value at a coordinate will
include that point in the fit.
order : int, optional
The order of the polynomial to fit. Must be 0, 1, or 2. Default is 2.
Returns
-------
FIT3D : numpy.ndarray
3D array representing the fitted field.
Residuals : numpy.ndarray
3D array representing the residuals of the fit.
b : numpy.ndarray
1D array representing the coefficients of the fitted polynomial.
Raises
------
ValueError
If `field` and `mask` shapes are not the same.
| def generate_shimmed_field(field, mask, order=2):
"""
Simulate field shimming by fitting the field with second- and third-order Legendre polynomials.
Parameters
----------
field : numpy.ndarray
3D array representing the magnetic field to fit.
mask : numpy.ndarray
3D binary array. Must be the same shape as `field`. A True value at a coordinate will
include that point in the fit.
order : int, optional
The order of the polynomial to fit. Must be 0, 1, or 2. Default is 2.
Returns
-------
FIT3D : numpy.ndarray
3D array representing the fitted field.
Residuals : numpy.ndarray
3D array representing the residuals of the fit.
b : numpy.ndarray
1D array representing the coefficients of the fitted polynomial.
Raises
------
ValueError
If `field` and `mask` shapes are not the same.
"""
dim = field.shape
## for volume fitting
#mask = np.ones(mask.shape)
indices = np.nonzero(mask)
x1, y1, z1 = indices
R = field[indices]
b = None
if len(indices[0]) > (3*order)**2:
model = _create_model(x1, y1, z1, dim, order)
b = np.linalg.pinv(model) @ R
temp = R - model @ b
del model, R
indices = np.meshgrid(*[range(d) for d in dim], indexing='ij')
x1, y1, z1 = [ind.flatten() for ind in indices]
model = _create_model(x1, y1, z1, dim, order)
Fit = model @ b
del model
FIT3D = Fit.reshape(dim)
Residuals = (field-FIT3D)
else:
FIT3D = np.zeros_like(field)
Residuals = (field-FIT3D) * mask
return FIT3D, Residuals, b
| (field, mask, order=2) | [
0.04502508044242859,
-0.00546340923756361,
-0.008240871131420135,
0.056153230369091034,
0.0024480100255459547,
-0.03744769096374512,
-0.04063238948583603,
-0.031188104301691055,
-0.023793742060661316,
-0.020206376910209656,
0.0910751223564148,
0.038289621472358704,
-0.03640442341566086,
0.016628164798021317,
-0.04989364743232727,
-0.008913502097129822,
-0.004777051508426666,
0.03880210220813751,
-0.052492655813694,
-0.03301839157938957,
0.0007870237459428608,
-0.03181040287017822,
0.04978382959961891,
0.11633309721946716,
0.049564193934202194,
0.018138153478503227,
-0.025861967355012894,
-0.0018314317567273974,
0.031371135264635086,
-0.003857331583276391,
0.011183058843016624,
-0.011832810938358307,
-0.005120230372995138,
0.0439269095659256,
-0.022878598421812057,
-0.05930132791399956,
0.03365899249911308,
0.052456051111221313,
-0.07225976139307022,
0.003502713283523917,
0.04293855279684067,
-0.0024869036860764027,
0.051540907472372055,
-0.051248058676719666,
0.024653976783156395,
-0.0455375611782074,
0.04502508044242859,
0.0011227672221139073,
-0.02110321819782257,
0.012985892593860626,
0.047441061586141586,
-0.05468900129199028,
0.030218051746487617,
-0.0492713488638401,
-0.030108235776424408,
0.01879705674946308,
0.03173718973994255,
0.04542774334549904,
0.0076277246698737144,
-0.017122343182563782,
-0.04583040624856949,
0.0030428534373641014,
-0.029632359743118286,
-0.002235239138826728,
-0.03283536434173584,
0.005060745868831873,
-0.021817030385136604,
-0.026557477191090584,
-0.015017511323094368,
0.005870648194104433,
-0.03208494558930397,
0.027381105348467827,
0.03924136981368065,
-0.006442613434046507,
-0.0018005457241088152,
0.009055349044501781,
0.032579123973846436,
-0.0747123509645462,
0.010139795020222664,
-0.042975157499313354,
0.026850322261452675,
0.024031680077314377,
-0.005115654319524765,
0.019986743107438087,
-0.0557139627635479,
-0.03464734926819801,
0.03353087231516838,
0.016271259635686874,
0.10967084765434265,
-0.09458927810192108,
-0.03450092673301697,
-0.03640442341566086,
-0.012720500119030476,
0.05849599838256836,
-0.03711823746562004,
-0.03380541503429413,
0.00443615997210145,
-0.025642333552241325,
-0.0733945444226265,
0.03479377180337906,
-0.007087789475917816,
0.02641105279326439,
-0.06065573915839195,
0.05886205658316612,
0.053737252950668335,
0.061021797358989716,
-0.034244686365127563,
-0.011567419394850731,
0.005326137412339449,
-0.02046261727809906,
-0.02132285386323929,
0.04293855279684067,
-0.05681213364005089,
0.024580765515565872,
-0.008808259852230549,
-0.010094037279486656,
0.0009454580722376704,
0.02469058334827423,
0.04853923246264458,
-0.009544950909912586,
0.050442732870578766,
0.014660605229437351,
-0.06988038867712021,
-0.012107353657484055,
0.015850292518734932,
0.02329956367611885,
0.054249729961156845,
0.02426961623132229,
0.017067434266209602,
-0.04487865790724754,
-0.016490893438458443,
0.03971724584698677,
-0.03235948830842972,
-0.005115654319524765,
-0.02399507351219654,
0.031938523054122925,
0.03149925544857979,
-0.04886868596076965,
0.01531950943171978,
0.014230487868189812,
-0.03230458125472069,
0.04952758923172951,
0.02809491753578186,
0.04454920440912247,
-0.002653917297720909,
-0.0037086207885295153,
0.07412666082382202,
-0.01297674048691988,
0.024324525147676468,
0.004454463254660368,
0.011960931122303009,
-0.032286278903484344,
0.04114487022161484,
0.05750764533877373,
0.022183088585734367,
0.011219664476811886,
0.012656440027058125,
-0.0498204343020916,
-0.011173907667398453,
0.03913155570626259,
0.0016770012443885207,
-0.008570322766900063,
-0.007183879613876343,
0.031243013218045235,
-0.008373566903173923,
0.02399507351219654,
0.03993688151240349,
-0.0661466047167778,
-0.006003343965858221,
0.042169831693172455,
-0.02683201991021633,
-0.015109025873243809,
-0.04202340915799141,
-0.00933446828275919,
-0.013736310414969921,
0.07709172368049622,
-0.05776388570666313,
-0.04352424666285515,
-0.037886958569288254,
-0.0006566157680936158,
-0.014486728236079216,
0.01361734140664339,
0.029906904324889183,
0.04271891713142395,
-0.005637286696583033,
0.03508661687374115,
0.010533306747674942,
-0.02635614573955536,
0.06310832500457764,
0.001135350437834859,
-0.02214648202061653,
0.03704502433538437,
0.002640190301463008,
0.004516235087066889,
0.0029604905284941196,
-0.019382748752832413,
0.04249928519129753,
-0.03484867885708809,
-0.008217992261052132,
0.038069985806941986,
-0.015099874697625637,
-0.014971754513680935,
0.005765406880527735,
0.03774053603410721,
-0.026777110993862152,
0.016097381711006165,
0.07379720360040665,
-0.012464260682463646,
0.004905171226710081,
0.03971724584698677,
0.0396440364420414,
-0.00403120880946517,
-0.04114487022161484,
0.012006687931716442,
0.01688440516591072,
-0.014541637152433395,
-0.011704690754413605,
0.05618983507156372,
0.02092019096016884,
0.023921862244606018,
-0.07482216507196426,
0.03138943761587143,
-0.05117484927177429,
0.04572059214115143,
-0.040485966950654984,
0.03329293429851532,
0.004703839775174856,
0.03267063945531845,
0.008048690855503082,
-0.041474323719739914,
-0.008483383804559708,
0.03572721779346466,
-0.0506257601082325,
-0.08448608964681625,
0.008204265497624874,
0.01919971965253353,
0.012345291674137115,
-0.03865567967295647,
0.041254688054323196,
0.0037429386284202337,
0.03287196904420853,
0.0029627785552293062,
0.004651219118386507,
0.014349456876516342,
0.03688029944896698,
-0.005646437872201204,
0.0007658610702492297,
-0.026246327906847,
0.006021646782755852,
-0.010707183741033077,
-0.08287543058395386,
0.0388387069106102,
0.0330733023583889,
0.08228974044322968,
0.06380383670330048,
-0.012903529219329357,
0.10315502434968948,
0.003049717051908374,
0.03283536434173584,
0.007147273980081081,
-0.029394423589110374,
-0.06812331080436707,
0.04063238948583603,
-0.08324149250984192,
0.028881942853331566,
-0.02930290810763836,
-0.005920981056988239,
0.06420649588108063,
0.018412696197628975,
0.019638989120721817,
0.0023061626125127077,
0.04637949541211128,
-0.027307894080877304,
-0.033219724893569946,
0.010963424108922482,
0.011951779946684837,
0.01040518656373024,
0.06643944978713989,
0.04612325504422188,
-0.005170563235878944,
-0.0249102171510458,
-0.004232540726661682,
0.010039129294455051,
0.008478808216750622,
-0.026850322261452675,
0.037886958569288254,
-0.012766257859766483,
0.056226443499326706,
0.03728296235203743,
-0.041254688054323196,
0.012995043769478798,
0.020078258588910103,
0.015456780791282654,
-0.037136539816856384,
0.0011513654608279467,
0.011832810938358307,
-0.038765497505664825,
-0.00422110129147768,
0.013663099147379398,
-0.036495938897132874,
-0.00815393216907978,
0.025074943900108337,
0.027069957926869392,
0.0380333811044693,
0.0295957550406456,
0.0013955944450572133,
0.0002430851018289104,
-0.02756413444876671,
0.015621506609022617,
0.016262106597423553,
-0.028314553201198578,
0.0034798348788172007,
-0.037886958569288254,
-0.026374448090791702,
0.0781898945569992,
0.018174758180975914,
0.05157751217484474,
0.05439615622162819,
0.04491526260972023,
-0.002917021280154586,
0.06457255780696869,
-0.009009592235088348,
-0.020828675478696823,
0.05179714784026146,
-0.026173116639256477,
-0.06512164324522018,
0.01606992818415165,
0.013351949863135815,
0.0069367908872663975,
-0.012262928299605846,
-0.021030006930232048,
0.05340779945254326,
0.00221922411583364,
0.05051594600081444,
-0.01352582685649395,
-0.011036635376513004,
0.08002018183469772,
-0.07870237529277802,
0.00046872528037056327,
-0.034299593418836594,
0.025770453736186028,
-0.05816654860973358,
-0.0902697965502739,
0.0024869036860764027,
-0.009490042924880981,
-0.0009506057249382138,
0.03109659068286419,
0.03186530992388725,
0.005600680597126484,
0.06687872111797333,
0.05501845106482506,
-0.07485876977443695,
0.05706837400794029,
0.013809521682560444,
0.0346839539706707,
0.008574898354709148,
-0.06548769772052765,
-0.032817061990499496,
0.0060582528822124004,
0.07079553604125977,
0.017936820164322853,
-0.06490200757980347,
-0.004969231318682432,
0.00372234801761806,
0.006081131286919117,
-0.0776774138212204,
-0.06416989117860794,
0.060216471552848816,
0.04220643639564514,
-0.012354442849755287,
0.036569152027368546,
-0.058349575847387314,
-0.032817061990499496,
-0.012226322665810585,
0.0396440364420414,
-0.013891885057091713,
-0.019437657669186592,
0.008570322766900063,
-0.015987563878297806,
-0.02167060784995556,
0.012107353657484055,
-0.018513360992074013,
-0.040376149117946625,
-0.03979045897722244,
0.006977972574532032,
0.043560851365327835,
0.0648287981748581,
0.0465991273522377,
-0.0016552666202187538,
-0.05011327937245369,
0.029449330642819405,
-0.009563254192471504,
0.1074012890458107,
-0.04085202515125275,
-0.013351949863135815,
0.049966856837272644,
-0.06691532582044601,
0.03382372111082077,
-0.043158188462257385,
-0.01147590484470129,
-0.02445264533162117,
-0.05051594600081444,
-0.056226443499326706,
0.002007596893236041,
0.020718857645988464,
-0.037484295666217804,
-0.016966767609119415,
-0.0015328660374507308,
0.049051713198423386,
0.0024274191819131374,
-0.01248256303369999,
0.05688534677028656,
0.03245100378990173,
-0.06504842638969421,
-0.013946793042123318,
0.0321398563683033,
-0.019401051104068756,
-0.03215815871953964,
-0.009032470174133778,
0.08280222117900848,
0.03671557456254959,
-0.03799677640199661,
-0.014239639043807983,
0.02739940956234932,
-0.019455960020422935,
-0.009178893640637398,
-0.030858652666211128,
0.06109500676393509,
-0.005646437872201204,
0.07467574626207352,
-0.022695569321513176,
0.012208020314574242,
-0.035178132355213165,
-0.026630688458681107,
-0.006785792298614979,
-0.0380333811044693,
0.017122343182563782,
0.0029376118909567595,
-0.037484295666217804,
-0.02983369119465351,
0.07489538192749023,
0.005481712054461241,
-0.013745461590588093,
-0.09173402935266495,
-0.019913531839847565,
0.028076615184545517,
0.012336140498518944,
0.05527469143271446,
-0.013397706672549248,
0.015356115065515041,
0.07672566920518875,
0.036788783967494965,
0.04733124375343323,
0.0011244830675423145,
0.0305292010307312,
-0.008034964092075825,
0.03651424124836922,
-0.07211334258317947,
-0.025532515719532967,
-0.01355328131467104,
0.011622327379882336,
0.02763734571635723,
-0.0033173966221511364,
-0.017186403274536133,
0.010817001573741436,
0.02439773641526699,
-0.00835068803280592,
-0.018925176933407784,
-0.01052415557205677,
-0.01606077514588833,
-0.008034964092075825,
-0.04440278187394142,
-0.0000610215101914946,
-0.025715544819831848,
0.04143771529197693,
0.02879042737185955,
-0.008341536857187748,
0.06929469853639603,
-0.03774053603410721,
-0.0666956901550293,
0.02086528204381466,
-0.05487202852964401,
0.0028483853675425053,
-0.011393541470170021,
0.011256270110607147,
-0.007723814807832241,
-0.01572217233479023,
0.047660697251558304,
0.019968440756201744,
-0.017735488712787628,
-0.035873640328645706,
-0.0029078698717057705,
0.011210513301193714,
0.04681876301765442,
-0.005586953833699226,
0.011183058843016624,
-0.013278738595545292,
0.03865567967295647,
-0.018119849264621735,
-0.026557477191090584,
-0.02284199185669422,
-0.006373977288603783,
-0.05227302014827728,
0.007874813862144947,
0.011539964936673641,
-0.05069897323846817,
0.00684985239058733,
-0.010643123649060726,
0.028534187003970146,
0.013809521682560444,
-0.0688188225030899,
-0.00015743335825391114,
-0.02070055529475212,
-0.00543595477938652,
-0.03351256996393204,
0.03755750507116318,
-0.06929469853639603,
0.03591024875640869,
-0.043560851365327835,
-0.007348605897277594,
0.0008093304350040853,
0.019455960020422935,
0.004612325225025415,
-0.0070694866590201855,
-0.002704250393435359,
0.002406828571110964,
-0.0036994693800807,
-0.05637286603450775,
0.055238086730241776,
-0.006904760841280222,
0.011887719854712486,
-0.016280410811305046,
0.0463428869843483,
0.03799677640199661,
0.06116821989417076,
-0.0198220182210207,
-0.005394773557782173,
-0.0057837096974253654,
-0.005550347734242678,
-0.05538450926542282,
0.00988355465233326,
0.034482624381780624,
-0.016033321619033813,
-0.05018649250268936,
0.04293855279684067,
0.014605697244405746,
0.012683894485235214,
-0.02855249121785164,
0.012445957399904728,
-0.03492189198732376,
-0.0270516537129879,
-0.006913912482559681,
0.06812331080436707,
-0.05267568305134773,
0.041767168790102005,
0.0027797496877610683,
-0.007257091347128153,
-0.004605461843311787,
-0.026173116639256477,
-0.05073557794094086,
-0.021542487666010857,
0.001810841029509902,
0.005655589513480663,
-0.00007006570376688614,
-0.06442613154649734,
-0.022219695150852203,
0.0017948260065168142,
0.03261572867631912,
0.005513742100447416,
-0.027436014264822006,
0.0001509987487224862,
0.03451922908425331,
0.07870237529277802,
0.08243616670370102,
0.0073440298438072205,
0.001949256518855691,
-0.00006255866901483387,
-0.07870237529277802,
0.0141298221424222,
-0.05717819184064865,
0.00782905612140894,
-0.04637949541211128,
0.010560761205852032,
-0.049857042729854584,
-0.028113221749663353,
0.0015740474918857217,
0.04052257165312767,
0.03792356327176094,
-0.0241048913449049,
0.030712230131030083,
0.008103599771857262,
0.04828299209475517,
-0.023775439709424973,
-0.00465350691229105,
0.006524976342916489,
0.008643534034490585,
-0.052346233278512955,
0.008986713364720345,
-0.0018062653252854943,
-0.01688440516591072,
-0.039680641144514084,
-0.009156014770269394,
-0.018522512167692184,
-0.04872226342558861,
-0.04989364743232727,
-0.04301176592707634,
-0.0455375611782074,
-0.024031680077314377,
0.05289531871676445,
-0.07273563742637634,
-0.029797086492180824,
-0.028406066820025444,
-0.003386032534763217,
-0.037429384887218475,
-0.013873581774532795,
-0.027015049010515213,
-0.043158188462257385,
-0.02531288005411625,
0.07892201095819473,
-0.025422697886824608,
-0.0683063417673111,
0.004561992362141609,
0.02126794494688511,
-0.011201361194252968,
0.00448191724717617,
-0.016161441802978516,
0.02774716354906559,
-0.023555804044008255,
0.007165576796978712,
-0.011494208127260208,
-0.005184290464967489,
0.038179803639650345,
0.010762092657387257,
-0.035287950187921524,
0.01664646714925766,
-0.02046261727809906,
-0.05212659761309624,
0.022622358053922653,
-0.04301176592707634,
0.022970112040638924,
-0.021890243515372276,
-0.032286278903484344,
-0.042279649525880814,
-0.009590708650648594,
-0.0573246143758297,
-0.008890623226761818,
0.0338786281645298,
-0.09261256456375122,
-0.0008705306681804359,
-0.0557139627635479,
-0.07010002434253693,
0.0362946093082428,
-0.05769067257642746,
-0.010002522729337215,
0.0677572563290596,
0.002157451817765832,
0.013708855956792831,
-0.0447322353720665,
-0.008753351867198944,
-0.028369462117552757,
0.014230487868189812,
0.005051594227552414,
0.024727188050746918,
-0.08653601258993149,
-0.006250433158129454,
0.016326166689395905,
0.0838271826505661,
-0.020535830408334732,
0.017717186361551285,
-0.0002433710906188935,
-0.02890024520456791,
-0.0506257601082325,
-0.028369462117552757,
-0.029577450826764107,
0.024013375863432884,
0.04085202515125275,
0.009663919918239117,
0.021176429465413094,
-0.00041639048140496016,
0.024306222796440125,
0.07972733676433563,
-0.012885226868093014,
-0.005554923787713051,
0.03658745437860489,
0.06124143302440643,
-0.017643975093960762,
0.015420175157487392,
0.03382372111082077,
-0.05190696194767952,
0.004472766071557999,
0.010176400654017925,
-0.011576570570468903,
0.036221396178007126,
-0.0038253015372902155,
0.03285366669297218,
0.002926172688603401,
0.026630688458681107,
0.013406858779489994,
-0.0054908636957407,
0.026209721341729164,
0.001094168983399868,
-0.03699011728167534,
-0.009480890817940235,
0.04389030113816261,
-0.07020983844995499,
0.043560851365327835,
-0.053224772214889526,
-0.0008264893549494445,
-0.05311495438218117,
-0.01825712062418461,
-0.005339864641427994,
0.06852597743272781,
0.02860739827156067,
-0.034482624381780624,
0.019986743107438087,
-0.02935781702399254,
-0.027820374816656113,
0.035068314522504807,
0.025129852816462517,
0.01987692527472973,
0.01947426237165928,
0.054030098021030426,
-0.007980055175721645,
0.00020033073087688535,
-0.015804534777998924,
-0.029412725940346718,
-0.06036289408802986,
-0.014971754513680935,
-0.07657924294471741,
0.010661426931619644,
0.017021676525473595,
0.04788032919168472,
-0.033439360558986664,
0.01976710930466652,
0.04169395565986633,
-0.01763482391834259,
0.0037200599908828735,
-0.004440736025571823,
-0.03686199709773064,
0.028515884652733803,
-0.04173056408762932,
-0.0249102171510458,
0.015054117888212204,
-0.02324465475976467,
0.014294547960162163,
0.05736122280359268,
0.013104860670864582,
0.007545361761003733,
-0.014925997704267502,
-0.009837796911597252,
0.024123193696141243,
0.014450122602283955,
0.012208020314574242,
-0.015218843705952168,
0.023720530793070793,
-0.05099181830883026,
0.0017959699034690857,
0.020590737462043762,
0.015584900975227356,
0.00262417527846992,
-0.08485214412212372,
-0.03682539239525795,
0.024251313880085945,
0.037667322903871536,
0.014990057796239853,
-0.033219724893569946,
-0.008346112444996834,
-0.014184731058776379
] |
725,885 | qsm_forward.qsm_forward | generate_signal |
Compute the MRI signal based on the given parameters.
Parameters
----------
field : numpy.ndarray
The magnetic field distribution.
B0 : float, optional
The main magnetic field strength. Default is 3.
TR : float, optional
The repetition time. Default is 1.
TE : float, optional
The echo time. Default is 30e-3.
flip_angle : float, optional
The flip angle in degrees. Default is 90.
phase_offset : float, optional
The phase offset. Default is 0.
R1 : float or numpy.ndarray, optional
The longitudinal relaxation rate. Can be a single value or a 3D numpy array. Default is 1.
R2star : float or numpy.ndarray, optional
The effective transverse relaxation rate. Can be a single value or a 3D numpy array. Default is 50.
M0 : float or numpy.ndarray, optional
The equilibrium magnetization. Can be a single value or a 3D numpy array. Default is 1.
Returns
-------
numpy.ndarray
The computed MRI signal.
| def generate_signal(field, B0=3, TR=1, TE=30e-3, flip_angle=90, phase_offset=0, R1=1, R2star=50, M0=1):
"""
Compute the MRI signal based on the given parameters.
Parameters
----------
field : numpy.ndarray
The magnetic field distribution.
B0 : float, optional
The main magnetic field strength. Default is 3.
TR : float, optional
The repetition time. Default is 1.
TE : float, optional
The echo time. Default is 30e-3.
flip_angle : float, optional
The flip angle in degrees. Default is 90.
phase_offset : float, optional
The phase offset. Default is 0.
R1 : float or numpy.ndarray, optional
The longitudinal relaxation rate. Can be a single value or a 3D numpy array. Default is 1.
R2star : float or numpy.ndarray, optional
The effective transverse relaxation rate. Can be a single value or a 3D numpy array. Default is 50.
M0 : float or numpy.ndarray, optional
The equilibrium magnetization. Can be a single value or a 3D numpy array. Default is 1.
Returns
-------
numpy.ndarray
The computed MRI signal.
"""
sigHR = M0 * np.exp(1j * (2 * np.pi * field * B0 * 42.58 * TE + phase_offset)) * np.exp(-TE * R2star) \
* (1 - np.exp(-TR * R1)) * np.sin(np.deg2rad(flip_angle)) / (1 - np.cos(np.deg2rad(flip_angle)) * np.exp(-TR * R1))
sigHR[np.isnan(sigHR)]
return sigHR
| (field, B0=3, TR=1, TE=0.03, flip_angle=90, phase_offset=0, R1=1, R2star=50, M0=1) | [
0.046992991119623184,
-0.006483660079538822,
0.0017067015869542956,
0.03897419944405556,
-0.0008573014638386667,
-0.05129135027527809,
-0.06978513300418854,
0.0024923260789364576,
-0.04717359319329262,
-0.02288244292140007,
0.07054366916418076,
0.12295475602149963,
0.01504425797611475,
0.07621461153030396,
-0.035795580595731735,
0.03052196465432644,
-0.03608454763889313,
0.029456404969096184,
-0.011269648559391499,
-0.016750959679484367,
0.013364647515118122,
0.018818868324160576,
-0.004627960734069347,
0.10568907856941223,
0.04608997330069542,
0.0550478994846344,
-0.03489256650209427,
-0.019848307594656944,
-0.003928122576326132,
0.009174649603664875,
-0.002201103139668703,
-0.040166184306144714,
0.01422251295298338,
-0.03734876960515976,
0.002810639562085271,
-0.03980497643351555,
-0.0010824912460520864,
0.029727309942245483,
-0.13010664284229279,
0.0035172500647604465,
0.059996429830789566,
-0.039516013115644455,
0.07379452884197235,
-0.020823566243052483,
-0.0053052231669425964,
-0.03259890154004097,
0.011919820681214333,
0.031443040817976,
-0.01966770365834236,
0.01889110915362835,
0.07830961048603058,
-0.01294022984802723,
-0.01141413114964962,
-0.034928686916828156,
-0.015748610720038414,
0.04161100834608078,
-0.03756549581885338,
-0.0012066561030223966,
0.026909897103905678,
0.0391186848282814,
0.0000066712123043544125,
0.02506774477660656,
0.017112167552113533,
0.010402752086520195,
0.0280657596886158,
0.043778251856565475,
0.030612265691161156,
-0.015062319114804268,
0.04117756336927414,
0.0275239497423172,
0.02369515784084797,
0.00722413370385766,
0.0026864747051149607,
0.01562218926846981,
0.05580643191933632,
-0.011450251564383507,
-0.03261696174740791,
-0.032075151801109314,
-0.015613159164786339,
-0.011513463221490383,
0.059237897396087646,
0.04493411257863045,
0.028535328805446625,
-0.019920548424124718,
-0.04031066596508026,
-0.017003804445266724,
-0.012795746326446533,
-0.04298359528183937,
0.004612158052623272,
-0.08423339575529099,
-0.057648587971925735,
-0.07133831828832626,
-0.009057257324457169,
0.03599424660205841,
-0.006492690183222294,
-0.05566195026040077,
-0.01950516179203987,
-0.01258805301040411,
-0.008483842015266418,
-0.0007297503761947155,
-0.017988093197345734,
0.023568736389279366,
-0.058515481650829315,
0.005865093320608139,
0.04811273142695427,
0.07700926810503006,
-0.02703632041811943,
0.01790682226419449,
0.04840169474482536,
-0.044645145535469055,
-0.0018274800386279821,
0.041213683784008026,
-0.04887126386165619,
-0.03133467957377434,
-0.056817810982465744,
0.011829518713057041,
0.010086696594953537,
0.03649993613362312,
0.034224335104227066,
-0.027975456789135933,
0.024598175659775734,
-0.035091228783130646,
-0.08098253607749939,
0.00482210936024785,
0.039516013115644455,
-0.017951972782611847,
0.03272532671689987,
-0.015143590047955513,
0.03846851363778114,
-0.01721149869263172,
-0.08076581358909607,
0.04265850782394409,
0.038143426179885864,
-0.016010485589504242,
-0.08524477481842041,
0.016046607866883278,
0.024652356281876564,
-0.018854988738894463,
0.02916743978857994,
0.03850463405251503,
0.0038920019287616014,
0.03668053820729256,
0.0383240282535553,
0.013039560988545418,
0.0014911063481122255,
0.02134731411933899,
0.04215281829237938,
0.01660647802054882,
0.008203906938433647,
0.006515265442430973,
-0.028264423832297325,
0.004422524478286505,
0.04554816335439682,
0.06183858588337898,
0.04739031568169594,
0.0007986053824424744,
0.03341161832213402,
0.039299286901950836,
-0.09427494555711746,
-0.012895078398287296,
0.0025623098481446505,
0.040382906794548035,
-0.01119740679860115,
-0.012976350262761116,
0.01840347982943058,
0.047209713608026505,
-0.02228645235300064,
0.06982125341892242,
0.013093742541968822,
-0.00955391675233841,
-0.03660829737782478,
-0.06241651624441147,
-0.06104392930865288,
-0.042188942432403564,
-0.03341161832213402,
0.0674734115600586,
-0.03543437644839287,
-0.017681067809462547,
-0.05811815708875656,
0.035416316241025925,
0.009562946856021881,
-0.0038242756854742765,
0.010881351307034492,
-0.034097909927368164,
0.022033607587218285,
-0.029944034293293953,
0.0377822183072567,
-0.04948531463742256,
0.09319132566452026,
-0.04045514762401581,
0.04757092148065567,
0.027216924354434013,
-0.015658309683203697,
0.0062127551063895226,
0.010276329703629017,
-0.01340979803353548,
0.06559513509273529,
-0.028101880103349686,
0.05428936332464218,
0.00933719240128994,
0.07729823142290115,
0.010854260995984077,
-0.026946019381284714,
0.005558067932724953,
-0.03330325707793236,
-0.030106578022241592,
0.025537312030792236,
-0.029727309942245483,
-0.032201576977968216,
0.04908799007534981,
0.04569264501333237,
-0.013075682334601879,
-0.002675187075510621,
-0.009454584680497646,
0.023839641362428665,
0.02463429607450962,
0.024923261255025864,
0.0639697015285492,
-0.03680695965886116,
0.015224861912429333,
-0.009590037167072296,
0.031208258122205734,
-0.04616221413016319,
-0.0030838020611554384,
0.023568736389279366,
0.022792141884565353,
-0.008407085202634335,
-0.02031787671148777,
-0.04674014449119568,
-0.042514026165008545,
0.02746976912021637,
0.0653061717748642,
-0.025952700525522232,
-0.034278515726327896,
-0.016516175121068954,
0.009454584680497646,
0.04757092148065567,
0.0020001819357275963,
-0.026187485083937645,
-0.009590037167072296,
0.006533326115459204,
0.00763049116358161,
0.0036052942741662264,
0.04847393557429314,
0.04468126595020294,
-0.025374770164489746,
0.057215139269828796,
0.007531159557402134,
-0.07025469839572906,
0.004907895810902119,
-0.01593824476003647,
-0.02403830550611019,
0.0016243013087660074,
0.03810730576515198,
0.051255229860544205,
0.03227381780743599,
0.07484202831983566,
0.009960274212062359,
0.047968246042728424,
0.0013793580001220107,
0.062886081635952,
-0.07332495599985123,
-0.0019245543517172337,
-0.05331410840153694,
0.008154240436851978,
0.012461630627512932,
-0.030503904446959496,
0.060863327234983444,
-0.001615271088667214,
0.02315334789454937,
0.022737961262464523,
0.017988093197345734,
-0.04002169892191887,
-0.05833487957715988,
0.011784368194639683,
0.002896426012739539,
0.033989548683166504,
0.02533864974975586,
-0.007707247510552406,
0.025844337418675423,
-0.09152977168560028,
-0.0391186848282814,
0.0811992660164833,
0.035958126187324524,
-0.058732207864522934,
0.04385049268603325,
0.004427039530128241,
0.030052395537495613,
0.030720628798007965,
-0.015766670927405357,
0.03357416018843651,
0.021365376189351082,
-0.045295316725969315,
-0.017193438485264778,
0.04753480106592178,
0.012696415185928345,
-0.019414858892560005,
-0.03113601543009281,
0.036517996340990067,
-0.05779306963086128,
0.022701840847730637,
0.0545060895383358,
-0.010709778405725956,
-0.0209138672798872,
-0.05053281411528587,
-0.027072440832853317,
0.012985380366444588,
-0.026277786120772362,
-0.00609084777534008,
-0.024941321462392807,
-0.06508944183588028,
0.05074954032897949,
0.04970204085111618,
-0.025483131408691406,
0.0474986806511879,
0.0377822183072567,
0.05385591834783554,
0.021437617018818855,
0.028914595022797585,
0.03666247799992561,
0.0499187633395195,
0.001976477913558483,
-0.0014233801048249006,
0.04171937331557274,
-0.018927229568362236,
-0.03456747904419899,
-0.08517253398895264,
0.011531523428857327,
-0.05172479897737503,
-0.023189468309283257,
-0.013807125389575958,
0.04034678637981415,
-0.011540553532540798,
0.033772826194763184,
-0.03379088640213013,
-0.0005282647907733917,
0.038901958614587784,
-0.06061048060655594,
-0.02943834476172924,
-0.010285360738635063,
0.011748247779905796,
-0.06216366961598396,
-0.02134731411933899,
0.04948531463742256,
-0.015378374606370926,
-0.02353261597454548,
0.03003433533012867,
-0.03194873034954071,
0.019523221999406815,
0.008519962430000305,
0.02512192539870739,
0.033501919358968735,
0.013563310727477074,
0.051905401051044464,
0.006334662437438965,
-0.010023485869169235,
-0.09080736339092255,
0.00006000122812110931,
-0.025681795552372932,
0.04793212562799454,
-0.014809474349021912,
0.021600158885121346,
0.01312986295670271,
-0.0017033152980729938,
-0.02347843535244465,
-0.022701840847730637,
-0.06707607954740524,
0.09557528793811798,
0.02174464240670204,
0.017464343458414078,
0.030395543202757835,
0.007075136061757803,
-0.03915480524301529,
0.03696950525045395,
0.010980683378875256,
0.005377464462071657,
0.026024941354990005,
-0.007355071138590574,
0.0010745899053290486,
-0.02523028664290905,
-0.01725664921104908,
-0.01037566177546978,
-0.028354724869132042,
-0.039082564413547516,
0.019577402621507645,
0.02150985784828663,
0.08517253398895264,
0.04428393766283989,
-0.022304512560367584,
-0.053277984261512756,
-0.01748240366578102,
-0.031045714393258095,
0.0016525206156075,
-0.0298176109790802,
-0.024002185091376305,
-0.011666975915431976,
-0.021925246343016624,
0.020949987694621086,
-0.034386876970529556,
-0.039732735604047775,
-0.0766480565071106,
-0.04767928272485733,
-0.08885684609413147,
0.01223587617278099,
0.012633203528821468,
-0.062452636659145355,
-0.0023388133849948645,
-0.015143590047955513,
0.05410876125097275,
-0.03785445913672447,
0.012795746326446533,
0.04139428585767746,
-0.019577402621507645,
-0.04515083506703377,
-0.0023771915584802628,
-0.027271104976534843,
-0.002110801637172699,
-0.06967677175998688,
0.00015210187120828778,
0.07086875289678574,
-0.01471917238086462,
-0.004460902418941259,
0.02862562984228134,
0.04525919631123543,
-0.01064656674861908,
0.025465071201324463,
0.0267112348228693,
0.04031066596508026,
-0.023659037426114082,
0.07592564821243286,
0.016452964395284653,
0.02425502799451351,
-0.04366988688707352,
-0.013725854456424713,
-0.025483131408691406,
-0.010809110477566719,
-0.02396606281399727,
-0.030901232734322548,
0.022430935874581337,
-0.014863654971122742,
0.04753480106592178,
-0.011450251564383507,
-0.028426965698599815,
-0.08163271099328995,
-0.03626514971256256,
-0.0298176109790802,
-0.0022293224465101957,
-0.018475722521543503,
0.02196136675775051,
0.014285724610090256,
0.01064656674861908,
0.033393558114767075,
0.013093742541968822,
-0.031443040817976,
0.04204445704817772,
-0.0025690824259072542,
0.06003255024552345,
-0.05761246755719185,
-0.005544522777199745,
-0.057865310460329056,
0.01163085550069809,
0.07765943557024002,
-0.01100777368992567,
-0.047859884798526764,
0.06136901676654816,
0.05291678011417389,
0.027379466220736504,
-0.021997487172484398,
-0.04269462823867798,
-0.02970924973487854,
-0.01655229553580284,
0.0047814734280109406,
-0.022304512560367584,
0.006926137953996658,
0.0319848507642746,
-0.01894528977572918,
-0.04327256232500076,
0.01676901988685131,
-0.0550478994846344,
-0.04753480106592178,
0.025754036381840706,
-0.06624530255794525,
-0.013310465961694717,
0.020498478785157204,
0.011703096330165863,
0.010041546076536179,
-0.03447717800736427,
0.010113786906003952,
0.00435479823499918,
-0.053277984261512756,
-0.012741565704345703,
-0.012136545032262802,
-0.0010379048762843013,
0.10373856127262115,
-0.020733263343572617,
0.03875747695565224,
0.025537312030792236,
-0.0006513008265756071,
-0.023677097633481026,
-0.007779488805681467,
0.02129313349723816,
-0.028824293985962868,
-0.06519780308008194,
-0.0061134230345487595,
-0.04670402407646179,
-0.026909897103905678,
-0.05732350051403046,
-0.03478420525789261,
0.013969668187201023,
-0.014475357718765736,
0.0077388533391058445,
0.029095198959112167,
-0.04204445704817772,
-0.03575946018099785,
-0.06458375602960587,
-0.001046934979967773,
-0.025573432445526123,
-0.0006010705255903304,
-0.06667875498533249,
-0.028535328805446625,
-0.019360678270459175,
0.005007227882742882,
-0.022160030901432037,
0.04161100834608078,
0.009653248824179173,
0.01731985993683338,
-0.057648587971925735,
-0.08372770994901657,
0.07115771621465683,
0.007648551370948553,
0.009427494369447231,
0.016687748953700066,
0.0290048960596323,
0.013021500781178474,
0.016994774341583252,
-0.02223227173089981,
0.049774281680583954,
-0.05609539896249771,
-0.014330875128507614,
-0.06978513300418854,
-0.012768656015396118,
-0.0010604802519083023,
-0.004790503531694412,
0.011170316487550735,
0.01318404357880354,
-0.012470660731196404,
0.0149088054895401,
-0.010330511257052422,
0.03980497643351555,
-0.0303594209253788,
-0.022593477740883827,
-0.019685763865709305,
0.0010723323794081807,
-0.05013548955321312,
0.030955413356423378,
0.03187648952007294,
0.023333951830863953,
0.026638992130756378,
0.006384328007698059,
0.0007760300068184733,
-0.02593464031815529,
-0.03194873034954071,
-0.019866367802023888,
0.012515811249613762,
-0.052555572241544724,
0.03864911571145058,
0.024381451308727264,
-0.0113328592851758,
0.019523221999406815,
-0.003165073459967971,
0.021943306550383568,
0.0429113544523716,
0.06350013613700867,
0.01686835289001465,
-0.018981412053108215,
0.015577037818729877,
0.0011908533051609993,
-0.06660651415586472,
-0.00810908991843462,
-0.06657039374113083,
0.0201011523604393,
0.0015656051691621542,
-0.00335244950838387,
-0.0658479779958725,
0.011188376694917679,
0.0017778141191229224,
-0.0036504450254142284,
0.01950516179203987,
-0.028806233778595924,
0.04554816335439682,
0.0062804813496768475,
-0.019469039514660835,
-0.04135816544294357,
-0.010700748302042484,
-0.010980683378875256,
0.05804591253399849,
0.02965506911277771,
-0.0356149785220623,
-0.03203903138637543,
0.0534224696457386,
-0.04894350469112396,
-0.02895071543753147,
0.03084705024957657,
-0.044211696833372116,
-0.02163628116250038,
-0.014059970155358315,
-0.042188942432403564,
-0.012172665446996689,
0.03436881676316261,
-0.004740837961435318,
0.0229366235435009,
-0.0032327999360859394,
0.023406192660331726,
0.01720246858894825,
0.027542009949684143,
-0.028824293985962868,
-0.041322045028209686,
0.019577402621507645,
0.06884599477052689,
0.0031853914260864258,
-0.013653612695634365,
-0.009391373954713345,
-0.04457290470600128,
-0.029835673049092293,
0.013427858240902424,
0.0041967700235545635,
0.006014091428369284,
-0.07520323246717453,
-0.022737961262464523,
-0.028408905491232872,
-0.019523221999406815,
-0.04327256232500076,
0.02113059163093567,
-0.03314071148633957,
0.03359222039580345,
0.002724852878600359,
-0.021040288731455803,
0.04211669787764549,
-0.03164170682430267,
0.027830975130200386,
-0.03397148847579956,
0.0321112759411335,
-0.035470496863126755,
-0.04088859632611275,
-0.025085804983973503,
0.0006654104217886925,
-0.011992061510682106,
-0.04569264501333237,
-0.03305041044950485,
-0.021220892667770386,
-0.01872856728732586,
0.018060334026813507,
-0.04515083506703377,
-0.01024020928889513,
0.07599788904190063,
-0.02889653481543064,
0.00209499872289598,
0.0021649824921041727,
0.002438145224004984,
0.00031012980616651475,
0.015974365174770355,
-0.0003665683325380087,
0.058407120406627655,
-0.03785445913672447,
-0.0322376973927021,
-0.04757092148065567,
0.04948531463742256,
-0.01312986295670271,
-0.008989531546831131,
-0.04608997330069542,
0.05270005390048027,
-0.030828990042209625,
0.018493782728910446,
-0.01146831177175045,
0.0661008208990097,
0.03447717800736427,
0.020769383758306503,
-0.012624173425137997,
0.00609084777534008,
0.03019687905907631,
0.0731082335114479,
0.032020971179008484,
0.018204817548394203,
0.009933183901011944,
0.08943477272987366,
-0.008641869761049747,
0.030124638229608536,
0.03915480524301529,
-0.07722599059343338,
0.0015780216781422496,
0.00023083364067133516,
-0.024887140840291977,
0.007066105958074331,
0.004454129841178656,
0.049774281680583954,
0.04952143505215645,
-0.016245270147919655,
0.03875747695565224,
0.024074425920844078,
-0.014186392538249493,
0.022105848416686058,
-0.030431663617491722,
0.05056893453001976,
0.07780391722917557,
-0.056817810982465744,
0.0005248784436844289,
0.006682323757559061,
-0.0195593424141407,
-0.022430935874581337,
-0.00470923213288188,
-0.00348790199495852,
0.055625829845666885,
0.017951972782611847,
0.02347843535244465,
0.006379812955856323,
-0.026964079588651657,
-0.04872678220272064,
0.07809288799762726,
-0.02190718613564968,
-0.024832960218191147,
-0.01567636989057064,
-0.03817954659461975,
0.016136908903717995,
0.013861306942999363,
-0.028101880103349686,
-0.03129855915904045,
0.021166712045669556,
0.011983031406998634,
-0.040166184306144714,
-0.012326178140938282,
0.003115407656878233,
0.01872856728732586,
-0.001176179270260036,
0.02020951360464096,
0.07433633506298065,
-0.03212933614850044,
-0.0377822183072567,
-0.0029935003258287907,
-0.02058878168463707,
0.04793212562799454,
-0.03480226546525955,
0.0134910698980093,
0.0067906854674220085,
-0.006781655363738537,
0.0020114697981625795,
0.059888068586587906,
-0.014728202484548092,
0.008072969503700733,
-0.01253387238830328,
0.0015498024877160788,
0.02282826229929924,
-0.03052196465432644,
-0.0052104066126048565,
0.02474265731871128,
-0.008867624215781689,
-0.041863854974508286,
-0.0010384692577645183,
-0.0018026471370831132,
-0.0010638665407896042,
-0.004212573170661926,
-0.05006324499845505,
0.021058348938822746,
0.04952143505215645,
0.02654869109392166,
-0.00745440274477005,
0.038901958614587784,
-0.028029639273881912,
-0.026476450264453888
] |
725,886 | qsm_forward.qsm_forward | generate_susceptibility_phantom | null | def generate_susceptibility_phantom(resolution, background, large_cylinder_val, small_cylinder_radii, small_cylinder_vals):
assert len(small_cylinder_radii) == len(small_cylinder_vals), "Number of small cylinders and their values should be the same"
# Initialize the 3D array with the background value
array = np.full(resolution, fill_value=background, dtype=float)
# Calculate the center and the large radius
center = [res//2 for res in resolution]
large_radius = min(center[1:]) * 0.75
# Create coordinates for the 3D array
z,y,x = np.indices(resolution)
# Calculate the lower and upper limit for the height
lower_limit1 = (1 - 0.75) / 2 * resolution[0]
upper_limit2 = (1 + 0.75) / 2 * resolution[0]
lower_limit3 = (1 - 0.6) / 2 * resolution[0]
upper_limit4 = (1 + 0.6) / 2 * resolution[0]
# Create the large cylinder along x-axis
large_cylinder = ((z-center[2])**2 + (y-center[1])**2 < large_radius**2) & (x >= lower_limit1) & (x < upper_limit2)
array[large_cylinder] = large_cylinder_val
# Calculate angle between each small cylinder
angle = 2*np.pi/len(small_cylinder_radii)
# Create the small cylinders
for i, (small_radius, small_val) in enumerate(zip(small_cylinder_radii, small_cylinder_vals)):
# Calculate center of the small cylinder
small_center_z = center[2] + large_radius/2 * np.cos(i*angle)
small_center_y = center[1] + large_radius/2 * np.sin(i*angle)
small_cylinder = ((z-small_center_z)**2 + (y-small_center_y)**2 < small_radius**2) & (x >= lower_limit3) & (x < upper_limit4)
array[small_cylinder] = small_val
return array
| (resolution, background, large_cylinder_val, small_cylinder_radii, small_cylinder_vals) | [
0.031755756586790085,
-0.03817368298768997,
-0.04095602035522461,
-0.0036634120624512434,
0.014393963851034641,
0.04644650220870972,
-0.05905976891517639,
-0.04002857580780983,
-0.046409402042627335,
-0.03489052131772041,
0.046669088304042816,
0.05145471170544624,
-0.008662346750497818,
-0.03709784522652626,
-0.06076626852154732,
-0.06009850651025772,
0.017955357208848,
-0.019995737820863724,
0.024503126740455627,
-0.023427288979291916,
-0.01736179180443287,
0.02442893013358116,
-0.0230192132294178,
0.03646717965602875,
-0.0071413349360227585,
0.011194274760782719,
-0.02934439480304718,
0.0160819161683321,
0.002309340750798583,
-0.030828308314085007,
-0.00686310138553381,
0.03155171498656273,
0.0100256921723485,
0.06369699537754059,
0.022592587396502495,
0.021646592766046524,
0.05093533918261528,
0.058614592999219894,
-0.08547343313694,
0.0680745467543602,
-0.011917682364583015,
0.024503126740455627,
0.006376191973686218,
-0.056277431547641754,
0.008305279538035393,
0.0027521962765604258,
0.025504767894744873,
0.026376567780971527,
-0.012344307266175747,
0.0058382730931043625,
0.026005588471889496,
-0.07508603483438492,
-0.01947636902332306,
0.014959705993533134,
-0.03053152561187744,
0.062138888984918594,
0.009960771538317204,
0.028806475922465324,
0.022128863260149956,
-0.017742043361067772,
-0.01619320921599865,
0.011435410939157009,
0.012603992596268654,
-0.029733922332525253,
-0.028954867273569107,
-0.018020277842879295,
0.0002338903141207993,
0.03847046568989754,
0.037134941667318344,
-0.006121144164353609,
0.03310982510447502,
0.011602350510656834,
0.02769354172050953,
-0.03272029757499695,
-0.006501397117972374,
0.026450762525200844,
0.017083557322621346,
-0.022815173491835594,
0.021794984117150307,
-0.027767736464738846,
-0.012455601245164871,
0.028583889827132225,
0.06903909146785736,
0.014393963851034641,
-0.025319278240203857,
-0.004808808211237192,
-0.015516173094511032,
0.029641177505254745,
0.05954204127192497,
-0.008996226824820042,
-0.00027475590468384326,
0.013948789797723293,
0.03720913827419281,
0.014523806050419807,
0.05097243934869766,
0.05842910334467888,
0.024466028437018394,
-0.00636691739782691,
0.03594781085848808,
-0.035521186888217926,
0.022796625271439552,
-0.012743109837174416,
0.013401595875620842,
0.0029771020635962486,
-0.00957124400883913,
0.013234656304121017,
0.012056799605488777,
-0.0020183546002954245,
0.010341024026274681,
0.04919174313545227,
-0.020682048052549362,
-0.015358507633209229,
-0.05713067948818207,
0.005434834398329258,
-0.04885786026716232,
-0.022852271795272827,
-0.04997079446911812,
0.021516749635338783,
-0.015562545508146286,
-0.05894847586750984,
0.015414154157042503,
-0.06150822713971138,
0.022815173491835594,
0.017556555569171906,
0.043256085366010666,
0.05130631849169731,
0.02910325862467289,
0.019290879368782043,
-0.054162852466106415,
0.04028825834393501,
-0.03182994946837425,
0.03754301741719246,
0.04503678157925606,
-0.03594781085848808,
-0.02593139372766018,
-0.023149054497480392,
-0.045964229851961136,
-0.056166134774684906,
0.08844126015901566,
-0.04221734777092934,
0.005365275777876377,
0.011899133212864399,
-0.056388724595308304,
0.0037816613912582397,
-0.007257265970110893,
0.02956698276102543,
0.029771020635962486,
-0.0638824850320816,
0.012808030471205711,
0.03511311113834381,
-0.02711852453649044,
0.04451741278171539,
0.07208111137151718,
0.018029551953077316,
0.017992453649640083,
-0.03485342487692833,
0.03181140124797821,
-0.026376567780971527,
-0.010053515434265137,
0.0742327868938446,
0.011008785106241703,
-0.023278897628188133,
0.007057864684611559,
0.0038697689305990934,
-0.026580605655908585,
0.01572021096944809,
-0.0007378993323072791,
-0.07304565608501434,
-0.03004925325512886,
0.03357354924082756,
-0.025653159245848656,
-0.018224315717816353,
-0.03531714901328087,
0.011602350510656834,
0.008875659666955471,
0.0038326710928231478,
0.009793831035494804,
-0.03277594596147537,
0.012696737423539162,
-0.017881160601973534,
-0.02947423793375492,
-0.00347560434602201,
-0.004141046665608883,
0.02019977569580078,
0.002826391952112317,
0.07041171193122864,
0.06870520859956741,
-0.023334544152021408,
0.07716351747512817,
-0.02381681650876999,
-0.027990324422717094,
0.012149544432759285,
0.04377545788884163,
0.05542417988181114,
0.06506961584091187,
-0.00662660226225853,
0.06380829215049744,
-0.031403325498104095,
-0.02498539723455906,
0.04017696529626846,
-0.05256764590740204,
-0.0068306406028568745,
-0.030661368742585182,
-0.042773813009262085,
0.05846620351076126,
0.002340642036870122,
0.020273972302675247,
-0.020570755004882812,
-0.0029098622035235167,
-0.0057501657865941525,
-0.06907618790864944,
0.025671707466244698,
-0.03910112753510475,
0.018817881122231483,
0.029863765463232994,
-0.025616060942411423,
-0.017065009102225304,
-0.0471513606607914,
-0.050415970385074615,
-0.05119502544403076,
-0.08102168887853622,
0.019754601642489433,
-0.012121720239520073,
-0.011426135897636414,
-0.05156600475311279,
0.052753135561943054,
0.036077652126550674,
0.01473711896687746,
-0.0022374638356268406,
0.000028149437639513053,
-0.010257554240524769,
-0.0018943087197840214,
0.07156173884868622,
-0.007771998178213835,
-0.04188346490263939,
0.01808519847691059,
-0.026024138554930687,
-0.02275952696800232,
0.005332814995199442,
0.05434834212064743,
-0.011324116960167885,
-0.05327250435948372,
0.025783002376556396,
0.05505320057272911,
0.01196405477821827,
0.03323967009782791,
-0.04095602035522461,
0.06525510549545288,
0.024818457663059235,
-0.03743172436952591,
-0.09059293568134308,
-0.038210779428482056,
0.021090123802423477,
-0.010303926654160023,
0.0535321906208992,
-0.06377119570970535,
0.025170886889100075,
-0.027786284685134888,
0.04555615410208702,
-0.04893205687403679,
-0.0211457721889019,
0.026784643530845642,
0.027155622839927673,
0.060617879033088684,
-0.049117546528577805,
0.013883868232369423,
-0.025374924764037132,
0.06288084387779236,
-0.04388675093650818,
0.02229580469429493,
-0.08087330311536789,
0.041030216962099075,
-0.00305129773914814,
-0.03312837332487106,
0.035632479935884476,
0.0612485408782959,
0.05564676597714424,
0.02795322611927986,
0.02817581221461296,
0.0009570084512233734,
-0.042551226913928986,
-0.022722430527210236,
0.07122786343097687,
-0.01320683304220438,
0.030939601361751556,
-0.04473999887704849,
-0.018697313964366913,
-0.027619345113635063,
0.04355286806821823,
-0.032905787229537964,
-0.1286553293466568,
-0.016230307519435883,
-0.04878366366028786,
-0.01314191147685051,
0.03195979446172714,
0.010814021341502666,
-0.028101617470383644,
-0.024373283609747887,
-0.05189988389611244,
-0.04767072945833206,
0.029288748279213905,
0.02110867388546467,
-0.003744563553482294,
0.014097181148827076,
-0.03392598032951355,
0.00437058974057436,
0.038544658571481705,
-0.053680580109357834,
-0.02500394731760025,
-0.008541778661310673,
-0.03275739774107933,
0.03696800023317337,
0.018715862184762955,
0.05342089757323265,
0.005583225749433041,
0.011806389316916466,
0.04013986885547638,
-0.0031370865181088448,
0.05494190752506256,
0.04856107756495476,
0.02429908886551857,
-0.05646291747689247,
-0.04388675093650818,
-0.0032901151571422815,
0.04566744714975357,
-0.024781359359622,
0.0001734614052111283,
0.017074283212423325,
0.01887352764606476,
0.00908897165209055,
-0.07486344873905182,
-0.0012914687395095825,
0.0010729392524808645,
0.002378899371251464,
0.06106305122375488,
-0.010470866225659847,
0.05141761153936386,
-0.04110440984368324,
0.021034477278590202,
-0.08384113013744354,
0.0013621865073218942,
-0.04110440984368324,
-0.04188346490263939,
0.0062509868294000626,
-0.009432126767933369,
-0.027322562411427498,
0.061805009841918945,
-0.06685031205415726,
0.0009210699354298413,
-0.03489052131772041,
0.04997079446911812,
0.036689769476652145,
0.04815300181508064,
0.07067139446735382,
0.04755943641066551,
0.04915464296936989,
-0.020719146355986595,
-0.027637893334031105,
-0.03259045630693436,
0.051232121884822845,
0.019049743190407753,
-0.02275952696800232,
0.007952850311994553,
0.011008785106241703,
-0.03910112753510475,
-0.018919900059700012,
-0.04455450922250748,
0.02862098626792431,
0.003255335846915841,
-0.015312135219573975,
-0.006552406586706638,
-0.022574039176106453,
-0.022258706390857697,
-0.004310305695980787,
0.05739036574959755,
-0.008360926993191242,
-0.1132226213812828,
-0.023186152800917625,
-0.005680607631802559,
-0.0067842681892216206,
-0.006042311433702707,
-0.0038558572996407747,
-0.04577874019742012,
0.00904723722487688,
-0.04188346490263939,
-0.03438970074057579,
0.007651430554687977,
0.00019128575513605028,
-0.02615397982299328,
0.019420720636844635,
0.025783002376556396,
-0.0398801825940609,
0.0874767154455185,
0.00821717269718647,
0.045815836638212204,
0.04503678157925606,
0.009534145705401897,
0.03693090379238129,
-0.04963691532611847,
0.04937722906470299,
-0.0251152403652668,
-0.0368938073515892,
-0.020719146355986595,
-0.05208537355065346,
-0.021628042683005333,
-0.09148328751325607,
0.042551226913928986,
0.03670831769704819,
0.028250008821487427,
0.05189988389611244,
-0.05572096258401871,
-0.012928598560392857,
0.05126922205090523,
-0.027081426233053207,
-0.048894960433244705,
-0.026469312608242035,
-0.027137072756886482,
-0.014996803365647793,
-0.024855555966496468,
0.0015117371222004294,
0.057687148451805115,
-0.04507388174533844,
0.015460526570677757,
0.05664840713143349,
-0.01631377637386322,
0.007642155978828669,
0.00957124400883913,
0.014709295704960823,
0.013290302827954292,
0.011500331573188305,
-0.0034477808512747288,
-0.024948300793766975,
-0.04281091317534447,
-0.0028565339744091034,
-0.01238140556961298,
0.005407010670751333,
-0.015757309272885323,
0.045704543590545654,
0.002675682073459029,
-0.029158905148506165,
0.032813042402267456,
0.021312711760401726,
-0.012603992596268654,
0.05917106196284294,
-0.00025751121575012803,
0.013234656304121017,
-0.009905124083161354,
-0.022945016622543335,
-0.003004925325512886,
0.00838875025510788,
0.03299853205680847,
-0.027990324422717094,
0.024224892258644104,
0.009478499181568623,
0.014217749238014221,
-0.019161036238074303,
0.014579452574253082,
-0.05950494110584259,
-0.03348080441355705,
-0.028120165690779686,
0.09571243822574615,
0.029084710404276848,
-0.03850756213068962,
0.011064431630074978,
-0.006288084667176008,
0.027990324422717094,
-0.014125004410743713,
0.02428053878247738,
0.017333967611193657,
0.016285954043269157,
0.020570755004882812,
0.027674991637468338,
-0.0142641207203269,
-0.03413001820445061,
0.0088107381016016,
-0.003997292835265398,
-0.053717680275440216,
0.041141510009765625,
-0.037042196840047836,
0.00568988174200058,
-0.035613931715488434,
-0.016833147034049034,
0.01619320921599865,
-0.004704470280557871,
-0.013540713116526604,
-0.008875659666955471,
0.018242865800857544,
0.004618681501597166,
0.045259371399879456,
-0.006881650071591139,
-0.017333967611193657,
-0.017992453649640083,
0.016044817864894867,
0.03780270367860794,
-0.02172078751027584,
0.0031069444958120584,
-0.01585005410015583,
-0.011212823912501335,
0.012743109837174416,
-0.012297935783863068,
-0.025152338668704033,
0.017306145280599594,
-0.007934301160275936,
-0.04893205687403679,
0.03507601097226143,
-0.039026930928230286,
-0.006209251470863819,
-0.02780483476817608,
-0.03700510039925575,
0.07133915275335312,
0.020607853308320045,
0.02429908886551857,
-0.017389614135026932,
-0.03700510039925575,
-0.0030304300598800182,
0.03377758711576462,
0.004011204466223717,
0.004887640941888094,
0.01197332888841629,
-0.04006567224860191,
-0.016527090221643448,
0.004314943216741085,
-0.009830928407609463,
0.046075522899627686,
0.030809760093688965,
-0.012056799605488777,
-0.023074859753251076,
-0.059208158403635025,
0.002650177339091897,
0.013874594122171402,
-0.049599818885326385,
-0.05490481108427048,
-0.02428053878247738,
0.06703580170869827,
-0.00437522679567337,
-0.04373835772275925,
-0.004391457419842482,
-0.022110315039753914,
0.09712215512990952,
-0.029548432677984238,
-0.009385754354298115,
0.010841844603419304,
0.03969469293951988,
-0.02220305986702442,
-0.013995162211358547,
0.004934013355523348,
0.04555615410208702,
-0.02700723148882389,
-0.026895936578512192,
-0.025078142061829567,
0.04399804398417473,
0.002193409949541092,
0.016703303903341293,
-0.0323864184319973,
0.024466028437018394,
0.02947423793375492,
0.006199977360665798,
-0.047373946756124496,
-0.025300730019807816,
0.01715775392949581,
0.08792188763618469,
0.0057501657865941525,
0.042439933866262436,
-0.04503678157925606,
-0.023056309670209885,
-0.00196734513156116,
-0.03793254494667053,
0.07946358621120453,
-0.006677612196654081,
-0.029900861904025078,
-0.018465451896190643,
0.017055733129382133,
0.02266678214073181,
0.04807880520820618,
-0.0025180161464959383,
-0.0389898344874382,
0.061100151389837265,
-0.022110315039753914,
-0.0387672483921051,
-0.035966359078884125,
0.019661856815218925,
-0.03307272866368294,
-0.05575805902481079,
-0.08814448118209839,
0.05178859084844589,
0.04095602035522461,
0.02639511600136757,
0.05386606976389885,
-0.020626401528716087,
0.00253888382576406,
0.01748235896229744,
0.048301395028829575,
-0.035502638667821884,
-0.04377545788884163,
-0.03581796959042549,
0.027081426233053207,
-0.013716927729547024,
-0.029400041326880455,
-0.009121432900428772,
0.03763576224446297,
-0.06681321561336517,
0.026840290054678917,
-0.039731793105602264,
0.017408164218068123,
-0.004915464203804731,
0.004189737606793642,
0.05868878960609436,
-0.11752597242593765,
-0.036671217530965805,
-0.08117008209228516,
0.006227800622582436,
0.0305129773914814,
-0.06017270311713219,
-0.04307059571146965,
0.004887640941888094,
0.03592926263809204,
-0.06555189192295074,
-0.04051084443926811,
0.05279023200273514,
0.016480717808008194,
-0.02817581221461296,
0.021071575582027435,
0.031384777277708054,
-0.018929174169898033,
0.00013455214502755553,
-0.005573951173573732,
0.061322737485170364,
-0.020459461957216263,
-0.01995863951742649,
-0.024558773264288902,
0.025152338668704033,
0.05865169316530228,
0.01244632713496685,
-0.0197175033390522,
-0.021201418712735176,
0.008064144290983677,
-0.03678251430392265,
0.0029191365465521812,
0.013067715801298618,
0.018595295026898384,
-0.021090123802423477,
-0.03164445981383324,
-0.03980598598718643,
0.03566957637667656,
-0.03722768649458885,
-0.04870947077870369,
0.023742619901895523,
0.01607264019548893,
-0.053940266370773315,
-0.011259195394814014,
-0.01391169149428606,
0.08302497863769531,
0.001962707843631506,
-0.027971774339675903,
0.024132147431373596,
-0.002893631812185049,
-0.017167028039693832,
0.007196981925517321,
0.025560414418578148,
0.022147413343191147,
0.06532930582761765,
0.044888392090797424,
0.008968403562903404,
-0.019754601642489433,
0.03407436981797218,
0.005022120662033558,
0.07282306998968124,
-0.044999685138463974,
-0.00026417721528559923,
0.021201418712735176,
0.021980471909046173,
-0.05701938644051552,
0.0081522511318326,
-0.043256085366010666,
0.008059506304562092,
0.042662519961595535,
-0.0066312397830188274,
0.04544486105442047,
0.03895273804664612,
0.07078268378973007,
-0.0054812063463032246,
-0.012418502941727638,
-0.031273484230041504,
0.04485129565000534,
0.05894847586750984,
-0.008991589769721031,
-0.017435986548662186,
-0.017065009102225304,
-0.04473999887704849,
0.00534208957105875,
0.0011280063772574067,
-0.022982114925980568,
0.002118055010214448,
-0.030846858397126198,
-0.013577811419963837,
0.02112722210586071,
-0.012770933099091053,
0.04774492606520653,
0.03145897015929222,
0.025987040251493454,
0.01467219740152359,
-0.03004925325512886,
-0.057093583047389984,
0.04589003324508667,
-0.03333241492509842,
0.020570755004882812,
0.04028825834393501,
0.007526224944740534,
0.07694093137979507,
-0.07708931714296341,
-0.00016665046859998256,
0.044665805995464325,
0.04744814336299896,
-0.056054841727018356,
-0.0506756566464901,
-0.016119012609124184,
-0.011333391070365906,
0.052641842514276505,
0.061434030532836914,
-0.002363828243687749,
-0.0030837582889944315,
0.07946358621120453,
0.042439933866262436,
-0.006176791153848171,
-0.07938938587903976,
0.018261414021253586,
0.07185852527618408,
-0.01583150587975979,
-0.012112446129322052,
-0.04192056506872177,
-0.004157277289777994,
0.049933698028326035,
-0.045964229851961136,
0.011982603929936886,
0.0009523712215013802,
0.011157176457345486,
-0.014375414699316025,
-0.03121783584356308,
-0.00908897165209055,
0.0033318500500172377,
-0.04577874019742012,
-0.02806451916694641,
-0.016731128096580505,
-0.06588577479124069,
0.04073343425989151,
0.03168155997991562,
0.025263631716370583,
0.022351451218128204,
0.03340660780668259,
-0.005847547668963671,
0.0034477808512747288,
0.013049166649580002,
-0.03917532414197922,
0.04507388174533844,
-0.003317938419058919,
-0.009543420746922493,
0.021182868629693985,
0.001975460210815072,
-0.007401019800454378,
-0.024317637085914612,
-0.046075522899627686,
0.0009007820044644177,
-0.019624760374426842,
0.09600922465324402,
-0.016221031546592712,
0.04844978451728821,
-0.01903119497001171,
0.0194949172437191
] |
725,888 | qsm_forward.qsm_forward | resize |
Resize a Nifti image to a voxel size.
Parameters
----------
nii : nibabel.nifti1.Nifti1Image
The input Nifti image.
voxel_size : list of float
The desired voxel size after resizing.
interpolation : str
Can be 'continuous', 'linear', or 'nearest'. Indicates the resample method. Default='continuous'.
Returns
-------
nibabel.nifti1.Nifti1Image
The resized Nifti image.
| def resize(nii, voxel_size, interpolation='continuous'):
"""
Resize a Nifti image to a voxel size.
Parameters
----------
nii : nibabel.nifti1.Nifti1Image
The input Nifti image.
voxel_size : list of float
The desired voxel size after resizing.
interpolation : str
Can be 'continuous', 'linear', or 'nearest'. Indicates the resample method. Default='continuous'.
Returns
-------
nibabel.nifti1.Nifti1Image
The resized Nifti image.
"""
original_shape = np.array(nii.header.get_data_shape())
target_shape = np.array(np.round((np.array(nii.header.get_zooms()) / voxel_size) * original_shape), dtype=int)
if np.array_equal(original_shape, target_shape):
return nii
# Create a new affine matrix that directly sets the diagonal to the new voxel sizes
new_affine = np.eye(4)
new_affine[:3, :3] = nii.affine[:3, :3]
scale_factors = np.divide(nii.header.get_zooms(), voxel_size)
for i in range(3):
new_affine[i, i] = nii.affine[i, i] / scale_factors[i]
new_affine[:3, 3] = nii.affine[:3, 3]
# Adjust the voxel sizes in the new affine
for i in range(3):
new_affine[i, i] = voxel_size[i] * (nii.affine[i, i] / nii.header.get_zooms()[i])
return resample_img(
nii,
target_affine=new_affine,
target_shape=target_shape,
interpolation=interpolation
)
| (nii, voxel_size, interpolation='continuous') | [
-0.016124319285154343,
-0.04931917414069176,
0.03309830278158188,
-0.05260197073221207,
-0.005947653204202652,
0.005928342230618,
-0.005513165146112442,
-0.02116437628865242,
-0.018412619829177856,
-0.006937319412827492,
0.008438715711236,
-0.013420840725302696,
0.014193262904882431,
0.03703765571117401,
-0.00491695199161768,
-0.005986274220049381,
0.013700843788683414,
0.042560476809740067,
-0.009887007996439934,
-0.02162782847881317,
0.01915607787668705,
-0.051481958478689194,
0.06021033227443695,
-0.04707914963364601,
0.01196289248764515,
0.008935962803661823,
0.05225437879562378,
-0.0164139773696661,
0.032306570559740067,
-0.03134104236960411,
-0.10389082133769989,
-0.0008200954180210829,
0.040590800344944,
0.03779076784849167,
0.016558807343244553,
-0.005373163614422083,
-0.00531040458008647,
0.013102215714752674,
-0.03883353993296623,
0.061793796718120575,
-0.032383810728788376,
-0.025296835228800774,
0.004064873326569796,
-0.03622661530971527,
0.02792307175695896,
0.049937114119529724,
-0.005324887577444315,
0.011914616450667381,
-0.0077097415924072266,
0.05673443153500557,
-0.014695337042212486,
-0.08774719387292862,
0.032248638570308685,
0.032383810728788376,
-0.02585684135556221,
0.04507084935903549,
0.009800110012292862,
0.018982281908392906,
0.08087263256311417,
-0.04259910061955452,
-0.031186556443572044,
-0.05480337515473366,
0.029101015999913216,
-0.039296992123126984,
-0.04217426851391792,
0.013826361857354641,
-0.04677018150687218,
0.015998801216483116,
-0.03605281934142113,
-0.004183150362223387,
0.03141828253865242,
-0.01888572983443737,
0.02452441304922104,
-0.014193262904882431,
0.011393231339752674,
0.08488922566175461,
-0.06403382122516632,
0.007526291534304619,
0.01454085297882557,
-0.019117455929517746,
0.03273140266537666,
0.007671120576560497,
0.007173873484134674,
-0.032924506813287735,
-0.005049712024629116,
-0.0255285631865263,
0.02786513976752758,
-0.03477832302451134,
0.007444221526384354,
-0.09130033850669861,
0.01695467345416546,
-0.004665914457291365,
0.02238094061613083,
-0.007077320944517851,
0.006884215399622917,
0.03414107486605644,
0.002027608919888735,
-0.058704107999801636,
0.003579695476219058,
-0.0606737844645977,
-0.04321703687310219,
-0.03060724027454853,
-0.007714569568634033,
-0.05298818275332451,
0.0038065945263952017,
0.03277002274990082,
-0.02512304112315178,
0.07816915214061737,
-0.032866574823856354,
0.0001223505096277222,
-0.03182380646467209,
0.01758226566016674,
-0.07643119990825653,
-0.011653924360871315,
0.004591085948050022,
-0.028309283778071404,
0.01031184010207653,
0.038215599954128265,
0.02452441304922104,
-0.002935205353423953,
0.002060195431113243,
-0.010321495123207569,
0.014193262904882431,
-0.015825005248188972,
-0.011441507376730442,
0.016616737470030785,
-0.013034628704190254,
0.03429555892944336,
0.004023838322609663,
-0.01717674545943737,
-0.08558440953493118,
-0.028347903862595558,
-0.07836225628852844,
0.045457061380147934,
-0.005266955588012934,
-0.027768587693572044,
-0.010041492059826851,
0.015361552126705647,
0.0030389996245503426,
0.060789648443460464,
0.009312517940998077,
0.023404400795698166,
-0.01242634654045105,
0.03657420352101326,
0.04047493636608124,
-0.04132460057735443,
0.037134211510419846,
0.033387962728738785,
0.011026330292224884,
-0.04603637754917145,
-0.05144333466887474,
0.042637720704078674,
0.015429139137268066,
-0.01410636492073536,
0.036535583436489105,
-0.028425145894289017,
0.03321416676044464,
0.011441507376730442,
-0.04078390449285507,
0.004019010812044144,
-0.0460750013589859,
0.030838966369628906,
-0.03361968696117401,
0.04020458832383156,
-0.06573314964771271,
-0.03394796699285507,
0.027884451672434807,
0.0012708763824775815,
-0.02444717101752758,
0.06963388621807098,
-0.01693536341190338,
-0.05565303936600685,
-0.06461314111948013,
-0.002766238059848547,
0.034334179013967514,
0.10528118163347244,
-0.03068448230624199,
-0.06140758469700813,
-0.0016172595787793398,
-0.003603833494707942,
-0.02778789773583412,
-0.06940215826034546,
0.015081549063324928,
-0.02479476109147072,
-0.07643119990825653,
0.048199161887168884,
0.02987343817949295,
0.046731557697057724,
0.014173951931297779,
-0.0976341962814331,
0.11478197574615479,
0.015342241153120995,
-0.04051356017589569,
-0.012822212651371956,
-0.004661086946725845,
-0.03632316738367081,
-0.03784869983792305,
-0.008332507684826851,
0.019580909982323647,
0.005706271156668663,
-0.044298429042100906,
0.006700764875859022,
0.0519840307533741,
-0.00454522343352437,
0.01044701412320137,
-0.02002505213022232,
-0.01386498287320137,
-0.01439602393656969,
0.03172725439071655,
0.030182408168911934,
0.0073621515184640884,
0.03315623477101326,
0.00629524327814579,
0.02048850618302822,
-0.023713368922472,
-0.015796039253473282,
-0.037269383668899536,
-0.00694697443395853,
-0.017157433554530144,
-0.004704535473138094,
-0.004948331508785486,
0.03491349518299103,
0.01463740598410368,
0.004009355325251818,
-0.00745387701317668,
0.0017077778466045856,
0.013218079693615437,
-0.02095196023583412,
0.03952872008085251,
-0.03242243453860283,
-0.010195976123213768,
-0.013623600825667381,
-0.023713368922472,
0.015438794158399105,
0.02384854294359684,
-0.032596226781606674,
-0.04070666432380676,
-0.0035338327288627625,
0.021878866478800774,
0.009650452993810177,
-0.055498555302619934,
-0.027768587693572044,
-0.07558153569698334,
-0.0196195300668478,
-0.015110514126718044,
-0.03856319189071655,
-0.006845593918114901,
0.05727512761950493,
-0.021338170394301414,
0.012580830603837967,
0.028502389788627625,
-0.07403669506311417,
-0.0510571263730526,
0.028116177767515182,
0.012880144640803337,
0.04781294986605644,
-0.08164505660533905,
-0.0021808864548802376,
-0.009051825851202011,
-0.0620255246758461,
0.0464998334646225,
-0.046731557697057724,
-0.022400250658392906,
0.047117769718170166,
-0.03514522314071655,
0.012271861545741558,
-0.0038065945263952017,
0.04541844129562378,
-0.021878866478800774,
-0.0005986274336464703,
0.14197124540805817,
0.10242322087287903,
-0.03321416676044464,
0.016568461433053017,
0.03184311464428902,
0.0519840307533741,
0.013440150767564774,
-0.015796039253473282,
-0.0015726038254797459,
-0.027884451672434807,
0.0008086297893896699,
-0.022863704711198807,
0.002227955963462591,
-0.022226456552743912,
0.025065109133720398,
-0.008598027750849724,
-0.006942146923393011,
0.06484486907720566,
-0.025509251281619072,
0.018460897728800774,
-0.02832859382033348,
0.044646017253398895,
-0.0174470916390419,
-0.026957543566823006,
-0.07226011902093887,
0.012928420677781105,
-0.11068814247846603,
0.013874638825654984,
-0.007260771002620459,
-0.013208423741161823,
-0.07473187148571014,
-0.02892722189426422,
-0.05032332241535187,
-0.07419117540121078,
0.04468464106321335,
0.03236450254917145,
-0.024563034996390343,
0.016298113390803337,
-0.02263197861611843,
0.012880144640803337,
-0.015448449179530144,
-0.037269383668899536,
-0.06917043030261993,
-0.05484199523925781,
0.07430703938007355,
-0.042908068746328354,
0.05488061532378197,
0.04368048906326294,
0.02699616551399231,
0.033117614686489105,
0.008192505687475204,
0.034527283161878586,
-0.04387359693646431,
-0.050670914351940155,
0.01576707325875759,
-0.029912060126662254,
0.01584431529045105,
0.004704535473138094,
-0.030491376295685768,
-0.0052186790853738785,
0.003794525284320116,
0.008607682771980762,
-0.017408471554517746,
-0.004605568945407867,
-0.07886433601379395,
-0.05009159818291664,
0.07504083961248398,
0.03427624702453613,
0.009167688898742199,
0.0515591986477375,
-0.03516453132033348,
0.02653271146118641,
-0.015313275158405304,
-0.04341014102101326,
0.006826283410191536,
-0.026165811344981194,
-0.026339605450630188,
-0.07813053578138351,
-0.00903251487761736,
0.0064400723204016685,
-0.015641555190086365,
-0.004120390862226486,
0.038350775837898254,
-0.011171160265803337,
-0.007241460494697094,
0.015863627195358276,
0.0025224420242011547,
-0.037211451679468155,
0.03093552030622959,
-0.041440464556217194,
-0.057468231767416,
0.04734949767589569,
-0.011296678334474564,
-0.04306255280971527,
0.05352887511253357,
-0.018007099628448486,
0.0028096868190914392,
-0.016211217269301414,
0.03267347067594528,
0.01423188392072916,
-0.012841523624956608,
-0.029776886105537415,
-0.03487487509846687,
-0.010949088260531425,
0.031302422285079956,
-0.06739386171102524,
-0.05082539841532707,
-0.001992608653381467,
-0.055228207260370255,
0.018306411802768707,
-0.01600845530629158,
0.027614103630185127,
0.01939745992422104,
-0.018760209903120995,
-0.006517314352095127,
0.026281675323843956,
0.04773570969700813,
0.04955090209841728,
-0.03730800375342369,
-0.03558936342597008,
-0.06781869381666183,
0.02585684135556221,
-0.0001322320895269513,
0.05526682734489441,
-0.034334179013967514,
0.009640797972679138,
-0.029023773968219757,
0.02819341979920864,
-0.026706507429480553,
-0.0289465319365263,
0.005440750624984503,
-0.005624201148748398,
-0.02846376784145832,
0.05947652831673622,
0.029776886105537415,
-0.02290232665836811,
0.05453302711248398,
-0.0038210772909224033,
0.06248897686600685,
-0.06001722440123558,
0.0578930638730526,
0.037404559552669525,
-0.008240781724452972,
-0.002507959259673953,
-0.023597506806254387,
0.04503222927451134,
-0.007772501092404127,
0.0028193420730531216,
-0.03047206625342369,
-0.010997365228831768,
-0.020411264151334763,
0.017051225528120995,
-0.019764360040426254,
0.05615511164069176,
-0.009660108014941216,
-0.11810339242219925,
0.03390934690833092,
-0.010273219086229801,
-0.0009999250760301948,
-0.013507737778127193,
-0.04619086533784866,
0.04499360918998718,
0.026107879355549812,
0.03669006749987602,
-0.008916651830077171,
-0.05410819500684738,
0.004229012876749039,
-0.01433809194713831,
0.005489027127623558,
0.07237598299980164,
0.039142508059740067,
-0.005740064661949873,
0.02645546942949295,
-0.02705409750342369,
-0.00612627575173974,
0.02330784872174263,
-0.02832859382033348,
0.04873985797166824,
-0.08110436052083969,
-0.01761123165488243,
0.07751259207725525,
-0.07102424651384354,
-0.047658465802669525,
-0.03605281934142113,
-0.0049531590193510056,
-0.04978262633085251,
-0.012349104508757591,
0.028425145894289017,
-0.0008068194147199392,
-0.0383121557533741,
0.0004136684292461723,
0.03765559569001198,
0.012378069572150707,
0.003171759657561779,
-0.01677122339606285,
0.01852848380804062,
-0.02265128865838051,
-0.027305133640766144,
0.06542418152093887,
-0.014811201021075249,
0.02732444554567337,
0.011856684461236,
-0.01677122339606285,
-0.049473658204078674,
0.0765470638871193,
0.05179092660546303,
-0.023867854848504066,
0.028618251904845238,
0.05043918639421463,
-0.010504945181310177,
0.0324031226336956,
0.03609143942594528,
0.056502703577280045,
-0.015062238089740276,
-0.026571333408355713,
-0.010939433239400387,
0.02124161832034588,
0.007782156579196453,
-0.04032045230269432,
0.007125597447156906,
-0.006787662394344807,
0.024408549070358276,
-0.02504579909145832,
0.06438141316175461,
-0.0015013961819931865,
0.014280159957706928,
-0.023655438795685768,
-0.02639753744006157,
0.010813914239406586,
-0.005629028659313917,
0.015496726147830486,
0.02792307175695896,
0.04248323664069176,
-0.023365778848528862,
-0.013556014746427536,
0.03643903136253357,
-0.048392266035079956,
0.020449884235858917,
0.025354767218232155,
-0.040281832218170166,
-0.02819341979920864,
0.002790376078337431,
0.0017657094867900014,
0.006546280346810818,
0.0542626790702343,
0.004238668363541365,
-0.04066804423928261,
0.06333864480257034,
0.011480129323899746,
-0.018518827855587006,
-0.008617337793111801,
-0.002981067867949605,
0.01720570959150791,
0.008134573698043823,
-0.0007730259094387293,
0.020334022119641304,
0.046113621443510056,
-0.006609039846807718,
0.02705409750342369,
0.042097024619579315,
-0.03643903136253357,
0.006459382828325033,
0.01996712014079094,
0.00998356007039547,
0.020739542320370674,
-0.006797317881137133,
-0.017215365543961525,
0.0060152397491037846,
0.07739672809839249,
-0.01684846542775631,
-0.07314840704202652,
0.018103651702404022,
-0.01212703250348568,
0.017572611570358276,
-0.04495498910546303,
0.04626810550689697,
0.041633572429418564,
0.018818141892552376,
0.026165811344981194,
-0.04093839228153229,
-0.039026644080877304,
0.011132539249956608,
0.02539338916540146,
0.005097988061606884,
0.0478515699505806,
0.032924506813287735,
-0.018818141892552376,
-0.07670155167579651,
-0.029699644073843956,
0.01622087135910988,
-0.01440567895770073,
0.07129459083080292,
0.13293389976024628,
-0.00889734085649252,
-0.004002113826572895,
0.023481642827391624,
0.0038355602882802486,
0.008231126703321934,
0.02593408338725567,
0.03860181197524071,
-0.005001435521990061,
-0.004052804317325354,
0.03584040328860283,
-0.004501774907112122,
-0.06310691684484482,
-0.011026330292224884,
0.04032045230269432,
-0.04024321213364601,
0.025837531313300133,
-0.08017744868993759,
-0.027169959619641304,
-0.00179588224273175,
0.05097988247871399,
-0.0683593899011612,
-0.022940946742892265,
0.019494011998176575,
-0.03558936342597008,
0.09245897084474564,
0.0038983195554465055,
0.030781034380197525,
0.030027924105525017,
0.01842227578163147,
0.017292607575654984,
0.021550586447119713,
-0.019069179892539978,
-0.024698209017515182,
-0.0031210696324706078,
-0.011808408424258232,
0.019300905987620354,
-0.049859870225191116,
0.01008011307567358,
-0.02906239591538906,
-0.015805695205926895,
0.03398658707737923,
-0.02236163057386875,
-0.006570418830960989,
0.03035620227456093,
-0.013855327852070332,
0.02110644429922104,
-0.018654001876711845,
0.05889721214771271,
0.04140184447169304,
0.02021815814077854,
-0.03068448230624199,
-0.09060515463352203,
0.028038935735821724,
-0.016626393422484398,
-0.014994651079177856,
0.03387072682380676,
-0.0043424624018371105,
-0.03669006749987602,
0.009380104951560497,
0.021222306415438652,
-0.04619086533784866,
-0.0039610788226127625,
-0.01062080916017294,
0.007516636047512293,
-0.0077531905844807625,
-0.023655438795685768,
-0.020990580320358276,
-0.014183607883751392,
-0.04086114838719368,
0.040011484175920486,
-0.01720570959150791,
-0.00813940167427063,
0.019339527934789658,
-0.022458182647824287,
0.04499360918998718,
-0.03910388797521591,
0.013295321725308895,
0.09686177968978882,
-0.031785182654857635,
0.03643903136253357,
0.038621123880147934,
0.007202839478850365,
-0.035666607320308685,
0.053413014858961105,
-0.004521085415035486,
-0.03522246330976486,
-0.01439602393656969,
0.021994730457663536,
0.06484486907720566,
0.005517993122339249,
-0.03618799149990082,
0.0478515699505806,
0.011306334286928177,
-0.03703765571117401,
-0.00952493492513895,
-0.035261087119579315,
-0.04931917414069176,
0.07859398424625397,
0.01463740598410368,
-0.014676026999950409,
-0.02023746818304062,
0.09446726739406586,
-0.0022134731989353895,
0.02297956869006157,
-0.00626144977286458,
-0.07002009451389313,
0.026339605450630188,
0.03858250379562378,
-0.023809922859072685,
0.023713368922472,
0.04205840453505516,
0.01866365782916546,
0.0008683718042448163,
-0.022612668573856354,
-0.003113828133791685,
-0.06094413250684738,
0.03974113613367081,
-0.03288588672876358,
-0.02116437628865242,
0.013266355730593204,
0.006324208807200193,
0.024138202890753746,
-0.04495498910546303,
-0.036670755594968796,
-0.047195013612508774,
-0.0633772611618042,
0.027845829725265503,
0.04576602950692177,
0.027517549693584442,
-0.011016675271093845,
-0.009312517940998077,
0.050941262394189835,
-0.018036063760519028,
-0.0064400723204016685,
0.06322278082370758,
-0.023365778848528862,
-0.03763628378510475,
0.05627097561955452,
-0.012996007688343525,
-0.024756139144301414,
-0.017813993617892265,
0.012947731651365757,
0.04653845354914665,
-0.00813940167427063,
0.015293965116143227,
0.0002649167727213353,
0.06550142168998718,
0.026204431429505348,
0.002392095746472478,
0.021511966362595558,
0.009713212959468365,
-0.008776649832725525,
0.05144333466887474,
0.0015605348162353039,
0.03109000436961651,
-0.008612510748207569,
0.007598706055432558,
0.024138202890753746,
-0.01208841148763895,
-0.005305576603859663,
-0.04047493636608124,
-0.012996007688343525,
0.022226456552743912,
0.023558884859085083,
0.036670755594968796,
-0.024080270901322365,
-0.0025948567781597376,
0.042444612830877304,
0.02558649331331253,
-0.021878866478800774,
-0.00837112870067358,
0.045109473168849945,
0.025277525186538696,
0.022014040499925613,
0.002828997327014804,
-0.03387072682380676,
0.000830354169011116,
0.039142508059740067,
-0.013420840725302696,
0.04425980895757675,
-0.0339672788977623,
0.028386525809764862,
0.026841681450605392,
0.010823570191860199,
-0.009201482869684696,
-0.002203817944973707,
0.038621123880147934,
0.0330403707921505,
0.028232041746377945,
-0.006111792754381895,
-0.0447232611477375,
0.0492805540561676,
-0.06534694135189056,
0.018219515681266785,
0.022670598700642586,
0.014251194894313812,
0.004243495874106884,
0.002025195164605975,
-0.06955664604902267,
-0.0026624437887221575,
0.012822212651371956,
0.006401451304554939,
0.03041413426399231,
0.04306255280971527,
-0.021511966362595558
] |
725,892 | validator_collection.checkers | are_dicts_equivalent | Indicate if :ref:`dicts <python:dict>` passed to this function have identical
keys and values.
:param args: One or more values, passed as positional arguments.
:param strict_typing: If ``True``, will only identify items as equivalent if they have
identical sub-typing. If ``False``, related sub-types will be returned as equivalent.
Defaults to ``True``.
:type strict_typing: :class:`bool <python:bool>`
:param missing_as_none: If ``True``, will treat missing keys in one value and
:obj:`None <python:None>` keys in the other as equivalent. If ``False``, missing and
:obj:`None <pythoN:None>` keys will fail. Defaults to ``False``.
:type missing_as_none: :class:`bool <python:bool>`
:returns: ``True`` if ``args`` have identical keys/values, and ``False`` if not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (*args, **kwargs) | [
0.0027183322235941887,
0.013799999840557575,
-0.03053659200668335,
-0.007108339108526707,
0.007262113504111767,
0.017113586887717247,
0.0016171099850907922,
0.054009489715099335,
-0.07531962543725967,
0.0073265996761620045,
0.01014414057135582,
-0.006279942579567432,
0.08262142539024353,
-0.002713371766731143,
-0.030278649181127548,
-0.02103235013782978,
-0.04631085693836212,
0.027639683336019516,
-0.007971459068357944,
-0.03053659200668335,
-0.03779870644211769,
0.09055815637111664,
0.04258058965206146,
-0.016726670786738396,
0.020030338317155838,
0.02008986286818981,
0.028988929465413094,
0.022322069853544235,
-0.018006470054388046,
0.03863206505775452,
-0.0223617535084486,
-0.02254033088684082,
0.02281811647117138,
-0.024187203496694565,
-0.0012984004570171237,
-0.013869446702301502,
0.014176994562149048,
0.037322502583265305,
-0.017550107091665268,
-0.014960747212171555,
-0.059327103197574615,
0.04508066177368164,
-0.012282099574804306,
0.024286411702632904,
0.005193601828068495,
-0.06734320521354675,
-0.053930122405290604,
0.010506254620850086,
-0.051866572350263596,
-0.038016967475414276,
-0.002730733249336481,
-0.06766067445278168,
0.011091588996350765,
-0.07266081869602203,
-0.009836592711508274,
-0.008060747757554054,
-0.01709374599158764,
0.04055672138929367,
0.02156808041036129,
0.05563652142882347,
0.05031890794634819,
0.0017448418075218797,
0.0073315599001944065,
-0.020437095314264297,
-0.027758734300732613,
-0.037243135273456573,
-0.04738231375813484,
-0.054287273436784744,
-0.0528983473777771,
-0.010992379859089851,
-0.045834653079509735,
0.02394910156726837,
-0.001046657096594572,
0.023631632328033447,
-0.015754422172904015,
-0.06162875518202782,
-0.03387002274394035,
0.05869216471910477,
-0.014405176043510437,
0.019970811903476715,
0.039981309324502945,
-0.015913156792521477,
-0.030417541041970253,
-0.08547864854335785,
-0.02192523330450058,
0.024187203496694565,
-0.08928827941417694,
0.017212796956300735,
0.030139755457639694,
-0.0044247303158044815,
-0.015962760895490646,
0.00500262388959527,
0.028353989124298096,
-0.0345049612224102,
-0.06115255132317543,
-0.03335413336753845,
0.04519971087574959,
-0.00995564367622137,
-0.013522214256227016,
-0.006785909179598093,
0.00854687299579382,
-0.00033049064222723246,
0.06674794852733612,
-0.011458663269877434,
0.02335384674370289,
-0.010064773261547089,
0.018641408532857895,
-0.013224586844444275,
-0.01024831086397171,
0.027480948716402054,
0.007539899554103613,
-0.07107347249984741,
-0.023016534745693207,
-0.008809776976704597,
-0.01993112824857235,
-0.04333458095788956,
-0.03887016698718071,
-0.00009176851017400622,
-0.06817656010389328,
-0.03097311221063137,
-0.015595686621963978,
0.04988238587975502,
-0.00025561871007084846,
0.04214406758546829,
0.08555801212787628,
-0.04226312041282654,
-0.01376031618565321,
-0.009891157038509846,
0.0008724209037609398,
-0.003747627604752779,
-0.03752091899514198,
0.00891890749335289,
-0.06551775336265564,
0.04083450883626938,
0.028254780918359756,
0.04849345609545708,
-0.018849749118089676,
-0.026032494381070137,
-0.023373687639832497,
-0.022421279922127724,
0.02974291890859604,
0.07714507728815079,
0.027719050645828247,
-0.04781883582472801,
-0.0365486703813076,
0.038215383887290955,
-0.016667146235704422,
0.00004867451571044512,
0.013085694052278996,
0.021607764065265656,
-0.01978231407701969,
-0.053572967648506165,
0.045477498322725296,
0.06627174466848373,
-0.08992321789264679,
-0.06539870798587799,
-0.03025880642235279,
-0.012043996714055538,
-0.0030234004370868206,
-0.023393530398607254,
0.035893891006708145,
0.05964457243680954,
-0.04142976179718971,
0.016845721751451492,
0.019544212147593498,
0.040616247802972794,
-0.019762473180890083,
-0.009147088043391705,
-0.009285980835556984,
0.0047546010464429855,
-0.040874190628528595,
-0.01850251667201519,
0.013204745016992092,
0.015357584692537785,
-0.027480948716402054,
0.057382602244615555,
-0.06718447059392929,
-0.009836592711508274,
-0.0025471963454037905,
0.029861969873309135,
0.017996549606323242,
-0.004583464935421944,
-0.015099640935659409,
0.007782961707562208,
-0.031131846830248833,
0.02972307614982128,
0.02226254530251026,
-0.051430050283670425,
0.027758734300732613,
-0.01921682246029377,
-0.044882241636514664,
0.03595341369509697,
0.048771243542432785,
-0.09603450447320938,
0.013006326742470264,
0.029088137671351433,
-0.012569805607199669,
0.029762759804725647,
0.007063695229589939,
0.035536736249923706,
0.012282099574804306,
0.01581394672393799,
0.023671315982937813,
0.014028181321918964,
0.05023954063653946,
-0.01645880751311779,
0.00890402588993311,
0.04889029636979103,
0.058533430099487305,
-0.009360387921333313,
-0.050636377185583115,
-0.060120776295661926,
0.0018204888328909874,
0.06504154950380325,
0.061192236840724945,
0.01885966956615448,
0.015030194073915482,
-0.043453630059957504,
0.021250611171126366,
0.007133141625672579,
0.0038046729750931263,
0.02369115687906742,
-0.04031861945986748,
0.04849345609545708,
0.03720344975590706,
-0.053930122405290604,
-0.02484198473393917,
0.06238274648785591,
0.005565636325627565,
-0.04448540508747101,
-0.007157944142818451,
0.001129124779254198,
0.033949390053749084,
0.061192236840724945,
-0.03488195687532425,
0.021171243861317635,
-0.014940905384719372,
0.04996175318956375,
-0.024107836186885834,
0.012212652713060379,
0.03928684443235397,
0.011508267372846603,
-0.05785880610346794,
-0.10206642746925354,
-0.01957397535443306,
0.009950682520866394,
0.009132207371294498,
0.046033069491386414,
-0.033155716955661774,
-0.02220301888883114,
-0.01574449986219406,
0.015466714277863503,
-0.01576434262096882,
-0.10357441008090973,
-0.03158821165561676,
0.022659381851553917,
-0.010664989240467548,
-0.07452595233917236,
0.03131042420864105,
0.002387221436947584,
-0.028592092916369438,
-0.013671028427779675,
0.07202588021755219,
0.07651013880968094,
-0.05654924362897873,
-0.019583895802497864,
0.05575557053089142,
0.040596406906843185,
-0.011280085891485214,
-0.030695326626300812,
0.12397181987762451,
0.01642904430627823,
0.08468497544527054,
0.0493268147110939,
-0.0007874730508774519,
-0.004866211209446192,
0.028334148228168488,
-0.033770810812711716,
0.02218317799270153,
0.03311603143811226,
-0.017996549606323242,
0.043969519436359406,
0.027044428512454033,
-0.04436635598540306,
0.0287508275359869,
-0.044961608946323395,
0.040239252150058746,
0.05563652142882347,
-0.025695182383060455,
0.011756290681660175,
0.0201890729367733,
-0.04014004394412041,
0.04595370218157768,
-0.0076639107428491116,
-0.03587404638528824,
0.1206383928656578,
0.05139036476612091,
-0.014970668591558933,
-0.02511977031826973,
-0.05254119262099266,
-0.06647016853094101,
0.011438821442425251,
0.015010352246463299,
-0.048850610852241516,
0.0370447151362896,
-0.006051761098206043,
-0.02256017178297043,
-0.018562041223049164,
-0.03250093385577202,
0.01890927366912365,
0.013780158013105392,
0.029981020838022232,
0.004141984041780233,
-0.018026312813162804,
0.018085837364196777,
0.001484417705796659,
-0.0025087527465075254,
-0.04083450883626938,
-0.0350010059773922,
0.0241475198417902,
-0.03569547086954117,
0.021369662135839462,
0.030953271314501762,
0.01442501787096262,
-0.007703594397753477,
-0.031647734344005585,
-0.007842487655580044,
0.07583551108837128,
-0.015020273625850677,
0.02877066843211651,
-0.028016678988933563,
-0.07234334945678711,
0.057025447487831116,
0.02261969819664955,
0.060557298362255096,
-0.04349331557750702,
-0.018740618601441383,
0.00007467817340511829,
0.036707405000925064,
0.04198533296585083,
-0.002666247310116887,
0.006294823717325926,
-0.0091371675953269,
-0.013631344772875309,
-0.03150884434580803,
0.009514162316918373,
-0.012480517849326134,
0.0232546366751194,
0.0569857656955719,
0.07412911206483841,
-0.060477931052446365,
-0.03906858339905739,
-0.00011533069482538849,
-0.06543838977813721,
-0.057898491621017456,
-0.009593529626727104,
0.024980876594781876,
0.029703235253691673,
-0.01157771423459053,
-0.04127102717757225,
0.03912810981273651,
-0.013423005118966103,
-0.009271100163459778,
-0.007028971798717976,
-0.07520057260990143,
0.06178748980164528,
-0.024603882804512978,
0.010942774824798107,
0.05039827525615692,
0.00026414450258016586,
0.004258554894477129,
0.05833500996232033,
-0.019643422216176987,
-0.024901509284973145,
0.003988210111856461,
-0.0270841121673584,
0.0018180086044594646,
-0.02023867703974247,
-0.02315542846918106,
0.038929689675569534,
0.00016943071386776865,
-0.003110208548605442,
0.07722444087266922,
-0.04658864066004753,
0.03543752804398537,
-0.023929258808493614,
-0.022302228957414627,
0.02752063237130642,
-0.06091444939374924,
-0.016696909442543983,
0.01096261665225029,
0.020298203453421593,
0.007301797159016132,
-0.04694579541683197,
-0.01816520467400551,
-0.07662918418645859,
0.024068152531981468,
0.028473040089011192,
-0.06702573597431183,
-0.002131757792085409,
0.03666771948337555,
0.021706974133849144,
-0.017827892675995827,
0.019762473180890083,
0.0028969086706638336,
0.07670855522155762,
0.02394910156726837,
-0.02202444337308407,
0.03879079967737198,
-0.03470337763428688,
0.029762759804725647,
-0.050199855118989944,
-0.009836592711508274,
-0.0523824580013752,
0.0114983469247818,
0.00721250893548131,
-0.022937167435884476,
-0.013125377707183361,
0.012847591191530228,
-0.031369950622320175,
0.04686642810702324,
0.013740474358201027,
0.023413371294736862,
-0.021171243861317635,
-0.024425305426120758,
-0.0005630122032016516,
-0.015853630378842354,
-0.04678706079721451,
0.04972365126013756,
0.0014645758783444762,
-0.05404917150735855,
-0.029088137671351433,
0.004608267452567816,
0.013204745016992092,
-0.006934723351150751,
-0.03176678717136383,
-0.020913299173116684,
-0.008621280081570148,
0.011022142134606838,
-0.013799999840557575,
-0.03299698233604431,
-0.02396894246339798,
-0.028988929465413094,
0.04857282340526581,
-0.00034816228435374796,
0.009598489850759506,
-0.0046777138486504555,
-0.023492738604545593,
0.04186628386378288,
0.009409992955625057,
-0.009732422418892384,
0.052223723381757736,
-0.03795744106173515,
-0.004556182771921158,
-0.021270452067255974,
-0.02769920974969864,
-0.029227031394839287,
0.0368066132068634,
0.05464442819356918,
0.011230481788516045,
-0.014355571940541267,
-0.026607908308506012,
-0.008487347513437271,
-0.025238821282982826,
-0.027183322235941887,
0.004759561270475388,
-0.0013331236550584435,
0.026647591963410378,
0.07960546016693115,
0.03690582141280174,
-0.03992178291082382,
-0.0006609812844544649,
0.0019246585434302688,
0.012669014744460583,
0.01459367386996746,
0.0850818082690239,
-0.0029787563253194094,
0.026032494381070137,
-0.02767936699092388,
0.035378001630306244,
0.010694751515984535,
-0.01655801571905613,
0.04781883582472801,
-0.028175413608551025,
-0.03887016698718071,
-0.03827491030097008,
-0.012014234438538551,
0.03010007180273533,
0.0329572968184948,
-0.039445579051971436,
-0.018869590014219284,
-0.040953557938337326,
-0.030318332836031914,
0.04516002908349037,
0.023095902055501938,
-0.028790511190891266,
0.0007893331930972636,
0.010645147413015366,
-0.02317526936531067,
0.009395111352205276,
0.10166958719491959,
0.05758102238178253,
0.02361178956925869,
-0.0028597053606063128,
0.02557613141834736,
-0.02164744772017002,
0.006175772752612829,
-0.005798778031021357,
-0.017391372472047806,
0.020070021972060204,
-0.04186628386378288,
0.05575557053089142,
0.019941048696637154,
0.030992954969406128,
0.01051617506891489,
0.022480804473161697,
0.04285837337374687,
0.010010208934545517,
0.021548239514231682,
-0.022222861647605896,
-0.034127965569496155,
0.005580517463386059,
0.02654838189482689,
-0.02059582993388176,
0.006790869869291782,
0.05936678498983383,
0.011617397889494896,
-0.01822473108768463,
0.014157152734696865,
-0.020635513588786125,
0.03978288918733597,
0.023195112124085426,
-0.013482530601322651,
-0.01278806570917368,
0.056946080178022385,
-0.012688856571912766,
0.02103235013782978,
-0.037223294377326965,
0.03196520358324051,
-0.0048042056150734425,
0.046826742589473724,
-0.003955966793000698,
-0.005253127310425043,
-0.019762473180890083,
-0.015952840447425842,
0.04865219444036484,
0.029445290565490723,
-0.044961608946323395,
-0.004154385533183813,
0.022877642884850502,
0.023413371294736862,
-0.0252983458340168,
-0.005858303513377905,
0.09373285621404648,
-0.05420790612697601,
0.0287508275359869,
-0.02049662172794342,
0.008412940427660942,
0.01653817482292652,
0.02573486790060997,
-0.0027555355336517096,
0.05317613109946251,
0.01504011545330286,
-0.0039162831380963326,
-0.042739324271678925,
-0.07226398587226868,
-0.012728540226817131,
0.02192523330450058,
0.04297742620110512,
-0.02226254530251026,
0.029881810769438744,
0.007554780691862106,
-0.022778432816267014,
-0.014157152734696865,
0.02599281072616577,
0.012946801260113716,
-0.019583895802497864,
-0.003001078264787793,
-0.029961178079247475,
-0.02051646262407303,
0.01038720365613699,
-0.025536447763442993,
-0.030596118420362473,
-0.03478274494409561,
-0.018393386155366898,
-0.03140963241457939,
-0.05154910311102867,
-0.026667432859539986,
-0.05381106957793236,
-0.011022142134606838,
-0.003931164741516113,
0.08428813517093658,
0.03252077475190163,
-0.018591804429888725,
0.022044284269213676,
-0.014811933971941471,
0.032897770404815674,
-0.016905248165130615,
-0.021349819377064705,
-0.01898864097893238,
-0.05849374458193779,
0.015605607070028782,
-0.022699065506458282,
-0.050993528217077255,
0.016528252512216568,
0.031012795865535736,
0.011478505097329617,
-0.005580517463386059,
0.004099820274859667,
-0.031171530485153198,
0.030338173732161522,
0.008432782255113125,
0.07726413011550903,
0.0621049590408802,
-0.05139036476612091,
-0.01931603252887726,
0.023572105914354324,
-0.030298490077257156,
-0.004047735594213009,
0.03381049633026123,
-0.0029167504981160164,
0.03035801649093628,
0.07746254652738571,
-0.009295902214944363,
-0.018978720530867577,
-0.03996146470308304,
-0.024167360737919807,
-0.08317699283361435,
0.017163192853331566,
-0.048334721475839615,
-0.04021941125392914,
-0.004055175930261612,
0.01918705925345421,
-0.043890152126550674,
-0.02049662172794342,
-0.038116175681352615,
-0.028611933812499046,
-0.024464989081025124,
0.007505176123231649,
0.023988785222172737,
-0.042025018483400345,
-0.03260014206171036,
0.003712904406711459,
0.023849891498684883,
-0.024385621771216393,
0.024087993428111076,
0.06496218591928482,
0.01000524777919054,
0.05904931575059891,
0.027024585753679276,
0.027401581406593323,
0.09365348517894745,
0.029227031394839287,
0.0012246136320754886,
0.030675485730171204,
0.03640977665781975,
-0.007048813626170158,
0.0035963335540145636,
-0.009653055109083652,
-0.021607764065265656,
0.04559654742479324,
-0.013492451049387455,
0.01561552844941616,
-0.017798131331801414,
0.05432695895433426,
0.03015959821641445,
-0.045834653079509735,
-0.0636129379272461,
-0.018661251291632652,
-0.0014062904519960284,
-0.03178662806749344,
0.05230309069156647,
-0.018036233261227608,
-0.04127102717757225,
-0.03694550693035126,
0.0026315241120755672,
-0.036965347826480865,
-0.03595341369509697,
-0.004070057533681393,
0.026687275618314743,
-0.03843364492058754,
-0.023988785222172737,
-0.015139324590563774,
0.04865219444036484,
0.011200718581676483,
0.00973738357424736,
0.027738893404603004,
-0.03170726075768471,
-0.014762328937649727,
-0.09809806197881699,
0.00663213524967432,
-0.005032386630773544,
0.0013666067970916629,
-0.007559741381555796,
-0.012321783229708672,
-0.0815102830529213,
-0.0023562186397612095,
0.11325722187757492,
0.05095384642481804,
-0.02254033088684082,
0.0135420560836792,
0.013373400084674358,
0.045477498322725296,
0.038572538644075394,
-0.0011260244064033031,
0.06730352342128754,
-0.056231774389743805,
0.0040378146804869175,
0.061390653252601624,
0.03418749198317528,
-0.01473256666213274,
0.013551976531744003,
0.02742142416536808,
-0.05627145990729332,
0.021250611171126366,
-0.04555686563253403,
-0.02563565783202648,
0.03263982757925987,
0.007668871432542801,
-0.020992666482925415,
0.04039798676967621,
-0.0006572609418071806,
0.019593818113207817,
-0.00728195533156395,
0.03585420548915863,
-0.07960546016693115,
-0.03267950937151909,
0.03138979151844978,
0.007480373606085777,
-0.048136305063962936,
0.040675774216651917,
-0.020695040002465248,
-0.01658777892589569,
0.03317555785179138,
-0.014127390459179878,
0.019583895802497864,
-0.023393530398607254,
0.031012795865535736,
-0.09365348517894745,
0.006468439940363169,
0.010198705829679966,
0.0029613946098834276,
0.008665923960506916,
-0.0291278213262558,
0.010952696204185486,
0.03805664926767349,
0.049485549330711365,
0.01983192004263401,
0.05123163014650345,
-0.027996836230158806,
0.03508037328720093,
-0.029346082359552383,
-0.03043738380074501,
0.002559597371146083,
0.09849489480257034,
-0.01243091281503439,
-0.06480345129966736,
-0.007177785970270634,
0.006165851838886738,
0.017550107091665268,
-0.04789820313453674,
-0.059247735887765884,
0.008348454721271992,
-0.04198533296585083,
0.012926959432661533,
0.005396980792284012,
-0.02049662172794342,
-0.017728684470057487
] |
725,893 | validator_collection.checkers | are_equivalent | Indicate if arguments passed to this function are equivalent.
.. hint::
This checker operates recursively on the members contained within iterables
and :class:`dict <python:dict>` objects.
.. caution::
If you only pass one argument to this checker - even if it is an iterable -
the checker will *always* return ``True``.
To evaluate members of an iterable for equivalence, you should instead
unpack the iterable into the function like so:
.. code-block:: python
obj = [1, 1, 1, 2]
result = are_equivalent(*obj)
# Will return ``False`` by unpacking and evaluating the iterable's members
result = are_equivalent(obj)
# Will always return True
:param args: One or more values, passed as positional arguments.
:param strict_typing: If ``True``, will only identify items as equivalent if they have
identical sub-typing. If ``False``, related sub-types will be returned as equivalent.
Defaults to ``True``.
:type strict_typing: :class:`bool <python:bool>`
:returns: ``True`` if ``args`` are equivalent, and ``False`` if not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (*args, **kwargs) | [
0.0027183322235941887,
0.013799999840557575,
-0.03053659200668335,
-0.007108339108526707,
0.007262113504111767,
0.017113586887717247,
0.0016171099850907922,
0.054009489715099335,
-0.07531962543725967,
0.0073265996761620045,
0.01014414057135582,
-0.006279942579567432,
0.08262142539024353,
-0.002713371766731143,
-0.030278649181127548,
-0.02103235013782978,
-0.04631085693836212,
0.027639683336019516,
-0.007971459068357944,
-0.03053659200668335,
-0.03779870644211769,
0.09055815637111664,
0.04258058965206146,
-0.016726670786738396,
0.020030338317155838,
0.02008986286818981,
0.028988929465413094,
0.022322069853544235,
-0.018006470054388046,
0.03863206505775452,
-0.0223617535084486,
-0.02254033088684082,
0.02281811647117138,
-0.024187203496694565,
-0.0012984004570171237,
-0.013869446702301502,
0.014176994562149048,
0.037322502583265305,
-0.017550107091665268,
-0.014960747212171555,
-0.059327103197574615,
0.04508066177368164,
-0.012282099574804306,
0.024286411702632904,
0.005193601828068495,
-0.06734320521354675,
-0.053930122405290604,
0.010506254620850086,
-0.051866572350263596,
-0.038016967475414276,
-0.002730733249336481,
-0.06766067445278168,
0.011091588996350765,
-0.07266081869602203,
-0.009836592711508274,
-0.008060747757554054,
-0.01709374599158764,
0.04055672138929367,
0.02156808041036129,
0.05563652142882347,
0.05031890794634819,
0.0017448418075218797,
0.0073315599001944065,
-0.020437095314264297,
-0.027758734300732613,
-0.037243135273456573,
-0.04738231375813484,
-0.054287273436784744,
-0.0528983473777771,
-0.010992379859089851,
-0.045834653079509735,
0.02394910156726837,
-0.001046657096594572,
0.023631632328033447,
-0.015754422172904015,
-0.06162875518202782,
-0.03387002274394035,
0.05869216471910477,
-0.014405176043510437,
0.019970811903476715,
0.039981309324502945,
-0.015913156792521477,
-0.030417541041970253,
-0.08547864854335785,
-0.02192523330450058,
0.024187203496694565,
-0.08928827941417694,
0.017212796956300735,
0.030139755457639694,
-0.0044247303158044815,
-0.015962760895490646,
0.00500262388959527,
0.028353989124298096,
-0.0345049612224102,
-0.06115255132317543,
-0.03335413336753845,
0.04519971087574959,
-0.00995564367622137,
-0.013522214256227016,
-0.006785909179598093,
0.00854687299579382,
-0.00033049064222723246,
0.06674794852733612,
-0.011458663269877434,
0.02335384674370289,
-0.010064773261547089,
0.018641408532857895,
-0.013224586844444275,
-0.01024831086397171,
0.027480948716402054,
0.007539899554103613,
-0.07107347249984741,
-0.023016534745693207,
-0.008809776976704597,
-0.01993112824857235,
-0.04333458095788956,
-0.03887016698718071,
-0.00009176851017400622,
-0.06817656010389328,
-0.03097311221063137,
-0.015595686621963978,
0.04988238587975502,
-0.00025561871007084846,
0.04214406758546829,
0.08555801212787628,
-0.04226312041282654,
-0.01376031618565321,
-0.009891157038509846,
0.0008724209037609398,
-0.003747627604752779,
-0.03752091899514198,
0.00891890749335289,
-0.06551775336265564,
0.04083450883626938,
0.028254780918359756,
0.04849345609545708,
-0.018849749118089676,
-0.026032494381070137,
-0.023373687639832497,
-0.022421279922127724,
0.02974291890859604,
0.07714507728815079,
0.027719050645828247,
-0.04781883582472801,
-0.0365486703813076,
0.038215383887290955,
-0.016667146235704422,
0.00004867451571044512,
0.013085694052278996,
0.021607764065265656,
-0.01978231407701969,
-0.053572967648506165,
0.045477498322725296,
0.06627174466848373,
-0.08992321789264679,
-0.06539870798587799,
-0.03025880642235279,
-0.012043996714055538,
-0.0030234004370868206,
-0.023393530398607254,
0.035893891006708145,
0.05964457243680954,
-0.04142976179718971,
0.016845721751451492,
0.019544212147593498,
0.040616247802972794,
-0.019762473180890083,
-0.009147088043391705,
-0.009285980835556984,
0.0047546010464429855,
-0.040874190628528595,
-0.01850251667201519,
0.013204745016992092,
0.015357584692537785,
-0.027480948716402054,
0.057382602244615555,
-0.06718447059392929,
-0.009836592711508274,
-0.0025471963454037905,
0.029861969873309135,
0.017996549606323242,
-0.004583464935421944,
-0.015099640935659409,
0.007782961707562208,
-0.031131846830248833,
0.02972307614982128,
0.02226254530251026,
-0.051430050283670425,
0.027758734300732613,
-0.01921682246029377,
-0.044882241636514664,
0.03595341369509697,
0.048771243542432785,
-0.09603450447320938,
0.013006326742470264,
0.029088137671351433,
-0.012569805607199669,
0.029762759804725647,
0.007063695229589939,
0.035536736249923706,
0.012282099574804306,
0.01581394672393799,
0.023671315982937813,
0.014028181321918964,
0.05023954063653946,
-0.01645880751311779,
0.00890402588993311,
0.04889029636979103,
0.058533430099487305,
-0.009360387921333313,
-0.050636377185583115,
-0.060120776295661926,
0.0018204888328909874,
0.06504154950380325,
0.061192236840724945,
0.01885966956615448,
0.015030194073915482,
-0.043453630059957504,
0.021250611171126366,
0.007133141625672579,
0.0038046729750931263,
0.02369115687906742,
-0.04031861945986748,
0.04849345609545708,
0.03720344975590706,
-0.053930122405290604,
-0.02484198473393917,
0.06238274648785591,
0.005565636325627565,
-0.04448540508747101,
-0.007157944142818451,
0.001129124779254198,
0.033949390053749084,
0.061192236840724945,
-0.03488195687532425,
0.021171243861317635,
-0.014940905384719372,
0.04996175318956375,
-0.024107836186885834,
0.012212652713060379,
0.03928684443235397,
0.011508267372846603,
-0.05785880610346794,
-0.10206642746925354,
-0.01957397535443306,
0.009950682520866394,
0.009132207371294498,
0.046033069491386414,
-0.033155716955661774,
-0.02220301888883114,
-0.01574449986219406,
0.015466714277863503,
-0.01576434262096882,
-0.10357441008090973,
-0.03158821165561676,
0.022659381851553917,
-0.010664989240467548,
-0.07452595233917236,
0.03131042420864105,
0.002387221436947584,
-0.028592092916369438,
-0.013671028427779675,
0.07202588021755219,
0.07651013880968094,
-0.05654924362897873,
-0.019583895802497864,
0.05575557053089142,
0.040596406906843185,
-0.011280085891485214,
-0.030695326626300812,
0.12397181987762451,
0.01642904430627823,
0.08468497544527054,
0.0493268147110939,
-0.0007874730508774519,
-0.004866211209446192,
0.028334148228168488,
-0.033770810812711716,
0.02218317799270153,
0.03311603143811226,
-0.017996549606323242,
0.043969519436359406,
0.027044428512454033,
-0.04436635598540306,
0.0287508275359869,
-0.044961608946323395,
0.040239252150058746,
0.05563652142882347,
-0.025695182383060455,
0.011756290681660175,
0.0201890729367733,
-0.04014004394412041,
0.04595370218157768,
-0.0076639107428491116,
-0.03587404638528824,
0.1206383928656578,
0.05139036476612091,
-0.014970668591558933,
-0.02511977031826973,
-0.05254119262099266,
-0.06647016853094101,
0.011438821442425251,
0.015010352246463299,
-0.048850610852241516,
0.0370447151362896,
-0.006051761098206043,
-0.02256017178297043,
-0.018562041223049164,
-0.03250093385577202,
0.01890927366912365,
0.013780158013105392,
0.029981020838022232,
0.004141984041780233,
-0.018026312813162804,
0.018085837364196777,
0.001484417705796659,
-0.0025087527465075254,
-0.04083450883626938,
-0.0350010059773922,
0.0241475198417902,
-0.03569547086954117,
0.021369662135839462,
0.030953271314501762,
0.01442501787096262,
-0.007703594397753477,
-0.031647734344005585,
-0.007842487655580044,
0.07583551108837128,
-0.015020273625850677,
0.02877066843211651,
-0.028016678988933563,
-0.07234334945678711,
0.057025447487831116,
0.02261969819664955,
0.060557298362255096,
-0.04349331557750702,
-0.018740618601441383,
0.00007467817340511829,
0.036707405000925064,
0.04198533296585083,
-0.002666247310116887,
0.006294823717325926,
-0.0091371675953269,
-0.013631344772875309,
-0.03150884434580803,
0.009514162316918373,
-0.012480517849326134,
0.0232546366751194,
0.0569857656955719,
0.07412911206483841,
-0.060477931052446365,
-0.03906858339905739,
-0.00011533069482538849,
-0.06543838977813721,
-0.057898491621017456,
-0.009593529626727104,
0.024980876594781876,
0.029703235253691673,
-0.01157771423459053,
-0.04127102717757225,
0.03912810981273651,
-0.013423005118966103,
-0.009271100163459778,
-0.007028971798717976,
-0.07520057260990143,
0.06178748980164528,
-0.024603882804512978,
0.010942774824798107,
0.05039827525615692,
0.00026414450258016586,
0.004258554894477129,
0.05833500996232033,
-0.019643422216176987,
-0.024901509284973145,
0.003988210111856461,
-0.0270841121673584,
0.0018180086044594646,
-0.02023867703974247,
-0.02315542846918106,
0.038929689675569534,
0.00016943071386776865,
-0.003110208548605442,
0.07722444087266922,
-0.04658864066004753,
0.03543752804398537,
-0.023929258808493614,
-0.022302228957414627,
0.02752063237130642,
-0.06091444939374924,
-0.016696909442543983,
0.01096261665225029,
0.020298203453421593,
0.007301797159016132,
-0.04694579541683197,
-0.01816520467400551,
-0.07662918418645859,
0.024068152531981468,
0.028473040089011192,
-0.06702573597431183,
-0.002131757792085409,
0.03666771948337555,
0.021706974133849144,
-0.017827892675995827,
0.019762473180890083,
0.0028969086706638336,
0.07670855522155762,
0.02394910156726837,
-0.02202444337308407,
0.03879079967737198,
-0.03470337763428688,
0.029762759804725647,
-0.050199855118989944,
-0.009836592711508274,
-0.0523824580013752,
0.0114983469247818,
0.00721250893548131,
-0.022937167435884476,
-0.013125377707183361,
0.012847591191530228,
-0.031369950622320175,
0.04686642810702324,
0.013740474358201027,
0.023413371294736862,
-0.021171243861317635,
-0.024425305426120758,
-0.0005630122032016516,
-0.015853630378842354,
-0.04678706079721451,
0.04972365126013756,
0.0014645758783444762,
-0.05404917150735855,
-0.029088137671351433,
0.004608267452567816,
0.013204745016992092,
-0.006934723351150751,
-0.03176678717136383,
-0.020913299173116684,
-0.008621280081570148,
0.011022142134606838,
-0.013799999840557575,
-0.03299698233604431,
-0.02396894246339798,
-0.028988929465413094,
0.04857282340526581,
-0.00034816228435374796,
0.009598489850759506,
-0.0046777138486504555,
-0.023492738604545593,
0.04186628386378288,
0.009409992955625057,
-0.009732422418892384,
0.052223723381757736,
-0.03795744106173515,
-0.004556182771921158,
-0.021270452067255974,
-0.02769920974969864,
-0.029227031394839287,
0.0368066132068634,
0.05464442819356918,
0.011230481788516045,
-0.014355571940541267,
-0.026607908308506012,
-0.008487347513437271,
-0.025238821282982826,
-0.027183322235941887,
0.004759561270475388,
-0.0013331236550584435,
0.026647591963410378,
0.07960546016693115,
0.03690582141280174,
-0.03992178291082382,
-0.0006609812844544649,
0.0019246585434302688,
0.012669014744460583,
0.01459367386996746,
0.0850818082690239,
-0.0029787563253194094,
0.026032494381070137,
-0.02767936699092388,
0.035378001630306244,
0.010694751515984535,
-0.01655801571905613,
0.04781883582472801,
-0.028175413608551025,
-0.03887016698718071,
-0.03827491030097008,
-0.012014234438538551,
0.03010007180273533,
0.0329572968184948,
-0.039445579051971436,
-0.018869590014219284,
-0.040953557938337326,
-0.030318332836031914,
0.04516002908349037,
0.023095902055501938,
-0.028790511190891266,
0.0007893331930972636,
0.010645147413015366,
-0.02317526936531067,
0.009395111352205276,
0.10166958719491959,
0.05758102238178253,
0.02361178956925869,
-0.0028597053606063128,
0.02557613141834736,
-0.02164744772017002,
0.006175772752612829,
-0.005798778031021357,
-0.017391372472047806,
0.020070021972060204,
-0.04186628386378288,
0.05575557053089142,
0.019941048696637154,
0.030992954969406128,
0.01051617506891489,
0.022480804473161697,
0.04285837337374687,
0.010010208934545517,
0.021548239514231682,
-0.022222861647605896,
-0.034127965569496155,
0.005580517463386059,
0.02654838189482689,
-0.02059582993388176,
0.006790869869291782,
0.05936678498983383,
0.011617397889494896,
-0.01822473108768463,
0.014157152734696865,
-0.020635513588786125,
0.03978288918733597,
0.023195112124085426,
-0.013482530601322651,
-0.01278806570917368,
0.056946080178022385,
-0.012688856571912766,
0.02103235013782978,
-0.037223294377326965,
0.03196520358324051,
-0.0048042056150734425,
0.046826742589473724,
-0.003955966793000698,
-0.005253127310425043,
-0.019762473180890083,
-0.015952840447425842,
0.04865219444036484,
0.029445290565490723,
-0.044961608946323395,
-0.004154385533183813,
0.022877642884850502,
0.023413371294736862,
-0.0252983458340168,
-0.005858303513377905,
0.09373285621404648,
-0.05420790612697601,
0.0287508275359869,
-0.02049662172794342,
0.008412940427660942,
0.01653817482292652,
0.02573486790060997,
-0.0027555355336517096,
0.05317613109946251,
0.01504011545330286,
-0.0039162831380963326,
-0.042739324271678925,
-0.07226398587226868,
-0.012728540226817131,
0.02192523330450058,
0.04297742620110512,
-0.02226254530251026,
0.029881810769438744,
0.007554780691862106,
-0.022778432816267014,
-0.014157152734696865,
0.02599281072616577,
0.012946801260113716,
-0.019583895802497864,
-0.003001078264787793,
-0.029961178079247475,
-0.02051646262407303,
0.01038720365613699,
-0.025536447763442993,
-0.030596118420362473,
-0.03478274494409561,
-0.018393386155366898,
-0.03140963241457939,
-0.05154910311102867,
-0.026667432859539986,
-0.05381106957793236,
-0.011022142134606838,
-0.003931164741516113,
0.08428813517093658,
0.03252077475190163,
-0.018591804429888725,
0.022044284269213676,
-0.014811933971941471,
0.032897770404815674,
-0.016905248165130615,
-0.021349819377064705,
-0.01898864097893238,
-0.05849374458193779,
0.015605607070028782,
-0.022699065506458282,
-0.050993528217077255,
0.016528252512216568,
0.031012795865535736,
0.011478505097329617,
-0.005580517463386059,
0.004099820274859667,
-0.031171530485153198,
0.030338173732161522,
0.008432782255113125,
0.07726413011550903,
0.0621049590408802,
-0.05139036476612091,
-0.01931603252887726,
0.023572105914354324,
-0.030298490077257156,
-0.004047735594213009,
0.03381049633026123,
-0.0029167504981160164,
0.03035801649093628,
0.07746254652738571,
-0.009295902214944363,
-0.018978720530867577,
-0.03996146470308304,
-0.024167360737919807,
-0.08317699283361435,
0.017163192853331566,
-0.048334721475839615,
-0.04021941125392914,
-0.004055175930261612,
0.01918705925345421,
-0.043890152126550674,
-0.02049662172794342,
-0.038116175681352615,
-0.028611933812499046,
-0.024464989081025124,
0.007505176123231649,
0.023988785222172737,
-0.042025018483400345,
-0.03260014206171036,
0.003712904406711459,
0.023849891498684883,
-0.024385621771216393,
0.024087993428111076,
0.06496218591928482,
0.01000524777919054,
0.05904931575059891,
0.027024585753679276,
0.027401581406593323,
0.09365348517894745,
0.029227031394839287,
0.0012246136320754886,
0.030675485730171204,
0.03640977665781975,
-0.007048813626170158,
0.0035963335540145636,
-0.009653055109083652,
-0.021607764065265656,
0.04559654742479324,
-0.013492451049387455,
0.01561552844941616,
-0.017798131331801414,
0.05432695895433426,
0.03015959821641445,
-0.045834653079509735,
-0.0636129379272461,
-0.018661251291632652,
-0.0014062904519960284,
-0.03178662806749344,
0.05230309069156647,
-0.018036233261227608,
-0.04127102717757225,
-0.03694550693035126,
0.0026315241120755672,
-0.036965347826480865,
-0.03595341369509697,
-0.004070057533681393,
0.026687275618314743,
-0.03843364492058754,
-0.023988785222172737,
-0.015139324590563774,
0.04865219444036484,
0.011200718581676483,
0.00973738357424736,
0.027738893404603004,
-0.03170726075768471,
-0.014762328937649727,
-0.09809806197881699,
0.00663213524967432,
-0.005032386630773544,
0.0013666067970916629,
-0.007559741381555796,
-0.012321783229708672,
-0.0815102830529213,
-0.0023562186397612095,
0.11325722187757492,
0.05095384642481804,
-0.02254033088684082,
0.0135420560836792,
0.013373400084674358,
0.045477498322725296,
0.038572538644075394,
-0.0011260244064033031,
0.06730352342128754,
-0.056231774389743805,
0.0040378146804869175,
0.061390653252601624,
0.03418749198317528,
-0.01473256666213274,
0.013551976531744003,
0.02742142416536808,
-0.05627145990729332,
0.021250611171126366,
-0.04555686563253403,
-0.02563565783202648,
0.03263982757925987,
0.007668871432542801,
-0.020992666482925415,
0.04039798676967621,
-0.0006572609418071806,
0.019593818113207817,
-0.00728195533156395,
0.03585420548915863,
-0.07960546016693115,
-0.03267950937151909,
0.03138979151844978,
0.007480373606085777,
-0.048136305063962936,
0.040675774216651917,
-0.020695040002465248,
-0.01658777892589569,
0.03317555785179138,
-0.014127390459179878,
0.019583895802497864,
-0.023393530398607254,
0.031012795865535736,
-0.09365348517894745,
0.006468439940363169,
0.010198705829679966,
0.0029613946098834276,
0.008665923960506916,
-0.0291278213262558,
0.010952696204185486,
0.03805664926767349,
0.049485549330711365,
0.01983192004263401,
0.05123163014650345,
-0.027996836230158806,
0.03508037328720093,
-0.029346082359552383,
-0.03043738380074501,
0.002559597371146083,
0.09849489480257034,
-0.01243091281503439,
-0.06480345129966736,
-0.007177785970270634,
0.006165851838886738,
0.017550107091665268,
-0.04789820313453674,
-0.059247735887765884,
0.008348454721271992,
-0.04198533296585083,
0.012926959432661533,
0.005396980792284012,
-0.02049662172794342,
-0.017728684470057487
] |
725,894 | validator_collection.validators | bytesIO | Validate that ``value`` is a :class:`BytesIO <python:io.BytesIO>` object.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` / :obj:`None <python:None>`
:rtype: :class:`BytesIO <python:io.BytesIO>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises NotBytesIOError: if ``value`` is not a :class:`BytesIO <python:io.BytesIO>`
object.
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,896 | validator_collection.validators | date | Validate that ``value`` is a valid date.
:param value: The value to validate.
:type value: :class:`str <python:str>` / :class:`datetime <python:datetime.datetime>`
/ :class:`date <python:datetime.date>` / :obj:`None <python:None>`
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:param minimum: If supplied, will make sure that ``value`` is on or after this value.
:type minimum: :class:`datetime <python:datetime.datetime>` /
:class:`date <python:datetime.date>` / compliant :class:`str <python:str>`
/ :obj:`None <python:None>`
:param maximum: If supplied, will make sure that ``value`` is on or before this
value.
:type maximum: :class:`datetime <python:datetime.datetime>` /
:class:`date <python:datetime.date>` / compliant :class:`str <python:str>`
/ :obj:`None <python:None>`
:param coerce_value: If ``True``, will attempt to coerce ``value`` to a
:class:`date <python:datetime.date>` if it is a timestamp value. If ``False``,
will not.
:type coerce_value: :class:`bool <python:bool>`
:returns: ``value`` / :obj:`None <python:None>`
:rtype: :class:`date <python:datetime.date>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`date <python:datetime.date>` and is not :obj:`None <python:None>`
:raises MinimumValueError: if ``minimum`` is supplied but ``value`` occurs before
``minimum``
:raises MaximumValueError: if ``maximum`` is supplied but ``value`` occurs after
``maximum``
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, minimum=None, maximum=None, coerce_value=True, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,897 | validator_collection.validators | datetime | Validate that ``value`` is a valid datetime.
.. caution::
If supplying a string, the string needs to be in an ISO 8601-format to pass
validation. If it is not in an ISO 8601-format, validation will fail.
:param value: The value to validate.
:type value: :class:`str <python:str>` / :class:`datetime <python:datetime.datetime>`
/ :class:`date <python:datetime.date>` / :obj:`None <python:None>`
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:param minimum: If supplied, will make sure that ``value`` is on or after this value.
:type minimum: :class:`datetime <python:datetime.datetime>` /
:class:`date <python:datetime.date>` / compliant :class:`str <python:str>` /
:obj:`None <python:None>`
:param maximum: If supplied, will make sure that ``value`` is on or before this
value.
:type maximum: :class:`datetime <python:datetime.datetime>` /
:class:`date <python:datetime.date>` / compliant :class:`str <python:str>` /
:obj:`None <python:None>`
:param coerce_value: If ``True``, will coerce dates to
:class:`datetime <python:datetime.datetime>` objects with times of 00:00:00. If ``False``, will error
if ``value`` is not an unambiguous timestamp. Defaults to ``True``.
:type coerce_value: :class:`bool <python:bool>`
:returns: ``value`` / :obj:`None <python:None>`
:rtype: :class:`datetime <python:datetime.datetime>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`datetime <python:datetime.datetime>` value and is not
:obj:`None <python:None>`
:raises MinimumValueError: if ``minimum`` is supplied but ``value`` occurs
before ``minimum``
:raises MaximumValueError: if ``maximum`` is supplied but ``value`` occurs
after ``minimum``
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, minimum=None, maximum=None, coerce_value=True, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,898 | validator_collection.validators | decimal | Validate that ``value`` is a :class:`Decimal <python:decimal.Decimal>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if ``value``
is :obj:`None <python:None>`. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>` if
``value`` is :obj:`None <python:None>`. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:param minimum: If supplied, will make sure that ``value`` is greater than or
equal to this value.
:type minimum: numeric
:param maximum: If supplied, will make sure that ``value`` is less than or
equal to this value.
:type maximum: numeric
:returns: ``value`` / :obj:`None <python:None>`
:rtype: :class:`Decimal <python:decimal.Decimal>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is :obj:`None <python:None>` and
``allow_empty`` is ``False``
:raises MinimumValueError: if ``minimum`` is supplied and ``value`` is less than the
``minimum``
:raises MaximumValueError: if ``maximum`` is supplied and ``value`` is more than the
``maximum``
:raises CannotCoerceError: if unable to coerce ``value`` to a
:class:`Decimal <python:decimal.Decimal>`
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, minimum=None, maximum=None, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,899 | validator_collection.validators | dict | Validate that ``value`` is a :class:`dict <python:dict>`.
.. hint::
If ``value`` is a string, this validator will assume it is a JSON
object and try to convert it into a :class:`dict <python:dict>`
You can override the JSON serializer used by passing it to the
``json_serializer`` property. By default, will utilize the Python
:class:`json <json>` encoder/decoder.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:param json_serializer: The JSON encoder/decoder to use to deserialize a
string passed in ``value``. If not supplied, will default to the Python
:class:`json <python:json>` encoder/decoder.
:type json_serializer: callable
:returns: ``value`` / :obj:`None <python:None>`
:rtype: :class:`dict <python:dict>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`dict <python:dict>`
:raises NotADictError: if ``value`` is not a :class:`dict <python:dict>`
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, json_serializer=None, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,900 | validator_collection.validators | directory_exists | Validate that ``value`` is a valid directory that exists on the local
filesystem.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: The file name represented by ``value``.
:rtype: Path-like object / :obj:`None <python:None>`
:raises EmptyValueError: if ``allow_empty`` is ``False`` and ``value``
is empty
:raises NotPathlikeError: if ``value`` is not a path-like object
:raises PathExistsError: if ``value`` does not exist on the local filesystem
:raises NotADirectoryError: if ``value`` is not a valid directory
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,901 | validator_collection.validators | domain | Validate that ``value`` is a valid domain name.
.. caution::
This validator does not verify that ``value`` **exists** as a domain. It
merely verifies that its contents *might* exist as a domain.
.. note::
This validator checks to validate that ``value`` resembles a valid
domain name. It is - generally - compliant with
`RFC 1035 <https://tools.ietf.org/html/rfc1035>`_ and
`RFC 6761 <https://tools.ietf.org/html/rfc6761>`_, however it diverges
in a number of key ways:
* Including authentication (e.g. ``username:[email protected]``) will
fail validation.
* Including a path (e.g. ``domain.dev/path/to/file``) will fail validation.
* Including a port (e.g. ``domain.dev:8080``) will fail validation.
If you are hoping to validate a more complete URL, we recommend that you
see :func:`url <validator_collection.validators.url>`.
.. hint::
Leading and trailing whitespace will be automatically stripped.
:param value: The value to validate.
:type value: :class:`str <python:str>` / :obj:`None <python:None>`
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:param allow_ips: If ``True``, will succeed when validating IP addresses,
If ``False``, will raise a :class:`InvalidDomainError` if ``value`` is an IP
address. Defaults to ``False``.
:type allow_ips: :class:`bool <python:bool>`
:returns: ``value`` / :obj:`None <python:None>`
:rtype: :class:`str <python:str>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` is not a :class:`str <python:str>` or
:obj:`None <python:None>`
:raises InvalidDomainError: if ``value`` is not a valid domain name or
empty with ``allow_empty`` set to ``True``
:raises SlashInDomainError: if ``value`` contains a slash or backslash
:raises AtInDomainError: if ``value`` contains an ``@`` symbol
:raises ColonInDomainError: if ``value`` contains a ``:`` symbol
:raises WhitespaceInDomainError: if ``value`` contains whitespace
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, allow_ips=False, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,902 | validator_collection.validators | email | Validate that ``value`` is a valid email address.
.. note::
Email address validation is...complicated. The methodology that we have
adopted here is *generally* compliant with
`RFC 5322 <https://tools.ietf.org/html/rfc5322>`_ and uses a combination of
string parsing and regular expressions.
String parsing in particular is used to validate certain *highly unusual*
but still valid email patterns, including the use of escaped text and
comments within an email address' local address (the user name part).
This approach ensures more complete coverage for unusual edge cases, while
still letting us use regular expressions that perform quickly.
:param value: The value to validate.
:type value: :class:`str <python:str>` / :obj:`None <python:None>`
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` / :obj:`None <python:None>`
:rtype: :class:`str <python:str>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` is not a :class:`str <python:str>` or
:obj:`None <python:None>`
:raises InvalidEmailError: if ``value`` is not a valid email address or
empty with ``allow_empty`` set to ``True``
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,904 | validator_collection.validators | file_exists | Validate that ``value`` is a valid file that exists on the local filesystem.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: The file name represented by ``value``.
:rtype: Path-like object / :obj:`None <python:None>`
:raises EmptyValueError: if ``allow_empty`` is ``False`` and ``value``
is empty
:raises NotPathlikeError: if ``value`` is not a path-like object
:raises PathExistsError: if ``value`` does not exist on the local filesystem
:raises NotAFileError: if ``value`` is not a valid file
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,905 | validator_collection.validators | float | Validate that ``value`` is a :class:`float <python:float>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is :obj:`None <python:None>`. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>` if
``value`` is :obj:`None <python:None>`. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` / :obj:`None <python:None>`
:rtype: :class:`float <python:float>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is :obj:`None <python:None>` and
``allow_empty`` is ``False``
:raises MinimumValueError: if ``minimum`` is supplied and ``value`` is less
than the ``minimum``
:raises MaximumValueError: if ``maximum`` is supplied and ``value`` is more
than the ``maximum``
:raises CannotCoerceError: if unable to coerce ``value`` to a
:class:`float <python:float>`
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, minimum=None, maximum=None, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,906 | validator_collection.validators | fraction | Validate that ``value`` is a :class:`Fraction <python:fractions.Fraction>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if ``value``
is :obj:`None <python:None>`. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>` if
``value`` is :obj:`None <python:None>`. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` / :obj:`None <python:None>`
:rtype: :class:`Fraction <python:fractions.Fraction>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is :obj:`None <python:None>` and
``allow_empty`` is ``False``
:raises MinimumValueError: if ``minimum`` is supplied and ``value`` is less
than the ``minimum``
:raises MaximumValueError: if ``maximum`` is supplied and ``value`` is more
than the ``maximum``
:raises CannotCoerceError: if unable to coerce ``value`` to a
:class:`Fraction <python:fractions.Fraction>`
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, minimum=None, maximum=None, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,907 | validator_collection.checkers | has_length | Indicate whether ``value`` has a length greater than or equal to a
supplied ``minimum`` and/or less than or equal to ``maximum``.
.. note::
This function works on any ``value`` that supports the
:func:`len() <python:len>` operation. This means that ``value`` must implement
the :func:`__len__ <python:__len__>` magic method.
If ``value`` does not support length evaluation, the checker will raise
:class:`NotImplemented <python:NotImplemented>`.
:param value: The ``value`` to check.
:type value: anything that supports length evaluation
:param minimum: If supplied, will return ``True`` if ``value`` is greater than or
equal to this value.
:type minimum: numeric
:param maximum: If supplied, will return ``True`` if ``value`` is less than or
equal to this value.
:type maximum: numeric
:returns: ``True`` if ``value`` has length greater than or equal to a
supplied ``minimum`` and less than or equal to a supplied ``maximum``.
Otherwise, returns ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
:raises TypeError: if ``value`` does not support length evaluation
:raises ValueError: if both ``minimum`` and ``maximum`` are
:obj:`None <python:None>`
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, minimum=None, maximum=None, **kwargs) | [
0.0027183322235941887,
0.013799999840557575,
-0.03053659200668335,
-0.007108339108526707,
0.007262113504111767,
0.017113586887717247,
0.0016171099850907922,
0.054009489715099335,
-0.07531962543725967,
0.0073265996761620045,
0.01014414057135582,
-0.006279942579567432,
0.08262142539024353,
-0.002713371766731143,
-0.030278649181127548,
-0.02103235013782978,
-0.04631085693836212,
0.027639683336019516,
-0.007971459068357944,
-0.03053659200668335,
-0.03779870644211769,
0.09055815637111664,
0.04258058965206146,
-0.016726670786738396,
0.020030338317155838,
0.02008986286818981,
0.028988929465413094,
0.022322069853544235,
-0.018006470054388046,
0.03863206505775452,
-0.0223617535084486,
-0.02254033088684082,
0.02281811647117138,
-0.024187203496694565,
-0.0012984004570171237,
-0.013869446702301502,
0.014176994562149048,
0.037322502583265305,
-0.017550107091665268,
-0.014960747212171555,
-0.059327103197574615,
0.04508066177368164,
-0.012282099574804306,
0.024286411702632904,
0.005193601828068495,
-0.06734320521354675,
-0.053930122405290604,
0.010506254620850086,
-0.051866572350263596,
-0.038016967475414276,
-0.002730733249336481,
-0.06766067445278168,
0.011091588996350765,
-0.07266081869602203,
-0.009836592711508274,
-0.008060747757554054,
-0.01709374599158764,
0.04055672138929367,
0.02156808041036129,
0.05563652142882347,
0.05031890794634819,
0.0017448418075218797,
0.0073315599001944065,
-0.020437095314264297,
-0.027758734300732613,
-0.037243135273456573,
-0.04738231375813484,
-0.054287273436784744,
-0.0528983473777771,
-0.010992379859089851,
-0.045834653079509735,
0.02394910156726837,
-0.001046657096594572,
0.023631632328033447,
-0.015754422172904015,
-0.06162875518202782,
-0.03387002274394035,
0.05869216471910477,
-0.014405176043510437,
0.019970811903476715,
0.039981309324502945,
-0.015913156792521477,
-0.030417541041970253,
-0.08547864854335785,
-0.02192523330450058,
0.024187203496694565,
-0.08928827941417694,
0.017212796956300735,
0.030139755457639694,
-0.0044247303158044815,
-0.015962760895490646,
0.00500262388959527,
0.028353989124298096,
-0.0345049612224102,
-0.06115255132317543,
-0.03335413336753845,
0.04519971087574959,
-0.00995564367622137,
-0.013522214256227016,
-0.006785909179598093,
0.00854687299579382,
-0.00033049064222723246,
0.06674794852733612,
-0.011458663269877434,
0.02335384674370289,
-0.010064773261547089,
0.018641408532857895,
-0.013224586844444275,
-0.01024831086397171,
0.027480948716402054,
0.007539899554103613,
-0.07107347249984741,
-0.023016534745693207,
-0.008809776976704597,
-0.01993112824857235,
-0.04333458095788956,
-0.03887016698718071,
-0.00009176851017400622,
-0.06817656010389328,
-0.03097311221063137,
-0.015595686621963978,
0.04988238587975502,
-0.00025561871007084846,
0.04214406758546829,
0.08555801212787628,
-0.04226312041282654,
-0.01376031618565321,
-0.009891157038509846,
0.0008724209037609398,
-0.003747627604752779,
-0.03752091899514198,
0.00891890749335289,
-0.06551775336265564,
0.04083450883626938,
0.028254780918359756,
0.04849345609545708,
-0.018849749118089676,
-0.026032494381070137,
-0.023373687639832497,
-0.022421279922127724,
0.02974291890859604,
0.07714507728815079,
0.027719050645828247,
-0.04781883582472801,
-0.0365486703813076,
0.038215383887290955,
-0.016667146235704422,
0.00004867451571044512,
0.013085694052278996,
0.021607764065265656,
-0.01978231407701969,
-0.053572967648506165,
0.045477498322725296,
0.06627174466848373,
-0.08992321789264679,
-0.06539870798587799,
-0.03025880642235279,
-0.012043996714055538,
-0.0030234004370868206,
-0.023393530398607254,
0.035893891006708145,
0.05964457243680954,
-0.04142976179718971,
0.016845721751451492,
0.019544212147593498,
0.040616247802972794,
-0.019762473180890083,
-0.009147088043391705,
-0.009285980835556984,
0.0047546010464429855,
-0.040874190628528595,
-0.01850251667201519,
0.013204745016992092,
0.015357584692537785,
-0.027480948716402054,
0.057382602244615555,
-0.06718447059392929,
-0.009836592711508274,
-0.0025471963454037905,
0.029861969873309135,
0.017996549606323242,
-0.004583464935421944,
-0.015099640935659409,
0.007782961707562208,
-0.031131846830248833,
0.02972307614982128,
0.02226254530251026,
-0.051430050283670425,
0.027758734300732613,
-0.01921682246029377,
-0.044882241636514664,
0.03595341369509697,
0.048771243542432785,
-0.09603450447320938,
0.013006326742470264,
0.029088137671351433,
-0.012569805607199669,
0.029762759804725647,
0.007063695229589939,
0.035536736249923706,
0.012282099574804306,
0.01581394672393799,
0.023671315982937813,
0.014028181321918964,
0.05023954063653946,
-0.01645880751311779,
0.00890402588993311,
0.04889029636979103,
0.058533430099487305,
-0.009360387921333313,
-0.050636377185583115,
-0.060120776295661926,
0.0018204888328909874,
0.06504154950380325,
0.061192236840724945,
0.01885966956615448,
0.015030194073915482,
-0.043453630059957504,
0.021250611171126366,
0.007133141625672579,
0.0038046729750931263,
0.02369115687906742,
-0.04031861945986748,
0.04849345609545708,
0.03720344975590706,
-0.053930122405290604,
-0.02484198473393917,
0.06238274648785591,
0.005565636325627565,
-0.04448540508747101,
-0.007157944142818451,
0.001129124779254198,
0.033949390053749084,
0.061192236840724945,
-0.03488195687532425,
0.021171243861317635,
-0.014940905384719372,
0.04996175318956375,
-0.024107836186885834,
0.012212652713060379,
0.03928684443235397,
0.011508267372846603,
-0.05785880610346794,
-0.10206642746925354,
-0.01957397535443306,
0.009950682520866394,
0.009132207371294498,
0.046033069491386414,
-0.033155716955661774,
-0.02220301888883114,
-0.01574449986219406,
0.015466714277863503,
-0.01576434262096882,
-0.10357441008090973,
-0.03158821165561676,
0.022659381851553917,
-0.010664989240467548,
-0.07452595233917236,
0.03131042420864105,
0.002387221436947584,
-0.028592092916369438,
-0.013671028427779675,
0.07202588021755219,
0.07651013880968094,
-0.05654924362897873,
-0.019583895802497864,
0.05575557053089142,
0.040596406906843185,
-0.011280085891485214,
-0.030695326626300812,
0.12397181987762451,
0.01642904430627823,
0.08468497544527054,
0.0493268147110939,
-0.0007874730508774519,
-0.004866211209446192,
0.028334148228168488,
-0.033770810812711716,
0.02218317799270153,
0.03311603143811226,
-0.017996549606323242,
0.043969519436359406,
0.027044428512454033,
-0.04436635598540306,
0.0287508275359869,
-0.044961608946323395,
0.040239252150058746,
0.05563652142882347,
-0.025695182383060455,
0.011756290681660175,
0.0201890729367733,
-0.04014004394412041,
0.04595370218157768,
-0.0076639107428491116,
-0.03587404638528824,
0.1206383928656578,
0.05139036476612091,
-0.014970668591558933,
-0.02511977031826973,
-0.05254119262099266,
-0.06647016853094101,
0.011438821442425251,
0.015010352246463299,
-0.048850610852241516,
0.0370447151362896,
-0.006051761098206043,
-0.02256017178297043,
-0.018562041223049164,
-0.03250093385577202,
0.01890927366912365,
0.013780158013105392,
0.029981020838022232,
0.004141984041780233,
-0.018026312813162804,
0.018085837364196777,
0.001484417705796659,
-0.0025087527465075254,
-0.04083450883626938,
-0.0350010059773922,
0.0241475198417902,
-0.03569547086954117,
0.021369662135839462,
0.030953271314501762,
0.01442501787096262,
-0.007703594397753477,
-0.031647734344005585,
-0.007842487655580044,
0.07583551108837128,
-0.015020273625850677,
0.02877066843211651,
-0.028016678988933563,
-0.07234334945678711,
0.057025447487831116,
0.02261969819664955,
0.060557298362255096,
-0.04349331557750702,
-0.018740618601441383,
0.00007467817340511829,
0.036707405000925064,
0.04198533296585083,
-0.002666247310116887,
0.006294823717325926,
-0.0091371675953269,
-0.013631344772875309,
-0.03150884434580803,
0.009514162316918373,
-0.012480517849326134,
0.0232546366751194,
0.0569857656955719,
0.07412911206483841,
-0.060477931052446365,
-0.03906858339905739,
-0.00011533069482538849,
-0.06543838977813721,
-0.057898491621017456,
-0.009593529626727104,
0.024980876594781876,
0.029703235253691673,
-0.01157771423459053,
-0.04127102717757225,
0.03912810981273651,
-0.013423005118966103,
-0.009271100163459778,
-0.007028971798717976,
-0.07520057260990143,
0.06178748980164528,
-0.024603882804512978,
0.010942774824798107,
0.05039827525615692,
0.00026414450258016586,
0.004258554894477129,
0.05833500996232033,
-0.019643422216176987,
-0.024901509284973145,
0.003988210111856461,
-0.0270841121673584,
0.0018180086044594646,
-0.02023867703974247,
-0.02315542846918106,
0.038929689675569534,
0.00016943071386776865,
-0.003110208548605442,
0.07722444087266922,
-0.04658864066004753,
0.03543752804398537,
-0.023929258808493614,
-0.022302228957414627,
0.02752063237130642,
-0.06091444939374924,
-0.016696909442543983,
0.01096261665225029,
0.020298203453421593,
0.007301797159016132,
-0.04694579541683197,
-0.01816520467400551,
-0.07662918418645859,
0.024068152531981468,
0.028473040089011192,
-0.06702573597431183,
-0.002131757792085409,
0.03666771948337555,
0.021706974133849144,
-0.017827892675995827,
0.019762473180890083,
0.0028969086706638336,
0.07670855522155762,
0.02394910156726837,
-0.02202444337308407,
0.03879079967737198,
-0.03470337763428688,
0.029762759804725647,
-0.050199855118989944,
-0.009836592711508274,
-0.0523824580013752,
0.0114983469247818,
0.00721250893548131,
-0.022937167435884476,
-0.013125377707183361,
0.012847591191530228,
-0.031369950622320175,
0.04686642810702324,
0.013740474358201027,
0.023413371294736862,
-0.021171243861317635,
-0.024425305426120758,
-0.0005630122032016516,
-0.015853630378842354,
-0.04678706079721451,
0.04972365126013756,
0.0014645758783444762,
-0.05404917150735855,
-0.029088137671351433,
0.004608267452567816,
0.013204745016992092,
-0.006934723351150751,
-0.03176678717136383,
-0.020913299173116684,
-0.008621280081570148,
0.011022142134606838,
-0.013799999840557575,
-0.03299698233604431,
-0.02396894246339798,
-0.028988929465413094,
0.04857282340526581,
-0.00034816228435374796,
0.009598489850759506,
-0.0046777138486504555,
-0.023492738604545593,
0.04186628386378288,
0.009409992955625057,
-0.009732422418892384,
0.052223723381757736,
-0.03795744106173515,
-0.004556182771921158,
-0.021270452067255974,
-0.02769920974969864,
-0.029227031394839287,
0.0368066132068634,
0.05464442819356918,
0.011230481788516045,
-0.014355571940541267,
-0.026607908308506012,
-0.008487347513437271,
-0.025238821282982826,
-0.027183322235941887,
0.004759561270475388,
-0.0013331236550584435,
0.026647591963410378,
0.07960546016693115,
0.03690582141280174,
-0.03992178291082382,
-0.0006609812844544649,
0.0019246585434302688,
0.012669014744460583,
0.01459367386996746,
0.0850818082690239,
-0.0029787563253194094,
0.026032494381070137,
-0.02767936699092388,
0.035378001630306244,
0.010694751515984535,
-0.01655801571905613,
0.04781883582472801,
-0.028175413608551025,
-0.03887016698718071,
-0.03827491030097008,
-0.012014234438538551,
0.03010007180273533,
0.0329572968184948,
-0.039445579051971436,
-0.018869590014219284,
-0.040953557938337326,
-0.030318332836031914,
0.04516002908349037,
0.023095902055501938,
-0.028790511190891266,
0.0007893331930972636,
0.010645147413015366,
-0.02317526936531067,
0.009395111352205276,
0.10166958719491959,
0.05758102238178253,
0.02361178956925869,
-0.0028597053606063128,
0.02557613141834736,
-0.02164744772017002,
0.006175772752612829,
-0.005798778031021357,
-0.017391372472047806,
0.020070021972060204,
-0.04186628386378288,
0.05575557053089142,
0.019941048696637154,
0.030992954969406128,
0.01051617506891489,
0.022480804473161697,
0.04285837337374687,
0.010010208934545517,
0.021548239514231682,
-0.022222861647605896,
-0.034127965569496155,
0.005580517463386059,
0.02654838189482689,
-0.02059582993388176,
0.006790869869291782,
0.05936678498983383,
0.011617397889494896,
-0.01822473108768463,
0.014157152734696865,
-0.020635513588786125,
0.03978288918733597,
0.023195112124085426,
-0.013482530601322651,
-0.01278806570917368,
0.056946080178022385,
-0.012688856571912766,
0.02103235013782978,
-0.037223294377326965,
0.03196520358324051,
-0.0048042056150734425,
0.046826742589473724,
-0.003955966793000698,
-0.005253127310425043,
-0.019762473180890083,
-0.015952840447425842,
0.04865219444036484,
0.029445290565490723,
-0.044961608946323395,
-0.004154385533183813,
0.022877642884850502,
0.023413371294736862,
-0.0252983458340168,
-0.005858303513377905,
0.09373285621404648,
-0.05420790612697601,
0.0287508275359869,
-0.02049662172794342,
0.008412940427660942,
0.01653817482292652,
0.02573486790060997,
-0.0027555355336517096,
0.05317613109946251,
0.01504011545330286,
-0.0039162831380963326,
-0.042739324271678925,
-0.07226398587226868,
-0.012728540226817131,
0.02192523330450058,
0.04297742620110512,
-0.02226254530251026,
0.029881810769438744,
0.007554780691862106,
-0.022778432816267014,
-0.014157152734696865,
0.02599281072616577,
0.012946801260113716,
-0.019583895802497864,
-0.003001078264787793,
-0.029961178079247475,
-0.02051646262407303,
0.01038720365613699,
-0.025536447763442993,
-0.030596118420362473,
-0.03478274494409561,
-0.018393386155366898,
-0.03140963241457939,
-0.05154910311102867,
-0.026667432859539986,
-0.05381106957793236,
-0.011022142134606838,
-0.003931164741516113,
0.08428813517093658,
0.03252077475190163,
-0.018591804429888725,
0.022044284269213676,
-0.014811933971941471,
0.032897770404815674,
-0.016905248165130615,
-0.021349819377064705,
-0.01898864097893238,
-0.05849374458193779,
0.015605607070028782,
-0.022699065506458282,
-0.050993528217077255,
0.016528252512216568,
0.031012795865535736,
0.011478505097329617,
-0.005580517463386059,
0.004099820274859667,
-0.031171530485153198,
0.030338173732161522,
0.008432782255113125,
0.07726413011550903,
0.0621049590408802,
-0.05139036476612091,
-0.01931603252887726,
0.023572105914354324,
-0.030298490077257156,
-0.004047735594213009,
0.03381049633026123,
-0.0029167504981160164,
0.03035801649093628,
0.07746254652738571,
-0.009295902214944363,
-0.018978720530867577,
-0.03996146470308304,
-0.024167360737919807,
-0.08317699283361435,
0.017163192853331566,
-0.048334721475839615,
-0.04021941125392914,
-0.004055175930261612,
0.01918705925345421,
-0.043890152126550674,
-0.02049662172794342,
-0.038116175681352615,
-0.028611933812499046,
-0.024464989081025124,
0.007505176123231649,
0.023988785222172737,
-0.042025018483400345,
-0.03260014206171036,
0.003712904406711459,
0.023849891498684883,
-0.024385621771216393,
0.024087993428111076,
0.06496218591928482,
0.01000524777919054,
0.05904931575059891,
0.027024585753679276,
0.027401581406593323,
0.09365348517894745,
0.029227031394839287,
0.0012246136320754886,
0.030675485730171204,
0.03640977665781975,
-0.007048813626170158,
0.0035963335540145636,
-0.009653055109083652,
-0.021607764065265656,
0.04559654742479324,
-0.013492451049387455,
0.01561552844941616,
-0.017798131331801414,
0.05432695895433426,
0.03015959821641445,
-0.045834653079509735,
-0.0636129379272461,
-0.018661251291632652,
-0.0014062904519960284,
-0.03178662806749344,
0.05230309069156647,
-0.018036233261227608,
-0.04127102717757225,
-0.03694550693035126,
0.0026315241120755672,
-0.036965347826480865,
-0.03595341369509697,
-0.004070057533681393,
0.026687275618314743,
-0.03843364492058754,
-0.023988785222172737,
-0.015139324590563774,
0.04865219444036484,
0.011200718581676483,
0.00973738357424736,
0.027738893404603004,
-0.03170726075768471,
-0.014762328937649727,
-0.09809806197881699,
0.00663213524967432,
-0.005032386630773544,
0.0013666067970916629,
-0.007559741381555796,
-0.012321783229708672,
-0.0815102830529213,
-0.0023562186397612095,
0.11325722187757492,
0.05095384642481804,
-0.02254033088684082,
0.0135420560836792,
0.013373400084674358,
0.045477498322725296,
0.038572538644075394,
-0.0011260244064033031,
0.06730352342128754,
-0.056231774389743805,
0.0040378146804869175,
0.061390653252601624,
0.03418749198317528,
-0.01473256666213274,
0.013551976531744003,
0.02742142416536808,
-0.05627145990729332,
0.021250611171126366,
-0.04555686563253403,
-0.02563565783202648,
0.03263982757925987,
0.007668871432542801,
-0.020992666482925415,
0.04039798676967621,
-0.0006572609418071806,
0.019593818113207817,
-0.00728195533156395,
0.03585420548915863,
-0.07960546016693115,
-0.03267950937151909,
0.03138979151844978,
0.007480373606085777,
-0.048136305063962936,
0.040675774216651917,
-0.020695040002465248,
-0.01658777892589569,
0.03317555785179138,
-0.014127390459179878,
0.019583895802497864,
-0.023393530398607254,
0.031012795865535736,
-0.09365348517894745,
0.006468439940363169,
0.010198705829679966,
0.0029613946098834276,
0.008665923960506916,
-0.0291278213262558,
0.010952696204185486,
0.03805664926767349,
0.049485549330711365,
0.01983192004263401,
0.05123163014650345,
-0.027996836230158806,
0.03508037328720093,
-0.029346082359552383,
-0.03043738380074501,
0.002559597371146083,
0.09849489480257034,
-0.01243091281503439,
-0.06480345129966736,
-0.007177785970270634,
0.006165851838886738,
0.017550107091665268,
-0.04789820313453674,
-0.059247735887765884,
0.008348454721271992,
-0.04198533296585083,
0.012926959432661533,
0.005396980792284012,
-0.02049662172794342,
-0.017728684470057487
] |
725,908 | validator_collection.validators | integer | Validate that ``value`` is an :class:`int <python:int>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is :obj:`None <python:None>`. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>` if
``value`` is :obj:`None <python:None>`.
Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:param coerce_value: If ``True``, will force any numeric ``value`` to an integer
(always rounding up). If ``False``, will raise an error if ``value`` is numeric
but not a whole number. Defaults to ``False``.
:type coerce_value: :class:`bool <python:bool>`
:param minimum: If supplied, will make sure that ``value`` is greater than or
equal to this value.
:type minimum: numeric
:param maximum: If supplied, will make sure that ``value`` is less than or
equal to this value.
:type maximum: numeric
:param base: Indicates the base that is used to determine the integer value.
The allowed values are 0 and 2–36. Base-2, -8, and -16 literals can be
optionally prefixed with ``0b/0B``, ``0o/0O/0``, or ``0x/0X``, as with
integer literals in code. Base 0 means to interpret the string exactly as
an integer literal, so that the actual base is 2, 8, 10, or 16. Defaults to
``10``.
:returns: ``value`` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is :obj:`None <python:None>` and
``allow_empty`` is ``False``
:raises MinimumValueError: if ``minimum`` is supplied and ``value`` is less
than the ``minimum``
:raises MaximumValueError: if ``maximum`` is supplied and ``value`` is more
than the ``maximum``
:raises NotAnIntegerError: if ``coerce_value`` is ``False``, and ``value``
is not an integer
:raises CannotCoerceError: if ``value`` cannot be coerced to an
:class:`int <python:int>`
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, coerce_value=False, minimum=None, maximum=None, base=10, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,909 | validator_collection.validators | ip_address | Validate that ``value`` is a valid IP address.
.. note::
First, the validator will check if the address is a valid IPv6 address.
If that doesn't work, the validator will check if the address is a valid
IPv4 address.
If neither works, the validator will raise an error (as always).
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises InvalidIPAddressError: if ``value`` is not a valid IP address or empty with
``allow_empty`` set to ``True``
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,910 | validator_collection.validators | ipv4 | Validate that ``value`` is a valid IP version 4 address.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises InvalidIPAddressError: if ``value`` is not a valid IP version 4 address or
empty with ``allow_empty`` set to ``True``
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,911 | validator_collection.validators | ipv6 | Validate that ``value`` is a valid IP address version 6.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises InvalidIPAddressError: if ``value`` is not a valid IP version 6 address or
empty with ``allow_empty`` is not set to ``True``
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,912 | validator_collection.checkers | is_between | Indicate whether ``value`` is greater than or equal to a supplied ``minimum``
and/or less than or equal to ``maximum``.
.. note::
This function works on any ``value`` that support comparison operators,
whether they are numbers or not. Technically, this means that ``value``,
``minimum``, or ``maximum`` need to implement the Python magic methods
:func:`__lte__ <python:object.__lte__>` and :func:`__gte__ <python:object.__gte__>`.
If ``value``, ``minimum``, or ``maximum`` do not support comparison
operators, they will raise :class:`NotImplemented <python:NotImplemented>`.
:param value: The ``value`` to check.
:type value: anything that supports comparison operators
:param minimum: If supplied, will return ``True`` if ``value`` is greater than or
equal to this value.
:type minimum: anything that supports comparison operators /
:obj:`None <python:None>`
:param maximum: If supplied, will return ``True`` if ``value`` is less than or
equal to this value.
:type maximum: anything that supports comparison operators /
:obj:`None <python:None>`
:returns: ``True`` if ``value`` is greater than or equal to a supplied ``minimum``
and less than or equal to a supplied ``maximum``. Otherwise, returns ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
:raises NotImplemented: if ``value``, ``minimum``, or ``maximum`` do not
support comparison operators
:raises ValueError: if both ``minimum`` and ``maximum`` are
:obj:`None <python:None>`
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, minimum=None, maximum=None, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,913 | validator_collection.checkers | is_bytesIO | Indicate whether ``value`` is a :class:`BytesIO <python:io.BytesIO>` object.
.. note::
This checker will return ``True`` even if ``value`` is empty, so long as
its type is a :class:`BytesIO <python:io.BytesIO>`.
:param value: The value to evaluate.
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,914 | validator_collection.checkers | is_date | Indicate whether ``value`` is a :class:`date <python:datetime.date>`.
:param value: The value to evaluate.
:param minimum: If supplied, will make sure that ``value`` is on or after
this value.
:type minimum: :class:`datetime <python:datetime.datetime>` /
:class:`date <python:datetime.date>` / compliant :class:`str <python:str>`
/ :obj:`None <python:None>`
:param maximum: If supplied, will make sure that ``value`` is on or before this
value.
:type maximum: :class:`datetime <python:datetime.datetime>` /
:class:`date <python:datetime.date>` / compliant :class:`str <python:str>`
/ :obj:`None <python:None>`
:param coerce_value: If ``True``, will return ``True`` if ``value`` can be
coerced to a :class:`date <python:datetime.date>`. If ``False``,
will only return ``True`` if ``value`` is a date value only. Defaults to
``False``.
:type coerce_value: :class:`bool <python:bool>`
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, minimum=None, maximum=None, coerce_value=False, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,915 | validator_collection.checkers | is_datetime | Indicate whether ``value`` is a :class:`datetime <python:datetime.datetime>`.
:param value: The value to evaluate.
:param minimum: If supplied, will make sure that ``value`` is on or after
this value.
:type minimum: :class:`datetime <python:datetime.datetime>` /
:class:`date <python:datetime.date>` / compliant :class:`str <python:str>`
/ :obj:`None <python:None>`
:param maximum: If supplied, will make sure that ``value`` is on or before this
value.
:type maximum: :class:`datetime <python:datetime.datetime>` /
:class:`date <python:datetime.date>` / compliant :class:`str <python:str>`
/ :obj:`None <python:None>`
:param coerce_value: If ``True``, will return ``True`` if ``value`` can be
coerced to a :class:`datetime <python:datetime.datetime>`. If ``False``,
will only return ``True`` if ``value`` is a complete timestamp. Defaults to
``False``.
:type coerce_value: :class:`bool <python:bool>`
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, minimum=None, maximum=None, coerce_value=False, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,916 | validator_collection.checkers | is_decimal | Indicate whether ``value`` contains a :class:`Decimal <python:decimal.Decimal>`.
:param value: The value to evaluate.
:param minimum: If supplied, will make sure that ``value`` is greater than or
equal to this value.
:type minimum: numeric
:param maximum: If supplied, will make sure that ``value`` is less than or
equal to this value.
:type maximum: numeric
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, minimum=None, maximum=None, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,917 | validator_collection.checkers | is_dict | Indicate whether ``value`` is a valid :class:`dict <python:dict>`
.. note::
This will return ``True`` even if ``value`` is an empty
:class:`dict <python:dict>`.
:param value: The value to evaluate.
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,918 | validator_collection.checkers | is_directory | Indicate whether ``value`` is a directory that exists on the local filesystem.
:param value: The value to evaluate.
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,919 | validator_collection.checkers | is_domain | Indicate whether ``value`` is a valid domain.
.. caution::
This validator does not verify that ``value`` **exists** as a domain. It
merely verifies that its contents *might* exist as a domain.
.. note::
This validator checks to validate that ``value`` resembles a valid
domain name. It is - generally - compliant with
`RFC 1035 <https://tools.ietf.org/html/rfc1035>`_ and
`RFC 6761 <https://tools.ietf.org/html/rfc6761>`_, however it diverges
in a number of key ways:
* Including authentication (e.g. ``username:[email protected]``) will
fail validation.
* Including a path (e.g. ``domain.dev/path/to/file``) will fail validation.
* Including a port (e.g. ``domain.dev:8080``) will fail validation.
If you are hoping to validate a more complete URL, we recommend that you
see :func:`url <validator_collection.validators.url>`.
:param value: The value to evaluate.
:param allow_ips: If ``True``, will succeed when validating IP addresses,
If ``False``, will fail if ``value`` is an IP address. Defaults to ``False``.
:type allow_ips: :class:`bool <python:bool>`
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,920 | validator_collection.checkers | is_email | Indicate whether ``value`` is an email address.
.. note::
Email address validation is...complicated. The methodology that we have
adopted here is *generally* compliant with
`RFC 5322 <https://tools.ietf.org/html/rfc5322>`_ and uses a combination of
string parsing and regular expressions.
String parsing in particular is used to validate certain *highly unusual*
but still valid email patterns, including the use of escaped text and
comments within an email address' local address (the user name part).
This approach ensures more complete coverage for unusual edge cases, while
still letting us use regular expressions that perform quickly.
:param value: The value to evaluate.
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,921 | validator_collection.checkers | is_file | Indicate whether ``value`` is a file that exists on the local filesystem.
:param value: The value to evaluate.
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,922 | validator_collection.checkers | is_float | Indicate whether ``value`` is a :class:`float <python:float>`.
:param value: The value to evaluate.
:param minimum: If supplied, will make sure that ``value`` is greater than or
equal to this value.
:type minimum: numeric
:param maximum: If supplied, will make sure that ``value`` is less than or
equal to this value.
:type maximum: numeric
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, minimum=None, maximum=None, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,923 | validator_collection.checkers | is_fraction | Indicate whether ``value`` is a :class:`Fraction <python:fractions.Fraction>`.
:param value: The value to evaluate.
:param minimum: If supplied, will make sure that ``value`` is greater than or
equal to this value.
:type minimum: numeric
:param maximum: If supplied, will make sure that ``value`` is less than or
equal to this value.
:type maximum: numeric
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, minimum=None, maximum=None, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,924 | validator_collection.checkers | is_integer | Indicate whether ``value`` contains a whole number.
:param value: The value to evaluate.
:param coerce_value: If ``True``, will return ``True`` if ``value`` can be coerced
to whole number. If ``False``, will only return ``True`` if ``value`` is already
a whole number (regardless of type). Defaults to ``False``.
:type coerce_value: :class:`bool <python:bool>`
:param minimum: If supplied, will make sure that ``value`` is greater than or
equal to this value.
:type minimum: numeric
:param maximum: If supplied, will make sure that ``value`` is less than or
equal to this value.
:type maximum: numeric
:param base: Indicates the base that is used to determine the integer value.
The allowed values are 0 and 2–36. Base-2, -8, and -16 literals can be
optionally prefixed with ``0b/0B``, ``0o/0O/0``, or ``0x/0X``, as with
integer literals in code. Base 0 means to interpret the string exactly as
an integer literal, so that the actual base is 2, 8, 10, or 16. Defaults to
``10``.
:type base: :class:`int <python:int>`
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, coerce_value=False, minimum=None, maximum=None, base=10, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,925 | validator_collection.checkers | is_ip_address | Indicate whether ``value`` is a valid IP address (version 4 or version 6).
:param value: The value to evaluate.
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,926 | validator_collection.checkers | is_ipv4 | Indicate whether ``value`` is a valid IP version 4 address.
:param value: The value to evaluate.
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,927 | validator_collection.checkers | is_ipv6 | Indicate whether ``value`` is a valid IP version 6 address.
:param value: The value to evaluate.
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,928 | validator_collection.checkers | is_iterable | Indicate whether ``obj`` is iterable.
:param forbid_literals: A collection of literals that will be considered invalid
even if they are (actually) iterable. Defaults to a :class:`tuple <python:tuple>`
containing :class:`str <python:str>` and :class:`bytes <python:bytes>`.
:type forbid_literals: iterable
:param minimum_length: If supplied, indicates the minimum number of members
needed to be valid.
:type minimum_length: :class:`int <python:int>`
:param maximum_length: If supplied, indicates the minimum number of members
needed to be valid.
:type maximum_length: :class:`int <python:int>`
:returns: ``True`` if ``obj`` is a valid iterable, ``False`` if not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (obj, forbid_literals=(<class 'str'>, <class 'bytes'>), minimum_length=None, maximum_length=None, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,929 | validator_collection.checkers | is_mac_address | Indicate whether ``value`` is a valid MAC address.
:param value: The value to evaluate.
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,930 | validator_collection.checkers | is_none | Indicate whether ``value`` is :obj:`None <python:None>`.
:param value: The value to evaluate.
:param allow_empty: If ``True``, accepts falsey values as equivalent to
:obj:`None <python:None>`. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``True`` if ``value`` is :obj:`None <python:None>`, ``False``
if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, allow_empty=False, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,931 | validator_collection.checkers | is_not_empty | Indicate whether ``value`` is empty.
:param value: The value to evaluate.
:returns: ``True`` if ``value`` is empty, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,932 | validator_collection.checkers | is_numeric | Indicate whether ``value`` is a numeric value.
:param value: The value to evaluate.
:param minimum: If supplied, will make sure that ``value`` is greater than or
equal to this value.
:type minimum: numeric
:param maximum: If supplied, will make sure that ``value`` is less than or
equal to this value.
:type maximum: numeric
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, minimum=None, maximum=None, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,933 | validator_collection.checkers | is_on_filesystem | Indicate whether ``value`` is a file or directory that exists on the local
filesystem.
:param value: The value to evaluate.
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,934 | validator_collection.checkers | is_pathlike | Indicate whether ``value`` is a path-like object.
:param value: The value to evaluate.
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,935 | validator_collection.checkers | is_string | Indicate whether ``value`` is a string.
:param value: The value to evaluate.
:param coerce_value: If ``True``, will check whether ``value`` can be coerced
to a string if it is not already. Defaults to ``False``.
:type coerce_value: :class:`bool <python:bool>`
:param minimum_length: If supplied, indicates the minimum number of characters
needed to be valid.
:type minimum_length: :class:`int <python:int>`
:param maximum_length: If supplied, indicates the minimum number of characters
needed to be valid.
:type maximum_length: :class:`int <python:int>`
:param whitespace_padding: If ``True`` and the value is below the
``minimum_length``, pad the value with spaces. Defaults to ``False``.
:type whitespace_padding: :class:`bool <python:bool>`
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, coerce_value=False, minimum_length=None, maximum_length=None, whitespace_padding=False, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,936 | validator_collection.checkers | is_stringIO | Indicate whether ``value`` is a :class:`StringIO <python:io.StringIO>` object.
.. note::
This checker will return ``True`` even if ``value`` is empty, so long as
its type is a :class:`String <python:io.StringIO>`.
:param value: The value to evaluate.
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, **kwargs) | [
0.0026687942445278168,
0.013790423981845379,
-0.03057704120874405,
-0.007123399060219526,
0.007202768232673407,
0.017153700813651085,
0.001577465794980526,
0.05409020930528641,
-0.07540088146924973,
0.007381349336355925,
0.01016919780522585,
-0.006329705473035574,
0.08270286023616791,
-0.0027208805549889803,
-0.030299248173832893,
-0.020993193611502647,
-0.04631201550364494,
0.027600690722465515,
-0.00799150113016367,
-0.03049767203629017,
-0.037839338183403015,
0.0905604287981987,
0.04246260225772858,
-0.016756853088736534,
0.019991153851151466,
0.020120128989219666,
0.02894997037947178,
0.022322628647089005,
-0.01805652678012848,
0.03861318901181221,
-0.02236231416463852,
-0.022540895268321037,
0.022898057475686073,
-0.024187808856368065,
-0.001287271617911756,
-0.013869794085621834,
0.014217034913599491,
0.03722422569990158,
-0.017580309882760048,
-0.015030570328235626,
-0.05928890407085419,
0.045161157846450806,
-0.012341933324933052,
0.024267178028821945,
0.005238377023488283,
-0.06734488904476166,
-0.05389178916811943,
0.010546201840043068,
-0.051828183233737946,
-0.037998076528310776,
-0.002693597227334976,
-0.06774173676967621,
0.01105218194425106,
-0.07266263663768768,
-0.009797153994441032,
-0.008065910078585148,
-0.017133858054876328,
0.040537893772125244,
0.021568620577454567,
0.05559822916984558,
0.050439219921827316,
0.0017101614503189921,
0.007391270715743303,
-0.020437607541680336,
-0.027699902653694153,
-0.037283752113580704,
-0.047343816608190536,
-0.05428863316774368,
-0.05293935537338257,
-0.011042260564863682,
-0.04583580046892166,
0.02396954409778118,
-0.001016299705952406,
0.023612381890416145,
-0.0158837903290987,
-0.06170966848731041,
-0.03379150107502937,
0.058733318001031876,
-0.01446506381034851,
0.019941547885537148,
0.03998230770230293,
-0.015923475846648216,
-0.03041830286383629,
-0.08548078685998917,
-0.021925782784819603,
0.024167966097593307,
-0.08929051458835602,
0.017252912744879723,
0.03008098341524601,
-0.00438267644494772,
-0.01590363308787346,
0.004948182962834835,
0.02837454155087471,
-0.03452566638588905,
-0.06111439689993858,
-0.0333351269364357,
0.04520084336400032,
-0.009916207753121853,
-0.013522552326321602,
-0.00687040900811553,
0.008462756872177124,
-0.00034724088618531823,
0.06674962490797043,
-0.0114192645996809,
0.023354431614279747,
-0.010084867477416992,
0.0186319537460804,
-0.013224917463958263,
-0.010189040564000607,
0.027441952377557755,
0.007510324474424124,
-0.07099588215351105,
-0.02301711030304432,
-0.008824879303574562,
-0.019971312955021858,
-0.043375350534915924,
-0.0388512946665287,
-0.00010952039883704856,
-0.06817827373743057,
-0.030954046174883842,
-0.015546470880508423,
0.04984395205974579,
-0.00028073808061890304,
0.042065754532814026,
0.0855601578950882,
-0.042224492877721786,
-0.013711054809391499,
-0.009901326149702072,
0.0008463996928185225,
-0.0037105169612914324,
-0.037521857768297195,
0.008934012614190578,
-0.06551939994096756,
0.04079584404826164,
0.028255488723516464,
0.04845498874783516,
-0.018800614401698112,
-0.026033146306872368,
-0.023394115269184113,
-0.02252105250954628,
0.02974366396665573,
0.07710732519626617,
0.02771974541246891,
-0.04785971716046333,
-0.03658926859498024,
0.03827586770057678,
-0.01658819429576397,
0.00004065354005433619,
0.013046336360275745,
0.021608304232358932,
-0.019782809540629387,
-0.05357430875301361,
0.045478638261556625,
0.06627340614795685,
-0.08992547541856766,
-0.06540033966302872,
-0.030219879001379013,
-0.012093904428184032,
-0.0029912323225289583,
-0.023433800786733627,
0.035894788801670074,
0.05964606627821922,
-0.04143080115318298,
0.016856065019965172,
0.019544702023267746,
0.04055773839354515,
-0.019753046333789825,
-0.00917212013155222,
-0.0093159768730402,
0.0047274366952478886,
-0.04087521508336067,
-0.018542664125561714,
0.013274523429572582,
0.015387732535600662,
-0.027422109618782997,
0.05730466917157173,
-0.06722583621740341,
-0.009826917201280594,
-0.0025720628909766674,
0.029862716794013977,
0.017947394400835037,
-0.00456621777266264,
-0.015000807121396065,
0.00772362994030118,
-0.031251680105924606,
0.02974366396665573,
0.02226310223340988,
-0.05143133923411369,
0.027759429067373276,
-0.019256988540291786,
-0.0448833666741848,
0.03601384162902832,
0.048812150955200195,
-0.09595753997564316,
0.013006651774048805,
0.029148392379283905,
-0.012570120394229889,
0.02968413569033146,
0.0070936353877186775,
0.03537888824939728,
0.012381617911159992,
0.015873869881033897,
0.023671908304095268,
0.013988847844302654,
0.050280481576919556,
-0.01648898236453533,
0.008849682286381721,
0.04893120378255844,
0.0585348941385746,
-0.009301095269620419,
-0.05059795826673508,
-0.060122281312942505,
0.0017436454072594643,
0.0650828629732132,
0.06119376793503761,
0.01892958953976631,
0.015040491707623005,
-0.04349440336227417,
0.02121145837008953,
0.007158122956752777,
0.0038047682028263807,
0.023711591958999634,
-0.04029978811740875,
0.04845498874783516,
0.03714485466480255,
-0.05393147096037865,
-0.024862447753548622,
0.06238430738449097,
0.00557073624804616,
-0.04452620446681976,
-0.007202768232673407,
0.0010646653827279806,
0.03393039479851723,
0.06119376793503761,
-0.03480345755815506,
0.02129082754254341,
-0.014891673810780048,
0.04992331936955452,
-0.024108439683914185,
0.012222879566252232,
0.03928782790899277,
0.011488713324069977,
-0.05782056972384453,
-0.10214835405349731,
-0.019495096057653427,
0.009995576925575733,
0.009112593717873096,
0.04599453881382942,
-0.03317638859152794,
-0.022223416715860367,
-0.015754815191030502,
0.015437338501214981,
-0.015814343467354774,
-0.10365636646747589,
-0.03164852783083916,
0.022640107199549675,
-0.010685098357498646,
-0.07448813319206238,
0.03127152472734451,
0.002412084024399519,
-0.028553122654557228,
-0.013651528395712376,
0.07198800146579742,
0.07655173540115356,
-0.056550659239292145,
-0.019514938816428185,
0.05571728199720383,
0.0406767912209034,
-0.011290289461612701,
-0.03073577955365181,
0.12397491931915283,
0.01637984998524189,
0.08468709141016006,
0.04936773329973221,
-0.0008005143026821315,
-0.004871293902397156,
0.028315015137195587,
-0.033692289143800735,
0.022243259474635124,
0.03317638859152794,
-0.018046606332063675,
0.04397061839699745,
0.027025263756513596,
-0.044367466121912,
0.02877138927578926,
-0.044923052191734314,
0.04024025797843933,
0.05571728199720383,
-0.02569582685828209,
0.011736742220818996,
0.020189577713608742,
-0.040121205151081085,
0.04599453881382942,
-0.0077186692506074905,
-0.03585510328412056,
0.12064141035079956,
0.05139165371656418,
-0.014941279776394367,
-0.025160083547234535,
-0.05254250764846802,
-0.0663924589753151,
0.011498634703457355,
0.015030570328235626,
-0.048812150955200195,
0.037045642733573914,
-0.0060320706106722355,
-0.02252105250954628,
-0.018552584573626518,
-0.03246206417679787,
0.01887006312608719,
0.013840029947459698,
0.029961928725242615,
0.004204095341265202,
-0.01805652678012848,
0.01821526512503624,
0.0014063256094232202,
-0.002512536011636257,
-0.04087521508336067,
-0.035001881420612335,
0.024088596925139427,
-0.03583526238799095,
0.021449565887451172,
0.031013572588562965,
0.01442537922412157,
-0.007693866267800331,
-0.03160884231328964,
-0.007773235440254211,
0.07583741098642349,
-0.015040491707623005,
0.028751546517014503,
-0.027997538447380066,
-0.07238484919071198,
0.05706655979156494,
0.022580578923225403,
0.06055881455540657,
-0.043534088879823685,
-0.018780771642923355,
0.00003695247869472951,
0.036708325147628784,
0.04194670170545578,
-0.0026712745893746614,
0.0063743507489562035,
-0.009053066372871399,
-0.01357215829193592,
-0.03154931589961052,
0.009549125097692013,
-0.012431223876774311,
0.023294903337955475,
0.05690782144665718,
0.07417065650224686,
-0.06047944352030754,
-0.03902987763285637,
-0.00017486060096416622,
-0.06547971069812775,
-0.05789994075894356,
-0.009568966925144196,
0.024941816926002502,
0.02976350486278534,
-0.011528397910296917,
-0.04131174460053444,
0.0391092449426651,
-0.013443183153867722,
-0.009266371838748455,
-0.007009305525571108,
-0.07520245760679245,
0.061828721314668655,
-0.024584656581282616,
0.010913285426795483,
0.050359852612018585,
0.00033576955320313573,
0.004238819237798452,
0.05837615579366684,
-0.01960422843694687,
-0.024941816926002502,
0.003956065978854895,
-0.027104632928967476,
0.0017746490193530917,
-0.020229263231158257,
-0.02309648133814335,
0.03893066570162773,
0.00019904343935195357,
-0.003013554960489273,
0.07722637802362442,
-0.04658980667591095,
0.035478100180625916,
-0.023949701339006424,
-0.02226310223340988,
0.02756100706756115,
-0.06095565855503082,
-0.016766775399446487,
0.010982733219861984,
0.020308632403612137,
0.0072722164914011955,
-0.0469866544008255,
-0.018225187435746193,
-0.0766311064362526,
0.0241481252014637,
0.028513438999652863,
-0.06706710159778595,
-0.002208700170740485,
0.036748006939888,
0.021727358922362328,
-0.017739050090312958,
0.019693519920110703,
0.0028498556930571795,
0.07675015926361084,
0.023949701339006424,
-0.022064678370952606,
0.038732241839170456,
-0.034684404730796814,
0.029723821207880974,
-0.05016142874956131,
-0.009802114218473434,
-0.05234408378601074,
0.011478791944682598,
0.007267255801707506,
-0.02301711030304432,
-0.013115785084664822,
0.012867755256593227,
-0.031430263072252274,
0.046867601573467255,
0.013711054809391499,
0.02341395802795887,
-0.021171772852540016,
-0.024445759132504463,
-0.0005689170211553574,
-0.01585402712225914,
-0.046788230538368225,
0.04968521371483803,
0.0013492789585143328,
-0.05397115647792816,
-0.029128551483154297,
0.004680311307311058,
0.013195154257118702,
-0.0070192269049584866,
-0.03178742527961731,
-0.020874138921499252,
-0.008621495217084885,
0.011032339185476303,
-0.013959083706140518,
-0.033057332038879395,
-0.024009227752685547,
-0.02894997037947178,
0.04853435605764389,
-0.00023485266137868166,
0.009618572890758514,
-0.004690232221037149,
-0.02349332720041275,
0.041827645152807236,
0.009435031563043594,
-0.009697942063212395,
0.052225030958652496,
-0.03789886459708214,
-0.004447164013981819,
-0.021350353956222534,
-0.02764037624001503,
-0.02910870872437954,
0.03682737797498703,
0.05456642806529999,
0.01126052625477314,
-0.014395616017282009,
-0.026628416031599045,
-0.008457796648144722,
-0.025239452719688416,
-0.02714431658387184,
0.004767121281474829,
-0.0012847912730649114,
0.026608573272824287,
0.07956777513027191,
0.036867063492536545,
-0.03992278128862381,
-0.000719284696970135,
0.002000355627387762,
0.012728859670460224,
0.014603960327804089,
0.08508393913507462,
-0.0029589885380119085,
0.025973619893193245,
-0.02771974541246891,
0.03537888824939728,
0.010724782943725586,
-0.016608037054538727,
0.04789940267801285,
-0.028156276792287827,
-0.03887113928794861,
-0.03829571232199669,
-0.011974850669503212,
0.03008098341524601,
0.03291843831539154,
-0.03948625177145004,
-0.018860140815377235,
-0.04091490060091019,
-0.030338933691382408,
0.04512147605419159,
0.02315600775182247,
-0.028751546517014503,
0.0008470197790302336,
0.010625571943819523,
-0.023235376924276352,
0.009400307200849056,
0.10167213529348373,
0.057582464069128036,
0.023533012717962265,
-0.0028126512188464403,
0.02553708851337433,
-0.02162814699113369,
0.006185848731547594,
-0.005793962627649307,
-0.017391808331012726,
0.02011020854115486,
-0.04186733067035675,
0.05567759647965431,
0.019931627437472343,
0.031013572588562965,
0.010496596805751324,
0.022481368854641914,
0.0427800789475441,
0.009980695322155952,
0.021588463336229324,
-0.022223416715860367,
-0.034108977764844894,
0.0054963272996246815,
0.026568889617919922,
-0.020596345886588097,
0.006796000525355339,
0.05928890407085419,
0.011578003875911236,
-0.018185501918196678,
0.014187270775437355,
-0.020616188645362854,
0.039803728461265564,
0.023215534165501595,
-0.013423341326415539,
-0.012798307463526726,
0.056947506964206696,
-0.012619726359844208,
0.021072562783956528,
-0.0372639074921608,
0.031906478106975555,
-0.004829128738492727,
0.04682791605591774,
-0.003913900814950466,
-0.005233416333794594,
-0.01974312588572502,
-0.015963159501552582,
0.048653408885002136,
0.029465870931744576,
-0.045002419501543045,
-0.004092481918632984,
0.022878214716911316,
0.023453641682863235,
-0.02529897913336754,
-0.005863410420715809,
0.09381456673145294,
-0.05424895137548447,
0.028652334585785866,
-0.020437607541680336,
0.008338741958141327,
0.016528666019439697,
0.025675984099507332,
-0.0028002497274428606,
0.05317746475338936,
0.015020648948848248,
-0.003951105289161205,
-0.04266102612018585,
-0.0721864253282547,
-0.012718938291072845,
0.021886097267270088,
0.04301818832755089,
-0.02226310223340988,
0.029803190380334854,
0.007579772733151913,
-0.022779002785682678,
-0.014217034913599491,
0.025993460789322853,
0.012947125360369682,
-0.019564544782042503,
-0.003003633813932538,
-0.029961928725242615,
-0.02049713395535946,
0.010427148081362247,
-0.02553708851337433,
-0.030596883967518806,
-0.03472409024834633,
-0.01834424026310444,
-0.031430263072252274,
-0.05155039206147194,
-0.026707785204052925,
-0.05373304709792137,
-0.011002575978636742,
-0.004015592858195305,
0.08436961472034454,
0.03260096162557602,
-0.018572427332401276,
0.02202499471604824,
-0.014832147397100925,
0.032799381762742996,
-0.016865987330675125,
-0.021270984783768654,
-0.01897919550538063,
-0.05845552682876587,
0.015625840052962303,
-0.022640107199549675,
-0.05107417702674866,
0.01653858833014965,
0.031112784519791603,
0.011498634703457355,
-0.005640184506773949,
0.004057758022099733,
-0.03105325810611248,
0.03031909093260765,
0.008393308147788048,
0.07726605981588364,
0.06202714517712593,
-0.05139165371656418,
-0.01934627816081047,
0.023612381890416145,
-0.030259564518928528,
-0.004057758022099733,
0.03379150107502937,
-0.002834973856806755,
0.030358776450157166,
0.07746448367834091,
-0.009330859407782555,
-0.018959352746605873,
-0.039962466806173325,
-0.0241481252014637,
-0.08309970796108246,
0.01708425208926201,
-0.0482962504029274,
-0.040200576186180115,
-0.004085041116923094,
0.01915777660906315,
-0.04381188005208969,
-0.02049713395535946,
-0.03807744383811951,
-0.028572965413331985,
-0.024485444650053978,
0.007525206543505192,
0.02396954409778118,
-0.04194670170545578,
-0.032561276108026505,
0.0037154776509851217,
0.023870332166552544,
-0.024425916373729706,
0.024029070511460304,
0.06492412835359573,
0.010005498304963112,
0.05909048020839691,
0.027104632928967476,
0.02738242596387863,
0.09365583211183548,
0.029168235138058662,
0.0011824793182313442,
0.030676253139972687,
0.03643053025007248,
-0.0070043448358774185,
0.0035889826249331236,
-0.009633454494178295,
-0.021568620577454567,
0.04559769108891487,
-0.013472947292029858,
0.015625840052962303,
-0.017748970538377762,
0.05420926585793495,
0.03016035258769989,
-0.04579611495137215,
-0.06361453235149384,
-0.018671639263629913,
-0.0013281964929774404,
-0.03188663721084595,
0.052304401993751526,
-0.018116053193807602,
-0.04127206280827522,
-0.03688690438866615,
0.002696077572181821,
-0.036946430802345276,
-0.0359543152153492,
-0.004107363987714052,
0.02674747072160244,
-0.03843460604548454,
-0.024009227752685547,
-0.015149624086916447,
0.048653408885002136,
0.011161314323544502,
0.009712823666632175,
0.027838798239827156,
-0.03172789886593819,
-0.01476269867271185,
-0.09810051321983337,
0.006657104007899761,
-0.004928340669721365,
0.0014100461266934872,
-0.007500403560698032,
-0.01227248553186655,
-0.08151232451200485,
-0.0024319265503436327,
0.11326006054878235,
0.05095512047410011,
-0.022560738027095795,
0.01357215829193592,
0.013343972153961658,
0.045478638261556625,
0.03853381797671318,
-0.0010838876478374004,
0.06730520725250244,
-0.056233182549476624,
0.0039907898753881454,
0.061352506279945374,
0.03424787521362305,
-0.014723014086484909,
0.01354239508509636,
0.02738242596387863,
-0.05631255358457565,
0.021191615611314774,
-0.045637376606464386,
-0.02559661492705345,
0.03262080252170563,
0.007688905578106642,
-0.020993193611502647,
0.040379155427217484,
-0.0006870409124530852,
0.019643913954496384,
-0.007326783146709204,
0.03587494418025017,
-0.07956777513027191,
-0.03262080252170563,
0.03141041845083237,
0.007490482181310654,
-0.04813750833272934,
0.04071647673845291,
-0.02071540057659149,
-0.016548508778214455,
0.03319622948765755,
-0.014127744361758232,
0.019614150747656822,
-0.023314746096730232,
0.031033415347337723,
-0.09373520314693451,
0.0064834835939109325,
0.01024856697767973,
0.0028275330550968647,
0.008700864389538765,
-0.029148392379283905,
0.01097281277179718,
0.03803776204586029,
0.04948678985238075,
0.01976296864449978,
0.05127260088920593,
-0.027997538447380066,
0.03512093797326088,
-0.02934681624174118,
-0.030457988381385803,
0.002554700942710042,
0.09849736094474792,
-0.012460988014936447,
-0.06488443911075592,
-0.007158122956752777,
0.006116400472819805,
0.01751086302101612,
-0.04789940267801285,
-0.05924921855330467,
0.008378426544368267,
-0.041986387223005295,
0.012966967187821865,
0.005362391471862793,
-0.02049713395535946,
-0.017729127779603004
] |
725,937 | validator_collection.checkers | is_time | Indicate whether ``value`` is a :class:`time <python:datetime.time>`.
:param value: The value to evaluate.
:param minimum: If supplied, will make sure that ``value`` is on or after this value.
:type minimum: :func:`datetime <validator_collection.validators.datetime>` or
:func:`time <validator_collection.validators.time>`-compliant
:class:`str <python:str>` / :class:`datetime <python:datetime.datetime>` /
:class:`time <python:datetime.time> / numeric / :obj:`None <python:None>`
:param maximum: If supplied, will make sure that ``value`` is on or before this
value.
:type maximum: :func:`datetime <validator_collection.validators.datetime>` or
:func:`time <validator_collection.validators.time>`-compliant
:class:`str <python:str>` / :class:`datetime <python:datetime.datetime>` /
:class:`time <python:datetime.time> / numeric / :obj:`None <python:None>`
:param coerce_value: If ``True``, will return ``True`` if ``value`` can be
coerced to a :class:`time <python:datetime.time>`. If ``False``,
will only return ``True`` if ``value`` is a valid time. Defaults to
``False``.
:type coerce_value: :class:`bool <python:bool>`
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, minimum=None, maximum=None, coerce_value=False, **kwargs) | [
0.0026687942445278168,
0.013790423981845379,
-0.03057704120874405,
-0.007123399060219526,
0.007202768232673407,
0.017153700813651085,
0.001577465794980526,
0.05409020930528641,
-0.07540088146924973,
0.007381349336355925,
0.01016919780522585,
-0.006329705473035574,
0.08270286023616791,
-0.0027208805549889803,
-0.030299248173832893,
-0.020993193611502647,
-0.04631201550364494,
0.027600690722465515,
-0.00799150113016367,
-0.03049767203629017,
-0.037839338183403015,
0.0905604287981987,
0.04246260225772858,
-0.016756853088736534,
0.019991153851151466,
0.020120128989219666,
0.02894997037947178,
0.022322628647089005,
-0.01805652678012848,
0.03861318901181221,
-0.02236231416463852,
-0.022540895268321037,
0.022898057475686073,
-0.024187808856368065,
-0.001287271617911756,
-0.013869794085621834,
0.014217034913599491,
0.03722422569990158,
-0.017580309882760048,
-0.015030570328235626,
-0.05928890407085419,
0.045161157846450806,
-0.012341933324933052,
0.024267178028821945,
0.005238377023488283,
-0.06734488904476166,
-0.05389178916811943,
0.010546201840043068,
-0.051828183233737946,
-0.037998076528310776,
-0.002693597227334976,
-0.06774173676967621,
0.01105218194425106,
-0.07266263663768768,
-0.009797153994441032,
-0.008065910078585148,
-0.017133858054876328,
0.040537893772125244,
0.021568620577454567,
0.05559822916984558,
0.050439219921827316,
0.0017101614503189921,
0.007391270715743303,
-0.020437607541680336,
-0.027699902653694153,
-0.037283752113580704,
-0.047343816608190536,
-0.05428863316774368,
-0.05293935537338257,
-0.011042260564863682,
-0.04583580046892166,
0.02396954409778118,
-0.001016299705952406,
0.023612381890416145,
-0.0158837903290987,
-0.06170966848731041,
-0.03379150107502937,
0.058733318001031876,
-0.01446506381034851,
0.019941547885537148,
0.03998230770230293,
-0.015923475846648216,
-0.03041830286383629,
-0.08548078685998917,
-0.021925782784819603,
0.024167966097593307,
-0.08929051458835602,
0.017252912744879723,
0.03008098341524601,
-0.00438267644494772,
-0.01590363308787346,
0.004948182962834835,
0.02837454155087471,
-0.03452566638588905,
-0.06111439689993858,
-0.0333351269364357,
0.04520084336400032,
-0.009916207753121853,
-0.013522552326321602,
-0.00687040900811553,
0.008462756872177124,
-0.00034724088618531823,
0.06674962490797043,
-0.0114192645996809,
0.023354431614279747,
-0.010084867477416992,
0.0186319537460804,
-0.013224917463958263,
-0.010189040564000607,
0.027441952377557755,
0.007510324474424124,
-0.07099588215351105,
-0.02301711030304432,
-0.008824879303574562,
-0.019971312955021858,
-0.043375350534915924,
-0.0388512946665287,
-0.00010952039883704856,
-0.06817827373743057,
-0.030954046174883842,
-0.015546470880508423,
0.04984395205974579,
-0.00028073808061890304,
0.042065754532814026,
0.0855601578950882,
-0.042224492877721786,
-0.013711054809391499,
-0.009901326149702072,
0.0008463996928185225,
-0.0037105169612914324,
-0.037521857768297195,
0.008934012614190578,
-0.06551939994096756,
0.04079584404826164,
0.028255488723516464,
0.04845498874783516,
-0.018800614401698112,
-0.026033146306872368,
-0.023394115269184113,
-0.02252105250954628,
0.02974366396665573,
0.07710732519626617,
0.02771974541246891,
-0.04785971716046333,
-0.03658926859498024,
0.03827586770057678,
-0.01658819429576397,
0.00004065354005433619,
0.013046336360275745,
0.021608304232358932,
-0.019782809540629387,
-0.05357430875301361,
0.045478638261556625,
0.06627340614795685,
-0.08992547541856766,
-0.06540033966302872,
-0.030219879001379013,
-0.012093904428184032,
-0.0029912323225289583,
-0.023433800786733627,
0.035894788801670074,
0.05964606627821922,
-0.04143080115318298,
0.016856065019965172,
0.019544702023267746,
0.04055773839354515,
-0.019753046333789825,
-0.00917212013155222,
-0.0093159768730402,
0.0047274366952478886,
-0.04087521508336067,
-0.018542664125561714,
0.013274523429572582,
0.015387732535600662,
-0.027422109618782997,
0.05730466917157173,
-0.06722583621740341,
-0.009826917201280594,
-0.0025720628909766674,
0.029862716794013977,
0.017947394400835037,
-0.00456621777266264,
-0.015000807121396065,
0.00772362994030118,
-0.031251680105924606,
0.02974366396665573,
0.02226310223340988,
-0.05143133923411369,
0.027759429067373276,
-0.019256988540291786,
-0.0448833666741848,
0.03601384162902832,
0.048812150955200195,
-0.09595753997564316,
0.013006651774048805,
0.029148392379283905,
-0.012570120394229889,
0.02968413569033146,
0.0070936353877186775,
0.03537888824939728,
0.012381617911159992,
0.015873869881033897,
0.023671908304095268,
0.013988847844302654,
0.050280481576919556,
-0.01648898236453533,
0.008849682286381721,
0.04893120378255844,
0.0585348941385746,
-0.009301095269620419,
-0.05059795826673508,
-0.060122281312942505,
0.0017436454072594643,
0.0650828629732132,
0.06119376793503761,
0.01892958953976631,
0.015040491707623005,
-0.04349440336227417,
0.02121145837008953,
0.007158122956752777,
0.0038047682028263807,
0.023711591958999634,
-0.04029978811740875,
0.04845498874783516,
0.03714485466480255,
-0.05393147096037865,
-0.024862447753548622,
0.06238430738449097,
0.00557073624804616,
-0.04452620446681976,
-0.007202768232673407,
0.0010646653827279806,
0.03393039479851723,
0.06119376793503761,
-0.03480345755815506,
0.02129082754254341,
-0.014891673810780048,
0.04992331936955452,
-0.024108439683914185,
0.012222879566252232,
0.03928782790899277,
0.011488713324069977,
-0.05782056972384453,
-0.10214835405349731,
-0.019495096057653427,
0.009995576925575733,
0.009112593717873096,
0.04599453881382942,
-0.03317638859152794,
-0.022223416715860367,
-0.015754815191030502,
0.015437338501214981,
-0.015814343467354774,
-0.10365636646747589,
-0.03164852783083916,
0.022640107199549675,
-0.010685098357498646,
-0.07448813319206238,
0.03127152472734451,
0.002412084024399519,
-0.028553122654557228,
-0.013651528395712376,
0.07198800146579742,
0.07655173540115356,
-0.056550659239292145,
-0.019514938816428185,
0.05571728199720383,
0.0406767912209034,
-0.011290289461612701,
-0.03073577955365181,
0.12397491931915283,
0.01637984998524189,
0.08468709141016006,
0.04936773329973221,
-0.0008005143026821315,
-0.004871293902397156,
0.028315015137195587,
-0.033692289143800735,
0.022243259474635124,
0.03317638859152794,
-0.018046606332063675,
0.04397061839699745,
0.027025263756513596,
-0.044367466121912,
0.02877138927578926,
-0.044923052191734314,
0.04024025797843933,
0.05571728199720383,
-0.02569582685828209,
0.011736742220818996,
0.020189577713608742,
-0.040121205151081085,
0.04599453881382942,
-0.0077186692506074905,
-0.03585510328412056,
0.12064141035079956,
0.05139165371656418,
-0.014941279776394367,
-0.025160083547234535,
-0.05254250764846802,
-0.0663924589753151,
0.011498634703457355,
0.015030570328235626,
-0.048812150955200195,
0.037045642733573914,
-0.0060320706106722355,
-0.02252105250954628,
-0.018552584573626518,
-0.03246206417679787,
0.01887006312608719,
0.013840029947459698,
0.029961928725242615,
0.004204095341265202,
-0.01805652678012848,
0.01821526512503624,
0.0014063256094232202,
-0.002512536011636257,
-0.04087521508336067,
-0.035001881420612335,
0.024088596925139427,
-0.03583526238799095,
0.021449565887451172,
0.031013572588562965,
0.01442537922412157,
-0.007693866267800331,
-0.03160884231328964,
-0.007773235440254211,
0.07583741098642349,
-0.015040491707623005,
0.028751546517014503,
-0.027997538447380066,
-0.07238484919071198,
0.05706655979156494,
0.022580578923225403,
0.06055881455540657,
-0.043534088879823685,
-0.018780771642923355,
0.00003695247869472951,
0.036708325147628784,
0.04194670170545578,
-0.0026712745893746614,
0.0063743507489562035,
-0.009053066372871399,
-0.01357215829193592,
-0.03154931589961052,
0.009549125097692013,
-0.012431223876774311,
0.023294903337955475,
0.05690782144665718,
0.07417065650224686,
-0.06047944352030754,
-0.03902987763285637,
-0.00017486060096416622,
-0.06547971069812775,
-0.05789994075894356,
-0.009568966925144196,
0.024941816926002502,
0.02976350486278534,
-0.011528397910296917,
-0.04131174460053444,
0.0391092449426651,
-0.013443183153867722,
-0.009266371838748455,
-0.007009305525571108,
-0.07520245760679245,
0.061828721314668655,
-0.024584656581282616,
0.010913285426795483,
0.050359852612018585,
0.00033576955320313573,
0.004238819237798452,
0.05837615579366684,
-0.01960422843694687,
-0.024941816926002502,
0.003956065978854895,
-0.027104632928967476,
0.0017746490193530917,
-0.020229263231158257,
-0.02309648133814335,
0.03893066570162773,
0.00019904343935195357,
-0.003013554960489273,
0.07722637802362442,
-0.04658980667591095,
0.035478100180625916,
-0.023949701339006424,
-0.02226310223340988,
0.02756100706756115,
-0.06095565855503082,
-0.016766775399446487,
0.010982733219861984,
0.020308632403612137,
0.0072722164914011955,
-0.0469866544008255,
-0.018225187435746193,
-0.0766311064362526,
0.0241481252014637,
0.028513438999652863,
-0.06706710159778595,
-0.002208700170740485,
0.036748006939888,
0.021727358922362328,
-0.017739050090312958,
0.019693519920110703,
0.0028498556930571795,
0.07675015926361084,
0.023949701339006424,
-0.022064678370952606,
0.038732241839170456,
-0.034684404730796814,
0.029723821207880974,
-0.05016142874956131,
-0.009802114218473434,
-0.05234408378601074,
0.011478791944682598,
0.007267255801707506,
-0.02301711030304432,
-0.013115785084664822,
0.012867755256593227,
-0.031430263072252274,
0.046867601573467255,
0.013711054809391499,
0.02341395802795887,
-0.021171772852540016,
-0.024445759132504463,
-0.0005689170211553574,
-0.01585402712225914,
-0.046788230538368225,
0.04968521371483803,
0.0013492789585143328,
-0.05397115647792816,
-0.029128551483154297,
0.004680311307311058,
0.013195154257118702,
-0.0070192269049584866,
-0.03178742527961731,
-0.020874138921499252,
-0.008621495217084885,
0.011032339185476303,
-0.013959083706140518,
-0.033057332038879395,
-0.024009227752685547,
-0.02894997037947178,
0.04853435605764389,
-0.00023485266137868166,
0.009618572890758514,
-0.004690232221037149,
-0.02349332720041275,
0.041827645152807236,
0.009435031563043594,
-0.009697942063212395,
0.052225030958652496,
-0.03789886459708214,
-0.004447164013981819,
-0.021350353956222534,
-0.02764037624001503,
-0.02910870872437954,
0.03682737797498703,
0.05456642806529999,
0.01126052625477314,
-0.014395616017282009,
-0.026628416031599045,
-0.008457796648144722,
-0.025239452719688416,
-0.02714431658387184,
0.004767121281474829,
-0.0012847912730649114,
0.026608573272824287,
0.07956777513027191,
0.036867063492536545,
-0.03992278128862381,
-0.000719284696970135,
0.002000355627387762,
0.012728859670460224,
0.014603960327804089,
0.08508393913507462,
-0.0029589885380119085,
0.025973619893193245,
-0.02771974541246891,
0.03537888824939728,
0.010724782943725586,
-0.016608037054538727,
0.04789940267801285,
-0.028156276792287827,
-0.03887113928794861,
-0.03829571232199669,
-0.011974850669503212,
0.03008098341524601,
0.03291843831539154,
-0.03948625177145004,
-0.018860140815377235,
-0.04091490060091019,
-0.030338933691382408,
0.04512147605419159,
0.02315600775182247,
-0.028751546517014503,
0.0008470197790302336,
0.010625571943819523,
-0.023235376924276352,
0.009400307200849056,
0.10167213529348373,
0.057582464069128036,
0.023533012717962265,
-0.0028126512188464403,
0.02553708851337433,
-0.02162814699113369,
0.006185848731547594,
-0.005793962627649307,
-0.017391808331012726,
0.02011020854115486,
-0.04186733067035675,
0.05567759647965431,
0.019931627437472343,
0.031013572588562965,
0.010496596805751324,
0.022481368854641914,
0.0427800789475441,
0.009980695322155952,
0.021588463336229324,
-0.022223416715860367,
-0.034108977764844894,
0.0054963272996246815,
0.026568889617919922,
-0.020596345886588097,
0.006796000525355339,
0.05928890407085419,
0.011578003875911236,
-0.018185501918196678,
0.014187270775437355,
-0.020616188645362854,
0.039803728461265564,
0.023215534165501595,
-0.013423341326415539,
-0.012798307463526726,
0.056947506964206696,
-0.012619726359844208,
0.021072562783956528,
-0.0372639074921608,
0.031906478106975555,
-0.004829128738492727,
0.04682791605591774,
-0.003913900814950466,
-0.005233416333794594,
-0.01974312588572502,
-0.015963159501552582,
0.048653408885002136,
0.029465870931744576,
-0.045002419501543045,
-0.004092481918632984,
0.022878214716911316,
0.023453641682863235,
-0.02529897913336754,
-0.005863410420715809,
0.09381456673145294,
-0.05424895137548447,
0.028652334585785866,
-0.020437607541680336,
0.008338741958141327,
0.016528666019439697,
0.025675984099507332,
-0.0028002497274428606,
0.05317746475338936,
0.015020648948848248,
-0.003951105289161205,
-0.04266102612018585,
-0.0721864253282547,
-0.012718938291072845,
0.021886097267270088,
0.04301818832755089,
-0.02226310223340988,
0.029803190380334854,
0.007579772733151913,
-0.022779002785682678,
-0.014217034913599491,
0.025993460789322853,
0.012947125360369682,
-0.019564544782042503,
-0.003003633813932538,
-0.029961928725242615,
-0.02049713395535946,
0.010427148081362247,
-0.02553708851337433,
-0.030596883967518806,
-0.03472409024834633,
-0.01834424026310444,
-0.031430263072252274,
-0.05155039206147194,
-0.026707785204052925,
-0.05373304709792137,
-0.011002575978636742,
-0.004015592858195305,
0.08436961472034454,
0.03260096162557602,
-0.018572427332401276,
0.02202499471604824,
-0.014832147397100925,
0.032799381762742996,
-0.016865987330675125,
-0.021270984783768654,
-0.01897919550538063,
-0.05845552682876587,
0.015625840052962303,
-0.022640107199549675,
-0.05107417702674866,
0.01653858833014965,
0.031112784519791603,
0.011498634703457355,
-0.005640184506773949,
0.004057758022099733,
-0.03105325810611248,
0.03031909093260765,
0.008393308147788048,
0.07726605981588364,
0.06202714517712593,
-0.05139165371656418,
-0.01934627816081047,
0.023612381890416145,
-0.030259564518928528,
-0.004057758022099733,
0.03379150107502937,
-0.002834973856806755,
0.030358776450157166,
0.07746448367834091,
-0.009330859407782555,
-0.018959352746605873,
-0.039962466806173325,
-0.0241481252014637,
-0.08309970796108246,
0.01708425208926201,
-0.0482962504029274,
-0.040200576186180115,
-0.004085041116923094,
0.01915777660906315,
-0.04381188005208969,
-0.02049713395535946,
-0.03807744383811951,
-0.028572965413331985,
-0.024485444650053978,
0.007525206543505192,
0.02396954409778118,
-0.04194670170545578,
-0.032561276108026505,
0.0037154776509851217,
0.023870332166552544,
-0.024425916373729706,
0.024029070511460304,
0.06492412835359573,
0.010005498304963112,
0.05909048020839691,
0.027104632928967476,
0.02738242596387863,
0.09365583211183548,
0.029168235138058662,
0.0011824793182313442,
0.030676253139972687,
0.03643053025007248,
-0.0070043448358774185,
0.0035889826249331236,
-0.009633454494178295,
-0.021568620577454567,
0.04559769108891487,
-0.013472947292029858,
0.015625840052962303,
-0.017748970538377762,
0.05420926585793495,
0.03016035258769989,
-0.04579611495137215,
-0.06361453235149384,
-0.018671639263629913,
-0.0013281964929774404,
-0.03188663721084595,
0.052304401993751526,
-0.018116053193807602,
-0.04127206280827522,
-0.03688690438866615,
0.002696077572181821,
-0.036946430802345276,
-0.0359543152153492,
-0.004107363987714052,
0.02674747072160244,
-0.03843460604548454,
-0.024009227752685547,
-0.015149624086916447,
0.048653408885002136,
0.011161314323544502,
0.009712823666632175,
0.027838798239827156,
-0.03172789886593819,
-0.01476269867271185,
-0.09810051321983337,
0.006657104007899761,
-0.004928340669721365,
0.0014100461266934872,
-0.007500403560698032,
-0.01227248553186655,
-0.08151232451200485,
-0.0024319265503436327,
0.11326006054878235,
0.05095512047410011,
-0.022560738027095795,
0.01357215829193592,
0.013343972153961658,
0.045478638261556625,
0.03853381797671318,
-0.0010838876478374004,
0.06730520725250244,
-0.056233182549476624,
0.0039907898753881454,
0.061352506279945374,
0.03424787521362305,
-0.014723014086484909,
0.01354239508509636,
0.02738242596387863,
-0.05631255358457565,
0.021191615611314774,
-0.045637376606464386,
-0.02559661492705345,
0.03262080252170563,
0.007688905578106642,
-0.020993193611502647,
0.040379155427217484,
-0.0006870409124530852,
0.019643913954496384,
-0.007326783146709204,
0.03587494418025017,
-0.07956777513027191,
-0.03262080252170563,
0.03141041845083237,
0.007490482181310654,
-0.04813750833272934,
0.04071647673845291,
-0.02071540057659149,
-0.016548508778214455,
0.03319622948765755,
-0.014127744361758232,
0.019614150747656822,
-0.023314746096730232,
0.031033415347337723,
-0.09373520314693451,
0.0064834835939109325,
0.01024856697767973,
0.0028275330550968647,
0.008700864389538765,
-0.029148392379283905,
0.01097281277179718,
0.03803776204586029,
0.04948678985238075,
0.01976296864449978,
0.05127260088920593,
-0.027997538447380066,
0.03512093797326088,
-0.02934681624174118,
-0.030457988381385803,
0.002554700942710042,
0.09849736094474792,
-0.012460988014936447,
-0.06488443911075592,
-0.007158122956752777,
0.006116400472819805,
0.01751086302101612,
-0.04789940267801285,
-0.05924921855330467,
0.008378426544368267,
-0.041986387223005295,
0.012966967187821865,
0.005362391471862793,
-0.02049713395535946,
-0.017729127779603004
] |
725,938 | validator_collection.checkers | is_timezone | Indicate whether ``value`` is a :class:`tzinfo <python:datetime.tzinfo>`.
.. caution::
This does **not** validate whether the value is a timezone that actually
exists, nor can it resolve timzone names (e.g. ``'Eastern'`` or ``'CET'``).
For that kind of functionality, we recommend you utilize:
`pytz <https://pypi.python.org/pypi/pytz>`_
:param value: The value to evaluate.
:param positive: Indicates whether the ``value`` is positive or negative
(only has meaning if ``value`` is a string). Defaults to ``True``.
:type positive: :class:`bool <python:bool>`
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, positive=True, **kwargs) | [
0.0026687942445278168,
0.013790423981845379,
-0.03057704120874405,
-0.007123399060219526,
0.007202768232673407,
0.017153700813651085,
0.001577465794980526,
0.05409020930528641,
-0.07540088146924973,
0.007381349336355925,
0.01016919780522585,
-0.006329705473035574,
0.08270286023616791,
-0.0027208805549889803,
-0.030299248173832893,
-0.020993193611502647,
-0.04631201550364494,
0.027600690722465515,
-0.00799150113016367,
-0.03049767203629017,
-0.037839338183403015,
0.0905604287981987,
0.04246260225772858,
-0.016756853088736534,
0.019991153851151466,
0.020120128989219666,
0.02894997037947178,
0.022322628647089005,
-0.01805652678012848,
0.03861318901181221,
-0.02236231416463852,
-0.022540895268321037,
0.022898057475686073,
-0.024187808856368065,
-0.001287271617911756,
-0.013869794085621834,
0.014217034913599491,
0.03722422569990158,
-0.017580309882760048,
-0.015030570328235626,
-0.05928890407085419,
0.045161157846450806,
-0.012341933324933052,
0.024267178028821945,
0.005238377023488283,
-0.06734488904476166,
-0.05389178916811943,
0.010546201840043068,
-0.051828183233737946,
-0.037998076528310776,
-0.002693597227334976,
-0.06774173676967621,
0.01105218194425106,
-0.07266263663768768,
-0.009797153994441032,
-0.008065910078585148,
-0.017133858054876328,
0.040537893772125244,
0.021568620577454567,
0.05559822916984558,
0.050439219921827316,
0.0017101614503189921,
0.007391270715743303,
-0.020437607541680336,
-0.027699902653694153,
-0.037283752113580704,
-0.047343816608190536,
-0.05428863316774368,
-0.05293935537338257,
-0.011042260564863682,
-0.04583580046892166,
0.02396954409778118,
-0.001016299705952406,
0.023612381890416145,
-0.0158837903290987,
-0.06170966848731041,
-0.03379150107502937,
0.058733318001031876,
-0.01446506381034851,
0.019941547885537148,
0.03998230770230293,
-0.015923475846648216,
-0.03041830286383629,
-0.08548078685998917,
-0.021925782784819603,
0.024167966097593307,
-0.08929051458835602,
0.017252912744879723,
0.03008098341524601,
-0.00438267644494772,
-0.01590363308787346,
0.004948182962834835,
0.02837454155087471,
-0.03452566638588905,
-0.06111439689993858,
-0.0333351269364357,
0.04520084336400032,
-0.009916207753121853,
-0.013522552326321602,
-0.00687040900811553,
0.008462756872177124,
-0.00034724088618531823,
0.06674962490797043,
-0.0114192645996809,
0.023354431614279747,
-0.010084867477416992,
0.0186319537460804,
-0.013224917463958263,
-0.010189040564000607,
0.027441952377557755,
0.007510324474424124,
-0.07099588215351105,
-0.02301711030304432,
-0.008824879303574562,
-0.019971312955021858,
-0.043375350534915924,
-0.0388512946665287,
-0.00010952039883704856,
-0.06817827373743057,
-0.030954046174883842,
-0.015546470880508423,
0.04984395205974579,
-0.00028073808061890304,
0.042065754532814026,
0.0855601578950882,
-0.042224492877721786,
-0.013711054809391499,
-0.009901326149702072,
0.0008463996928185225,
-0.0037105169612914324,
-0.037521857768297195,
0.008934012614190578,
-0.06551939994096756,
0.04079584404826164,
0.028255488723516464,
0.04845498874783516,
-0.018800614401698112,
-0.026033146306872368,
-0.023394115269184113,
-0.02252105250954628,
0.02974366396665573,
0.07710732519626617,
0.02771974541246891,
-0.04785971716046333,
-0.03658926859498024,
0.03827586770057678,
-0.01658819429576397,
0.00004065354005433619,
0.013046336360275745,
0.021608304232358932,
-0.019782809540629387,
-0.05357430875301361,
0.045478638261556625,
0.06627340614795685,
-0.08992547541856766,
-0.06540033966302872,
-0.030219879001379013,
-0.012093904428184032,
-0.0029912323225289583,
-0.023433800786733627,
0.035894788801670074,
0.05964606627821922,
-0.04143080115318298,
0.016856065019965172,
0.019544702023267746,
0.04055773839354515,
-0.019753046333789825,
-0.00917212013155222,
-0.0093159768730402,
0.0047274366952478886,
-0.04087521508336067,
-0.018542664125561714,
0.013274523429572582,
0.015387732535600662,
-0.027422109618782997,
0.05730466917157173,
-0.06722583621740341,
-0.009826917201280594,
-0.0025720628909766674,
0.029862716794013977,
0.017947394400835037,
-0.00456621777266264,
-0.015000807121396065,
0.00772362994030118,
-0.031251680105924606,
0.02974366396665573,
0.02226310223340988,
-0.05143133923411369,
0.027759429067373276,
-0.019256988540291786,
-0.0448833666741848,
0.03601384162902832,
0.048812150955200195,
-0.09595753997564316,
0.013006651774048805,
0.029148392379283905,
-0.012570120394229889,
0.02968413569033146,
0.0070936353877186775,
0.03537888824939728,
0.012381617911159992,
0.015873869881033897,
0.023671908304095268,
0.013988847844302654,
0.050280481576919556,
-0.01648898236453533,
0.008849682286381721,
0.04893120378255844,
0.0585348941385746,
-0.009301095269620419,
-0.05059795826673508,
-0.060122281312942505,
0.0017436454072594643,
0.0650828629732132,
0.06119376793503761,
0.01892958953976631,
0.015040491707623005,
-0.04349440336227417,
0.02121145837008953,
0.007158122956752777,
0.0038047682028263807,
0.023711591958999634,
-0.04029978811740875,
0.04845498874783516,
0.03714485466480255,
-0.05393147096037865,
-0.024862447753548622,
0.06238430738449097,
0.00557073624804616,
-0.04452620446681976,
-0.007202768232673407,
0.0010646653827279806,
0.03393039479851723,
0.06119376793503761,
-0.03480345755815506,
0.02129082754254341,
-0.014891673810780048,
0.04992331936955452,
-0.024108439683914185,
0.012222879566252232,
0.03928782790899277,
0.011488713324069977,
-0.05782056972384453,
-0.10214835405349731,
-0.019495096057653427,
0.009995576925575733,
0.009112593717873096,
0.04599453881382942,
-0.03317638859152794,
-0.022223416715860367,
-0.015754815191030502,
0.015437338501214981,
-0.015814343467354774,
-0.10365636646747589,
-0.03164852783083916,
0.022640107199549675,
-0.010685098357498646,
-0.07448813319206238,
0.03127152472734451,
0.002412084024399519,
-0.028553122654557228,
-0.013651528395712376,
0.07198800146579742,
0.07655173540115356,
-0.056550659239292145,
-0.019514938816428185,
0.05571728199720383,
0.0406767912209034,
-0.011290289461612701,
-0.03073577955365181,
0.12397491931915283,
0.01637984998524189,
0.08468709141016006,
0.04936773329973221,
-0.0008005143026821315,
-0.004871293902397156,
0.028315015137195587,
-0.033692289143800735,
0.022243259474635124,
0.03317638859152794,
-0.018046606332063675,
0.04397061839699745,
0.027025263756513596,
-0.044367466121912,
0.02877138927578926,
-0.044923052191734314,
0.04024025797843933,
0.05571728199720383,
-0.02569582685828209,
0.011736742220818996,
0.020189577713608742,
-0.040121205151081085,
0.04599453881382942,
-0.0077186692506074905,
-0.03585510328412056,
0.12064141035079956,
0.05139165371656418,
-0.014941279776394367,
-0.025160083547234535,
-0.05254250764846802,
-0.0663924589753151,
0.011498634703457355,
0.015030570328235626,
-0.048812150955200195,
0.037045642733573914,
-0.0060320706106722355,
-0.02252105250954628,
-0.018552584573626518,
-0.03246206417679787,
0.01887006312608719,
0.013840029947459698,
0.029961928725242615,
0.004204095341265202,
-0.01805652678012848,
0.01821526512503624,
0.0014063256094232202,
-0.002512536011636257,
-0.04087521508336067,
-0.035001881420612335,
0.024088596925139427,
-0.03583526238799095,
0.021449565887451172,
0.031013572588562965,
0.01442537922412157,
-0.007693866267800331,
-0.03160884231328964,
-0.007773235440254211,
0.07583741098642349,
-0.015040491707623005,
0.028751546517014503,
-0.027997538447380066,
-0.07238484919071198,
0.05706655979156494,
0.022580578923225403,
0.06055881455540657,
-0.043534088879823685,
-0.018780771642923355,
0.00003695247869472951,
0.036708325147628784,
0.04194670170545578,
-0.0026712745893746614,
0.0063743507489562035,
-0.009053066372871399,
-0.01357215829193592,
-0.03154931589961052,
0.009549125097692013,
-0.012431223876774311,
0.023294903337955475,
0.05690782144665718,
0.07417065650224686,
-0.06047944352030754,
-0.03902987763285637,
-0.00017486060096416622,
-0.06547971069812775,
-0.05789994075894356,
-0.009568966925144196,
0.024941816926002502,
0.02976350486278534,
-0.011528397910296917,
-0.04131174460053444,
0.0391092449426651,
-0.013443183153867722,
-0.009266371838748455,
-0.007009305525571108,
-0.07520245760679245,
0.061828721314668655,
-0.024584656581282616,
0.010913285426795483,
0.050359852612018585,
0.00033576955320313573,
0.004238819237798452,
0.05837615579366684,
-0.01960422843694687,
-0.024941816926002502,
0.003956065978854895,
-0.027104632928967476,
0.0017746490193530917,
-0.020229263231158257,
-0.02309648133814335,
0.03893066570162773,
0.00019904343935195357,
-0.003013554960489273,
0.07722637802362442,
-0.04658980667591095,
0.035478100180625916,
-0.023949701339006424,
-0.02226310223340988,
0.02756100706756115,
-0.06095565855503082,
-0.016766775399446487,
0.010982733219861984,
0.020308632403612137,
0.0072722164914011955,
-0.0469866544008255,
-0.018225187435746193,
-0.0766311064362526,
0.0241481252014637,
0.028513438999652863,
-0.06706710159778595,
-0.002208700170740485,
0.036748006939888,
0.021727358922362328,
-0.017739050090312958,
0.019693519920110703,
0.0028498556930571795,
0.07675015926361084,
0.023949701339006424,
-0.022064678370952606,
0.038732241839170456,
-0.034684404730796814,
0.029723821207880974,
-0.05016142874956131,
-0.009802114218473434,
-0.05234408378601074,
0.011478791944682598,
0.007267255801707506,
-0.02301711030304432,
-0.013115785084664822,
0.012867755256593227,
-0.031430263072252274,
0.046867601573467255,
0.013711054809391499,
0.02341395802795887,
-0.021171772852540016,
-0.024445759132504463,
-0.0005689170211553574,
-0.01585402712225914,
-0.046788230538368225,
0.04968521371483803,
0.0013492789585143328,
-0.05397115647792816,
-0.029128551483154297,
0.004680311307311058,
0.013195154257118702,
-0.0070192269049584866,
-0.03178742527961731,
-0.020874138921499252,
-0.008621495217084885,
0.011032339185476303,
-0.013959083706140518,
-0.033057332038879395,
-0.024009227752685547,
-0.02894997037947178,
0.04853435605764389,
-0.00023485266137868166,
0.009618572890758514,
-0.004690232221037149,
-0.02349332720041275,
0.041827645152807236,
0.009435031563043594,
-0.009697942063212395,
0.052225030958652496,
-0.03789886459708214,
-0.004447164013981819,
-0.021350353956222534,
-0.02764037624001503,
-0.02910870872437954,
0.03682737797498703,
0.05456642806529999,
0.01126052625477314,
-0.014395616017282009,
-0.026628416031599045,
-0.008457796648144722,
-0.025239452719688416,
-0.02714431658387184,
0.004767121281474829,
-0.0012847912730649114,
0.026608573272824287,
0.07956777513027191,
0.036867063492536545,
-0.03992278128862381,
-0.000719284696970135,
0.002000355627387762,
0.012728859670460224,
0.014603960327804089,
0.08508393913507462,
-0.0029589885380119085,
0.025973619893193245,
-0.02771974541246891,
0.03537888824939728,
0.010724782943725586,
-0.016608037054538727,
0.04789940267801285,
-0.028156276792287827,
-0.03887113928794861,
-0.03829571232199669,
-0.011974850669503212,
0.03008098341524601,
0.03291843831539154,
-0.03948625177145004,
-0.018860140815377235,
-0.04091490060091019,
-0.030338933691382408,
0.04512147605419159,
0.02315600775182247,
-0.028751546517014503,
0.0008470197790302336,
0.010625571943819523,
-0.023235376924276352,
0.009400307200849056,
0.10167213529348373,
0.057582464069128036,
0.023533012717962265,
-0.0028126512188464403,
0.02553708851337433,
-0.02162814699113369,
0.006185848731547594,
-0.005793962627649307,
-0.017391808331012726,
0.02011020854115486,
-0.04186733067035675,
0.05567759647965431,
0.019931627437472343,
0.031013572588562965,
0.010496596805751324,
0.022481368854641914,
0.0427800789475441,
0.009980695322155952,
0.021588463336229324,
-0.022223416715860367,
-0.034108977764844894,
0.0054963272996246815,
0.026568889617919922,
-0.020596345886588097,
0.006796000525355339,
0.05928890407085419,
0.011578003875911236,
-0.018185501918196678,
0.014187270775437355,
-0.020616188645362854,
0.039803728461265564,
0.023215534165501595,
-0.013423341326415539,
-0.012798307463526726,
0.056947506964206696,
-0.012619726359844208,
0.021072562783956528,
-0.0372639074921608,
0.031906478106975555,
-0.004829128738492727,
0.04682791605591774,
-0.003913900814950466,
-0.005233416333794594,
-0.01974312588572502,
-0.015963159501552582,
0.048653408885002136,
0.029465870931744576,
-0.045002419501543045,
-0.004092481918632984,
0.022878214716911316,
0.023453641682863235,
-0.02529897913336754,
-0.005863410420715809,
0.09381456673145294,
-0.05424895137548447,
0.028652334585785866,
-0.020437607541680336,
0.008338741958141327,
0.016528666019439697,
0.025675984099507332,
-0.0028002497274428606,
0.05317746475338936,
0.015020648948848248,
-0.003951105289161205,
-0.04266102612018585,
-0.0721864253282547,
-0.012718938291072845,
0.021886097267270088,
0.04301818832755089,
-0.02226310223340988,
0.029803190380334854,
0.007579772733151913,
-0.022779002785682678,
-0.014217034913599491,
0.025993460789322853,
0.012947125360369682,
-0.019564544782042503,
-0.003003633813932538,
-0.029961928725242615,
-0.02049713395535946,
0.010427148081362247,
-0.02553708851337433,
-0.030596883967518806,
-0.03472409024834633,
-0.01834424026310444,
-0.031430263072252274,
-0.05155039206147194,
-0.026707785204052925,
-0.05373304709792137,
-0.011002575978636742,
-0.004015592858195305,
0.08436961472034454,
0.03260096162557602,
-0.018572427332401276,
0.02202499471604824,
-0.014832147397100925,
0.032799381762742996,
-0.016865987330675125,
-0.021270984783768654,
-0.01897919550538063,
-0.05845552682876587,
0.015625840052962303,
-0.022640107199549675,
-0.05107417702674866,
0.01653858833014965,
0.031112784519791603,
0.011498634703457355,
-0.005640184506773949,
0.004057758022099733,
-0.03105325810611248,
0.03031909093260765,
0.008393308147788048,
0.07726605981588364,
0.06202714517712593,
-0.05139165371656418,
-0.01934627816081047,
0.023612381890416145,
-0.030259564518928528,
-0.004057758022099733,
0.03379150107502937,
-0.002834973856806755,
0.030358776450157166,
0.07746448367834091,
-0.009330859407782555,
-0.018959352746605873,
-0.039962466806173325,
-0.0241481252014637,
-0.08309970796108246,
0.01708425208926201,
-0.0482962504029274,
-0.040200576186180115,
-0.004085041116923094,
0.01915777660906315,
-0.04381188005208969,
-0.02049713395535946,
-0.03807744383811951,
-0.028572965413331985,
-0.024485444650053978,
0.007525206543505192,
0.02396954409778118,
-0.04194670170545578,
-0.032561276108026505,
0.0037154776509851217,
0.023870332166552544,
-0.024425916373729706,
0.024029070511460304,
0.06492412835359573,
0.010005498304963112,
0.05909048020839691,
0.027104632928967476,
0.02738242596387863,
0.09365583211183548,
0.029168235138058662,
0.0011824793182313442,
0.030676253139972687,
0.03643053025007248,
-0.0070043448358774185,
0.0035889826249331236,
-0.009633454494178295,
-0.021568620577454567,
0.04559769108891487,
-0.013472947292029858,
0.015625840052962303,
-0.017748970538377762,
0.05420926585793495,
0.03016035258769989,
-0.04579611495137215,
-0.06361453235149384,
-0.018671639263629913,
-0.0013281964929774404,
-0.03188663721084595,
0.052304401993751526,
-0.018116053193807602,
-0.04127206280827522,
-0.03688690438866615,
0.002696077572181821,
-0.036946430802345276,
-0.0359543152153492,
-0.004107363987714052,
0.02674747072160244,
-0.03843460604548454,
-0.024009227752685547,
-0.015149624086916447,
0.048653408885002136,
0.011161314323544502,
0.009712823666632175,
0.027838798239827156,
-0.03172789886593819,
-0.01476269867271185,
-0.09810051321983337,
0.006657104007899761,
-0.004928340669721365,
0.0014100461266934872,
-0.007500403560698032,
-0.01227248553186655,
-0.08151232451200485,
-0.0024319265503436327,
0.11326006054878235,
0.05095512047410011,
-0.022560738027095795,
0.01357215829193592,
0.013343972153961658,
0.045478638261556625,
0.03853381797671318,
-0.0010838876478374004,
0.06730520725250244,
-0.056233182549476624,
0.0039907898753881454,
0.061352506279945374,
0.03424787521362305,
-0.014723014086484909,
0.01354239508509636,
0.02738242596387863,
-0.05631255358457565,
0.021191615611314774,
-0.045637376606464386,
-0.02559661492705345,
0.03262080252170563,
0.007688905578106642,
-0.020993193611502647,
0.040379155427217484,
-0.0006870409124530852,
0.019643913954496384,
-0.007326783146709204,
0.03587494418025017,
-0.07956777513027191,
-0.03262080252170563,
0.03141041845083237,
0.007490482181310654,
-0.04813750833272934,
0.04071647673845291,
-0.02071540057659149,
-0.016548508778214455,
0.03319622948765755,
-0.014127744361758232,
0.019614150747656822,
-0.023314746096730232,
0.031033415347337723,
-0.09373520314693451,
0.0064834835939109325,
0.01024856697767973,
0.0028275330550968647,
0.008700864389538765,
-0.029148392379283905,
0.01097281277179718,
0.03803776204586029,
0.04948678985238075,
0.01976296864449978,
0.05127260088920593,
-0.027997538447380066,
0.03512093797326088,
-0.02934681624174118,
-0.030457988381385803,
0.002554700942710042,
0.09849736094474792,
-0.012460988014936447,
-0.06488443911075592,
-0.007158122956752777,
0.006116400472819805,
0.01751086302101612,
-0.04789940267801285,
-0.05924921855330467,
0.008378426544368267,
-0.041986387223005295,
0.012966967187821865,
0.005362391471862793,
-0.02049713395535946,
-0.017729127779603004
] |
725,939 | validator_collection.checkers | is_type | Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (obj, type_, **kwargs) | [
0.0026687942445278168,
0.013790423981845379,
-0.03057704120874405,
-0.007123399060219526,
0.007202768232673407,
0.017153700813651085,
0.001577465794980526,
0.05409020930528641,
-0.07540088146924973,
0.007381349336355925,
0.01016919780522585,
-0.006329705473035574,
0.08270286023616791,
-0.0027208805549889803,
-0.030299248173832893,
-0.020993193611502647,
-0.04631201550364494,
0.027600690722465515,
-0.00799150113016367,
-0.03049767203629017,
-0.037839338183403015,
0.0905604287981987,
0.04246260225772858,
-0.016756853088736534,
0.019991153851151466,
0.020120128989219666,
0.02894997037947178,
0.022322628647089005,
-0.01805652678012848,
0.03861318901181221,
-0.02236231416463852,
-0.022540895268321037,
0.022898057475686073,
-0.024187808856368065,
-0.001287271617911756,
-0.013869794085621834,
0.014217034913599491,
0.03722422569990158,
-0.017580309882760048,
-0.015030570328235626,
-0.05928890407085419,
0.045161157846450806,
-0.012341933324933052,
0.024267178028821945,
0.005238377023488283,
-0.06734488904476166,
-0.05389178916811943,
0.010546201840043068,
-0.051828183233737946,
-0.037998076528310776,
-0.002693597227334976,
-0.06774173676967621,
0.01105218194425106,
-0.07266263663768768,
-0.009797153994441032,
-0.008065910078585148,
-0.017133858054876328,
0.040537893772125244,
0.021568620577454567,
0.05559822916984558,
0.050439219921827316,
0.0017101614503189921,
0.007391270715743303,
-0.020437607541680336,
-0.027699902653694153,
-0.037283752113580704,
-0.047343816608190536,
-0.05428863316774368,
-0.05293935537338257,
-0.011042260564863682,
-0.04583580046892166,
0.02396954409778118,
-0.001016299705952406,
0.023612381890416145,
-0.0158837903290987,
-0.06170966848731041,
-0.03379150107502937,
0.058733318001031876,
-0.01446506381034851,
0.019941547885537148,
0.03998230770230293,
-0.015923475846648216,
-0.03041830286383629,
-0.08548078685998917,
-0.021925782784819603,
0.024167966097593307,
-0.08929051458835602,
0.017252912744879723,
0.03008098341524601,
-0.00438267644494772,
-0.01590363308787346,
0.004948182962834835,
0.02837454155087471,
-0.03452566638588905,
-0.06111439689993858,
-0.0333351269364357,
0.04520084336400032,
-0.009916207753121853,
-0.013522552326321602,
-0.00687040900811553,
0.008462756872177124,
-0.00034724088618531823,
0.06674962490797043,
-0.0114192645996809,
0.023354431614279747,
-0.010084867477416992,
0.0186319537460804,
-0.013224917463958263,
-0.010189040564000607,
0.027441952377557755,
0.007510324474424124,
-0.07099588215351105,
-0.02301711030304432,
-0.008824879303574562,
-0.019971312955021858,
-0.043375350534915924,
-0.0388512946665287,
-0.00010952039883704856,
-0.06817827373743057,
-0.030954046174883842,
-0.015546470880508423,
0.04984395205974579,
-0.00028073808061890304,
0.042065754532814026,
0.0855601578950882,
-0.042224492877721786,
-0.013711054809391499,
-0.009901326149702072,
0.0008463996928185225,
-0.0037105169612914324,
-0.037521857768297195,
0.008934012614190578,
-0.06551939994096756,
0.04079584404826164,
0.028255488723516464,
0.04845498874783516,
-0.018800614401698112,
-0.026033146306872368,
-0.023394115269184113,
-0.02252105250954628,
0.02974366396665573,
0.07710732519626617,
0.02771974541246891,
-0.04785971716046333,
-0.03658926859498024,
0.03827586770057678,
-0.01658819429576397,
0.00004065354005433619,
0.013046336360275745,
0.021608304232358932,
-0.019782809540629387,
-0.05357430875301361,
0.045478638261556625,
0.06627340614795685,
-0.08992547541856766,
-0.06540033966302872,
-0.030219879001379013,
-0.012093904428184032,
-0.0029912323225289583,
-0.023433800786733627,
0.035894788801670074,
0.05964606627821922,
-0.04143080115318298,
0.016856065019965172,
0.019544702023267746,
0.04055773839354515,
-0.019753046333789825,
-0.00917212013155222,
-0.0093159768730402,
0.0047274366952478886,
-0.04087521508336067,
-0.018542664125561714,
0.013274523429572582,
0.015387732535600662,
-0.027422109618782997,
0.05730466917157173,
-0.06722583621740341,
-0.009826917201280594,
-0.0025720628909766674,
0.029862716794013977,
0.017947394400835037,
-0.00456621777266264,
-0.015000807121396065,
0.00772362994030118,
-0.031251680105924606,
0.02974366396665573,
0.02226310223340988,
-0.05143133923411369,
0.027759429067373276,
-0.019256988540291786,
-0.0448833666741848,
0.03601384162902832,
0.048812150955200195,
-0.09595753997564316,
0.013006651774048805,
0.029148392379283905,
-0.012570120394229889,
0.02968413569033146,
0.0070936353877186775,
0.03537888824939728,
0.012381617911159992,
0.015873869881033897,
0.023671908304095268,
0.013988847844302654,
0.050280481576919556,
-0.01648898236453533,
0.008849682286381721,
0.04893120378255844,
0.0585348941385746,
-0.009301095269620419,
-0.05059795826673508,
-0.060122281312942505,
0.0017436454072594643,
0.0650828629732132,
0.06119376793503761,
0.01892958953976631,
0.015040491707623005,
-0.04349440336227417,
0.02121145837008953,
0.007158122956752777,
0.0038047682028263807,
0.023711591958999634,
-0.04029978811740875,
0.04845498874783516,
0.03714485466480255,
-0.05393147096037865,
-0.024862447753548622,
0.06238430738449097,
0.00557073624804616,
-0.04452620446681976,
-0.007202768232673407,
0.0010646653827279806,
0.03393039479851723,
0.06119376793503761,
-0.03480345755815506,
0.02129082754254341,
-0.014891673810780048,
0.04992331936955452,
-0.024108439683914185,
0.012222879566252232,
0.03928782790899277,
0.011488713324069977,
-0.05782056972384453,
-0.10214835405349731,
-0.019495096057653427,
0.009995576925575733,
0.009112593717873096,
0.04599453881382942,
-0.03317638859152794,
-0.022223416715860367,
-0.015754815191030502,
0.015437338501214981,
-0.015814343467354774,
-0.10365636646747589,
-0.03164852783083916,
0.022640107199549675,
-0.010685098357498646,
-0.07448813319206238,
0.03127152472734451,
0.002412084024399519,
-0.028553122654557228,
-0.013651528395712376,
0.07198800146579742,
0.07655173540115356,
-0.056550659239292145,
-0.019514938816428185,
0.05571728199720383,
0.0406767912209034,
-0.011290289461612701,
-0.03073577955365181,
0.12397491931915283,
0.01637984998524189,
0.08468709141016006,
0.04936773329973221,
-0.0008005143026821315,
-0.004871293902397156,
0.028315015137195587,
-0.033692289143800735,
0.022243259474635124,
0.03317638859152794,
-0.018046606332063675,
0.04397061839699745,
0.027025263756513596,
-0.044367466121912,
0.02877138927578926,
-0.044923052191734314,
0.04024025797843933,
0.05571728199720383,
-0.02569582685828209,
0.011736742220818996,
0.020189577713608742,
-0.040121205151081085,
0.04599453881382942,
-0.0077186692506074905,
-0.03585510328412056,
0.12064141035079956,
0.05139165371656418,
-0.014941279776394367,
-0.025160083547234535,
-0.05254250764846802,
-0.0663924589753151,
0.011498634703457355,
0.015030570328235626,
-0.048812150955200195,
0.037045642733573914,
-0.0060320706106722355,
-0.02252105250954628,
-0.018552584573626518,
-0.03246206417679787,
0.01887006312608719,
0.013840029947459698,
0.029961928725242615,
0.004204095341265202,
-0.01805652678012848,
0.01821526512503624,
0.0014063256094232202,
-0.002512536011636257,
-0.04087521508336067,
-0.035001881420612335,
0.024088596925139427,
-0.03583526238799095,
0.021449565887451172,
0.031013572588562965,
0.01442537922412157,
-0.007693866267800331,
-0.03160884231328964,
-0.007773235440254211,
0.07583741098642349,
-0.015040491707623005,
0.028751546517014503,
-0.027997538447380066,
-0.07238484919071198,
0.05706655979156494,
0.022580578923225403,
0.06055881455540657,
-0.043534088879823685,
-0.018780771642923355,
0.00003695247869472951,
0.036708325147628784,
0.04194670170545578,
-0.0026712745893746614,
0.0063743507489562035,
-0.009053066372871399,
-0.01357215829193592,
-0.03154931589961052,
0.009549125097692013,
-0.012431223876774311,
0.023294903337955475,
0.05690782144665718,
0.07417065650224686,
-0.06047944352030754,
-0.03902987763285637,
-0.00017486060096416622,
-0.06547971069812775,
-0.05789994075894356,
-0.009568966925144196,
0.024941816926002502,
0.02976350486278534,
-0.011528397910296917,
-0.04131174460053444,
0.0391092449426651,
-0.013443183153867722,
-0.009266371838748455,
-0.007009305525571108,
-0.07520245760679245,
0.061828721314668655,
-0.024584656581282616,
0.010913285426795483,
0.050359852612018585,
0.00033576955320313573,
0.004238819237798452,
0.05837615579366684,
-0.01960422843694687,
-0.024941816926002502,
0.003956065978854895,
-0.027104632928967476,
0.0017746490193530917,
-0.020229263231158257,
-0.02309648133814335,
0.03893066570162773,
0.00019904343935195357,
-0.003013554960489273,
0.07722637802362442,
-0.04658980667591095,
0.035478100180625916,
-0.023949701339006424,
-0.02226310223340988,
0.02756100706756115,
-0.06095565855503082,
-0.016766775399446487,
0.010982733219861984,
0.020308632403612137,
0.0072722164914011955,
-0.0469866544008255,
-0.018225187435746193,
-0.0766311064362526,
0.0241481252014637,
0.028513438999652863,
-0.06706710159778595,
-0.002208700170740485,
0.036748006939888,
0.021727358922362328,
-0.017739050090312958,
0.019693519920110703,
0.0028498556930571795,
0.07675015926361084,
0.023949701339006424,
-0.022064678370952606,
0.038732241839170456,
-0.034684404730796814,
0.029723821207880974,
-0.05016142874956131,
-0.009802114218473434,
-0.05234408378601074,
0.011478791944682598,
0.007267255801707506,
-0.02301711030304432,
-0.013115785084664822,
0.012867755256593227,
-0.031430263072252274,
0.046867601573467255,
0.013711054809391499,
0.02341395802795887,
-0.021171772852540016,
-0.024445759132504463,
-0.0005689170211553574,
-0.01585402712225914,
-0.046788230538368225,
0.04968521371483803,
0.0013492789585143328,
-0.05397115647792816,
-0.029128551483154297,
0.004680311307311058,
0.013195154257118702,
-0.0070192269049584866,
-0.03178742527961731,
-0.020874138921499252,
-0.008621495217084885,
0.011032339185476303,
-0.013959083706140518,
-0.033057332038879395,
-0.024009227752685547,
-0.02894997037947178,
0.04853435605764389,
-0.00023485266137868166,
0.009618572890758514,
-0.004690232221037149,
-0.02349332720041275,
0.041827645152807236,
0.009435031563043594,
-0.009697942063212395,
0.052225030958652496,
-0.03789886459708214,
-0.004447164013981819,
-0.021350353956222534,
-0.02764037624001503,
-0.02910870872437954,
0.03682737797498703,
0.05456642806529999,
0.01126052625477314,
-0.014395616017282009,
-0.026628416031599045,
-0.008457796648144722,
-0.025239452719688416,
-0.02714431658387184,
0.004767121281474829,
-0.0012847912730649114,
0.026608573272824287,
0.07956777513027191,
0.036867063492536545,
-0.03992278128862381,
-0.000719284696970135,
0.002000355627387762,
0.012728859670460224,
0.014603960327804089,
0.08508393913507462,
-0.0029589885380119085,
0.025973619893193245,
-0.02771974541246891,
0.03537888824939728,
0.010724782943725586,
-0.016608037054538727,
0.04789940267801285,
-0.028156276792287827,
-0.03887113928794861,
-0.03829571232199669,
-0.011974850669503212,
0.03008098341524601,
0.03291843831539154,
-0.03948625177145004,
-0.018860140815377235,
-0.04091490060091019,
-0.030338933691382408,
0.04512147605419159,
0.02315600775182247,
-0.028751546517014503,
0.0008470197790302336,
0.010625571943819523,
-0.023235376924276352,
0.009400307200849056,
0.10167213529348373,
0.057582464069128036,
0.023533012717962265,
-0.0028126512188464403,
0.02553708851337433,
-0.02162814699113369,
0.006185848731547594,
-0.005793962627649307,
-0.017391808331012726,
0.02011020854115486,
-0.04186733067035675,
0.05567759647965431,
0.019931627437472343,
0.031013572588562965,
0.010496596805751324,
0.022481368854641914,
0.0427800789475441,
0.009980695322155952,
0.021588463336229324,
-0.022223416715860367,
-0.034108977764844894,
0.0054963272996246815,
0.026568889617919922,
-0.020596345886588097,
0.006796000525355339,
0.05928890407085419,
0.011578003875911236,
-0.018185501918196678,
0.014187270775437355,
-0.020616188645362854,
0.039803728461265564,
0.023215534165501595,
-0.013423341326415539,
-0.012798307463526726,
0.056947506964206696,
-0.012619726359844208,
0.021072562783956528,
-0.0372639074921608,
0.031906478106975555,
-0.004829128738492727,
0.04682791605591774,
-0.003913900814950466,
-0.005233416333794594,
-0.01974312588572502,
-0.015963159501552582,
0.048653408885002136,
0.029465870931744576,
-0.045002419501543045,
-0.004092481918632984,
0.022878214716911316,
0.023453641682863235,
-0.02529897913336754,
-0.005863410420715809,
0.09381456673145294,
-0.05424895137548447,
0.028652334585785866,
-0.020437607541680336,
0.008338741958141327,
0.016528666019439697,
0.025675984099507332,
-0.0028002497274428606,
0.05317746475338936,
0.015020648948848248,
-0.003951105289161205,
-0.04266102612018585,
-0.0721864253282547,
-0.012718938291072845,
0.021886097267270088,
0.04301818832755089,
-0.02226310223340988,
0.029803190380334854,
0.007579772733151913,
-0.022779002785682678,
-0.014217034913599491,
0.025993460789322853,
0.012947125360369682,
-0.019564544782042503,
-0.003003633813932538,
-0.029961928725242615,
-0.02049713395535946,
0.010427148081362247,
-0.02553708851337433,
-0.030596883967518806,
-0.03472409024834633,
-0.01834424026310444,
-0.031430263072252274,
-0.05155039206147194,
-0.026707785204052925,
-0.05373304709792137,
-0.011002575978636742,
-0.004015592858195305,
0.08436961472034454,
0.03260096162557602,
-0.018572427332401276,
0.02202499471604824,
-0.014832147397100925,
0.032799381762742996,
-0.016865987330675125,
-0.021270984783768654,
-0.01897919550538063,
-0.05845552682876587,
0.015625840052962303,
-0.022640107199549675,
-0.05107417702674866,
0.01653858833014965,
0.031112784519791603,
0.011498634703457355,
-0.005640184506773949,
0.004057758022099733,
-0.03105325810611248,
0.03031909093260765,
0.008393308147788048,
0.07726605981588364,
0.06202714517712593,
-0.05139165371656418,
-0.01934627816081047,
0.023612381890416145,
-0.030259564518928528,
-0.004057758022099733,
0.03379150107502937,
-0.002834973856806755,
0.030358776450157166,
0.07746448367834091,
-0.009330859407782555,
-0.018959352746605873,
-0.039962466806173325,
-0.0241481252014637,
-0.08309970796108246,
0.01708425208926201,
-0.0482962504029274,
-0.040200576186180115,
-0.004085041116923094,
0.01915777660906315,
-0.04381188005208969,
-0.02049713395535946,
-0.03807744383811951,
-0.028572965413331985,
-0.024485444650053978,
0.007525206543505192,
0.02396954409778118,
-0.04194670170545578,
-0.032561276108026505,
0.0037154776509851217,
0.023870332166552544,
-0.024425916373729706,
0.024029070511460304,
0.06492412835359573,
0.010005498304963112,
0.05909048020839691,
0.027104632928967476,
0.02738242596387863,
0.09365583211183548,
0.029168235138058662,
0.0011824793182313442,
0.030676253139972687,
0.03643053025007248,
-0.0070043448358774185,
0.0035889826249331236,
-0.009633454494178295,
-0.021568620577454567,
0.04559769108891487,
-0.013472947292029858,
0.015625840052962303,
-0.017748970538377762,
0.05420926585793495,
0.03016035258769989,
-0.04579611495137215,
-0.06361453235149384,
-0.018671639263629913,
-0.0013281964929774404,
-0.03188663721084595,
0.052304401993751526,
-0.018116053193807602,
-0.04127206280827522,
-0.03688690438866615,
0.002696077572181821,
-0.036946430802345276,
-0.0359543152153492,
-0.004107363987714052,
0.02674747072160244,
-0.03843460604548454,
-0.024009227752685547,
-0.015149624086916447,
0.048653408885002136,
0.011161314323544502,
0.009712823666632175,
0.027838798239827156,
-0.03172789886593819,
-0.01476269867271185,
-0.09810051321983337,
0.006657104007899761,
-0.004928340669721365,
0.0014100461266934872,
-0.007500403560698032,
-0.01227248553186655,
-0.08151232451200485,
-0.0024319265503436327,
0.11326006054878235,
0.05095512047410011,
-0.022560738027095795,
0.01357215829193592,
0.013343972153961658,
0.045478638261556625,
0.03853381797671318,
-0.0010838876478374004,
0.06730520725250244,
-0.056233182549476624,
0.0039907898753881454,
0.061352506279945374,
0.03424787521362305,
-0.014723014086484909,
0.01354239508509636,
0.02738242596387863,
-0.05631255358457565,
0.021191615611314774,
-0.045637376606464386,
-0.02559661492705345,
0.03262080252170563,
0.007688905578106642,
-0.020993193611502647,
0.040379155427217484,
-0.0006870409124530852,
0.019643913954496384,
-0.007326783146709204,
0.03587494418025017,
-0.07956777513027191,
-0.03262080252170563,
0.03141041845083237,
0.007490482181310654,
-0.04813750833272934,
0.04071647673845291,
-0.02071540057659149,
-0.016548508778214455,
0.03319622948765755,
-0.014127744361758232,
0.019614150747656822,
-0.023314746096730232,
0.031033415347337723,
-0.09373520314693451,
0.0064834835939109325,
0.01024856697767973,
0.0028275330550968647,
0.008700864389538765,
-0.029148392379283905,
0.01097281277179718,
0.03803776204586029,
0.04948678985238075,
0.01976296864449978,
0.05127260088920593,
-0.027997538447380066,
0.03512093797326088,
-0.02934681624174118,
-0.030457988381385803,
0.002554700942710042,
0.09849736094474792,
-0.012460988014936447,
-0.06488443911075592,
-0.007158122956752777,
0.006116400472819805,
0.01751086302101612,
-0.04789940267801285,
-0.05924921855330467,
0.008378426544368267,
-0.041986387223005295,
0.012966967187821865,
0.005362391471862793,
-0.02049713395535946,
-0.017729127779603004
] |
725,940 | validator_collection.checkers | is_url | Indicate whether ``value`` is a URL.
.. note::
URL validation is...complicated. The methodology that we have
adopted here is *generally* compliant with
`RFC 1738 <https://tools.ietf.org/html/rfc1738>`_,
`RFC 6761 <https://tools.ietf.org/html/rfc6761>`_,
`RFC 2181 <https://tools.ietf.org/html/rfc2181>`_ and uses a combination of
string parsing and regular expressions,
This approach ensures more complete coverage for unusual edge cases, while
still letting us use regular expressions that perform quickly.
:param value: The value to evaluate.
:param allow_special_ips: If ``True``, will succeed when validating special IP
addresses, such as loopback IPs like ``127.0.0.1`` or ``0.0.0.0``. If ``False``,
will fail if ``value`` is a special IP address. Defaults to ``False``.
:type allow_special_ips: :class:`bool <python:bool>`
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, **kwargs) | [
0.0026687942445278168,
0.013790423981845379,
-0.03057704120874405,
-0.007123399060219526,
0.007202768232673407,
0.017153700813651085,
0.001577465794980526,
0.05409020930528641,
-0.07540088146924973,
0.007381349336355925,
0.01016919780522585,
-0.006329705473035574,
0.08270286023616791,
-0.0027208805549889803,
-0.030299248173832893,
-0.020993193611502647,
-0.04631201550364494,
0.027600690722465515,
-0.00799150113016367,
-0.03049767203629017,
-0.037839338183403015,
0.0905604287981987,
0.04246260225772858,
-0.016756853088736534,
0.019991153851151466,
0.020120128989219666,
0.02894997037947178,
0.022322628647089005,
-0.01805652678012848,
0.03861318901181221,
-0.02236231416463852,
-0.022540895268321037,
0.022898057475686073,
-0.024187808856368065,
-0.001287271617911756,
-0.013869794085621834,
0.014217034913599491,
0.03722422569990158,
-0.017580309882760048,
-0.015030570328235626,
-0.05928890407085419,
0.045161157846450806,
-0.012341933324933052,
0.024267178028821945,
0.005238377023488283,
-0.06734488904476166,
-0.05389178916811943,
0.010546201840043068,
-0.051828183233737946,
-0.037998076528310776,
-0.002693597227334976,
-0.06774173676967621,
0.01105218194425106,
-0.07266263663768768,
-0.009797153994441032,
-0.008065910078585148,
-0.017133858054876328,
0.040537893772125244,
0.021568620577454567,
0.05559822916984558,
0.050439219921827316,
0.0017101614503189921,
0.007391270715743303,
-0.020437607541680336,
-0.027699902653694153,
-0.037283752113580704,
-0.047343816608190536,
-0.05428863316774368,
-0.05293935537338257,
-0.011042260564863682,
-0.04583580046892166,
0.02396954409778118,
-0.001016299705952406,
0.023612381890416145,
-0.0158837903290987,
-0.06170966848731041,
-0.03379150107502937,
0.058733318001031876,
-0.01446506381034851,
0.019941547885537148,
0.03998230770230293,
-0.015923475846648216,
-0.03041830286383629,
-0.08548078685998917,
-0.021925782784819603,
0.024167966097593307,
-0.08929051458835602,
0.017252912744879723,
0.03008098341524601,
-0.00438267644494772,
-0.01590363308787346,
0.004948182962834835,
0.02837454155087471,
-0.03452566638588905,
-0.06111439689993858,
-0.0333351269364357,
0.04520084336400032,
-0.009916207753121853,
-0.013522552326321602,
-0.00687040900811553,
0.008462756872177124,
-0.00034724088618531823,
0.06674962490797043,
-0.0114192645996809,
0.023354431614279747,
-0.010084867477416992,
0.0186319537460804,
-0.013224917463958263,
-0.010189040564000607,
0.027441952377557755,
0.007510324474424124,
-0.07099588215351105,
-0.02301711030304432,
-0.008824879303574562,
-0.019971312955021858,
-0.043375350534915924,
-0.0388512946665287,
-0.00010952039883704856,
-0.06817827373743057,
-0.030954046174883842,
-0.015546470880508423,
0.04984395205974579,
-0.00028073808061890304,
0.042065754532814026,
0.0855601578950882,
-0.042224492877721786,
-0.013711054809391499,
-0.009901326149702072,
0.0008463996928185225,
-0.0037105169612914324,
-0.037521857768297195,
0.008934012614190578,
-0.06551939994096756,
0.04079584404826164,
0.028255488723516464,
0.04845498874783516,
-0.018800614401698112,
-0.026033146306872368,
-0.023394115269184113,
-0.02252105250954628,
0.02974366396665573,
0.07710732519626617,
0.02771974541246891,
-0.04785971716046333,
-0.03658926859498024,
0.03827586770057678,
-0.01658819429576397,
0.00004065354005433619,
0.013046336360275745,
0.021608304232358932,
-0.019782809540629387,
-0.05357430875301361,
0.045478638261556625,
0.06627340614795685,
-0.08992547541856766,
-0.06540033966302872,
-0.030219879001379013,
-0.012093904428184032,
-0.0029912323225289583,
-0.023433800786733627,
0.035894788801670074,
0.05964606627821922,
-0.04143080115318298,
0.016856065019965172,
0.019544702023267746,
0.04055773839354515,
-0.019753046333789825,
-0.00917212013155222,
-0.0093159768730402,
0.0047274366952478886,
-0.04087521508336067,
-0.018542664125561714,
0.013274523429572582,
0.015387732535600662,
-0.027422109618782997,
0.05730466917157173,
-0.06722583621740341,
-0.009826917201280594,
-0.0025720628909766674,
0.029862716794013977,
0.017947394400835037,
-0.00456621777266264,
-0.015000807121396065,
0.00772362994030118,
-0.031251680105924606,
0.02974366396665573,
0.02226310223340988,
-0.05143133923411369,
0.027759429067373276,
-0.019256988540291786,
-0.0448833666741848,
0.03601384162902832,
0.048812150955200195,
-0.09595753997564316,
0.013006651774048805,
0.029148392379283905,
-0.012570120394229889,
0.02968413569033146,
0.0070936353877186775,
0.03537888824939728,
0.012381617911159992,
0.015873869881033897,
0.023671908304095268,
0.013988847844302654,
0.050280481576919556,
-0.01648898236453533,
0.008849682286381721,
0.04893120378255844,
0.0585348941385746,
-0.009301095269620419,
-0.05059795826673508,
-0.060122281312942505,
0.0017436454072594643,
0.0650828629732132,
0.06119376793503761,
0.01892958953976631,
0.015040491707623005,
-0.04349440336227417,
0.02121145837008953,
0.007158122956752777,
0.0038047682028263807,
0.023711591958999634,
-0.04029978811740875,
0.04845498874783516,
0.03714485466480255,
-0.05393147096037865,
-0.024862447753548622,
0.06238430738449097,
0.00557073624804616,
-0.04452620446681976,
-0.007202768232673407,
0.0010646653827279806,
0.03393039479851723,
0.06119376793503761,
-0.03480345755815506,
0.02129082754254341,
-0.014891673810780048,
0.04992331936955452,
-0.024108439683914185,
0.012222879566252232,
0.03928782790899277,
0.011488713324069977,
-0.05782056972384453,
-0.10214835405349731,
-0.019495096057653427,
0.009995576925575733,
0.009112593717873096,
0.04599453881382942,
-0.03317638859152794,
-0.022223416715860367,
-0.015754815191030502,
0.015437338501214981,
-0.015814343467354774,
-0.10365636646747589,
-0.03164852783083916,
0.022640107199549675,
-0.010685098357498646,
-0.07448813319206238,
0.03127152472734451,
0.002412084024399519,
-0.028553122654557228,
-0.013651528395712376,
0.07198800146579742,
0.07655173540115356,
-0.056550659239292145,
-0.019514938816428185,
0.05571728199720383,
0.0406767912209034,
-0.011290289461612701,
-0.03073577955365181,
0.12397491931915283,
0.01637984998524189,
0.08468709141016006,
0.04936773329973221,
-0.0008005143026821315,
-0.004871293902397156,
0.028315015137195587,
-0.033692289143800735,
0.022243259474635124,
0.03317638859152794,
-0.018046606332063675,
0.04397061839699745,
0.027025263756513596,
-0.044367466121912,
0.02877138927578926,
-0.044923052191734314,
0.04024025797843933,
0.05571728199720383,
-0.02569582685828209,
0.011736742220818996,
0.020189577713608742,
-0.040121205151081085,
0.04599453881382942,
-0.0077186692506074905,
-0.03585510328412056,
0.12064141035079956,
0.05139165371656418,
-0.014941279776394367,
-0.025160083547234535,
-0.05254250764846802,
-0.0663924589753151,
0.011498634703457355,
0.015030570328235626,
-0.048812150955200195,
0.037045642733573914,
-0.0060320706106722355,
-0.02252105250954628,
-0.018552584573626518,
-0.03246206417679787,
0.01887006312608719,
0.013840029947459698,
0.029961928725242615,
0.004204095341265202,
-0.01805652678012848,
0.01821526512503624,
0.0014063256094232202,
-0.002512536011636257,
-0.04087521508336067,
-0.035001881420612335,
0.024088596925139427,
-0.03583526238799095,
0.021449565887451172,
0.031013572588562965,
0.01442537922412157,
-0.007693866267800331,
-0.03160884231328964,
-0.007773235440254211,
0.07583741098642349,
-0.015040491707623005,
0.028751546517014503,
-0.027997538447380066,
-0.07238484919071198,
0.05706655979156494,
0.022580578923225403,
0.06055881455540657,
-0.043534088879823685,
-0.018780771642923355,
0.00003695247869472951,
0.036708325147628784,
0.04194670170545578,
-0.0026712745893746614,
0.0063743507489562035,
-0.009053066372871399,
-0.01357215829193592,
-0.03154931589961052,
0.009549125097692013,
-0.012431223876774311,
0.023294903337955475,
0.05690782144665718,
0.07417065650224686,
-0.06047944352030754,
-0.03902987763285637,
-0.00017486060096416622,
-0.06547971069812775,
-0.05789994075894356,
-0.009568966925144196,
0.024941816926002502,
0.02976350486278534,
-0.011528397910296917,
-0.04131174460053444,
0.0391092449426651,
-0.013443183153867722,
-0.009266371838748455,
-0.007009305525571108,
-0.07520245760679245,
0.061828721314668655,
-0.024584656581282616,
0.010913285426795483,
0.050359852612018585,
0.00033576955320313573,
0.004238819237798452,
0.05837615579366684,
-0.01960422843694687,
-0.024941816926002502,
0.003956065978854895,
-0.027104632928967476,
0.0017746490193530917,
-0.020229263231158257,
-0.02309648133814335,
0.03893066570162773,
0.00019904343935195357,
-0.003013554960489273,
0.07722637802362442,
-0.04658980667591095,
0.035478100180625916,
-0.023949701339006424,
-0.02226310223340988,
0.02756100706756115,
-0.06095565855503082,
-0.016766775399446487,
0.010982733219861984,
0.020308632403612137,
0.0072722164914011955,
-0.0469866544008255,
-0.018225187435746193,
-0.0766311064362526,
0.0241481252014637,
0.028513438999652863,
-0.06706710159778595,
-0.002208700170740485,
0.036748006939888,
0.021727358922362328,
-0.017739050090312958,
0.019693519920110703,
0.0028498556930571795,
0.07675015926361084,
0.023949701339006424,
-0.022064678370952606,
0.038732241839170456,
-0.034684404730796814,
0.029723821207880974,
-0.05016142874956131,
-0.009802114218473434,
-0.05234408378601074,
0.011478791944682598,
0.007267255801707506,
-0.02301711030304432,
-0.013115785084664822,
0.012867755256593227,
-0.031430263072252274,
0.046867601573467255,
0.013711054809391499,
0.02341395802795887,
-0.021171772852540016,
-0.024445759132504463,
-0.0005689170211553574,
-0.01585402712225914,
-0.046788230538368225,
0.04968521371483803,
0.0013492789585143328,
-0.05397115647792816,
-0.029128551483154297,
0.004680311307311058,
0.013195154257118702,
-0.0070192269049584866,
-0.03178742527961731,
-0.020874138921499252,
-0.008621495217084885,
0.011032339185476303,
-0.013959083706140518,
-0.033057332038879395,
-0.024009227752685547,
-0.02894997037947178,
0.04853435605764389,
-0.00023485266137868166,
0.009618572890758514,
-0.004690232221037149,
-0.02349332720041275,
0.041827645152807236,
0.009435031563043594,
-0.009697942063212395,
0.052225030958652496,
-0.03789886459708214,
-0.004447164013981819,
-0.021350353956222534,
-0.02764037624001503,
-0.02910870872437954,
0.03682737797498703,
0.05456642806529999,
0.01126052625477314,
-0.014395616017282009,
-0.026628416031599045,
-0.008457796648144722,
-0.025239452719688416,
-0.02714431658387184,
0.004767121281474829,
-0.0012847912730649114,
0.026608573272824287,
0.07956777513027191,
0.036867063492536545,
-0.03992278128862381,
-0.000719284696970135,
0.002000355627387762,
0.012728859670460224,
0.014603960327804089,
0.08508393913507462,
-0.0029589885380119085,
0.025973619893193245,
-0.02771974541246891,
0.03537888824939728,
0.010724782943725586,
-0.016608037054538727,
0.04789940267801285,
-0.028156276792287827,
-0.03887113928794861,
-0.03829571232199669,
-0.011974850669503212,
0.03008098341524601,
0.03291843831539154,
-0.03948625177145004,
-0.018860140815377235,
-0.04091490060091019,
-0.030338933691382408,
0.04512147605419159,
0.02315600775182247,
-0.028751546517014503,
0.0008470197790302336,
0.010625571943819523,
-0.023235376924276352,
0.009400307200849056,
0.10167213529348373,
0.057582464069128036,
0.023533012717962265,
-0.0028126512188464403,
0.02553708851337433,
-0.02162814699113369,
0.006185848731547594,
-0.005793962627649307,
-0.017391808331012726,
0.02011020854115486,
-0.04186733067035675,
0.05567759647965431,
0.019931627437472343,
0.031013572588562965,
0.010496596805751324,
0.022481368854641914,
0.0427800789475441,
0.009980695322155952,
0.021588463336229324,
-0.022223416715860367,
-0.034108977764844894,
0.0054963272996246815,
0.026568889617919922,
-0.020596345886588097,
0.006796000525355339,
0.05928890407085419,
0.011578003875911236,
-0.018185501918196678,
0.014187270775437355,
-0.020616188645362854,
0.039803728461265564,
0.023215534165501595,
-0.013423341326415539,
-0.012798307463526726,
0.056947506964206696,
-0.012619726359844208,
0.021072562783956528,
-0.0372639074921608,
0.031906478106975555,
-0.004829128738492727,
0.04682791605591774,
-0.003913900814950466,
-0.005233416333794594,
-0.01974312588572502,
-0.015963159501552582,
0.048653408885002136,
0.029465870931744576,
-0.045002419501543045,
-0.004092481918632984,
0.022878214716911316,
0.023453641682863235,
-0.02529897913336754,
-0.005863410420715809,
0.09381456673145294,
-0.05424895137548447,
0.028652334585785866,
-0.020437607541680336,
0.008338741958141327,
0.016528666019439697,
0.025675984099507332,
-0.0028002497274428606,
0.05317746475338936,
0.015020648948848248,
-0.003951105289161205,
-0.04266102612018585,
-0.0721864253282547,
-0.012718938291072845,
0.021886097267270088,
0.04301818832755089,
-0.02226310223340988,
0.029803190380334854,
0.007579772733151913,
-0.022779002785682678,
-0.014217034913599491,
0.025993460789322853,
0.012947125360369682,
-0.019564544782042503,
-0.003003633813932538,
-0.029961928725242615,
-0.02049713395535946,
0.010427148081362247,
-0.02553708851337433,
-0.030596883967518806,
-0.03472409024834633,
-0.01834424026310444,
-0.031430263072252274,
-0.05155039206147194,
-0.026707785204052925,
-0.05373304709792137,
-0.011002575978636742,
-0.004015592858195305,
0.08436961472034454,
0.03260096162557602,
-0.018572427332401276,
0.02202499471604824,
-0.014832147397100925,
0.032799381762742996,
-0.016865987330675125,
-0.021270984783768654,
-0.01897919550538063,
-0.05845552682876587,
0.015625840052962303,
-0.022640107199549675,
-0.05107417702674866,
0.01653858833014965,
0.031112784519791603,
0.011498634703457355,
-0.005640184506773949,
0.004057758022099733,
-0.03105325810611248,
0.03031909093260765,
0.008393308147788048,
0.07726605981588364,
0.06202714517712593,
-0.05139165371656418,
-0.01934627816081047,
0.023612381890416145,
-0.030259564518928528,
-0.004057758022099733,
0.03379150107502937,
-0.002834973856806755,
0.030358776450157166,
0.07746448367834091,
-0.009330859407782555,
-0.018959352746605873,
-0.039962466806173325,
-0.0241481252014637,
-0.08309970796108246,
0.01708425208926201,
-0.0482962504029274,
-0.040200576186180115,
-0.004085041116923094,
0.01915777660906315,
-0.04381188005208969,
-0.02049713395535946,
-0.03807744383811951,
-0.028572965413331985,
-0.024485444650053978,
0.007525206543505192,
0.02396954409778118,
-0.04194670170545578,
-0.032561276108026505,
0.0037154776509851217,
0.023870332166552544,
-0.024425916373729706,
0.024029070511460304,
0.06492412835359573,
0.010005498304963112,
0.05909048020839691,
0.027104632928967476,
0.02738242596387863,
0.09365583211183548,
0.029168235138058662,
0.0011824793182313442,
0.030676253139972687,
0.03643053025007248,
-0.0070043448358774185,
0.0035889826249331236,
-0.009633454494178295,
-0.021568620577454567,
0.04559769108891487,
-0.013472947292029858,
0.015625840052962303,
-0.017748970538377762,
0.05420926585793495,
0.03016035258769989,
-0.04579611495137215,
-0.06361453235149384,
-0.018671639263629913,
-0.0013281964929774404,
-0.03188663721084595,
0.052304401993751526,
-0.018116053193807602,
-0.04127206280827522,
-0.03688690438866615,
0.002696077572181821,
-0.036946430802345276,
-0.0359543152153492,
-0.004107363987714052,
0.02674747072160244,
-0.03843460604548454,
-0.024009227752685547,
-0.015149624086916447,
0.048653408885002136,
0.011161314323544502,
0.009712823666632175,
0.027838798239827156,
-0.03172789886593819,
-0.01476269867271185,
-0.09810051321983337,
0.006657104007899761,
-0.004928340669721365,
0.0014100461266934872,
-0.007500403560698032,
-0.01227248553186655,
-0.08151232451200485,
-0.0024319265503436327,
0.11326006054878235,
0.05095512047410011,
-0.022560738027095795,
0.01357215829193592,
0.013343972153961658,
0.045478638261556625,
0.03853381797671318,
-0.0010838876478374004,
0.06730520725250244,
-0.056233182549476624,
0.0039907898753881454,
0.061352506279945374,
0.03424787521362305,
-0.014723014086484909,
0.01354239508509636,
0.02738242596387863,
-0.05631255358457565,
0.021191615611314774,
-0.045637376606464386,
-0.02559661492705345,
0.03262080252170563,
0.007688905578106642,
-0.020993193611502647,
0.040379155427217484,
-0.0006870409124530852,
0.019643913954496384,
-0.007326783146709204,
0.03587494418025017,
-0.07956777513027191,
-0.03262080252170563,
0.03141041845083237,
0.007490482181310654,
-0.04813750833272934,
0.04071647673845291,
-0.02071540057659149,
-0.016548508778214455,
0.03319622948765755,
-0.014127744361758232,
0.019614150747656822,
-0.023314746096730232,
0.031033415347337723,
-0.09373520314693451,
0.0064834835939109325,
0.01024856697767973,
0.0028275330550968647,
0.008700864389538765,
-0.029148392379283905,
0.01097281277179718,
0.03803776204586029,
0.04948678985238075,
0.01976296864449978,
0.05127260088920593,
-0.027997538447380066,
0.03512093797326088,
-0.02934681624174118,
-0.030457988381385803,
0.002554700942710042,
0.09849736094474792,
-0.012460988014936447,
-0.06488443911075592,
-0.007158122956752777,
0.006116400472819805,
0.01751086302101612,
-0.04789940267801285,
-0.05924921855330467,
0.008378426544368267,
-0.041986387223005295,
0.012966967187821865,
0.005362391471862793,
-0.02049713395535946,
-0.017729127779603004
] |
725,941 | validator_collection.checkers | is_uuid | Indicate whether ``value`` contains a :class:`UUID <python:uuid.UUID>`
:param value: The value to evaluate.
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,942 | validator_collection.checkers | is_variable_name | Indicate whether ``value`` is a valid Python variable name.
.. caution::
This function does **NOT** check whether the variable exists. It only
checks that the ``value`` would work as a Python variable (or class, or
function, etc.) name.
:param value: The value to evaluate.
:returns: ``True`` if ``value`` is valid, ``False`` if it is not.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
| def is_type(obj,
type_,
**kwargs):
"""Indicate if ``obj`` is a type in ``type_``.
.. hint::
This checker is particularly useful when you want to evaluate whether
``obj`` is of a particular type, but importing that type directly to use
in :func:`isinstance() <python:isinstance>` would cause a circular import
error.
To use this checker in that kind of situation, you can instead pass the
*name* of the type you want to check as a string in ``type_``. The checker
will evaluate it and see whether ``obj`` is of a type or inherits from a
type whose name matches the string you passed.
:param obj: The object whose type should be checked.
:type obj: :class:`object <python:object>`
:param type_: The type(s) to check against.
:type type_: :class:`type <python:type>` / iterable of :class:`type <python:type>` /
:class:`str <python:str>` with type name / iterable of :class:`str <python:str>`
with type name
:returns: ``True`` if ``obj`` is a type in ``type_``. Otherwise, ``False``.
:rtype: :class:`bool <python:bool>`
:raises SyntaxError: if ``kwargs`` contains duplicate keyword parameters or duplicates
keyword parameters passed to the underlying validator
"""
if not is_iterable(type_):
type_ = [type_]
return_value = False
for check_for_type in type_:
if isinstance(check_for_type, type):
return_value = isinstance(obj, check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
elif obj.__class__.__name__ == check_for_type:
return_value = True
else:
return_value = _check_base_classes(obj.__class__.__bases__,
check_for_type)
if not return_value:
try:
return_value = issubclass(obj, check_for_type)
except TypeError:
pass
if return_value is True:
break
return return_value
| (value, **kwargs) | [
0.0027456344105303288,
0.013760415837168694,
-0.030576497316360474,
-0.007063745986670256,
0.007267126347869635,
0.01712363213300705,
0.0016245624283328652,
0.05404956266283989,
-0.07539954036474228,
0.007396099157631397,
0.010134292766451836,
-0.006275027059018612,
0.08270138502120972,
-0.0027084306348115206,
-0.030298708006739616,
-0.021032502874732018,
-0.0463508740067482,
0.02765972539782524,
-0.007946714758872986,
-0.03053681179881096,
-0.037838663905858994,
0.09047944098711014,
0.042501527816057205,
-0.016726791858673096,
0.02003048174083233,
0.020149534568190575,
0.028949454426765442,
0.02232223190367222,
-0.018006600439548492,
0.0386323407292366,
-0.022381756454706192,
-0.022540492936968803,
0.022917490452528,
-0.024147693067789078,
-0.0012946893693879247,
-0.013869546353816986,
0.014177097007632256,
0.037223562598228455,
-0.0176395233720541,
-0.015010460279881954,
-0.05924816429615021,
0.04516035318374634,
-0.012311950325965881,
0.024266745895147324,
0.005233323201537132,
-0.06738337874412537,
-0.05389082804322243,
0.010555935092270374,
-0.05182725936174393,
-0.037997398525476456,
-0.00271339132450521,
-0.06770084798336029,
0.011111510917544365,
-0.07266134023666382,
-0.009782098233699799,
-0.008080647327005863,
-0.017113709822297096,
0.04053717106580734,
0.021568236872553825,
0.05559723824262619,
0.050358954817056656,
0.0017225322080776095,
0.00732665229588747,
-0.02041740156710148,
-0.027739092707633972,
-0.03728308528661728,
-0.047342970967292786,
-0.05428766831755638,
-0.05293841287493706,
-0.01103214267641306,
-0.04579529911279678,
0.02394927479326725,
-0.0010386038338765502,
0.023631801828742027,
-0.015823982656002045,
-0.06162920221686363,
-0.033850423991680145,
0.05869258567690849,
-0.01444496400654316,
0.01998087763786316,
0.039981596171855927,
-0.0159628763794899,
-0.03043760173022747,
-0.0854792669415474,
-0.021925391629338264,
0.024167535826563835,
-0.08928892761468887,
0.0172526054084301,
0.030139973387122154,
-0.004392519127577543,
-0.015903349965810776,
0.00498281791806221,
0.028334353119134903,
-0.034544892609119415,
-0.06111330911517143,
-0.03339405730366707,
0.04523972049355507,
-0.009925952181220055,
-0.013532232493162155,
-0.006850444711744785,
0.008497329428792,
-0.0003487848734948784,
0.0667087510228157,
-0.011458745226264,
0.02335401438176632,
-0.010084687732160091,
0.01864154264330864,
-0.013284208253026009,
-0.010268226265907288,
0.027441462501883507,
0.0075151510536670685,
-0.07103429734706879,
-0.02301670052111149,
-0.008829683065414429,
-0.019941193982958794,
-0.043374575674533844,
-0.03885060176253319,
-0.00008293329301523045,
-0.06821674108505249,
-0.03095349483191967,
-0.015556114725768566,
0.04988274723291397,
-0.0002819731889758259,
0.042065005749464035,
0.08555863052606583,
-0.0422237403690815,
-0.01370088942348957,
-0.009851545095443726,
0.0008333633304573596,
-0.003678207751363516,
-0.037580717355012894,
0.008958655409514904,
-0.06551823019981384,
0.04079511761665344,
0.028254983946681023,
0.0484144389629364,
-0.018790358677506447,
-0.025992998853325844,
-0.023393698036670685,
-0.022461125627160072,
0.0297431331127882,
0.07714562863111496,
0.027739092707633972,
-0.04781917855143547,
-0.03654893487691879,
0.038255345076322556,
-0.016617661342024803,
0.0000722372205927968,
0.013085788115859032,
0.02160792052745819,
-0.01970309019088745,
-0.05353366956114769,
0.04547782614827156,
0.06627222150564194,
-0.08984450250864029,
-0.0653991773724556,
-0.03017965704202652,
-0.012123451568186283,
-0.0030308628920465708,
-0.023413540795445442,
0.035933833569288254,
0.05968468636274338,
-0.04139037802815437,
0.016806159168481827,
0.019564196467399597,
0.040616538375616074,
-0.019782457500696182,
-0.009157075546681881,
-0.009305890649557114,
0.004754635505378246,
-0.04087448492646217,
-0.01851257123053074,
0.013204840011894703,
0.015377537347376347,
-0.027381937950849533,
0.057383015751838684,
-0.06722463667392731,
-0.009836663492023945,
-0.0025447343941777945,
0.029862185940146446,
0.017937153577804565,
-0.004590938799083233,
-0.015050144866108894,
0.007792938966304064,
-0.03121143952012062,
0.029723290354013443,
0.022242862731218338,
-0.05147010460495949,
0.027739092707633972,
-0.01923680305480957,
-0.044842883944511414,
0.0360528826713562,
0.048811279237270355,
-0.09595583379268646,
0.01297665759921074,
0.029108189046382904,
-0.012550054118037224,
0.029683606699109077,
0.007113351020962,
0.03545762598514557,
0.012381397187709808,
0.015853744000196457,
0.02369132824242115,
0.014028281904757023,
0.05023990198969841,
-0.01652837172150612,
0.008849524892866611,
0.0489303320646286,
0.058494165539741516,
-0.009310850873589516,
-0.05055737495422363,
-0.06012120842933655,
0.0017498149536550045,
0.06512138992547989,
0.061192676424980164,
0.01889948919415474,
0.015069986693561077,
-0.04349362850189209,
0.021250763908028603,
0.007153035141527653,
0.0037774175871163607,
0.023731011897325516,
-0.040338750928640366,
0.048454124480485916,
0.03720371797680855,
-0.05389082804322243,
-0.02480247989296913,
0.062383197247982025,
0.005501189734786749,
-0.044565096497535706,
-0.0071728769689798355,
0.0010813880944624543,
0.03390995040535927,
0.06123236194252968,
-0.03482268005609512,
0.021211080253124237,
-0.014861645177006721,
0.04992242902517319,
-0.024147693067789078,
0.012163136154413223,
0.03934665396809578,
0.011488508433103561,
-0.057819537818431854,
-0.10206716507673264,
-0.01954435370862484,
0.009955715388059616,
0.009152114391326904,
0.04603340104222298,
-0.03317579627037048,
-0.022262705489993095,
-0.015764456242322922,
0.015446984209120274,
-0.015774376690387726,
-0.10365451872348785,
-0.03164796531200409,
0.02265954576432705,
-0.01072459202259779,
-0.07452648878097534,
0.03129080682992935,
0.0023748374078422785,
-0.028592297807335854,
-0.013661205768585205,
0.07198671251535416,
0.07651069015264511,
-0.05647028610110283,
-0.01954435370862484,
0.05579565837979317,
0.0406760647892952,
-0.011250404641032219,
-0.030735231935977936,
0.12397271394729614,
0.016389477998018265,
0.08460621535778046,
0.049327172338962555,
-0.0008067006128840148,
-0.004871206823736429,
0.028334353119134903,
-0.03379089757800102,
0.022203179076313972,
0.033155955374240875,
-0.01799667812883854,
0.043969836086034775,
0.027024781331419945,
-0.044326990842819214,
0.028751034289598465,
-0.044922251254320145,
0.04021970182657242,
0.05567660555243492,
-0.02569536864757538,
0.011696849018335342,
0.02015945501625538,
-0.04012048989534378,
0.045954033732414246,
-0.007733413018286228,
-0.035854462534189224,
0.12063925713300705,
0.05143042281270027,
-0.014980697073042393,
-0.025179477408528328,
-0.05258125439286232,
-0.06639127433300018,
0.01149842981249094,
0.01508982852101326,
-0.048811279237270355,
0.0370846651494503,
-0.0059873186983168125,
-0.022540492936968803,
-0.018572095781564713,
-0.03248132765293121,
0.018879646435379982,
0.013849704526364803,
0.029981236904859543,
0.004179217852652073,
-0.018046284094452858,
0.018175257369875908,
0.0014100209809839725,
-0.002531093079596758,
-0.04087448492646217,
-0.03500125929713249,
0.024108009412884712,
-0.03573541343212128,
0.021429341286420822,
0.030993178486824036,
0.01443504262715578,
-0.0077383737079799175,
-0.03172733262181282,
-0.007802859880030155,
0.07575669139623642,
-0.015040223486721516,
0.028810560703277588,
-0.028036722913384438,
-0.07238355278968811,
0.057105228304862976,
0.02258017659187317,
0.0605180487036705,
-0.043533310294151306,
-0.018760595470666885,
0.00004266801624908112,
0.03668782860040665,
0.04202532023191452,
-0.002634023316204548,
0.006314711179584265,
-0.009107470512390137,
-0.013591758906841278,
-0.031588438898324966,
0.009534073062241077,
-0.012460765428841114,
0.023274647071957588,
0.056946493685245514,
0.07412964850664139,
-0.060478366911411285,
-0.03906886652112007,
-0.00013486348325386643,
-0.06543885916471481,
-0.057898908853530884,
-0.009568796493113041,
0.024941373616456985,
0.0297431331127882,
-0.011518271639943123,
-0.04131101071834564,
0.03908870741724968,
-0.013452865183353424,
-0.009261245839297771,
-0.006994299124926329,
-0.075201116502285,
0.061787936836481094,
-0.02456437610089779,
0.01093293260782957,
0.05039863660931587,
0.00029638962587341666,
0.004280908033251762,
0.05837511643767357,
-0.019653484225273132,
-0.024881847202777863,
0.004000640008598566,
-0.027123991400003433,
0.0017349334666505456,
-0.020228901877999306,
-0.023135753348469734,
0.038949813693761826,
0.00021934692631475627,
-0.0030730271246284246,
0.0772646814584732,
-0.046549294143915176,
0.03547746688127518,
-0.023969115689396858,
-0.022262705489993095,
0.027560515329241753,
-0.06099425628781319,
-0.01678631827235222,
0.010972617194056511,
0.020298348739743233,
0.007282007951289415,
-0.046906448900699615,
-0.018185177817940712,
-0.07662974298000336,
0.024088168516755104,
0.028493087738752365,
-0.06710559129714966,
-0.0022086608223617077,
0.03672751039266586,
0.021726971492171288,
-0.017748653888702393,
0.019643563777208328,
0.002894449280574918,
0.07670910656452179,
0.023929432034492493,
-0.02204444445669651,
0.03875139355659485,
-0.03464410454034805,
0.0297431331127882,
-0.05016053467988968,
-0.009747374802827835,
-0.05234315246343613,
0.011528192088007927,
0.007232402916997671,
-0.022937333211302757,
-0.013105629943311214,
0.01284768432378769,
-0.03139001876115799,
0.0468667633831501,
0.013730652630329132,
0.023373857140541077,
-0.021151553839445114,
-0.024445323273539543,
-0.0005847184220328927,
-0.01586366631090641,
-0.046827081590890884,
0.04972400888800621,
0.0014075407525524497,
-0.05397019535303116,
-0.029167715460062027,
0.0046504647471010685,
0.013204840011894703,
-0.006934773176908493,
-0.03174717351794243,
-0.020873766392469406,
-0.008611421100795269,
0.011002379469573498,
-0.013869546353816986,
-0.03305674344301224,
-0.02402864210307598,
-0.02896929532289505,
0.04853349179029465,
-0.00028243823908269405,
0.009618401527404785,
-0.004640543833374977,
-0.023453224450349808,
0.04186658561229706,
0.009405099786818027,
-0.00966800656169653,
0.052263785153627396,
-0.03797755762934685,
-0.004519011825323105,
-0.021290447562932968,
-0.02765972539782524,
-0.02914787270128727,
0.036806877702474594,
0.05464482307434082,
0.011290088295936584,
-0.014365595765411854,
-0.02662794105708599,
-0.008551894687116146,
-0.02525884471833706,
-0.027183517813682556,
0.004749674815684557,
-0.0013455344596877694,
0.026608100160956383,
0.07960603386163712,
0.03692593052983284,
-0.039922069758176804,
-0.0007031502900645137,
0.0019643562845885754,
0.012698869220912457,
0.014573936350643635,
0.08508242666721344,
-0.0029539752285927534,
0.02603268250823021,
-0.027699409052729607,
0.035417940467596054,
0.01072459202259779,
-0.01655813492834568,
0.0478985495865345,
-0.02809624932706356,
-0.03892997279763222,
-0.038255345076322556,
-0.011984557844698429,
0.030139973387122154,
0.03293769061565399,
-0.039465706795454025,
-0.01884988509118557,
-0.040953852236270905,
-0.03033839352428913,
0.04512067139148712,
0.023115910589694977,
-0.028770875185728073,
0.0008122812141664326,
0.01063530333340168,
-0.023215120658278465,
0.009410060942173004,
0.10159095376729965,
0.057541750371456146,
0.023552434518933296,
-0.002834923332557082,
0.025576315820217133,
-0.021687287837266922,
0.006146054249256849,
-0.0058533851988613605,
-0.017341893166303635,
0.020119771361351013,
-0.04186658561229706,
0.055716291069984436,
0.01988166756927967,
0.031013019382953644,
0.010486488230526447,
0.022461125627160072,
0.042858682572841644,
0.009945794008672237,
0.021548394113779068,
-0.022242862731218338,
-0.03404884412884712,
0.005550794769078493,
0.026568416506052017,
-0.02057613618671894,
0.006751234643161297,
0.059367213398218155,
0.011597638949751854,
-0.018224861472845078,
0.014187018387019634,
-0.02057613618671894,
0.03978317603468895,
0.023195277899503708,
-0.013452865183353424,
-0.012778237462043762,
0.056946493685245514,
-0.012688948772847652,
0.021032502874732018,
-0.037302929908037186,
0.03190590813755989,
-0.004816641565412283,
0.0468667633831501,
-0.003951034974306822,
-0.005233323201537132,
-0.019812220707535744,
-0.01594303362071514,
0.04869222640991211,
0.029465345665812492,
-0.04504130408167839,
-0.004112251102924347,
0.022798439487814903,
0.023413540795445442,
-0.025278687477111816,
-0.005848424509167671,
0.0937335267663002,
-0.05420829728245735,
0.028731191530823708,
-0.020437242463231087,
0.008328672498464584,
0.016538294032216072,
0.02567552588880062,
-0.0027778777293860912,
0.053216200321912766,
0.015069986693561077,
-0.003953515086323023,
-0.0427396334707737,
-0.07222481817007065,
-0.012698869220912457,
0.021905548870563507,
0.042938053607940674,
-0.02232223190367222,
0.029762975871562958,
0.00754491426050663,
-0.02273891307413578,
-0.014206860214471817,
0.026012839749455452,
0.012907209806144238,
-0.01959395781159401,
-0.002988698659464717,
-0.029961394146084785,
-0.02049676887691021,
0.010407119989395142,
-0.025536632165312767,
-0.03061618097126484,
-0.03478299826383591,
-0.018353834748268127,
-0.031429700553417206,
-0.05154947191476822,
-0.026687467470765114,
-0.05373208969831467,
-0.011051984503865242,
-0.003990719094872475,
0.08436811715364456,
0.03252100944519043,
-0.018611781299114227,
0.02206428535282612,
-0.014792198315262794,
0.03283848240971565,
-0.016885528340935707,
-0.021290447562932968,
-0.018998699262738228,
-0.058494165539741516,
0.015635482966899872,
-0.022699229419231415,
-0.0509938970208168,
0.016498608514666557,
0.031092388555407524,
0.011478587053716183,
-0.005575597286224365,
0.004117211326956749,
-0.031151913106441498,
0.030298708006739616,
0.008378277532756329,
0.0772646814584732,
0.0620657242834568,
-0.05135105177760124,
-0.019306249916553497,
0.023572275415062904,
-0.03025902435183525,
-0.00404280424118042,
0.033771056681871414,
-0.0028845283668488264,
0.030378077179193497,
0.07746310532093048,
-0.009325732477009296,
-0.018909409642219543,
-0.040001437067985535,
-0.024108009412884712,
-0.08309822529554367,
0.017103789374232292,
-0.04833507165312767,
-0.04021970182657242,
-0.004060165956616402,
0.01918719708919525,
-0.043811097741127014,
-0.02049676887691021,
-0.03805692493915558,
-0.02861214056611061,
-0.024445323273539543,
0.007569716777652502,
0.023969115689396858,
-0.04194595292210579,
-0.03258053585886955,
0.0037079707253724337,
0.023830221965909004,
-0.024405639618635178,
0.02404848299920559,
0.06492296606302261,
0.009930912405252457,
0.05912911146879196,
0.027044624090194702,
0.027362095192074776,
0.09365416318178177,
0.029207399114966393,
0.0011979597620666027,
0.030655864626169205,
0.03641004115343094,
-0.007063745986670256,
0.0035665964242070913,
-0.009633283130824566,
-0.0216277614235878,
0.04555719345808029,
-0.01349254883825779,
0.015625562518835068,
-0.01776849664747715,
0.05428766831755638,
0.030159814283251762,
-0.045874666422605515,
-0.0636133998632431,
-0.018631622195243835,
-0.0013554554898291826,
-0.03182654082775116,
0.05230346694588661,
-0.018056204542517662,
-0.04127132520079613,
-0.03692593052983284,
0.002686108462512493,
-0.03692593052983284,
-0.03597351536154747,
-0.004129612818360329,
0.026687467470765114,
-0.038433920592069626,
-0.023988958448171616,
-0.015159275382757187,
0.04865254461765289,
0.011111510917544365,
0.009653124958276749,
0.02775893546640873,
-0.03172733262181282,
-0.01474259328097105,
-0.0980987623333931,
0.006567696575075388,
-0.005005140323191881,
0.001444744411855936,
-0.007505230139940977,
-0.012331793084740639,
-0.08151086419820786,
-0.0023959195241332054,
0.11325804144144058,
0.0509938970208168,
-0.022600019350647926,
0.013502469286322594,
0.013353655114769936,
0.04547782614827156,
0.03857281431555748,
-0.0011148714693263173,
0.06730400770902634,
-0.05623218044638634,
0.003988238517194986,
0.061351411044597626,
0.034187737852334976,
-0.01474259328097105,
0.013552074320614338,
0.027381937950849533,
-0.05635123327374458,
0.02127060666680336,
-0.045596878975629807,
-0.025655684992671013,
0.032640062272548676,
0.007713571190834045,
-0.02101266011595726,
0.04035859555006027,
-0.0006185118108987808,
0.01962372101843357,
-0.00732665229588747,
0.03587430715560913,
-0.07960603386163712,
-0.0326995886862278,
0.03139001876115799,
0.007485388312488794,
-0.04817633703351021,
0.04075543209910393,
-0.020715029910206795,
-0.016548214480280876,
0.033155955374240875,
-0.014147333800792694,
0.019613800570368767,
-0.02335401438176632,
0.030993178486824036,
-0.0937335267663002,
0.00648832879960537,
0.010258305817842484,
0.0029217321425676346,
0.008661026135087013,
-0.02912803180515766,
0.011051984503865242,
0.03807676583528519,
0.04948590695858002,
0.019812220707535744,
0.05127168446779251,
-0.02801688015460968,
0.035140153020620346,
-0.029346292838454247,
-0.030457444489002228,
0.002564576454460621,
0.09849560260772705,
-0.012460765428841114,
-0.06484360247850418,
-0.007153035141527653,
0.006185738369822502,
0.017530392855405807,
-0.0478985495865345,
-0.059287846088409424,
0.008318751119077206,
-0.041985638439655304,
0.01296673621982336,
0.00540694035589695,
-0.020476926118135452,
-0.01768912747502327
] |
725,943 | validator_collection.validators | iterable | Validate that ``value`` is a valid iterable.
.. hint::
This validator checks to ensure that ``value`` supports iteration using
any of Python's three iteration protocols: the ``__getitem__`` protocol,
the ``__iter__`` / ``next()`` protocol, or the inheritance from Python's
`Iterable` abstract base class.
If ``value`` supports any of these three iteration protocols, it will be
validated. However, if iteration across ``value`` raises an unsupported
exception, this function will raise an
:exc:`IterationFailedError <validator_collection.errors.IterationFailedError>`
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if ``value``
is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>` if
``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:param forbid_literals: A collection of literals that will be considered invalid
even if they are (actually) iterable. Defaults to :class:`str <python:str>` and
:class:`bytes <python:bytes>`.
:type forbid_literals: iterable
:param minimum_length: If supplied, indicates the minimum number of members
needed to be valid.
:type minimum_length: :class:`int <python:int>`
:param maximum_length: If supplied, indicates the minimum number of members
needed to be valid.
:type maximum_length: :class:`int <python:int>`
:returns: ``value`` / :obj:`None <python:None>`
:rtype: iterable / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises NotAnIterableError: if ``value`` is not a valid iterable or
:obj:`None <python:None>`
:raises IterationFailedError: if ``value`` is a valid iterable, but iteration
fails for some unexpected exception
:raises MinimumLengthError: if ``minimum_length`` is supplied and the length of
``value`` is less than ``minimum_length`` and ``whitespace_padding`` is
``False``
:raises MaximumLengthError: if ``maximum_length`` is supplied and the length of
``value`` is more than the ``maximum_length``
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, forbid_literals=(<class 'str'>, <class 'bytes'>), minimum_length=None, maximum_length=None, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,944 | validator_collection.validators | mac_address | Validate that ``value`` is a valid MAC address.
:param value: The value to validate.
:type value: :class:`str <python:str>` / :obj:`None <python:None>`
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` / :obj:`None <python:None>`
:rtype: :class:`str <python:str>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` is not a valid :class:`str <python:str>`
or string-like object
:raises InvalidMACAddressError: if ``value`` is not a valid MAC address or empty with
``allow_empty`` set to ``True``
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,945 | validator_collection.validators | none | Validate that ``value`` is :obj:`None <python:None>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if ``value``
is empty but **not** :obj:`None <python:None>`. If ``False``, raises a
:class:`NotNoneError` if ``value`` is empty but **not**
:obj:`None <python:None>`. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: :obj:`None <python:None>`
:raises NotNoneError: if ``allow_empty`` is ``False`` and ``value`` is empty
but **not** :obj:`None <python:None>` and
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
725,946 | validator_collection.validators | not_empty | Validate that ``value`` is not empty.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
| # -*- coding: utf-8 -*-
# The lack of a module docstring for this module is **INTENTIONAL**.
# The module is imported into the documentation using Sphinx's autodoc
# extension, and its member function documentation is automatically incorporated
# there as needed.
import decimal as decimal_
import fractions
import io
import math
import os
import uuid as uuid_
import datetime as datetime_
import string as string_
import sys
from ast import parse
import jsonschema
from validator_collection._compat import numeric_types, integer_types, datetime_types,\
date_types, time_types, timestamp_types, tzinfo_types, POSITIVE_INFINITY, \
NEGATIVE_INFINITY, TimeZone, json_, is_py2, is_py3, dict_, float_, basestring, re
from validator_collection._decorators import disable_on_env
from validator_collection import errors
URL_UNSAFE_CHARACTERS = ('[', ']', '{', '}', '|', '^', '%', '~')
URL_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address exclusion
# private & local networks
r"(?!(?:10|127)(?:\.\d{1,3}){3})"
r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})"
r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
r"(?:"
r"(?:localhost|invalid|test|example)|("
# host name
r"(?:(?:[A-z\u00a1-\uffff0-9]-*_*)*[A-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[A-z\u00a1-\uffff0-9]-*)*[A-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[A-z\u00a1-\uffff]{2,}))"
r")))"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
URL_SPECIAL_IP_REGEX = re.compile(
r"^"
# protocol identifier
r"(?:(?:https?|ftp)://)"
# user:pass authentication
r"(?:\S+(?::\S*)?@)?"
r"(?:"
# IP address dotted notation octets
# excludes loopback network 0.0.0.0
# excludes reserved space >= 224.0.0.0
# excludes network & broadcast addresses
# (first & last IP address of each class)
r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])"
r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}"
r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))"
r"|"
# host name
r"(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)"
# domain name
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*"
# TLD identifier
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
r")"
# port number
r"(?::\d{2,5})?"
# resource path
r"(?:/\S*)?"
r"$"
, re.UNICODE)
DOMAIN_REGEX = re.compile(
r"\b((?=[a-z\u00a1-\uffff0-9-]{1,63}\.)(xn--)?[a-z\u00a1-\uffff0-9]+"
r"(-[a-z\u00a1-\uffff0-9]+)*\.)+[a-z]{2,63}\b",
re.UNICODE|re.IGNORECASE
)
URL_PROTOCOLS = ('http://',
'https://',
'ftp://')
SPECIAL_USE_DOMAIN_NAMES = ('localhost',
'invalid',
'test',
'example')
EMAIL_REGEX = re.compile(
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")"
r"@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])"
r"?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}"
r"(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:"
r"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
VARIABLE_NAME_REGEX = re.compile(
r"(^[a-zA-Z_])([a-zA-Z0-9_]*)"
)
MAC_ADDRESS_REGEX = re.compile(r'^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$')
IPV6_REGEX = re.compile(
'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,4}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%25(?:[A-Za-z0-9\\-._~]|%[0-9A-Fa-f]{2})+)?$'
)
TIMEDELTA_REGEX = re.compile(r'((?P<days>\d+) days?, )?(?P<hours>\d+):'
r'(?P<minutes>\d+):(?P<seconds>\d+(\.\d+)?)')
MIME_TYPE_REGEX = re.compile(r"^multipart|[-\w.]+/[-\w.\+]+$")
# pylint: disable=W0613
## CORE
@disable_on_env
def uuid(value,
allow_empty = False,
**kwargs):
"""Validate that ``value`` is a valid :class:`UUID <python:uuid.UUID>`.
:param value: The value to validate.
:param allow_empty: If ``True``, returns :obj:`None <python:None>` if
``value`` is empty. If ``False``, raises a
:class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
if ``value`` is empty. Defaults to ``False``.
:type allow_empty: :class:`bool <python:bool>`
:returns: ``value`` coerced to a :class:`UUID <python:uuid.UUID>` object /
:obj:`None <python:None>`
:rtype: :class:`UUID <python:uuid.UUID>` / :obj:`None <python:None>`
:raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
:raises CannotCoerceError: if ``value`` cannot be coerced to a
:class:`UUID <python:uuid.UUID>`
"""
if not value and not allow_empty:
raise errors.EmptyValueError('value (%s) was empty' % value)
elif not value:
return None
if isinstance(value, uuid_.UUID):
return value
try:
value = uuid_.UUID(value)
except ValueError:
raise errors.CannotCoerceError('value (%s) cannot be coerced to a valid UUID')
return value
| (value, allow_empty=False, **kwargs) | [
0.03530561923980713,
0.0046048457734286785,
0.00770893320441246,
0.015979301184415817,
-0.012394755147397518,
-0.04832658916711807,
0.007466004695743322,
-0.02293245680630207,
-0.02688409388065338,
-0.04806746542453766,
0.04396467283368111,
0.09708505123853683,
0.04040171951055527,
0.016627110540866852,
0.04936308413743973,
0.06715625524520874,
-0.01360399927943945,
0.05748229846358299,
0.03083573281764984,
-0.02465994842350483,
-0.060375846922397614,
-0.05268850550055504,
-0.018073884770274162,
0.022371022030711174,
0.005981441121548414,
0.056143488734960556,
0.022241460159420967,
-0.014575714245438576,
0.009058536030352116,
0.020254844799637794,
0.03126760572195053,
-0.0003208681591786444,
0.003085192758589983,
0.029410552233457565,
0.03083573281764984,
-0.07346159964799881,
0.009447221644222736,
0.004313331563025713,
-0.0858563557267189,
0.01293459627777338,
-0.006224369630217552,
-0.015569021925330162,
-0.03541358560323715,
0.001861102762632072,
-0.005212167277932167,
0.02152886986732483,
-0.00919889472424984,
0.06681075692176819,
-0.09440743923187256,
-0.022263053804636,
-0.013819935731589794,
-0.0488448366522789,
-0.013031767681241035,
0.04176212102174759,
0.0300583615899086,
0.042798615992069244,
-0.018559742718935013,
0.10399501770734787,
0.013312485069036484,
-0.01156339980661869,
-0.007169092074036598,
-0.01921834796667099,
-0.01926153525710106,
0.016508346423506737,
-0.011077542789280415,
0.00934465229511261,
0.00358184683136642,
-0.06214652583003044,
-0.055322930216789246,
-0.036255739629268646,
0.021453291177749634,
0.011088339611887932,
0.0009440474095754325,
-0.008432320319116116,
0.08451754599809647,
-0.03454983979463577,
-0.008356742560863495,
0.03351334482431412,
-0.03107326291501522,
-0.01199527271091938,
0.1177285835146904,
0.015245117247104645,
0.01367957703769207,
-0.01796591654419899,
0.08576998114585876,
-0.022846082225441933,
0.041459809988737106,
0.03416115418076515,
-0.08045794069766998,
0.07467084378004074,
-0.006364728324115276,
-0.06672438234090805,
-0.020222453400492668,
0.03999143838882446,
-0.053681813180446625,
-0.049924518913030624,
0.004348421469330788,
-0.02571803703904152,
0.019736595451831818,
-0.06391720473766327,
-0.003714107908308506,
0.013841529376804829,
-0.1571153998374939,
0.007088115904480219,
0.016778266057372093,
-0.007914072833955288,
-0.06478095054626465,
0.02091345004737377,
-0.02966967597603798,
-0.047851528972387314,
-0.0020001118537038565,
-0.043813515454530716,
0.023429110646247864,
-0.011401447467505932,
0.04832658916711807,
-0.030900513753294945,
-0.002826069016009569,
-0.02876274287700653,
0.005538771394640207,
-0.017523247748613358,
0.019531456753611565,
0.03694673627614975,
-0.04513072967529297,
0.030943701043725014,
0.024012139067053795,
0.0170481875538826,
-0.03362131491303444,
-0.0007125904667191207,
0.04094156250357628,
0.006143393460661173,
-0.026992062106728554,
0.06400357931852341,
0.004307933151721954,
0.04979495704174042,
-0.027661465108394623,
-0.06616294384002686,
-0.015072368085384369,
0.030187923461198807,
-0.0608077198266983,
0.02645222097635269,
-0.02176639996469021,
0.017901135608553886,
-0.007833096198737621,
-0.0651264488697052,
0.0009298765799030662,
0.007331044413149357,
0.018473368138074875,
-0.006256760098040104,
-0.02645222097635269,
-0.023234767839312553,
0.02884911745786667,
-0.005420006345957518,
0.00146971782669425,
0.047376468777656555,
0.004116289783269167,
-0.014629698358476162,
-0.014122246764600277,
-0.08188312500715256,
-0.024940665811300278,
-0.03815598040819168,
-0.028395650908350945,
-0.04344642534852028,
-0.004124387167394161,
-0.05730954930186272,
0.010613279417157173,
0.04238833487033844,
0.04599447548389435,
-0.03040385991334915,
-0.008243376389145851,
0.028438838198781013,
-0.019768986850976944,
0.041502997279167175,
-0.017695996910333633,
0.06227608770132065,
0.013118142262101173,
0.039948251098394394,
0.021712414920330048,
-0.021464088931679726,
-0.020265640690922737,
0.043036144226789474,
0.016443565487861633,
0.01052150595933199,
0.03703311085700989,
0.03515446186065674,
0.036730799823999405,
0.020222453400492668,
-0.012589097954332829,
0.017847152426838875,
0.06149871647357941,
0.00895596668124199,
0.016065675765275955,
0.006445704493671656,
0.01715615577995777,
0.026279471814632416,
-0.0026128317695111036,
-0.031375572085380554,
0.0050799064338207245,
-0.0037168071139603853,
0.0015763364499434829,
-0.04798109084367752,
-0.01733970083296299,
0.0032876331824809313,
-0.050270017236471176,
-0.044871605932712555,
-0.04469885677099228,
-0.059943974018096924,
0.00025170098524540663,
0.027704652398824692,
-0.0026047341525554657,
0.017544841393828392,
-0.01970420591533184,
-0.049017585813999176,
-0.03366450220346451,
0.09440743923187256,
-0.030425453558564186,
-0.04325208067893982,
0.01758802868425846,
0.016508346423506737,
-0.02528616413474083,
0.02822289988398552,
0.049449458718299866,
-0.01028397586196661,
-0.01671348512172699,
-0.06357170641422272,
0.015741771087050438,
-0.0006916716229170561,
0.003921946510672569,
0.04126546531915665,
-0.007957260124385357,
-0.06970430165529251,
0.06473775953054428,
-0.05562524124979973,
0.051133763045072556,
0.0820990577340126,
0.021550463512539864,
0.04262586683034897,
0.059512101113796234,
-0.006424110848456621,
0.07497315108776093,
-0.0023753014393150806,
-0.042561084032058716,
-0.020103687420487404,
0.036773987114429474,
-0.025588475167751312,
0.054502371698617935,
0.006656242534518242,
-0.030943701043725014,
0.04163255915045738,
-0.019563846290111542,
-0.10036728531122208,
-0.08076024800539017,
0.04711734503507614,
-0.014154637232422829,
-0.035435181111097336,
-0.04927670955657959,
-0.011757742613554,
-0.017544841393828392,
-0.043662361800670624,
0.06927242875099182,
-0.005544169805943966,
0.022435802966356277,
-0.04124387353658676,
0.01023539062589407,
0.04854252561926842,
-0.02697046846151352,
-0.02707843668758869,
0.01970420591533184,
0.04595128819346428,
-0.051176950335502625,
-0.012383958324790001,
-0.05882110446691513,
0.008939770981669426,
-0.05091782659292221,
0.002599335741251707,
-0.039861876517534256,
-0.06093728169798851,
0.027683058753609657,
0.00011319796612951905,
0.02982083149254322,
-0.06862462311983109,
-0.03593183308839798,
0.03595342859625816,
0.03020951710641384,
-0.004531967453658581,
0.03595342859625816,
0.009279871359467506,
-0.005830285605043173,
0.007546980865299702,
-0.056143488734960556,
0.013884716667234898,
-0.031569916754961014,
-0.08684965968132019,
0.03595342859625816,
-0.011088339611887932,
-0.04426698386669159,
0.07346159964799881,
-0.004151379223912954,
-0.022651739418506622,
0.007460606284439564,
-0.06093728169798851,
-0.03889016434550285,
0.06335576623678207,
0.034895338118076324,
-0.0026816613972187042,
-0.048585712909698486,
0.025394132360816002,
-0.01970420591533184,
-0.026992062106728554,
0.04379192367196083,
0.0059490506537258625,
0.0013408306986093521,
-0.03236887976527214,
-0.010176007635891438,
0.01656232960522175,
0.06711306422948837,
0.0526021309196949,
0.016454361379146576,
0.020406000316143036,
0.026517001911997795,
0.037357013672590256,
0.02008209377527237,
0.0663788840174675,
0.049017585813999176,
-0.020870262756943703,
0.005873472895473242,
-0.01657312735915184,
0.015353085473179817,
0.0010068039409816265,
-0.03558633476495743,
0.017253326252102852,
-0.02239261567592621,
-0.007260865066200495,
0.013960294425487518,
0.041459809988737106,
0.017264124006032944,
-0.03843669593334198,
-0.0023820495698601007,
-0.06335576623678207,
-0.018462570384144783,
-0.05558205395936966,
0.029324177652597427,
0.020783888176083565,
-0.003916548099368811,
-0.007843893021345139,
-0.0023672038223594427,
-0.056618548929691315,
0.02716481126844883,
0.0013887416571378708,
-0.014932009391486645,
0.00008633242396172136,
0.004313331563025713,
0.007525387220084667,
-0.034182749688625336,
0.06447863578796387,
0.006758812349289656,
-0.06486732512712479,
-0.039278849959373474,
-0.015212726779282093,
0.039235662668943405,
0.04247470945119858,
-0.04016418755054474,
-0.010370350442826748,
-0.028870711103081703,
-0.04802427813410759,
0.028309274464845657,
-0.01979058049619198,
0.00045447886805050075,
0.04109271615743637,
0.05527974292635918,
-0.05014045536518097,
-0.0024738225620239973,
0.04538985341787338,
0.019563846290111542,
-0.12507042288780212,
-0.008923576213419437,
-0.03830713406205177,
0.06732900440692902,
0.019229145720601082,
-0.07315928488969803,
0.008248774334788322,
0.03582386672496796,
0.06465138494968414,
-0.0007186636794358492,
-0.016400378197431564,
0.010078836232423782,
-0.07294335216283798,
-0.02457357384264469,
0.013819935731589794,
-0.05044276639819145,
0.059943974018096924,
-0.027272779494524002,
-0.000050820992328226566,
0.06452182680368423,
-0.01203846000134945,
-0.01317212637513876,
0.024595167487859726,
0.014338184148073196,
0.028546806424856186,
-0.003101387992501259,
-0.015018383972346783,
-0.03694673627614975,
-0.01584973931312561,
0.003921946510672569,
0.049060773104429245,
0.030187923461198807,
0.0017031991155818105,
0.09164345264434814,
0.012999377213418484,
-0.0010445928201079369,
0.04556260257959366,
0.0058626760728657246,
-0.022090304642915726,
-0.028244493529200554,
-0.036687612533569336,
-0.027488715946674347,
0.04109271615743637,
-0.0435543917119503,
0.004183769691735506,
0.003101387992501259,
0.0294321458786726,
-0.014770057052373886,
-0.016216831281781197,
-0.02528616413474083,
0.07518909126520157,
-0.022522177547216415,
0.036968328058719635,
-0.01052150595933199,
-0.0007105660624802113,
-0.0012429844355210662,
-0.013150532729923725,
0.03221772611141205,
0.015288304537534714,
-0.011261088773608208,
-0.0595552884042263,
0.03139716759324074,
-0.026754532009363174,
0.0064187124371528625,
-0.013895513489842415,
0.03144035488367081,
-0.025566881522536278,
0.010462123900651932,
-0.018343806266784668,
0.03921406716108322,
-0.006828991696238518,
0.05605711415410042,
-0.018916036933660507,
-0.05394093692302704,
0.005576560273766518,
-0.014608104713261127,
-0.02567484974861145,
-0.033556532114744186,
-0.0372922345995903,
-0.022047117352485657,
-0.023234767839312553,
-0.02645222097635269,
0.01575256697833538,
0.014759260229766369,
0.0340963751077652,
-0.013409656472504139,
-0.02841724455356598,
0.007784510962665081,
0.062448836863040924,
0.01584973931312561,
-0.004002922680228949,
-0.05139288678765297,
0.038371916860342026,
0.04156777635216713,
-0.009285269305109978,
-0.014608104713261127,
0.04262586683034897,
-0.03999143838882446,
-0.01950986310839653,
-0.030900513753294945,
0.009387839585542679,
0.025221383199095726,
0.0372922345995903,
0.018894443288445473,
0.020146874710917473,
-0.0347873717546463,
-0.012589097954332829,
0.05333631485700607,
-0.036342114210128784,
0.01906719245016575,
0.005695325322449207,
0.00859967153519392,
-0.022759707644581795,
0.012254396453499794,
-0.02258695848286152,
-0.05359543859958649,
0.045303478837013245,
-0.038415104150772095,
-0.02301883138716221,
-0.025804411619901657,
0.020244047045707703,
0.027704652398824692,
-0.033750876784324646,
0.004372714087367058,
0.005533372983336449,
0.019617831334471703,
-0.02442241832613945,
0.004100094549357891,
-0.00963076762855053,
0.0031850633677095175,
-0.0003321710682939738,
0.020967435091733932,
0.01845177449285984,
-0.0016519142081961036,
-0.0030096150003373623,
0.024292856454849243,
-0.030079955235123634,
-0.05143607407808304,
-0.011930491775274277,
0.03178585320711136,
0.0315915085375309,
-0.01656232960522175,
0.022889269515872,
0.03683876618742943,
-0.014802447520196438,
-0.04368395358324051,
-0.040768813341856,
-0.030187923461198807,
0.058605168014764786,
0.010953378863632679,
-0.036925140768289566,
0.007849291898310184,
0.046987783163785934,
-0.0247031357139349,
0.002483269665390253,
-0.0032741371542215347,
-0.004934148862957954,
0.05350906401872635,
0.049060773104429245,
0.0366012379527092,
-0.03569430485367775,
0.026171503588557243,
-0.0008219082956202328,
-0.038760602474212646,
-0.0727706030011177,
-0.06128278002142906,
0.013722764328122139,
-0.007816901430487633,
0.04465566948056221,
-0.08032837510108948,
-0.02182038314640522,
-0.07233873009681702,
-0.04081200063228607,
0.031051669269800186,
0.006672437768429518,
-0.04582172632217407,
-0.03429071605205536,
-0.004221558570861816,
0.0435543917119503,
0.07410940527915955,
0.010435131378471851,
-0.028719555586576462,
0.039516378194093704,
0.0350680872797966,
0.015396272763609886,
0.001673507853411138,
-0.0019677213858813047,
-0.02278130128979683,
-0.019293926656246185,
-0.04513072967529297,
-0.013981888070702553,
-0.08171037584543228,
0.004202664364129305,
-0.011282682418823242,
-0.01912117749452591,
-0.06141234189271927,
0.041459809988737106,
-0.06313983350992203,
0.026668157428503036,
0.052472569048404694,
0.01235156785696745,
-0.036579642444849014,
-0.029561707749962807,
-0.03290872275829315,
-0.00026300392346456647,
0.028093338012695312,
-0.0007672493811696768,
0.03487374633550644,
0.02692728117108345,
-0.015633802860975266,
-0.06050540879368782,
0.03286553546786308,
0.008475507609546185,
0.058648355305194855,
0.07009299099445343,
-0.0663788840174675,
-0.029756050556898117,
-0.03221772611141205,
-0.0019110380671918392,
0.00024765217676758766,
0.008610468357801437,
-0.033988405019044876,
0.04560578987002373,
0.027575090527534485,
-0.010494514368474483,
0.040336936712265015,
0.02394735813140869,
-0.01375515479594469,
0.05290444195270538,
0.05091782659292221,
-0.05255894362926483,
0.025653256103396416,
-0.00791947077959776,
-0.022673333063721657,
-0.03072776459157467,
0.010764434933662415,
-0.061930589377880096,
0.017523247748613358,
0.019391097128391266,
-0.0016208733431994915,
-0.01853814907371998,
0.028093338012695312,
-0.013571608811616898,
-0.06015991047024727,
0.04668547213077545,
0.012913002632558346,
0.0015533932019025087,
-0.004974637180566788,
0.04789471626281738,
0.011865710839629173,
0.018775679171085358,
0.04152458906173706,
0.013582405634224415,
-0.044526107609272,
0.029108241200447083,
-0.058648355305194855,
-0.0012524316553026438,
0.007385028526186943,
0.018559742718935013,
-0.013690373860299587,
0.007676542736589909,
-0.00958758033812046,
-0.024724729359149933,
0.028546806424856186,
0.015039977617561817,
-0.04012100026011467,
0.04517391696572304,
-0.0069747488014400005,
-0.006963951978832483,
0.0002930325863417238,
0.010186804458498955,
0.01317212637513876,
0.053638625890016556,
-0.024487199261784554,
-0.08576998114585876,
0.05787098407745361,
0.016173643991351128,
0.021906757727265358,
0.04310092702507973,
-0.009333855472505093,
0.004326827824115753,
-0.022414209321141243,
0.04398626461625099,
-0.01864611729979515,
-0.012405551970005035,
0.013107345439493656,
-0.00459944736212492,
-0.02774783968925476,
-0.02090265415608883,
0.03858785331249237,
-0.005598153918981552,
-0.015039977617561817,
0.0038760602474212646,
0.0644354522228241,
-0.009646963328123093,
-0.025415726006031036,
0.029367364943027496,
-0.008086821995675564,
-0.02817971259355545,
0.04387829825282097,
0.04085518792271614,
0.015450256876647472,
0.01671348512172699,
-0.012016866356134415,
-0.005306639708578587,
0.009965469129383564,
0.03463621437549591,
0.10745000094175339,
-0.02504863403737545,
-0.02977764420211315,
-0.03737860918045044,
-0.010159812867641449,
-0.017857948318123817,
0.03835032135248184,
0.03303828462958336,
0.015482647344470024,
-0.009646963328123093,
-0.011023558676242828,
-0.013981888070702553,
-0.024098513647913933,
0.026646563783288002,
-0.04646953567862511,
-0.0050772069953382015,
-0.012016866356134415,
0.06858143210411072,
0.03811279311776161,
-0.011865710839629173,
0.005009726621210575,
0.0033065276220440865,
0.0340963751077652,
0.022414209321141243,
0.009485010989010334,
0.008874990046024323,
-0.06521282345056534,
-0.00595984747633338,
0.06106684356927872,
0.013517624698579311,
0.05592755228281021,
0.01062407623976469,
0.012869815342128277,
0.003938141744583845,
-0.010915590450167656,
-0.05666173994541168,
-0.03342697024345398,
0.015201929956674576,
0.02966967597603798,
0.0007874934235587716,
0.05139288678765297,
-0.0029502324759960175,
0.03863104060292244,
0.02104301191866398,
-0.021453291177749634,
0.053638625890016556,
-0.02134532295167446,
0.008135408163070679,
0.03323262929916382,
0.007444411050528288,
0.015569021925330162,
0.08896584063768387,
-0.0350680872797966,
0.07717570662498474,
-0.024508792906999588,
-0.04875846207141876,
0.018678506836295128,
0.010737442411482334,
-0.05290444195270538,
0.013539218343794346,
0.0013435299042612314,
-0.0002611482050269842,
-0.03204497694969177,
0.05877791717648506,
0.014813244342803955,
0.048585712909698486,
0.024767916649580002,
0.008982958272099495,
-0.02928099036216736,
-0.020578749477863312,
0.0015574420103803277,
-0.025998754426836967,
-0.09553030878305435,
-0.004477983340620995,
0.01575256697833538,
-0.030187923461198807,
-0.026711344718933105,
0.044094234704971313,
-0.024055326357483864,
-0.014964399859309196,
0.0008961365092545748,
0.047808341681957245,
-0.0010074786841869354,
-0.004955742508172989,
-0.00790327601134777,
0.026754532009363174,
-0.0175340436398983,
0.016022488474845886
] |
Subsets and Splits