How to use ts method in yandex-tank

Best Python code snippet using yandex-tank

dac2.py

Source:dac2.py Github

copy

Full Screen

1# -*-coding:utf-8 -*-2'''3 dac的@indicator版本4 提供更简单的使用方式和实现方式5'''67import operator89from collections import (10 deque,11 )1213from base import (14 BaseObject,15 fcustom,16 indicator,17 icache,18 t2order_if,19 )2021from dac import (22 XBASE, #10023 CBASE, #XBASE*XBASE,用于XATR24 FBASE, #1025 )262728XBASE = 100 #整数运算的放大倍数29CBASE = XBASE * XBASE #XATR倍数30FBASE = 10 #整数运算的放大倍数23132##########33#编写指标时,请务必确保这个判断中的标识字符串和下面赋值的名称的一致性,否则会每次都赋值和计算,内存立马挂掉34# if not hasattr(_ts,'ss'):35# _ts.ss = []36#37##########383940###############41# 基本序列运算42#43###############4445@indicator46def OPER1(source,oper,_ts=None):47 '''48 单参数序列运算49 '''50 if not _ts.initialized:51 _ts.initialized = True52 _ts.ss = []5354 for i in range(len(_ts.ss),len(source)):55 #print 'new data:',source[i]56 _ts.ss.append(oper(source[i]))5758 return _ts.ss5960'''61 不同的operator.xxx, 使OPER1下缓存的key不同,不会导致混淆62'''63NEG = fcustom(OPER1,oper=operator.neg)64ABS = fcustom(OPER1,oper=operator.abs)65NOT = fcustom(OPER1,oper=operator.not_)6667@indicator68def OPER2(source1,source2,oper,_ts=None):69 '''70 双参数序列运算71 '''72 assert len(source1) == len(source2),'len(source1) != len(source2)'73 if not _ts.initialized:74 _ts.initialized = True75 #print 'new oper2 ss'76 _ts.ss = []7778 for i in range(len(_ts.ss),len(source1)):79 #print 'new data:',source1[i],source2[i]80 _ts.ss.append(oper(source1[i],source2[i]))8182 return _ts.ss8384ADD = fcustom(OPER2,oper=operator.add)85SUB = fcustom(OPER2,oper=operator.sub)86MUL = fcustom(OPER2,oper=operator.mul)87#AND = fcustom(OPER2,oper=operator.and_) #这个是位操作88#OR = fcustom(OPER2,oper=operator.or_) #这个是位操作89#XOR = fcustom(OPER2,oper=operator.xor) #这个是位操作90LT = fcustom(OPER2,oper=operator.lt) 91LE = fcustom(OPER2,oper=operator.le) 92EQ = fcustom(OPER2,oper=operator.eq) 93GT = fcustom(OPER2,oper=operator.gt) 94GE = fcustom(OPER2,oper=operator.ge) 9596@indicator97def OPER21(source1,vs,oper,_ts=None):98 '''99 双参数运算,第一个为序列,第二个为数值100 '''101 if not _ts.initialized:102 _ts.initialized = True103 _ts.ss = []104105 for i in range(len(_ts.ss),len(source1)):106 #print 'new data:',source1[i]107 _ts.ss.append(oper(source1[i],vs))108109 return _ts.ss110111ADD1 = fcustom(OPER21,oper=operator.add)112SUB1 = fcustom(OPER21,oper=operator.sub)113MUL1 = fcustom(OPER21,oper=operator.mul)114#AND1 = fcustom(OPER21,oper=operator.and_) #这个是位操作115#OR1 = fcustom(OPER21,oper=operator.or_) #这个是位操作116#XOR1 = fcustom(OPER21,oper=operator.xor) #这个是位操作117LT1 = fcustom(OPER21,oper=operator.lt) 118LE1 = fcustom(OPER21,oper=operator.le) 119EQ1 = fcustom(OPER21,oper=operator.eq) 120GT1 = fcustom(OPER21,oper=operator.gt) 121GE1 = fcustom(OPER21,oper=operator.ge) 122123@indicator124def AND(source1,source2,_ts=None):125 '''126 双序列参数AND运算127 '''128 assert len(source1) == len(source2),'len(source1) != len(source2)'129 if not _ts.initialized:130 _ts.initialized = True131 _ts.ss = []132133 for i in range(len(_ts.ss),len(source1)):134 #print 'new data:',source1[i],source2[i]135 _ts.ss.append((source1[i] and source2[i])!=0)136137 return _ts.ss138139140@indicator141def GAND(_ts=None,*args):142 assert len(args)>0,'GAND params number less than 1'143 if not _ts.initialized:144 _ts.initialized = True145 _ts.ga = []146147 for i in range(len(_ts.ga),len(args[0])):148 rv = all([vs[i] for vs in args])149 _ts.ga.append(rv!=0)150 151 return _ts.ga152153@indicator154def GOR(_ts=None,*args):155 assert len(args)>0,'GOR params number less than 1'156 #print 'ts=%s,args=%s' % (_ts,args)157 if not _ts.initialized:158 _ts.initialized = True159 _ts.gor = []160161 for i in range(len(_ts.gor),len(args[0])):162 rv = any([vs[i] for vs in args])163 _ts.gor.append(rv!=0)164 165 return _ts.gor166167#GAND = fcustom(GOPER,oper=all) #有可变参数时,就不能再有_ts之外的参数用fcustom指定默认值168#GOR = fcustom(GOPER,oper=any) #有可变参数时,就不能再有_ts之外的参数用fcustom指定默认值169170171@indicator172def DIV(source1,source2,_ts=None):173 '''174 序列除法175 '''176 assert len(source1) == len(source2),'len(source1) != len(source2)'177 if not _ts.initialized:178 _ts.initialized = True179 _ts.ss = []180181 for i in range(len(_ts.ss),len(source1)):182 #print 'new data:',source1[i],source2[i]183 r = (source1[i]+source2[i]/2)/source2[i] if source2[i] != 0 else source1[i]*1000184 _ts.ss.append(r)185186 return _ts.ss187188@indicator189def DIV1(source1,vs,_ts=None):190 '''191 序列除常数192 '''193 assert vs!=0,'divisor vs == 0'194 if not _ts.initialized:195 _ts.initialized = True196 _ts.ss = []197198 for i in range(len(_ts.ss),len(source1)):199 #print 'new data:',source1[i]200 _ts.ss.append((source1[i]+vs/2)/vs)201202 return _ts.ss203204205############206# 常用指标207#208############209210211@indicator212def ACCUMULATE(source,_ts=None):213 '''214 累加215 '''216 if not _ts.initialized:217 _ts.initialized = True218 _ts.sa = []219220 ss = _ts.sa[-1] if _ts.sa else 0221 for i in range(len(_ts.sa),len(source)):222 ss += source[i]223 _ts.sa.append(ss)224 #print id(_ts),id(source),source,_ts.sa225 return _ts.sa226227NSUM = ACCUMULATE228229@indicator230def MSUM(source,mlen,_ts=None):231 '''232 移动求和233 '''234 if not _ts.initialized:235 _ts.initialized = True236 _ts.ms = []237238 ss = ACCUMULATE(source)239 for i in range(len(_ts.ms),len(source)):240 v = ss[i] - ss[i-mlen] if i>=mlen else ss[i]241 _ts.ms.append(v)242 return _ts.ms243244245@indicator246def MA(source,mlen,_ts=None):247 '''248 移动平均. 使用MSUM249 使用方式:250 rev = MA(source,13) #返回source的13期移动平均251 当序列中元素个数<mlen时,结果序列为到该元素为止的所有元素值的平均252 '''253 assert mlen>0,u'mlen should > 0'254 if not _ts.initialized:255 _ts.initialized = True256 _ts.ma = []257258 ms = MSUM(source,mlen)259 for i in range(len(_ts.ma),len(source)):260 #当累计个数<nlen时,求其平均值,而不是累计值/mlen261 rlen = mlen if i>=mlen else i+1262 _ts.ma.append((ms[i]+rlen/2)/rlen) 263 return _ts.ma264265266@indicator267def MA_2(source,mlen,_ts=None):268 '''269 移动平均. 直接计270 使用方式:271 rev = MA(source,13) #返回source的13期移动平均272 当序列中元素个数<mlen时,结果序列为到该元素为止的所有元素值的平均273 '''274 assert mlen>0,u'mlen should > 0'275 if not _ts.initialized:276 _ts.initialized = True277 _ts.sa = [0]*mlen #哨兵278 _ts.ma = []279280 slen = len(_ts.ma)281 ss = _ts.sa[-1]282 for i in range(slen,len(source)):283 ss += source[i]284 _ts.sa.append(ss)285 #print ss,_ts.sa[i-mlen]286 #当累计个数<nlen时,求其平均值,而不是累计值/mlen287 rlen = mlen if mlen < i+1 else i+1288 _ts.ma.append((ss-_ts.sa[-rlen-1]+rlen/2)/rlen) 289 #print _ts.sa290 return _ts.ma291292@indicator293def NMA(source,_ts=None):294 '''295 总平均296 使用方式:297 rev = MA(source) #返回source的当期及之前的平均值298 '''299 if not _ts.initialized:300 _ts.initialized = True301 _ts.sa = [0] #哨兵302 _ts.nma = []303 #print 'initial NMA'304305 slen = len(_ts.nma)306 ss = _ts.sa[-1]307 for i in range(slen,len(source)):308 ss += source[i]309 _ts.sa.append(ss)310 #print ss,_ts.sa[-1]311 _ts.nma.append((ss+(i+1)/2)/(i+1)) 312 #print _ts.sa313 return _ts.nma314315316@indicator317def CEXPMA(source,mlen,_ts=None):318 assert mlen>0,u'mlen should > 0'319 if len(source) == 0:#不计算空序列,直接返回320 return []321322 if not _ts.initialized:323 _ts.initialized = True324 #print 'new cexpma ema'325 _ts.ema = [source[0]] #哨兵元素是source[0],确保计算得到的值在<mlen元素的情况下也正确326327 cur = _ts.ema[-1]328 for i in range(len(_ts.ema),len(source)):329 cur = (source[i]*2 + cur*(mlen-1) + (mlen+1)/2)/(mlen+1)330 _ts.ema.append(cur)331 return _ts.ema332333EMA = CEXPMA334335@indicator336def MACD(source,ifast=12,islow=26,idiff=9,_ts=None):337 if not _ts.initialized:338 _ts.initialized = True339 _ts.diff = []340 _ts.dea = []341342 src = MUL1(source,FBASE)343 sfast = EMA(src,ifast)344 sslow = EMA(src,islow)345 _ts.diff = SUB(sfast,sslow)346 _ts.dea = EMA(_ts.diff,idiff)347 return _ts348349@indicator350def TR(sclose,shigh,slow,_ts=None):351 if len(sclose) == 0:352 return []353354 if not _ts.initialized:355 _ts.initialized = True356 _ts.tr = [(shigh[0]-slow[0]) * XBASE]357358 for i in range(len(_ts.tr),len(sclose)):359 #c,h,l = sclose[slen-1],shigh[slen],sclose[slen]360 hh = shigh[i] if shigh[i] > sclose[i-1] else sclose[i-1]361 ll = slow[i] if slow[i] < sclose[i-1] else sclose[i-1]362 _ts.tr.append((hh-ll)*XBASE)363 return _ts.tr364365@indicator366def ATR(sclose,shigh,slow,length=20,_ts=None):367 ltr = TR(sclose,shigh,slow)368 return CEXPMA(ltr,length)369370371@indicator372def XATR(sclose,shigh,slow,length=20,_ts=None):373 latr = ATR(sclose,shigh,slow,length)374 return DIV(MUL1(latr,CBASE),sclose)375376377@indicator378def STREND(source,_ts=None):379 ''' 简单累积趋势2380 与strend相比,上升过程中,平也当作上,下降中平作下381 若当前趋势为上升或0,trend值为n>0382 则新trend值为:383 n+1 当前值 >= pre384 -1 当前值 < pre385 若当前趋势为下降,trend值为n(负数)386 则下一trend值为:387 n-1 当前值 <= pre388 1 当前值 > pre389 0为初始趋势(缺少判断时)390 '''391 if len(source) == 0:392 return []393394 if not _ts.initialized:395 _ts.initialized = True396 _ts.sd = [0] #第一个是无趋势397398 slen = len(_ts.sd)399 scur = _ts.sd[-1]400 vpre = source[slen-1]401 for i in range(slen,len(source)):402 vcur = source[i]403 if vcur > vpre:404 scur = scur + 1 if scur > 0 else 1405 elif vcur < vpre:406 scur = scur - 1 if scur < 0 else -1407 else: #curv == pre_v408 scur = scur + 1 if scur >= 0 else scur-1 #最初为0时,也算上升409 _ts.sd.append(scur)410 vpre = vcur411 return _ts.sd412 413414#TMAX,TMIN,UCROSS,DCROSS415@indicator416def TMM(source,covered,vmm,fcmp,fgroup,_ts=None):417 ''' 418 vmm: 比较用的极值419 fcmp: 比较函数420 fgroup:整体比较函数421422 cover=0时,返回的是截止到当前元素的最值(cover<0也如此)423 '''424 assert covered >=0, 'TMM: cover <0'425 if len(source) == 0:426 return []427428 if not _ts.initialized:429 _ts.initialized = True430 #print 'new tmm'431 _ts.tmm = [] #第一个是无趋势432 _ts.buffer = None433434 slen = len(source)435 pre_len = slen if slen <= covered else covered436 cmm = _ts.tmm[-1] if _ts.tmm else vmm437 for i in range(len(_ts.tmm),pre_len):438 if fcmp(source[i],cmm):439 cmm = source[i]440 _ts.tmm.append(cmm)441 if slen <= covered:442 return _ts.tmm443 tlen = len(_ts.tmm)444 if _ts.buffer:445 buffer = _ts.buffer446 else:447 buffer = _ts.buffer = deque(source[tlen-covered:tlen]) 448 #print 'in tmm:tlen=%s,len(source)=%s' % (tlen,len(source))449 for i in range(tlen,len(source)):450 v = source[i]451 buffer.append(v)452 vquit=buffer.popleft()453 if fcmp(v,cmm):454 cmm = v455 if cmm == vquit and v != cmm: #退出的正好是最大值,计算前covered-1个元素的最大值, pre=source[i-1]456 #cmm = fgroup(source[i-covered+1:i+1])457 cmm = fgroup(buffer)458 _ts.tmm.append(cmm)459 return _ts.tmm460461TMAX = fcustom(TMM,vmm=-99999999,fcmp=operator.gt,fgroup=max)462TMIN = fcustom(TMM,vmm=99999999,fcmp=operator.lt,fgroup=min)463464@indicator465def NMM(source,vmm,fcmp,_ts=None):466 '''467 从index0算起的极值.468 相当于covered取最大值时的TMM469 '''470 if len(source) == 0:471 return []472473 if not _ts.initialized:474 _ts.initialized = True475 #print 'new nmm'476 _ts.nmm = [] #第一个是无趋势477478 slen = len(source)479 cmm = _ts.nmm[-1] if _ts.nmm else vmm480 for i in range(len(_ts.nmm),len(source)):481 if fcmp(source[i],cmm):482 cmm = source[i]483 _ts.nmm.append(cmm)484 return _ts.nmm485NMAX = fcustom(NMM,vmm=-99999999,fcmp=operator.gt)486NMIN = fcustom(NMM,vmm=99999999,fcmp=operator.lt)487488489@indicator490def CROSS(source1,source2,rcmp,_ts=None):491 '''492 source2去交叉source1493 rcmp为判断已交叉状态的函数494 返回值中,0为未×,1为×495 '''496 if len(source1) == 0:497 return []498499 if not _ts.initialized:500 _ts.initialized = True501 _ts.crs = [1 if rcmp(source2[0],source1[0]) else 0] #第一个取决于状态,如果为已×,则为1502503 ps = _ts.crs[-1]504 for i in range(len(_ts.crs),len(source1)):505 cs = rcmp(source2[i],source1[i])506 _ts.crs.append(1 if not ps and cs else 0)507 ps = cs508 return _ts.crs509510UPCROSS = fcustom(CROSS,rcmp = operator.gt) #追击-平-平-超越,以及超越-平-超越均算×511DOWNCROSS = fcustom(CROSS,rcmp = operator.lt) #追击-平-平-超越,以及超越-平-超越均算×512513@indicator514def NCROSS(source,target,rcmp,_ts=None):515 '''516 source去交叉target, target为数字517 rcmp为判断已交叉状态的函数518 返回值中,0为未×,1为×519 '''520 if len(source) == 0:521 return []522523 if not _ts.initialized:524 _ts.initialized = True525 _ts.crs = [1 if rcmp(source[0],target) else 0] #第一个取决于状态,如果为已×,则为1526527 ps = _ts.crs[-1]528 for i in range(len(_ts.crs),len(source)):529 cs = rcmp(source[i],target)530 _ts.crs.append(1 if not ps and cs else 0)531 ps = cs532 return _ts.crs533534NUPCROSS = fcustom(NCROSS,rcmp = operator.gt) #追击-平-平-超越,以及超越-平-超越均算×535NDOWNCROSS = fcustom(NCROSS,rcmp = operator.lt) #追击-平-平-超越,以及超越-平-超越均算×536537538@indicator539def REF(source,offset=1,_ts=None):540 '''541 取得偏移为offset的序列542 前offset部分用第一元素填充543 如果仅用于比较,不建议用这个函数,而直接用[-1]下标比较544 只有在偏移CROSS时才有意义545 '''546 if len(source) == 0:547 return []548549 if not _ts.initialized:550 _ts.initialized = True551 _ts.ref = [source[0]]552 #print 'initialize REF'553 554 for i in range(len(_ts.ref),offset if offset <= len(source) else len(source)):555 _ts.ref.append(source[0])556557 for i in range(len(_ts.ref),len(source)):558 _ts.ref.append(source[i-offset])559560 return _ts.ref561562NullMinute = BaseObject(sopen=[],sclose=[],shigh=[],slow=[],svol=[],iorder=[],sholding=[])563564@indicator565def MINUTE(ticks,pre_min1=None,t2order=t2order_if,_ts=None):566 '''567 分钟切分568 这个实现的最大问题是未处理最后一分钟的收尾569 但这种场景仅用于保存数据, 可以在使用MINUTE之后, 由特别的语句去判断最后一个tick,并收尾最后一分钟570571 pre_min1为默认时,只能用当日分钟572 反之延续之前的分钟573 '''574575 if len(ticks) == 0:576 return NullMinute577578 if not _ts.initialized:579 _ts.initialized = True580 if pre_min1 == None: #不接续581 _ts.sopen = []582 _ts.sclose = []583 _ts.shigh = []584 _ts.slow = []585 _ts.svol = []586 _ts.sholding=[]587 _ts.iorder = []588 _ts.min1 = []589 else:590 _ts.sopen = pre_min1.sopen591 _ts.sclose = pre_min1.sclose592 _ts.shigh = pre_min1.shigh593 _ts.slow = pre_min1.slow594 _ts.svol = pre_min1.svol595 _ts.sholding=pre_min1.sholding596 _ts.iorder = pre_min1.iorder597 _ts.min1 = pre_min1.min1598 _ts.cur = BaseObject(vopen = ticks[0].price, 599 vclose = ticks[0].price, 600 vhigh=ticks[0].price, 601 vlow=ticks[0].price, 602 open_dvol=ticks[0].dvolume,#存在初始误差603 close_dvol=ticks[0].dvolume,604 holding = ticks[0].holding,605 min1=ticks[0].min1, #当日第一min1606 iorder=t2order[ticks[0].min1]607 ) #这里对dvol的处理,使得中断恢复也必须从当日最开始开始,否则所有前述成交量被归结到第一tick608 _ts.ilast = 0609 _ts.modified = False #上周期完成标志610611 scur = _ts.cur612 for i in range(_ts.ilast,len(ticks)):613 tcur = ticks[i]614 #if tcur.min1 != scur.min1: #切换615 if tcur.min1 > scur.min1: #切换, 避免ticks数据错误引发分钟序列紊乱,如20120905:958:59:500插入在20120905:959:00:00之后,虽然非常罕见,但会导致分钟序列出现958->959->958->959...这个情况616 _ts.sopen.append(scur.vopen)617 _ts.sclose.append(scur.vclose)618 _ts.shigh.append(scur.vhigh)619 _ts.slow.append(scur.vlow)620 _ts.svol.append(scur.close_dvol - scur.open_dvol)621 _ts.sholding.append(scur.holding)622 _ts.min1.append(scur.min1)623 _ts.iorder.append(scur.iorder)624 scur.vopen = scur.vclose = scur.vhigh = scur.vlow = tcur.price625 scur.open_dvol = scur.close_dvol626 scur.close_dvol = tcur.dvolume627 scur.dvol = tcur.dvolume628 scur.holding = tcur.holding629 scur.min1 = tcur.min1630 scur.iorder = t2order[tcur.min1]631 _ts.modified = True632 else: #未切换633 scur.vclose = tcur.price634 scur.close_dvol = tcur.dvolume635 scur.holding = tcur.holding636 #print scur.min1,'close:',scur.vclose637 if tcur.price > scur.vhigh:638 scur.vhigh = tcur.price639 elif tcur.price < scur.vlow:640 scur.vlow = tcur.price641 _ts.modified = False642643 _ts.ilast = len(ticks)644 return _ts645646647##以下为确认周期结束的iorder函数648XS3 = lambda x:x%3==0 and x>0 ##914归入下一周期649XS5 = lambda x: x%5==0 and x>0 650XS10 = lambda x: x%10== 0 and x>0651XS15 = lambda x:x%15 == 0 and x>0652XS30 = lambda x:x%30 == 0 and x>0653XSDAY = lambda x:x == 270654655NullXMinute = BaseObject(sopen=[],sclose=[],shigh=[],slow=[],svol=[],iorder=[],sholding=[])656657@indicator658def XMINUTE(m1,sfunc,_ts=None):659 '''660 1分钟以上周期661 sfunc为确认周期结束的点662 '''663664 if len(m1.sclose) == 0:665 return NullXMinute666667 if not _ts.initialized:668 _ts.initialized = True669 _ts.sopen = []670 _ts.sclose = []671 _ts.shigh = []672 _ts.slow = []673 _ts.svol = []674 _ts.sholding=[]675 _ts.iorder = []676 _ts.xmin = [] #开盘分钟677 _ts.cur = BaseObject(vopen = 0,678 vclose = 0,679 vhigh=0,680 vlow=99999999,681 xmin =0, 682 svol=0,683 holding=0,684 iorder=0,685 ) 686 _ts.ilast = 0687 _ts.modified = False #上周期完成标志688689 scur = _ts.cur690 for i in range(_ts.ilast,len(m1.sclose)):691 morder = m1.iorder[i]692 if scur.vopen == 0:693 scur.vopen = m1.sopen[i]694 scur.xmin = m1.min1[i]695 scur.vclose = m1.sclose[i]696 scur.svol += m1.svol[i]697 scur.holding = m1.sholding[i]698 if m1.shigh[i] > scur.vhigh:699 scur.vhigh = m1.shigh[i]700 if m1.slow[i] < scur.vlow:701 scur.vlow = m1.slow[i]702 _ts.modified = False703 if sfunc(morder): #切换704 _ts.sopen.append(scur.vopen)705 _ts.sclose.append(scur.vclose)706 _ts.shigh.append(scur.vhigh)707 _ts.slow.append(scur.vlow)708 _ts.svol.append(scur.svol)709 _ts.sholding.append(scur.holding)710 _ts.iorder.append(scur.iorder)711 _ts.xmin.append(scur.xmin)712713 scur.vopen = 0714 scur.vclose = 0715 scur.vhigh = 0716 scur.vlow = 99999999717 scur.svol = 0718 scur.xmin = 0719 scur.holding = 0720 scur.iorder += 1721 _ts.modified = True722723 _ts.ilast = len(m1.sclose)724 return _ts725726MINUTE3 = fcustom(XMINUTE,sfunc=XS3) 727MINUTE5 = fcustom(XMINUTE,sfunc=XS5) 728MINUTE10 = fcustom(XMINUTE,sfunc=XS10) 729MINUTE15 = fcustom(XMINUTE,sfunc=XS15) 730MINUTE30 = fcustom(XMINUTE,sfunc=XS30) 731MINUTED = fcustom(XMINUTE,sfunc=XSDAY) ...

