Best Python code snippet using pytest-mock
dataUnitTest.py
Source:dataUnitTest.py
1from unittest import TestCase,TestSuite2if '__package__' not in globals() or __package__ is None or len(__package__)==0:3 def _mimport(name,level):4 try:5 return __import__(name,globals())6 except:7 return __import__('MDSplus.'+name,globals())8else:9 def _mimport(name,level):10 try:11 return __import__(name,globals(),{},[],level)12 except ValueError:13 return __import__(name,globals())14_data=_mimport('data',2)15for _item in _data.__dict__.keys():16 try:17 if issubclass(_data.__dict__[_item],_data.Data):18 globals()[_item]=_data.__dict__[_item]19 except:20 pass21_tree=_mimport('tree',2)22for _item in _tree.__dict__.keys():23 try:24 if issubclass(_tree.__dict__[_item],_data.Data):25 globals()[_item]=_tree.__dict__[_item]26 except:27 pass28import numpy29class dataTests(TestCase):30 def setUp(self):31 pass32 def basicBinaryOperators(self):33 def doit(operator,x,y,ans):34 z=eval('x'+operator+'y')35 check=None36 try:37 check=z==ans38 except:39 pass40 if isinstance(check,numpy.ndarray):41 self.assertEqual(check.all(),True)42 else:43 self.assertEqual(z,ans)44 self.assertEqual(type(z),type(ans))45 return46 doit('+',Uint8(30),Uint8(2),Uint8(32))47 doit('-',Uint8(30),Uint8(2),Uint8(28))48 doit('*',Uint8(30),Uint8(2),Uint8(60))49 doit('/',Uint8(30),Uint8(2),Uint8(15))50 doit('|',Uint8(4),Uint8(1),Uint8(5))51 doit('&',Uint8(255),Uint8(6),Uint8(6))52 doit('>',Uint8(4),Uint8(1),True)53 doit('>=',Uint8(4),Uint8(1),True)54 doit('<',Uint8(4),Uint8(1),False)55 doit('<=',Uint8(4),Uint8(1),False)56 doit('==',Uint8(4),Uint8(1),False)57 doit('!=',Uint8(4),Uint8(1),True)58 doit('<<',Uint8(1),Uint8(3),Uint8(8))59 doit('>>',Uint8(16),Uint8(3),Uint8(2))60 doit('+',Uint16(30),Uint16(2),Uint16(32))61 doit('-',Uint16(30),Uint16(2),Uint16(28))62 doit('*',Uint16(30),Uint16(2),Uint16(60))63 doit('/',Uint16(30),Uint16(2),Uint16(15))64 doit('|',Uint16(4),Uint16(1),Uint16(5))65 doit('&',Uint16(255),Uint16(6),Uint16(6))66 doit('>',Uint16(4),Uint16(1),True)67 doit('>=',Uint16(4),Uint16(1),True)68 doit('<',Uint16(4),Uint16(1),False)69 doit('<=',Uint16(4),Uint16(1),False)70 doit('==',Uint16(4),Uint16(1),False)71 doit('!=',Uint16(4),Uint16(1),True)72 doit('<<',Uint16(1),Uint16(3),Uint16(8))73 doit('>>',Uint16(16),Uint16(3),Uint16(2))74 doit('+',Uint32(30),Uint32(2),Uint32(32))75 doit('-',Uint32(30),Uint32(2),Uint32(28))76 doit('*',Uint32(30),Uint32(2),Uint32(60))77 doit('/',Uint32(30),Uint32(2),Uint32(15))78 doit('|',Uint32(4),Uint32(1),Uint32(5))79 doit('&',Uint32(255),Uint32(6),Uint32(6))80 doit('>',Uint32(4),Uint32(1),True)81 doit('>=',Uint32(4),Uint32(1),True)82 doit('<',Uint32(4),Uint32(1),False)83 doit('<=',Uint32(4),Uint32(1),False)84 doit('==',Uint32(4),Uint32(1),False)85 doit('!=',Uint32(4),Uint32(1),True)86 doit('<<',Uint32(1),Uint32(3),Uint32(8))87 doit('>>',Uint32(16),Uint32(3),Uint32(2))88 doit('+',Uint64(30),Uint64(2),Uint64(32))89 doit('-',Uint64(30),Uint64(2),Uint64(28))90 doit('*',Uint64(30),Uint64(2),Uint64(60))91 doit('/',Uint64(30),Uint64(2),Uint64(15))92 doit('|',Uint64(4),Uint64(1),Uint64(5))93 doit('&',Uint64(255),Uint64(6),Uint64(6))94 doit('>',Uint64(4),Uint64(1),True)95 doit('>=',Uint64(4),Uint64(1),True)96 doit('<',Uint64(4),Uint64(1),False)97 doit('<=',Uint64(4),Uint64(1),False)98 doit('==',Uint64(4),Uint64(1),False)99 doit('!=',Uint64(4),Uint64(1),True)100 doit('<<',Uint64(1),Uint64(3),Uint64(8))101 doit('>>',Uint64(16),Uint64(3),Uint64(2))102 doit('+',Int8(30),Int8(2),Int8(32))103 doit('-',Int8(30),Int8(2),Int8(28))104 doit('*',Int8(30),Int8(2),Int8(60))105 doit('/',Int8(30),Int8(2),Int8(15))106 doit('|',Int8(4),Int8(1),Uint8(5))107 doit('&',Int8(255),Int8(6),Uint8(6))108 doit('>',Int8(4),Int8(1),True)109 doit('>=',Int8(4),Int8(1),True)110 doit('<',Int8(4),Int8(1),False)111 doit('<=',Int8(4),Int8(1),False)112 doit('==',Int8(4),Int8(1),False)113 doit('!=',Int8(4),Int8(1),True)114 doit('<<',Int8(1),Int8(3),Int8(8))115 doit('>>',Int8(16),Int8(3),Int8(2))116 doit('+',Int16(30),Int16(2),Int16(32))117 doit('-',Int16(30),Int16(2),Int16(28))118 doit('*',Int16(30),Int16(2),Int16(60))119 doit('/',Int16(30),Int16(2),Int16(15))120 doit('|',Int16(4),Int16(1),Uint16(5))121 doit('&',Int16(255),Int16(6),Uint16(6))122 doit('>',Int16(4),Int16(1),True)123 doit('>=',Int16(4),Int16(1),True)124 doit('<',Int16(4),Int16(1),False)125 doit('<=',Int16(4),Int16(1),False)126 doit('==',Int16(4),Int16(1),False)127 doit('!=',Int16(4),Int16(1),True)128 doit('<<',Int16(1),Int16(3),Int16(8))129 doit('>>',Int16(16),Int16(3),Int16(2))130 doit('+',Int32(30),Int32(2),Int32(32))131 doit('-',Int32(30),Int32(2),Int32(28))132 doit('*',Int32(30),Int32(2),Int32(60))133 doit('/',Int32(30),Int32(2),Int32(15))134 doit('|',Int32(4),Int32(1),Uint32(5))135 doit('&',Int32(255),Int32(6),Uint32(6))136 doit('>',Int32(4),Int32(1),True)137 doit('>=',Int32(4),Int32(1),True)138 doit('<',Int32(4),Int32(1),False)139 doit('<=',Int32(4),Int32(1),False)140 doit('==',Int32(4),Int32(1),False)141 doit('!=',Int32(4),Int32(1),True)142 doit('<<',Int32(1),Int32(3),Int32(8))143 doit('>>',Int32(16),Int32(3),Int32(2))144 doit('+',Int64(30),Int64(2),Int64(32))145 doit('-',Int64(30),Int64(2),Int64(28))146 doit('*',Int64(30),Int64(2),Int64(60))147 doit('/',Int64(30),Int64(2),Int64(15))148 doit('|',Int64(4),Int64(1),Uint64(5))149 doit('&',Int64(255),Int64(6),Uint64(6))150 doit('>',Int64(4),Int64(1),True)151 doit('>=',Int64(4),Int64(1),True)152 doit('<',Int64(4),Int64(1),False)153 doit('<=',Int64(4),Int64(1),False)154 doit('==',Int64(4),Int64(1),False)155 doit('!=',Int64(4),Int64(1),True)156 doit('<<',Int64(1),Int64(3),Int64(8))157 doit('>>',Int64(16),Int64(3),Int64(2))158 doit('+',Float32(30),Float32(2),Float32(32))159 doit('-',Float32(30),Float32(2),Float32(28))160 doit('*',Float32(30),Float32(2),Float32(60))161 doit('/',Float32(30),Float32(2),Float32(15))162 doit('|',Float32(4),Float32(1),Uint32(5))163 doit('&',Float32(255),Float32(6),Uint32(6))164 doit('>',Float32(4),Float32(1),True)165 doit('>=',Float32(4),Float32(1),True)166 doit('<',Float32(4),Float32(1),False)167 doit('<=',Float32(4),Float32(1),False)168 doit('==',Float32(4),Float32(1),False)169 doit('!=',Float32(4),Float32(1),True)170 doit('<<',Float32(1),Float32(3),Int32(8))171 doit('>>',Float32(16),Float32(3),Int32(2))172 doit('+',Float64(30),Float64(2),Float64(32))173 doit('-',Float64(30),Float64(2),Float64(28))174 doit('*',Float64(30),Float64(2),Float64(60))175 doit('/',Float64(30),Float64(2),Float64(15))176 doit('|',Float64(4),Float64(1),Uint64(5))177 doit('&',Float64(255),Float64(6),Uint64(6))178 doit('>',Float64(4),Float64(1),True)179 doit('>=',Float64(4),Float64(1),True)180 doit('<',Float64(4),Float64(1),False)181 doit('<=',Float64(4),Float64(1),False)182 doit('==',Float64(4),Float64(1),False)183 doit('!=',Float64(4),Float64(1),True)184 doit('<<',Float64(1),Float64(3),Int64(8))185 doit('>>',Float64(16),Float64(3),Int64(2))186 doit('+',Uint8Array([29,30,31]),Uint8(2),Uint8Array([31,32,33]))187 doit('-',Uint8Array([29,30,31]),Uint8(2),Uint8Array([27,28,29]))188 doit('*',Uint8Array([29,30,31]),Uint8(2),Uint8Array([58,60,62]))189 doit('/',Uint8Array([29,30,31]),Uint8(2),Uint8Array([14,15,15]))190 doit('|',Uint8Array([2,4,8]),Uint8(1),Uint8Array([3,5,9]))191 doit('&',Uint8Array([3,7,255]),Uint8(6),Uint8Array([2,6,6]))192 doit('>',Uint8Array([2,4,8]),Uint8(4),numpy.array([False,False,True]))193 doit('>=',Uint8Array([2,4,8]),Uint8(4),numpy.array([False,True,True]))194 doit('<',Uint8Array([2,4,8]),Uint8(4),numpy.array([True,False,False]))195 doit('<=',Uint8Array([2,4,8]),Uint8(4),numpy.array([True,True,False]))196 doit('==',Uint8Array([2,4,8]),Uint8(4),numpy.array([False,True,False]))197 doit('!=',Uint8Array([2,4,8]),Uint8(4),numpy.array([True,False,True]))198 doit('<<',Uint8Array([1,2,4]),Uint8(3),Uint8Array([8,16,32]))199 doit('>>',Uint8Array([8,16,32]),Uint8(3),Uint8Array([1,2,4]))200 doit('+',Uint16Array([29,30,31]),Uint16(2),Uint16Array([31,32,33]))201 doit('-',Uint16Array([29,30,31]),Uint16(2),Uint16Array([27,28,29]))202 doit('*',Uint16Array([29,30,31]),Uint16(2),Uint16Array([58,60,62]))203 doit('/',Uint16Array([29,30,31]),Uint16(2),Uint16Array([14,15,15]))204 doit('|',Uint16Array([2,4,8]),Uint16(1),Uint16Array([3,5,9]))205 doit('&',Uint16Array([3,7,255]),Uint16(6),Uint16Array([2,6,6]))206 doit('>',Uint16Array([2,4,8]),Uint16(4),numpy.array([False,False,True]))207 doit('>=',Uint16Array([2,4,8]),Uint16(4),numpy.array([False,True,True]))208 doit('<',Uint16Array([2,4,8]),Uint16(4),numpy.array([True,False,False]))209 doit('<=',Uint16Array([2,4,8]),Uint16(4),numpy.array([True,True,False]))210 doit('==',Uint16Array([2,4,8]),Uint16(4),numpy.array([False,True,False]))211 doit('!=',Uint16Array([2,4,8]),Uint16(4),numpy.array([True,False,True]))212 doit('<<',Uint16Array([1,2,4]),Uint16(3),Uint16Array([8,16,32]))213 doit('>>',Uint16Array([8,16,32]),Uint16(3),Uint16Array([1,2,4]))214 doit('+',Uint32Array([29,30,31]),Uint32(2),Uint32Array([31,32,33]))215 doit('-',Uint32Array([29,30,31]),Uint32(2),Uint32Array([27,28,29]))216 doit('*',Uint32Array([29,30,31]),Uint32(2),Uint32Array([58,60,62]))217 doit('/',Uint32Array([29,30,31]),Uint32(2),Uint32Array([14,15,15]))218 doit('|',Uint32Array([2,4,8]),Uint32(1),Uint32Array([3,5,9]))219 doit('&',Uint32Array([3,7,255]),Uint32(6),Uint32Array([2,6,6]))220 doit('>',Uint32Array([2,4,8]),Uint32(4),numpy.array([False,False,True]))221 doit('>=',Uint32Array([2,4,8]),Uint32(4),numpy.array([False,True,True]))222 doit('<',Uint32Array([2,4,8]),Uint32(4),numpy.array([True,False,False]))223 doit('<=',Uint32Array([2,4,8]),Uint32(4),numpy.array([True,True,False]))224 doit('==',Uint32Array([2,4,8]),Uint32(4),numpy.array([False,True,False]))225 doit('!=',Uint32Array([2,4,8]),Uint32(4),numpy.array([True,False,True]))226 doit('<<',Uint32Array([1,2,4]),Uint32(3),Uint32Array([8,16,32]))227 doit('>>',Uint32Array([8,16,32]),Uint32(3),Uint32Array([1,2,4]))228 doit('+',Uint64Array([29,30,31]),Uint64(2),Uint64Array([31,32,33]))229 doit('-',Uint64Array([29,30,31]),Uint64(2),Uint64Array([27,28,29]))230 doit('*',Uint64Array([29,30,31]),Uint64(2),Uint64Array([58,60,62]))231 doit('/',Uint64Array([29,30,31]),Uint64(2),Uint64Array([14,15,15]))232 doit('|',Uint64Array([2,4,8]),Uint64(1),Uint64Array([3,5,9]))233 doit('&',Uint64Array([3,7,255]),Uint64(6),Uint64Array([2,6,6]))234 doit('>',Uint64Array([2,4,8]),Uint64(4),numpy.array([False,False,True]))235 doit('>=',Uint64Array([2,4,8]),Uint64(4),numpy.array([False,True,True]))236 doit('<',Uint64Array([2,4,8]),Uint64(4),numpy.array([True,False,False]))237 doit('<=',Uint64Array([2,4,8]),Uint64(4),numpy.array([True,True,False]))238 doit('==',Uint64Array([2,4,8]),Uint64(4),numpy.array([False,True,False]))239 doit('!=',Uint64Array([2,4,8]),Uint64(4),numpy.array([True,False,True]))240 doit('<<',Uint64Array([1,2,4]),Uint64(3),Uint64Array([8,16,32]))241 doit('>>',Uint64Array([8,16,32]),Uint64(3),Uint64Array([1,2,4]))242 doit('+',Int8Array([29,30,31]),Int8(2),Int8Array([31,32,33]))243 doit('-',Int8Array([29,30,31]),Int8(2),Int8Array([27,28,29]))244 doit('*',Int8Array([29,30,31]),Int8(2),Int8Array([58,60,62]))245 doit('/',Int8Array([29,30,31]),Int8(2),Int8Array([14,15,15]))246 doit('|',Int8Array([2,4,8]),Int8(1),Uint8Array([3,5,9]))247 doit('&',Int8Array([3,7,255]),Int8(6),Uint8Array([2,6,6]))248 doit('>',Int8Array([2,4,8]),Int8(4),numpy.array([False,False,True]))249 doit('>=',Int8Array([2,4,8]),Int8(4),numpy.array([False,True,True]))250 doit('<',Int8Array([2,4,8]),Int8(4),numpy.array([True,False,False]))251 doit('<=',Int8Array([2,4,8]),Int8(4),numpy.array([True,True,False]))252 doit('==',Int8Array([2,4,8]),Int8(4),numpy.array([False,True,False]))253 doit('!=',Int8Array([2,4,8]),Int8(4),numpy.array([True,False,True]))254 doit('<<',Int8Array([1,2,4]),Int8(3),Int8Array([8,16,32]))255 doit('>>',Int8Array([8,16,32]),Int8(3),Int8Array([1,2,4]))256 doit('+',Int16Array([29,30,31]),Int16(2),Int16Array([31,32,33]))257 doit('-',Int16Array([29,30,31]),Int16(2),Int16Array([27,28,29]))258 doit('*',Int16Array([29,30,31]),Int16(2),Int16Array([58,60,62]))259 doit('/',Int16Array([29,30,31]),Int16(2),Int16Array([14,15,15]))260 doit('|',Int16Array([2,4,8]),Int16(1),Uint16Array([3,5,9]))261 doit('&',Int16Array([3,7,255]),Int16(6),Uint16Array([2,6,6]))262 doit('>',Int16Array([2,4,8]),Int16(4),numpy.array([False,False,True]))263 doit('>=',Int16Array([2,4,8]),Int16(4),numpy.array([False,True,True]))264 doit('<',Int16Array([2,4,8]),Int16(4),numpy.array([True,False,False]))265 doit('<=',Int16Array([2,4,8]),Int16(4),numpy.array([True,True,False]))266 doit('==',Int16Array([2,4,8]),Int16(4),numpy.array([False,True,False]))267 doit('!=',Int16Array([2,4,8]),Int16(4),numpy.array([True,False,True]))268 doit('<<',Int16Array([1,2,4]),Int16(3),Int16Array([8,16,32]))269 doit('>>',Int16Array([8,16,32]),Int16(3),Int16Array([1,2,4]))270 doit('+',Int32Array([29,30,31]),Int32(2),Int32Array([31,32,33]))271 doit('-',Int32Array([29,30,31]),Int32(2),Int32Array([27,28,29]))272 doit('*',Int32Array([29,30,31]),Int32(2),Int32Array([58,60,62]))273 doit('/',Int32Array([29,30,31]),Int32(2),Int32Array([14,15,15]))274 doit('|',Int32Array([2,4,8]),Int32(1),Uint32Array([3,5,9]))275 doit('&',Int32Array([3,7,255]),Int32(6),Uint32Array([2,6,6]))276 doit('>',Int32Array([2,4,8]),Int32(4),numpy.array([False,False,True]))277 doit('>=',Int32Array([2,4,8]),Int32(4),numpy.array([False,True,True]))278 doit('<',Int32Array([2,4,8]),Int32(4),numpy.array([True,False,False]))279 doit('<=',Int32Array([2,4,8]),Int32(4),numpy.array([True,True,False]))280 doit('==',Int32Array([2,4,8]),Int32(4),numpy.array([False,True,False]))281 doit('!=',Int32Array([2,4,8]),Int32(4),numpy.array([True,False,True]))282 doit('<<',Int32Array([1,2,4]),Int32(3),Int32Array([8,16,32]))283 doit('>>',Int32Array([8,16,32]),Int32(3),Int32Array([1,2,4]))284 doit('+',Int64Array([29,30,31]),Int64(2),Int64Array([31,32,33]))285 doit('-',Int64Array([29,30,31]),Int64(2),Int64Array([27,28,29]))286 doit('*',Int64Array([29,30,31]),Int64(2),Int64Array([58,60,62]))287 doit('/',Int64Array([29,30,31]),Int64(2),Int64Array([14,15,15]))288 doit('|',Int64Array([2,4,8]),Int64(1),Uint64Array([3,5,9]))289 doit('&',Int64Array([3,7,255]),Int64(6),Uint64Array([2,6,6]))290 doit('>',Int64Array([2,4,8]),Int64(4),numpy.array([False,False,True]))291 doit('>=',Int64Array([2,4,8]),Int64(4),numpy.array([False,True,True]))292 doit('<',Int64Array([2,4,8]),Int64(4),numpy.array([True,False,False]))293 doit('<=',Int64Array([2,4,8]),Int64(4),numpy.array([True,True,False]))294 doit('==',Int64Array([2,4,8]),Int64(4),numpy.array([False,True,False]))295 doit('!=',Int64Array([2,4,8]),Int64(4),numpy.array([True,False,True]))296 doit('<<',Int64Array([1,2,4]),Int64(3),Int64Array([8,16,32]))297 doit('>>',Int64Array([8,16,32]),Int64(3),Int64Array([1,2,4]))298 doit('+',Float32Array([29,30,31]),Float32(2),Float32Array([31,32,33]))299 doit('-',Float32Array([29,30,31]),Float32(2),Float32Array([27,28,29]))300 doit('*',Float32Array([29,30,31]),Float32(2),Float32Array([58,60,62]))301 doit('/',Float32Array([29,30,31]),Float32(2),Float32Array([14.5,15,15.5]))302 doit('|',Float32Array([2,4,8]),Float32(1),Uint32Array([3,5,9]))303 doit('&',Float32Array([3,7,255]),Float32(6),Uint32Array([2,6,6]))304 doit('>',Float32Array([2,4,8]),Float32(4),numpy.array([False,False,True]))305 doit('>=',Float32Array([2,4,8]),Float32(4),numpy.array([False,True,True]))306 doit('<',Float32Array([2,4,8]),Float32(4),numpy.array([True,False,False]))307 doit('<=',Float32Array([2,4,8]),Float32(4),numpy.array([True,True,False]))308 doit('==',Float32Array([2,4,8]),Float32(4),numpy.array([False,True,False]))309 doit('!=',Float32Array([2,4,8]),Float32(4),numpy.array([True,False,True]))310 doit('<<',Float32Array([1,2,4]),Float32(3),Int32Array([8,16,32]))311 doit('>>',Float32Array([8,16,32]),Float32(3),Int32Array([1,2,4]))312 doit('+',Float64Array([29,30,31]),Float64(2),Float64Array([31,32,33]))313 doit('-',Float64Array([29,30,31]),Float64(2),Float64Array([27,28,29]))314 doit('*',Float64Array([29,30,31]),Float64(2),Float64Array([58,60,62]))315 doit('/',Float64Array([29,30,31]),Float64(2),Float64Array([14.5,15,15.5]))316 doit('|',Float64Array([2,4,8]),Float64(1),Uint64Array([3,5,9]))317 doit('&',Float64Array([3,7,255]),Float64(6),Uint64Array([2,6,6]))318 doit('>',Float64Array([2,4,8]),Float64(4),numpy.array([False,False,True]))319 doit('>=',Float64Array([2,4,8]),Float64(4),numpy.array([False,True,True]))320 doit('<',Float64Array([2,4,8]),Float64(4),numpy.array([True,False,False]))321 doit('<=',Float64Array([2,4,8]),Float64(4),numpy.array([True,True,False]))322 doit('==',Float64Array([2,4,8]),Float64(4),numpy.array([False,True,False]))323 doit('!=',Float64Array([2,4,8]),Float64(4),numpy.array([True,False,True]))324 doit('<<',Float64Array([1,2,4]),Float64(3),Int64Array([8,16,32]))325 doit('>>',Float64Array([8,16,32]),Float64(3),Int64Array([1,2,4]))326 doit('+',Int64Array([29,30,31]),Int64Array([2,3,4]),Int64Array([31,33,35]))327 doit('-',Int64Array([29,30,31]),Int64Array([2,3,4]),Int64Array([27,27,27]))328 doit('*',Int64Array([29,30,31]),Int64Array([2,3,4]),Int64Array([58,90,124]))329 doit('/',Int64Array([29,30,31]),Int64Array([2,3,4]),Int64Array([14,10,7]))330 doit('|',Int64Array([2,4,8]),Int64Array([1,2,3]),Uint64Array([3,6,11]))331 doit('&',Int64Array([3,7,255]),Int64Array([6,4,7]),Uint64Array([2,4,7]))332 doit('>',Int64Array([2,4,8]),Int64Array([3,4,5]),numpy.array([False,False,True]))333 doit('>=',Int64Array([2,4,8]),Int64Array([3,4,5]),numpy.array([False,True,True]))334 doit('<',Int64Array([2,4,8]),Int64Array([3,4,5]),numpy.array([True,False,False]))335 doit('<=',Int64Array([2,4,8]),Int64Array([3,4,5]),numpy.array([True,True,False]))336 doit('==',Int64Array([2,4,8]),Int64Array([3,4,5]),numpy.array([False,True,False]))337 doit('!=',Int64Array([2,4,8]),Int64Array([3,4,5]),numpy.array([True,False,True]))338 doit('<<',Int64Array([1,2,4]),Int64Array([3,4,5]),Int64Array([8,32,128]))339 doit('>>',Int64Array([8,16,32]),Int64Array([3,2,1]),Int64Array([1,4,16]))340 doit('+',Signal(Int64Array([29,30,31]),None,None),Int64Array([2,3,4]),Signal(Int64Array([31,33,35]),None,None))341 doit('-',Signal(Int64Array([29,30,31]),None,None),Int64Array([2,3,4]),Signal(Int64Array([27,27,27]),None,None))342 doit('*',Signal(Int64Array([29,30,31]),None,None),Int64Array([2,3,4]),Signal(Int64Array([58,90,124]),None,None))343 doit('/',Signal(Int64Array([29,30,31]),None,None),Int64Array([2,3,4]),Signal(Int64Array([14,10,7]),None,None))344 doit('|',Signal(Int64Array([2,4,8]),None,None),Int64Array([1,2,3]),Signal(Uint64Array([3,6,11]),None,None))345 doit('&',Signal(Int64Array([3,7,255]),None,None),Int64Array([6,4,7]),Signal(Uint64Array([2,4,7]),None,None))346 doit('>',Signal(Int64Array([2,4,8]),None,None),Int64Array([3,4,5]),numpy.array([False,False,True]))347 doit('>=',Signal(Int64Array([2,4,8]),None,None),Int64Array([3,4,5]),numpy.array([False,True,True]))348 doit('<',Signal(Int64Array([2,4,8]),None,None),Int64Array([3,4,5]),numpy.array([True,False,False]))349 doit('<=',Signal(Int64Array([2,4,8]),None,None),Int64Array([3,4,5]),numpy.array([True,True,False]))350 doit('==',Signal(Int64Array([2,4,8]),None,None),Int64Array([3,4,5]),numpy.array([False,True,False]))351 doit('!=',Signal(Int64Array([2,4,8]),None,None),Int64Array([3,4,5]),numpy.array([True,False,True]))352 doit('<<',Signal(Int64Array([1,2,4]),None,None),Int64Array([3,4,5]),Signal(Int64Array([8,32,128]),None,None))353 doit('>>',Signal(Int64Array([8,16,32]),None,None),Int64Array([3,2,1]),Signal(Int64Array([1,4,16]),None,None))354 return355 def mathFunctions(self):356 self.assertEqual(float(Uint8(255)),255.)357 self.assertEqual(float(Uint16(255)),255.)358 self.assertEqual(float(Uint32(255)),255.)359 self.assertEqual(float(Uint64(255)),255.)360 self.assertEqual(float(Int8(127)),127.)361 self.assertEqual(float(Int16(255)),255.)362 self.assertEqual(float(Int32(255)),255.)363 self.assertEqual(float(Int64(255)),255.)364 self.assertEqual(float(Float32(255)),255.)365 self.assertEqual(float(Float64(255)),255.)366 self.assertEqual(int(Uint8(255)),255)367 self.assertEqual(int(Uint16(255)),255)368 self.assertEqual(int(Uint32(255)),255)369 self.assertEqual(int(Uint64(255)),255)370 self.assertEqual(int(Int8(127)),127)371 self.assertEqual(int(Int16(255)),255)372 self.assertEqual(int(Int32(255)),255)373 self.assertEqual(int(Int64(255)),255)374 self.assertEqual(int(Float32(255)),255)375 self.assertEqual(int(Float64(255)),255)376 def tdiFunctions(self):377 def doUnaryArray(expression,ans):378 self.assertEqual(((Data.execute(expression))==ans).all(),True)379 """Test abort"""380 try:381 Data.execute('abort()')382 self.fail("Abort did not signal an error")383 except Exception:384 import sys385 e=sys.exc_info()[1]386 self.assertEqual(str(e),'%TDI-E-TdiABORT, Program requested abort')387 """Test abs"""388 self.assertEqual(abs(Uint8(255)),Uint8(255))389 self.assertEqual(abs(Uint16(255)),Uint16(255))390 self.assertEqual(abs(Uint32(255)),Uint32(255))391 self.assertEqual(abs(Uint64(255)),Uint64(255))392 self.assertEqual(abs(Int8(-10)),Int8(10))393 self.assertEqual(abs(Int16(-10)),Int16(10))394 self.assertEqual(abs(Int32(-10)),Int32(10))395 self.assertEqual(abs(Int64(-10)),Int64(10))396 self.assertEqual(abs(Float32(-10)),Float32(10))397 self.assertEqual(abs(Float64(-10)),Float64(10))398 self.assertEqual((abs(Uint8Array([254,255]))==Uint8Array([254,255])).all(),True)399 self.assertEqual((abs(Uint16Array([254,255]))==Uint16Array([254,255])).all(),True)400 self.assertEqual((abs(Uint32Array([254,255]))==Uint32Array([254,255])).all(),True)401 self.assertEqual((abs(Uint64Array([254,255]))==Uint64Array([254,255])).all(),True)402 self.assertEqual((abs(Int8Array([-10,-20]))==Int8Array([10,20])).all(),True)403 self.assertEqual((abs(Int16Array([-10,-20]))==Int16Array([10,20])).all(),True)404 self.assertEqual((abs(Int32Array([-10,-20]))==Int32Array([10,20])).all(),True)405 self.assertEqual((abs(Int64Array([-10,-20]))==Int64Array([10,20])).all(),True)406 self.assertEqual((abs(Float32Array([-10,-20]))==Float32Array([10,20])).all(),True)407 self.assertEqual((abs(Float64Array([-10,-20]))==Float64Array([10,20])).all(),True)408 self.assertEqual(Data.execute('execute("abs(cmplx(3.0,4.0))")'),Float32(5.0))409 """Test abs1"""410 self.assertEqual(Data.execute('execute("abs1(cmplx(3.0,4.0))")'),Float32(7.0))411 """Test abssq"""412 self.assertEqual(Data.execute('execute("abssq(cmplx(3.0,4.0))")'),Float32(25.0))413 """Test accumulate"""414 self.assertEqual((Data.execute('execute("ACCUMULATE([1,2,3])")')==Int32Array([1,3,6])).all(),True)415 """ Known to be broken in both documenation and/or implementation416 self.assertEqual((Data.execute('execute("ACCUMULATE([[1,3,5],[2,4,6]])")')==Int32Array([[1,6,15],[3,10,21]])).all(),True)417 self.assertEqual((Data.execute('execute("ACCUMULATE([[1,3,5],[2,4,5]],0)")')==Int32Array([[1,3,5],[3,7,11]])).all(),True)418 self.assertEqual((Data.execute('execute("ACCUMULATE([[1,3,5],[2,4,5]],1)")')==Int32Array([[1,4,9],[2,6,12]])).all(),True)419 """420 """Test achar"""421 self.assertEqual(str(Data.execute('achar(88)')),'X')422 """Test ACOS"""423 self.assertEqual(Data.execute('abs(acos(.54030231)-1.)<.0000001'),Uint8(1))424 """Test ACOSD"""425 self.assertEqual(Data.execute('abs(acosd(0.5)<60.0)<.0000001'),Uint8(1))426 """Test Add"""427 self.assertEqual((Data.execute('[2,3,4]+5.0')==Float32Array([7,8,9])).all(),True)428 """Test ADJUSTL"""429 self.assertEqual(str(Data.execute('adjustl(" WORD")')),"WORD ")430 """Test ADJUSTR"""431 self.assertEqual(str(Data.execute('adjustr("WORD ")'))," WORD")432 """Test AIMAG"""433 self.assertEqual(Data.execute('execute("AIMAG(CMPLX(2.0,3.0))")'),Float32(3.0))434 """Test AINT"""435 self.assertEqual(Data.execute('aint(2.783)'),Float32(2.0))436 self.assertEqual(Data.execute('aint(-2.783)'),Float32(-2.0))437 """Test ALL"""438 self.assertEqual(Data.execute('ALL([$TRUE,$FALSE,$TRUE])'),Uint8(0))439 """ Documenation and/or implementation known to be broken440 self.assertEqual((Data.execute('_b=[1,3,5],_c=[[0,3,5],[2,4,6],[7,4,8]],all(_b ne _c,0)')==Uint8Array([1,0,0])).all(),True)441 self.assertEqual((Data.execute('all(_b ne _c,1)')==Uint8Array([0,0])).all().True)442 """443 """Test allocated"""444 self.assertEqual(Data.execute('allocated("_xyz")'),Uint8(0))445 self.assertEqual(Data.execute('_xyz=0,allocated("_xyz")'),Uint8(1))446 self.assertEqual(Data.execute('allocated(_xyz)'),Uint8(1))447 """Test AND"""448 self.assertEqual((Data.execute('[0,0,1,1] && [0,1,0,1]')==Uint8Array([0,0,0,1])).all(),True)449 """Test AND_NOT"""450 self.assertEqual((Data.execute('[0,0,1,1] AND_NOT [0,1,0,1]')==Uint8Array([0,0,1,0])).all(),True)451 """Test ANINT"""452 self.assertEqual(Data.execute('ANINT(2.783)'),Float32(3.0))453 """Test ANY"""454 self.assertEqual(Data.execute('any([$TRUE,$FALSE,$TRUE])'),Uint8(1))455 """ Documentation and/or Implementation known to be broken456 self.assertEqual((Data.execute('_b=[1,3,5],_c=[[0,3,5],[2,4,6],[7,4,8]],any(_b ne _c,0)')==Uint8Array([1,0,1])).all(),True)457 self.assertEqual((Data.execute('_b=[1,3,5],_c=[[0,3,5],[2,4,6],[7,4,8]],any(_b ne _c,1)')==Uint8Array([1,1])).all(),True)458 """459 """Test ARG"""460 self.assertEqual(Data.execute('execute("abs(arg(cmplx(3.0,4.0)) - .9272952) < .000001")'),Uint8(1))461 """Test ARGD"""462 self.assertEqual(Data.execute('execute("abs(argd(cmplx(3.0,4.0)) - 53.1301) < .000001")'),Uint8(1))463 """Test arg_of"""464 self.assertEqual(Data.execute('arg_of(gub->foo(42,43))'),Int32(42))465 self.assertEqual(Data.execute('arg_of(pub->foo(42,43),1)'),Int32(43))466 self.assertEqual(Data.execute('arg_of(execute("Test"))'),String("Test"))467 self.assertEqual(Data.execute('arg_of(1+3,1)'),Int32(3))468 """Test Array"""469 doUnaryArray('zero(10)*0',Float32Array([range(10)])*0.0)470 doUnaryArray('zero(10,0)*0',Int32Array([range(10)])*0)471 doUnaryArray('zero(10,0BU)*0BU',Uint8Array([range(10)])*Uint8(0))472 """Test ASIN"""473 self.assertEqual(Data.execute('abs(asin(0.84147098) - 1.0) < .000001'),Uint8(1))474 """Test ASIND"""475 self.assertEqual(Data.execute('abs(asind(.5) - 30.0) < .000001'),Uint8(1))476 """Test as_is"""477 self.assertEqual(Data.execute('public fun as_is_test(as_is _n){return(kind(_n));},as_is_test($)',TreeNode(42,None)),Uint8(192))478 """Test atan"""479 self.assertEqual(Data.execute('abs(atan(1.5574077)-1.0) < .000001'),Uint8(1))480 """Test atan2"""481 self.assertEqual(Data.execute('abs(atan2(1.5574077,1.0) - 1.0) < .000001'),Uint8(1))482 doUnaryArray('zero(100)',Float32Array([range(100)])*0.0)483 def runTest(self):484 self.basicBinaryOperators()485 self.mathFunctions()486 self.tdiFunctions()487 488def suite():489 tests = ['basicBinaryOperators','mathFunctions','tdiFunctions']490 return TestSuite(map(dataTests,tests))491def test():492 """Exercise data operations"""493 print (abs(makeData(-10)))494 x=makeDataArray([29,30,31])495 y=makeDataArray([2,4,8])496 print (x+y)497 print (x-y)498 print (x&y)499 print (x==y)500 print (x>y)501 print (x>=y)502 print (x<y)503 print (x<=y)504 print (x%y)505 print (x!=y)506 print (-x)507 print (x!=0)508 print (x|y)509 print (+x)510 print (x*y)511 print (x/y)512 print (x//y)513 print (x<<y)514 print (x>>y)515 print (abs(makeData(-10)))516 print (float(x))517 print (int(x))518 print (x.getDouble())519 print (x.decompile())520 print (x)521 print (x.evaluate())522 print (x.getByte())523 print (x.getInt())524 print (x.getShape())525 print (x.getByteArray())526 print (x.getShortArray())527 print (x.getIntArray())528 print (x.getLongArray())529 print (x.getString())530 print (x.getUnits())531 x.setUnits('amps')532 print (x.getUnits())533 x.setError(42)534 print (x.getError())535 x.setHelp('This is help')536 print (x.getHelp())537 x=Data.execute('data(1:100.)')538 print (x+y)539 print (x-y)540 print (x&y)541 print (x==y)542 print (x>y)543 print (x>=y)544 print (x<y)545 print (x<=y)546 print (x%y)547 print (x!=y)548 print (-x)549 print (x!=0)550 print (x|y)551 print (+x)552 print (x*y)553 print (x/y)554 print (x//y)555 print (x<<y)556 print (x>>y)557 print (abs(makeData(-10)))558 print (float(x))559 print (x.decompile())560 print (x)561 print (x.evaluate())562 print (x.getShape())563 print (x.getByteArray())564 print (x.getShortArray())565 print (x.getIntArray())566 print (x.getLongArray())567 print (x.getString())568 print (x.getUnits())569 x.setUnits('amps')570 print (x.getUnits())571 x.setError(42)572 print (x.getError())573 x.setHelp('This is help')...
test.mock.valid.js
Source:test.mock.valid.js
1/* global require, chai, describe, before, it */2/* global window */3var expect = chai.expect4var Mock, Random, $, _5describe('Mock.valid', function() {6 before(function(done) {7 require(['mock', 'underscore', 'jquery'], function() {8 Mock = arguments[0]9 window.Random = Random = Mock.Random10 _ = arguments[1]11 $ = arguments[2]12 expect(Mock).to.not.equal(undefined)13 expect(_).to.not.equal(undefined)14 expect($).to.not.equal(undefined)15 done()16 })17 })18 function stringify(json) {19 return JSON.stringify(json /*, null, 4*/ )20 }21 function title(tpl, data, result, test) {22 test.title = stringify(tpl) + ' VS ' + stringify(data) + '\n\tresult: ' + stringify(result)23 // if (result.length) test.title += '\n\tresult: '24 // for (var i = 0; i < result.length; i++) {25 // test.title += '\n\t' + result[i].message // stringify(result)26 // }27 }28 function doit(tpl, data, len) {29 it('', function() {30 var result = Mock.valid(tpl, data)31 title(tpl, data, result, this.test)32 expect(result).to.be.an('array').with.length(len)33 })34 }35 describe('Name', function() {36 doit({37 name: 138 }, {39 name: 140 }, 0)41 doit({42 name1: 143 }, {44 name2: 145 }, 1)46 })47 describe('Value - Number', function() {48 doit({49 name: 150 }, {51 name: 152 }, 0)53 doit({54 name: 155 }, {56 name: 257 }, 1)58 doit({59 name: 1.160 }, {61 name: 2.262 }, 1)63 doit({64 'name|1-10': 165 }, {66 name: 567 }, 0)68 doit({69 'name|1-10': 170 }, {71 name: 072 }, 1)73 doit({74 'name|1-10': 175 }, {76 name: 1177 }, 1)78 })79 describe('Value - String', function() {80 doit({81 name: 'value'82 }, {83 name: 'value'84 }, 0)85 doit({86 name: 'value1'87 }, {88 name: 'value2'89 }, 1)90 doit({91 'name|1': 'value'92 }, {93 name: 'value'94 }, 0)95 doit({96 'name|2': 'value'97 }, {98 name: 'valuevalue'99 }, 0)100 doit({101 'name|2': 'value'102 }, {103 name: 'value'104 }, 1)105 doit({106 'name|2-3': 'value'107 }, {108 name: 'value'109 }, 1)110 doit({111 'name|2-3': 'value'112 }, {113 name: 'valuevaluevaluevalue'114 }, 1)115 })116 describe('Value - RgeExp', function() {117 doit({118 name: /value/119 }, {120 name: 'value'121 }, 0)122 doit({123 name: /value/124 }, {125 name: 'vvvvv'126 }, 1)127 doit({128 'name|1-10': /value/129 }, {130 name: 'valuevaluevaluevaluevalue'131 }, 0)132 doit({133 'name|1-10': /value/134 }, {135 name: 'vvvvvvvvvvvvvvvvvvvvvvvvv'136 }, 1)137 doit({138 'name|1-10': /^value$/139 }, {140 name: 'valuevaluevaluevaluevalue'141 }, 0)142 doit({143 name: /[a-z][A-Z][0-9]/144 }, {145 name: 'yL5'146 }, 0)147 })148 describe('Value - Object', function() {149 doit({150 name: 1151 }, {152 name: 1153 }, 0)154 doit({155 name1: 1156 }, {157 name2: 2158 }, 1)159 doit({160 name1: 1,161 name2: 2162 }, {163 name3: 3164 }, 1)165 doit({166 name1: 1,167 name2: 2168 }, {169 name1: '1',170 name2: '2'171 }, 2)172 doit({173 a: {174 b: {175 c: {176 d: 1177 }178 }179 }180 }, {181 a: {182 b: {183 c: {184 d: 2185 }186 }187 }188 }, 1)189 })190 describe('Value - Array', function() {191 doit([1, 2, 3], [1, 2, 3], 0)192 doit([1, 2, 3], [1, 2, 3, 4], 1)193 // 'name|1': array194 doit({195 'name|1': [1, 2, 3]196 }, {197 'name': 1198 }, 0)199 doit({200 'name|1': [1, 2, 3]201 }, {202 'name': 2203 }, 0)204 doit({205 'name|1': [1, 2, 3]206 }, {207 'name': 3208 }, 0)209 doit({ // ä¸æ£æµ210 'name|1': [1, 2, 3]211 }, {212 'name': 4213 }, 0)214 // 'name|+1': array215 doit({216 'name|+1': [1, 2, 3]217 }, {218 'name': 1219 }, 0)220 doit({221 'name|+1': [1, 2, 3]222 }, {223 'name': 2224 }, 0)225 doit({226 'name|+1': [1, 2, 3]227 }, {228 'name': 3229 }, 0)230 doit({231 'name|+1': [1, 2, 3]232 }, {233 'name': 4234 }, 0)235 // 'name|min-max': array236 doit({237 'name|2-3': [1]238 }, {239 'name': [1, 2, 3, 4]240 }, 1)241 doit({242 'name|2-3': [1]243 }, {244 'name': [1]245 }, 1)246 doit({247 'name|2-3': [1, 2, 3]248 }, {249 'name': [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]250 }, 1)251 doit({252 'name|2-3': [1, 2, 3]253 }, {254 'name': [1, 2, 3]255 }, 1)256 doit({257 'name|2-3': [1]258 }, {259 'name': [1, 1, 1]260 }, 0)261 doit({262 'name|2-3': [1]263 }, {264 'name': [1, 2, 3]265 }, 2)266 // 'name|count': array267 })268 describe('Value - Placeholder', function() {269 doit({270 name: '@email'271 }, {272 name: 'nuysoft@gmail.com'273 }, 0)274 doit({275 name: '@int'276 }, {277 name: 123278 }, 0)279 })...
test_matpow.py
Source:test_matpow.py
1from sympy.utilities.pytest import raises2from sympy.core import symbols, pi, S3from sympy.matrices import Identity, MatrixSymbol, ImmutableMatrix, ZeroMatrix4from sympy.matrices.expressions import MatPow, MatAdd, MatMul5from sympy.matrices.expressions.matexpr import ShapeError6n, m, l, k = symbols('n m l k', integer=True)7A = MatrixSymbol('A', n, m)8B = MatrixSymbol('B', m, l)9C = MatrixSymbol('C', n, n)10D = MatrixSymbol('D', n, n)11E = MatrixSymbol('E', m, n)12def test_entry():13 from sympy.concrete import Sum14 assert MatPow(A, 1)[0, 0] == A[0, 0]15 assert MatPow(C, 0)[0, 0] == 116 assert MatPow(C, 0)[0, 1] == 017 assert isinstance(MatPow(C, 2)[0, 0], Sum)18def test_as_explicit_symbol():19 X = MatrixSymbol('X', 2, 2)20 assert MatPow(X, 0).as_explicit() == ImmutableMatrix(Identity(2))21 assert MatPow(X, 1).as_explicit() == X.as_explicit()22 assert MatPow(X, 2).as_explicit() == (X.as_explicit())**223def test_as_explicit_nonsquare_symbol():24 X = MatrixSymbol('X', 2, 3)25 assert MatPow(X, 1).as_explicit() == X.as_explicit()26 for r in [0, 2, S.Half, S.Pi]:27 raises(ShapeError, lambda: MatPow(X, r).as_explicit())28def test_as_explicit():29 A = ImmutableMatrix([[1, 2], [3, 4]])30 assert MatPow(A, 0).as_explicit() == ImmutableMatrix(Identity(2))31 assert MatPow(A, 1).as_explicit() == A32 assert MatPow(A, 2).as_explicit() == A**233 assert MatPow(A, -1).as_explicit() == A.inv()34 assert MatPow(A, -2).as_explicit() == (A.inv())**235 # less expensive than testing on a 2x236 A = ImmutableMatrix([4]);37 assert MatPow(A, S.Half).as_explicit() == A**S.Half38def test_as_explicit_nonsquare():39 A = ImmutableMatrix([[1, 2, 3], [4, 5, 6]])40 assert MatPow(A, 1).as_explicit() == A41 raises(ShapeError, lambda: MatPow(A, 0).as_explicit())42 raises(ShapeError, lambda: MatPow(A, 2).as_explicit())43 raises(ShapeError, lambda: MatPow(A, -1).as_explicit())44 raises(ValueError, lambda: MatPow(A, pi).as_explicit())45def test_doit_nonsquare_MatrixSymbol():46 assert MatPow(A, 1).doit() == A47 for r in [0, 2, -1, pi]:48 assert MatPow(A, r).doit() == MatPow(A, r)49def test_doit_square_MatrixSymbol_symsize():50 assert MatPow(C, 0).doit() == Identity(n)51 assert MatPow(C, 1).doit() == C52 for r in [2, pi]:53 assert MatPow(C, r).doit() == MatPow(C, r)54def test_doit_with_MatrixBase():55 X = ImmutableMatrix([[1, 2], [3, 4]])56 assert MatPow(X, 0).doit() == ImmutableMatrix(Identity(2))57 assert MatPow(X, 1).doit() == X58 assert MatPow(X, 2).doit() == X**259 assert MatPow(X, -1).doit() == X.inv()60 assert MatPow(X, -2).doit() == (X.inv())**261 # less expensive than testing on a 2x262 assert MatPow(ImmutableMatrix([4]), S.Half).doit() == ImmutableMatrix([2])63 X = ImmutableMatrix([[0, 2], [0, 4]]) # det() == 064 raises(ValueError, lambda: MatPow(X,-1).doit())65 raises(ValueError, lambda: MatPow(X,-2).doit())66def test_doit_nonsquare():67 X = ImmutableMatrix([[1, 2, 3], [4, 5, 6]])68 assert MatPow(X, 1).doit() == X69 raises(ShapeError, lambda: MatPow(X, 0).doit())70 raises(ShapeError, lambda: MatPow(X, 2).doit())71 raises(ShapeError, lambda: MatPow(X, -1).doit())72 raises(ShapeError, lambda: MatPow(X, pi).doit())73def test_doit_equals_pow(): #1717974 X = ImmutableMatrix ([[1,0],[0,1]])75 assert MatPow(X, n).doit() == X**n == X76def test_doit_nested_MatrixExpr():77 X = ImmutableMatrix([[1, 2], [3, 4]])78 Y = ImmutableMatrix([[2, 3], [4, 5]])79 assert MatPow(MatMul(X, Y), 2).doit() == (X*Y)**280 assert MatPow(MatAdd(X, Y), 2).doit() == (X + Y)**281def test_identity_power():82 k = Identity(n)83 assert MatPow(k, 4).doit() == k84 assert MatPow(k, n).doit() == k85 assert MatPow(k, -3).doit() == k86 assert MatPow(k, 0).doit() == k87 l = Identity(3)88 assert MatPow(l, n).doit() == l89 assert MatPow(l, -1).doit() == l90 assert MatPow(l, 0).doit() == l91def test_zero_power():92 z1 = ZeroMatrix(n, n)93 assert MatPow(z1, 3).doit() == z194 raises(ValueError, lambda:MatPow(z1, -1).doit())95 assert MatPow(z1, 0).doit() == Identity(n)96 assert MatPow(z1, n).doit() == z197 raises(ValueError, lambda:MatPow(z1, -2).doit())98 z2 = ZeroMatrix(4, 4)99 assert MatPow(z2, n).doit() == z2100 raises(ValueError, lambda:MatPow(z2, -3).doit())101 assert MatPow(z2, 2).doit() == z2102 assert MatPow(z2, 0).doit() == Identity(4)103 raises(ValueError, lambda:MatPow(z2, -1).doit())104def test_transpose_power():105 from sympy.matrices.expressions.transpose import Transpose as TP106 assert (C*D).T**5 == ((C*D)**5).T == (D.T * C.T)**5107 assert ((C*D).T**5).T == (C*D)**5108 assert (C.T.I.T)**7 == C**-7109 assert (C.T**l).T**k == C**(l*k)110 assert ((E.T * A.T)**5).T == (A*E)**5111 assert ((A*E).T**5).T**7 == (A*E)**35112 assert TP(TP(C**2 * D**3)**5).doit() == (C**2 * D**3)**5113 assert ((D*C)**-5).T**-5 == ((D*C)**25).T...
admin.js
Source:admin.js
1var _doit_index=0;2//为ç®æ å¢å ä¸ä¸ªæ ç¾3function _doit_addtag(){4 miniwin(_url+'addtag&deviceid='+_deviceid+'&personid='+_personid,'为ç®æ å¢å ä¸ä¸ªæ ç¾');5}6//为ç®æ 移é¤ä¸ä¸ªæ ç¾7function _doit_removetag(){8 miniwin(_url+'removetag&deviceid='+_deviceid+'&personid='+_personid,'为ç®æ 移é¤ä¸ä¸ªæ ç¾');9}10//ä¿®æ¹ç®æ å±æ§11function _doit_setattr(){12 miniwin(_url+'setattr&deviceid='+_deviceid+'&personid='+_personid,'ä¿®æ¹ç®æ å±æ§');13}14//æ§è¡ä¸ä¸ªèæ¬15function _doit_script(){16 miniwin(_url+'script&deviceid='+_deviceid+'&personid='+_personid,'æ§è¡ä¸ä¸ªèæ¬');17}18//è¾åºä¸æ¡æ°æ®19function _doit_output(){20 miniwin(_url+'output&deviceid='+_deviceid+'&personid='+_personid,'è¾åºä¸æ¡æ°æ®');21}22//æ§è¡æ·»å æä½23function _doit_add(obj){24 if(typeof onez.ai=='object' && typeof onez.ai.doit=='function'){25 onez.ai.doit(obj);26 closeWin();27 return;28 }29 30 var json=$(obj).attr('data-json');31 json=json.replace(/\\\\/g,'\\');32 json=JSON.parse(json);33 34 _doit_index++;35 36 var btn=$('<button type="button" class="btn btn-xs btn-danger" onclick="_doit_del('+_doit_index+')">å é¤</button>');37 $('<li />').css({'padding':'3px 0'}).attr('data-index',_doit_index).attr('data-json',JSON.stringify(json)).html(json.text+' ').append(btn).appendTo('#_doit');38 closeWin();39}40//41function _doit_del(_doit_index){42 bootbox.confirm('ç¡®å®è¦å é¤åï¼',function(result){43 if(result){44 $('#_doit li[data-index="'+_doit_index+'"]').remove();45 }46 });47}48function _doit_get(){49 var doit=[];50 $('#_doit li[data-json]').each(function(){51 var json=$(this).attr('data-json');52 json=json.replace(/\\\\/g,'\\');53 json=JSON.parse(json);54 doit.push(json);55 });56 if(doit.length<1){57 return 'è³å°åºæ§è¡ä¸ç§æä½';58 }59 60 return doit;61}62$(function(){63 if(typeof _doits=='object'){64 for(var i=0;i<_doits.length;i++){65 var json=_doits[i];66 _doit_index++;67 var btn=$('<button type="button" class="btn btn-xs btn-danger" onclick="_doit_del('+_doit_index+')">å é¤</button>');68 $('<li />').css({'padding':'3px 0'}).attr('data-index',_doit_index).attr('data-json',JSON.stringify(json)).html(json.text+' ').append(btn).appendTo('#_doit');69 }70 }...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!