Full Screen

Full Screen

node.d.ts

Source:node.d.ts Github

copy

Full Screen

...48export declare function isExportDeclaration(node: ts.Node): node is ts.ExportDeclaration;49export declare function isExportSpecifier(node: ts.Node): node is ts.ExportSpecifier;50export declare function isExpression(node: ts.Node): node is ts.Expression;51export declare function isExpressionStatement(node: ts.Node): node is ts.ExpressionStatement;52export declare function isExpressionWithTypeArguments(node: ts.Node): node is ts.ExpressionWithTypeArguments;53export declare function isExternalModuleReference(node: ts.Node): node is ts.ExternalModuleReference;54export declare function isForInStatement(node: ts.Node): node is ts.ForInStatement;55export declare function isForInOrOfStatement(node: ts.Node): node is ts.ForInOrOfStatement;56export declare function isForOfStatement(node: ts.Node): node is ts.ForOfStatement;57export declare function isForStatement(node: ts.Node): node is ts.ForStatement;58export declare function isFunctionDeclaration(node: ts.Node): node is ts.FunctionDeclaration;59export declare function isFunctionExpression(node: ts.Node): node is ts.FunctionExpression;60export declare function isFunctionTypeNode(node: ts.Node): node is ts.FunctionTypeNode;61export declare function isGetAccessorDeclaration(node: ts.Node): node is ts.GetAccessorDeclaration;62export declare function isIdentifier(node: ts.Node): node is ts.Identifier;63export declare function isIfStatement(node: ts.Node): node is ts.IfStatement;64export declare function isImportClause(node: ts.Node): node is ts.ImportClause;65export declare function isImportDeclaration(node: ts.Node): node is ts.ImportDeclaration;66export declare function isImportEqualsDeclaration(node: ts.Node): node is ts.ImportEqualsDeclaration;67export declare function isImportSpecifier(node: ts.Node): node is ts.ImportSpecifier;68export declare function isIndexedAccessTypeNode(node: ts.Node): node is ts.IndexedAccessTypeNode;69export declare function isIndexSignatureDeclaration(node: ts.Node): node is ts.IndexSignatureDeclaration;70export declare function isInferTypeNode(node: ts.Node): node is ts.InferTypeNode;71export declare function isInterfaceDeclaration(node: ts.Node): node is ts.InterfaceDeclaration;72export declare function isIntersectionTypeNode(node: ts.Node): node is ts.IntersectionTypeNode;73export declare function isIterationStatement(node: ts.Node): node is ts.IterationStatement;74export declare function isJsDoc(node: ts.Node): node is ts.JSDoc;75export declare function isJsxAttribute(node: ts.Node): node is ts.JsxAttribute;76export declare function isJsxAttributeLike(node: ts.Node): node is ts.JsxAttributeLike;77export declare function isJsxAttributes(node: ts.Node): node is ts.JsxAttributes;78export declare function isJsxClosingElement(node: ts.Node): node is ts.JsxClosingElement;79export declare function isJsxClosingFragment(node: ts.Node): node is ts.JsxClosingFragment;80export declare function isJsxElement(node: ts.Node): node is ts.JsxElement;81export declare function isJsxExpression(node: ts.Node): node is ts.JsxExpression;82export declare function isJsxFragment(node: ts.Node): node is ts.JsxFragment;83export declare function isJsxOpeningElement(node: ts.Node): node is ts.JsxOpeningElement;84export declare function isJsxOpeningFragment(node: ts.Node): node is ts.JsxOpeningFragment;85export declare function isJsxOpeningLikeElement(node: ts.Node): node is ts.JsxOpeningLikeElement;86export declare function isJsxSelfClosingElement(node: ts.Node): node is ts.JsxSelfClosingElement;87export declare function isJsxSpreadAttribute(node: ts.Node): node is ts.JsxSpreadAttribute;88export declare function isJsxText(node: ts.Node): node is ts.JsxText;89export declare function isLabeledStatement(node: ts.Node): node is ts.LabeledStatement;90export declare function isLiteralExpression(node: ts.Node): node is ts.LiteralExpression;91export declare function isLiteralTypeNode(node: ts.Node): node is ts.LiteralTypeNode;92export declare function isMappedTypeNode(node: ts.Node): node is ts.MappedTypeNode;93export declare function isMetaProperty(node: ts.Node): node is ts.MetaProperty;94export declare function isMethodDeclaration(node: ts.Node): node is ts.MethodDeclaration;95export declare function isMethodSignature(node: ts.Node): node is ts.MethodSignature;96export declare function isModuleBlock(node: ts.Node): node is ts.ModuleBlock;97export declare function isModuleDeclaration(node: ts.Node): node is ts.ModuleDeclaration;98export declare function isNamedExports(node: ts.Node): node is ts.NamedExports;99export declare function isNamedImports(node: ts.Node): node is ts.NamedImports;100export declare function isNamespaceDeclaration(node: ts.Node): node is ts.NamespaceDeclaration;101export declare function isNamespaceImport(node: ts.Node): node is ts.NamespaceImport;102export declare function isNamespaceExportDeclaration(node: ts.Node): node is ts.NamespaceExportDeclaration;103export declare function isNewExpression(node: ts.Node): node is ts.NewExpression;104export declare function isNonNullExpression(node: ts.Node): node is ts.NonNullExpression;105export declare function isNoSubstitutionTemplateLiteral(node: ts.Node): node is ts.NoSubstitutionTemplateLiteral;106export declare function isNullLiteral(node: ts.Node): node is ts.NullLiteral;107export declare function isNumericLiteral(node: ts.Node): node is ts.NumericLiteral;108export declare function isNumericOrStringLikeLiteral(node: ts.Node): node is ts.NumericLiteral | ts.StringLiteral | ts.NoSubstitutionTemplateLiteral;109export declare function isObjectBindingPattern(node: ts.Node): node is ts.ObjectBindingPattern;110export declare function isObjectLiteralExpression(node: ts.Node): node is ts.ObjectLiteralExpression;111export declare function isOmittedExpression(node: ts.Node): node is ts.OmittedExpression;112export declare function isParameterDeclaration(node: ts.Node): node is ts.ParameterDeclaration;113export declare function isParenthesizedExpression(node: ts.Node): node is ts.ParenthesizedExpression;...

Full Screen

Full Screen

typeguard.d.ts

Source:typeguard.d.ts Github

copy

Full Screen

...41export declare function isExportAssignment(node: ts.Node): node is ts.ExportAssignment;42export declare function isExportDeclaration(node: ts.Node): node is ts.ExportDeclaration;43export declare function isExportSpecifier(node: ts.Node): node is ts.ExportSpecifier;44export declare function isExpressionStatement(node: ts.Node): node is ts.ExpressionStatement;45export declare function isExpressionWithTypeArguments(node: ts.Node): node is ts.ExpressionWithTypeArguments;46export declare function isExternalModuleReference(node: ts.Node): node is ts.ExternalModuleReference;47export declare function isForInStatement(node: ts.Node): node is ts.ForInStatement;48export declare function isForOfStatement(node: ts.Node): node is ts.ForOfStatement;49export declare function isForStatement(node: ts.Node): node is ts.ForStatement;50export declare function isFunctionDeclaration(node: ts.Node): node is ts.FunctionDeclaration;51export declare function isFunctionExpression(node: ts.Node): node is ts.FunctionExpression;52export declare function isFunctionTypeNode(node: ts.Node): node is ts.FunctionTypeNode;53export declare function isGetAccessorDeclaration(node: ts.Node): node is ts.GetAccessorDeclaration;54export declare function isIdentifier(node: ts.Node): node is ts.Identifier;55export declare function isIfStatement(node: ts.Node): node is ts.IfStatement;56export declare function isImportClause(node: ts.Node): node is ts.ImportClause;57export declare function isImportDeclaration(node: ts.Node): node is ts.ImportDeclaration;58export declare function isImportEqualsDeclaration(node: ts.Node): node is ts.ImportEqualsDeclaration;59export declare function isImportSpecifier(node: ts.Node): node is ts.ImportSpecifier;60export declare function isIndexedAccessTypeNode(node: ts.Node): node is ts.IndexedAccessTypeNode;61export declare function isIndexSignatureDeclaration(node: ts.Node): node is ts.IndexSignatureDeclaration;62export declare function isInterfaceDeclaration(node: ts.Node): node is ts.InterfaceDeclaration;63export declare function isIntersectionTypeNode(node: ts.Node): node is ts.IntersectionTypeNode;64export declare function isIterationStatement(node: ts.Node): node is ts.IterationStatement;65export declare function isJsxAttribute(node: ts.Node): node is ts.JsxAttribute;66export declare function isJsxAttributeLike(node: ts.Node): node is ts.JsxAttributeLike;67export declare function isJsxAttributes(node: ts.Node): node is ts.JsxAttributes;68export declare function isJsxClosingElement(node: ts.Node): node is ts.JsxClosingElement;69export declare function isJsxElement(node: ts.Node): node is ts.JsxElement;70export declare function isJsxExpression(node: ts.Node): node is ts.JsxExpression;71export declare function isJsxOpeningElement(node: ts.Node): node is ts.JsxOpeningElement;72export declare function isJsxOpeningLikeElement(node: ts.Node): node is ts.JsxOpeningLikeElement;73export declare function isJsxSelfClosingElement(node: ts.Node): node is ts.JsxSelfClosingElement;74export declare function isJsxSpreadAttribute(node: ts.Node): node is ts.JsxSpreadAttribute;75export declare function isJsxText(node: ts.Node): node is ts.JsxText;76export declare function isLabeledStatement(node: ts.Node): node is ts.LabeledStatement;77export declare function isLiteralExpression(node: ts.Node): node is ts.LiteralExpression;78export declare function isMetaProperty(node: ts.Node): node is ts.MetaProperty;79export declare function isMethodDeclaration(node: ts.Node): node is ts.MethodDeclaration;80export declare function isMethodSignature(node: ts.Node): node is ts.MethodSignature;81export declare function isModuleBlock(node: ts.Node): node is ts.ModuleBlock;82export declare function isModuleDeclaration(node: ts.Node): node is ts.ModuleDeclaration;83export declare function isNamedExports(node: ts.Node): node is ts.NamedExports;84export declare function isNamedImports(node: ts.Node): node is ts.NamedImports;85export declare function isNamespaceDeclaration(node: ts.Node): node is ts.NamespaceDeclaration;86export declare function isNamespaceImport(node: ts.Node): node is ts.NamespaceImport;87export declare function isNamespaceExportDeclaration(node: ts.Node): node is ts.NamespaceExportDeclaration;88export declare function isNewExpression(node: ts.Node): node is ts.NewExpression;89export declare function isNonNullExpression(node: ts.Node): node is ts.NonNullExpression;90export declare function isNoSubstitutionTemplateLiteral(node: ts.Node): node is ts.NoSubstitutionTemplateLiteral;91export declare function isNumericLiteral(node: ts.Node): node is ts.NumericLiteral;92export declare function isNumericliteral(node: ts.Node): node is ts.NumericLiteral;93export declare function isObjectBindingPattern(node: ts.Node): node is ts.ObjectBindingPattern;94export declare function isObjectLiteralExpression(node: ts.Node): node is ts.ObjectLiteralExpression;95export declare function isOmittedExpression(node: ts.Node): node is ts.OmittedExpression;96export declare function isParameterDeclaration(node: ts.Node): node is ts.ParameterDeclaration;97export declare function isParenthesizedExpression(node: ts.Node): node is ts.ParenthesizedExpression;98export declare function isPostfixUnaryExpression(node: ts.Node): node is ts.PostfixUnaryExpression;...

Full Screen

Full Screen

test_structmembers.py

Source:test_structmembers.py Github

copy

Full Screen

...22 9.99999,# T_FLOAT23 10.1010101010, # T_DOUBLE24 "hi" # T_STRING_INPLACE25 )26class ReadWriteTests(unittest.TestCase):27 def test_bool(self):28 ts.T_BOOL = True29 self.assertEqual(ts.T_BOOL, True)30 ts.T_BOOL = False31 self.assertEqual(ts.T_BOOL, False)32 self.assertRaises(TypeError, setattr, ts, 'T_BOOL', 1)33 def test_byte(self):34 ts.T_BYTE = CHAR_MAX35 self.assertEqual(ts.T_BYTE, CHAR_MAX)36 ts.T_BYTE = CHAR_MIN37 self.assertEqual(ts.T_BYTE, CHAR_MIN)38 ts.T_UBYTE = UCHAR_MAX39 self.assertEqual(ts.T_UBYTE, UCHAR_MAX)40 def test_short(self):41 ts.T_SHORT = SHRT_MAX42 self.assertEqual(ts.T_SHORT, SHRT_MAX)43 ts.T_SHORT = SHRT_MIN44 self.assertEqual(ts.T_SHORT, SHRT_MIN)45 ts.T_USHORT = USHRT_MAX46 self.assertEqual(ts.T_USHORT, USHRT_MAX)47 def test_int(self):48 ts.T_INT = INT_MAX49 self.assertEqual(ts.T_INT, INT_MAX)50 ts.T_INT = INT_MIN51 self.assertEqual(ts.T_INT, INT_MIN)52 ts.T_UINT = UINT_MAX53 self.assertEqual(ts.T_UINT, UINT_MAX)54 def test_long(self):55 ts.T_LONG = LONG_MAX56 self.assertEqual(ts.T_LONG, LONG_MAX)57 ts.T_LONG = LONG_MIN58 self.assertEqual(ts.T_LONG, LONG_MIN)59 ts.T_ULONG = ULONG_MAX60 self.assertEqual(ts.T_ULONG, ULONG_MAX)61 def test_py_ssize_t(self):62 ts.T_PYSSIZET = PY_SSIZE_T_MAX63 self.assertEqual(ts.T_PYSSIZET, PY_SSIZE_T_MAX)64 ts.T_PYSSIZET = PY_SSIZE_T_MIN65 self.assertEqual(ts.T_PYSSIZET, PY_SSIZE_T_MIN)66 @unittest.skipUnless(hasattr(ts, "T_LONGLONG"), "long long not present")67 def test_longlong(self):68 ts.T_LONGLONG = LLONG_MAX69 self.assertEqual(ts.T_LONGLONG, LLONG_MAX)70 ts.T_LONGLONG = LLONG_MIN71 self.assertEqual(ts.T_LONGLONG, LLONG_MIN)72 ts.T_ULONGLONG = ULLONG_MAX73 self.assertEqual(ts.T_ULONGLONG, ULLONG_MAX)74 ## make sure these will accept a plain int as well as a long75 ts.T_LONGLONG = 376 self.assertEqual(ts.T_LONGLONG, 3)77 ts.T_ULONGLONG = 478 self.assertEqual(ts.T_ULONGLONG, 4)79 def test_bad_assignments(self):80 integer_attributes = [81 'T_BOOL',82 'T_BYTE', 'T_UBYTE',83 'T_SHORT', 'T_USHORT',84 'T_INT', 'T_UINT',85 'T_LONG', 'T_ULONG',86 'T_PYSSIZET'87 ]88 if hasattr(ts, 'T_LONGLONG'):89 integer_attributes.extend(['T_LONGLONG', 'T_ULONGLONG'])90 # issue8014: this produced 'bad argument to internal function'91 # internal error92 for nonint in None, 3.2j, "full of eels", {}, []:93 for attr in integer_attributes:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run yandex-tank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful