How to use get_paths method in avocado

Best Python code snippet using avocado_python

plot_figure2.py

Source:plot_figure2.py Github

copy

Full Screen

...20# RCP2621v0 = ax1.violinplot(hyd[df['RCP']==26],positions=[1],showextrema=False)22for b in v0['bodies']:23 # get the center24 m = np.mean(b.get_paths()[0].vertices[:, 0])25 # modify the paths to not go further right than the center26 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], -np.inf, m)27 b.set_color('#0D72BA')28 b.set_edgecolor('black')29 b.set_alpha(.8)30v1 = ax1.violinplot(hyd[(df['RCP']==26)&(df['MODEL']==1)],positions=[1],showextrema=False)31for b in v1['bodies']:32 # get the center33 m = np.mean(b.get_paths()[0].vertices[:, 0])34 # modify the paths to not go further left than the center35 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)36 b.set_color('peru')37 b.set_edgecolor('black')38 b.set_alpha(.4)39v2 = ax1.violinplot(hyd[(df['RCP']==26)&(df['MODEL']==2)],positions=[1],showextrema=False)40for b in v2['bodies']:41 # get the center42 m = np.mean(b.get_paths()[0].vertices[:, 0])43 # modify the paths to not go further left than the center44 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)45 b.set_color('turquoise')46 b.set_edgecolor('black')47 b.set_alpha(.4)48 49v3 = ax1.violinplot(hyd[(df['RCP']==26)&(df['MODEL']==3)],positions=[1],showextrema=False)50for b in v3['bodies']:51 # get the center52 m = np.mean(b.get_paths()[0].vertices[:, 0])53 # modify the paths to not go further left than the center54 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)55 b.set_color('slateblue')56 b.set_edgecolor('black')57 b.set_alpha(.4)58 59# RCP4560v0 = ax1.violinplot(hyd[df['RCP']==45],positions=[2],showextrema=False)61for b in v0['bodies']:62 # get the center63 m = np.mean(b.get_paths()[0].vertices[:, 0])64 # modify the paths to not go further right than the center65 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], -np.inf, m)66 b.set_color('#76AC42')67 b.set_edgecolor('black')68 b.set_alpha(.8)69v1 = ax1.violinplot(hyd[(df['RCP']==45)&(df['MODEL']==1)],positions=[2],showextrema=False)70for b in v1['bodies']:71 # get the center72 m = np.mean(b.get_paths()[0].vertices[:, 0])73 # modify the paths to not go further left than the center74 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)75 b.set_color('peru')76 b.set_edgecolor('black')77 b.set_alpha(.4)78v2 = ax1.violinplot(hyd[(df['RCP']==45)&(df['MODEL']==2)],positions=[2],showextrema=False)79for b in v2['bodies']:80 # get the center81 m = np.mean(b.get_paths()[0].vertices[:, 0])82 # modify the paths to not go further left than the center83 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)84 b.set_color('turquoise')85 b.set_edgecolor('black')86 b.set_alpha(.4)87 88v3 = ax1.violinplot(hyd[(df['RCP']==45)&(df['MODEL']==3)],positions=[2],showextrema=False)89for b in v3['bodies']:90 # get the center91 m = np.mean(b.get_paths()[0].vertices[:, 0])92 # modify the paths to not go further left than the center93 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)94 b.set_color('slateblue')95 b.set_edgecolor('black')96 b.set_alpha(.4)97 98# RCP8599v0 = ax1.violinplot(hyd[df['RCP']==85],positions=[3],showextrema=False)100for b in v0['bodies']:101 # get the center102 m = np.mean(b.get_paths()[0].vertices[:, 0])103 # modify the paths to not go further right than the center104 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], -np.inf, m)105 b.set_color('#A21D31')106 b.set_edgecolor('black')107 b.set_alpha(.8)108 109v1 = ax1.violinplot(hyd[(df['RCP']==85)&(df['MODEL']==1)],positions=[3],showextrema=False)110for b in v1['bodies']:111 # get the center112 m = np.mean(b.get_paths()[0].vertices[:, 0])113 # modify the paths to not go further left than the center114 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)115 b.set_color('peru')116 b.set_edgecolor('black')117 b.set_alpha(.4)118v2 = ax1.violinplot(hyd[(df['RCP']==85)&(df['MODEL']==2)],positions=[3],showextrema=False)119for b in v2['bodies']:120 # get the center121 m = np.mean(b.get_paths()[0].vertices[:, 0])122 # modify the paths to not go further left than the center123 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)124 b.set_color('turquoise')125 b.set_edgecolor('black')126 b.set_alpha(.4)127 128v3 = ax1.violinplot(hyd[(df['RCP']==85)&(df['MODEL']==3)],positions=[3],showextrema=False)129for b in v3['bodies']:130 # get the center131 m = np.mean(b.get_paths()[0].vertices[:, 0])132 # modify the paths to not go further left than the center133 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)134 b.set_color('slateblue')135 b.set_edgecolor('black')136 b.set_alpha(.4)137# add medians138m26 = np.percentile(hyd[df['RCP']==26], 50)139m45 = np.percentile(hyd[df['RCP']==45], 50)140m85 = np.percentile(hyd[df['RCP']==85], 50)141ax1.scatter([1,2,3], [m26, m45, m85], marker='o', color='black', edgecolor='black', s=75, zorder=3)142### IRRIGATION ###143# RCP26144v0 = ax2.violinplot(irr[df['RCP']==26],positions=[1],showextrema=False)145for b in v0['bodies']:146 # get the center147 m = np.mean(b.get_paths()[0].vertices[:, 0])148 # modify the paths to not go further right than the center149 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], -np.inf, m)150 b.set_color('#0D72BA')151 b.set_edgecolor('black')152 b.set_alpha(.8)153v1 = ax2.violinplot(irr[(df['RCP']==26)&(df['MODEL']==1)],positions=[1],showextrema=False)154for b in v1['bodies']:155 # get the center156 m = np.mean(b.get_paths()[0].vertices[:, 0])157 # modify the paths to not go further left than the center158 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)159 b.set_color('peru')160 b.set_edgecolor('black')161 b.set_alpha(.4)162v2 = ax2.violinplot(irr[(df['RCP']==26)&(df['MODEL']==2)],positions=[1],showextrema=False)163for b in v2['bodies']:164 # get the center165 m = np.mean(b.get_paths()[0].vertices[:, 0])166 # modify the paths to not go further left than the center167 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)168 b.set_color('turquoise')169 b.set_edgecolor('black')170 b.set_alpha(.4)171 172v3 = ax2.violinplot(irr[(df['RCP']==26)&(df['MODEL']==3)],positions=[1],showextrema=False)173for b in v3['bodies']:174 # get the center175 m = np.mean(b.get_paths()[0].vertices[:, 0])176 # modify the paths to not go further left than the center177 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)178 b.set_color('slateblue')179 b.set_edgecolor('black')180 b.set_alpha(.4)181 182# RCP45183v0 = ax2.violinplot(irr[df['RCP']==45],positions=[2],showextrema=False)184for b in v0['bodies']:185 # get the center186 m = np.mean(b.get_paths()[0].vertices[:, 0])187 # modify the paths to not go further right than the center188 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], -np.inf, m)189 b.set_color('#76AC42')190 b.set_edgecolor('black')191 b.set_alpha(.8)192v1 = ax2.violinplot(irr[(df['RCP']==45)&(df['MODEL']==1)],positions=[2],showextrema=False)193for b in v1['bodies']:194 # get the center195 m = np.mean(b.get_paths()[0].vertices[:, 0])196 # modify the paths to not go further left than the center197 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)198 b.set_color('peru')199 b.set_edgecolor('black')200 b.set_alpha(.4)201v2 = ax2.violinplot(irr[(df['RCP']==45)&(df['MODEL']==2)],positions=[2],showextrema=False)202for b in v2['bodies']:203 # get the center204 m = np.mean(b.get_paths()[0].vertices[:, 0])205 # modify the paths to not go further left than the center206 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)207 b.set_color('turquoise')208 b.set_edgecolor('black')209 b.set_alpha(.4)210 211v3 = ax2.violinplot(irr[(df['RCP']==45)&(df['MODEL']==3)],positions=[2],showextrema=False)212for b in v3['bodies']:213 # get the center214 m = np.mean(b.get_paths()[0].vertices[:, 0])215 # modify the paths to not go further left than the center216 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)217 b.set_color('slateblue')218 b.set_edgecolor('black')219 b.set_alpha(.4)220 221# RCP85222v0 = ax2.violinplot(irr[df['RCP']==85],positions=[3],showextrema=False)223for b in v0['bodies']:224 # get the center225 m = np.mean(b.get_paths()[0].vertices[:, 0])226 # modify the paths to not go further right than the center227 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], -np.inf, m)228 b.set_color('#A21D31')229 b.set_edgecolor('black')230 b.set_alpha(.8)231 232v1 = ax2.violinplot(irr[(df['RCP']==85)&(df['MODEL']==1)],positions=[3],showextrema=False)233for b in v1['bodies']:234 # get the center235 m = np.mean(b.get_paths()[0].vertices[:, 0])236 # modify the paths to not go further left than the center237 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)238 b.set_color('peru')239 b.set_edgecolor('black')240 b.set_alpha(.4)241v2 = ax2.violinplot(irr[(df['RCP']==85)&(df['MODEL']==2)],positions=[3],showextrema=False)242for b in v2['bodies']:243 # get the center244 m = np.mean(b.get_paths()[0].vertices[:, 0])245 # modify the paths to not go further left than the center246 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)247 b.set_color('turquoise')248 b.set_edgecolor('black')249 b.set_alpha(.4)250 251v3 = ax2.violinplot(irr[(df['RCP']==85)&(df['MODEL']==3)],positions=[3],showextrema=False)252for b in v3['bodies']:253 # get the center254 m = np.mean(b.get_paths()[0].vertices[:, 0])255 # modify the paths to not go further left than the center256 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)257 b.set_color('slateblue')258 b.set_edgecolor('black')259 b.set_alpha(.4)260 261# add medians262m26 = np.percentile(irr[df['RCP']==26], 50)263m45 = np.percentile(irr[df['RCP']==45], 50)264m85 = np.percentile(irr[df['RCP']==85], 50)265ax2.scatter([1,2,3], [m26, m45, m85], marker='o', color='black', edgecolor='black', s=75, zorder=3)266 267### ENVIRONMENT ###268# RCP26269v0 = ax3.violinplot(env[df['RCP']==26],positions=[1],showextrema=False)270for b in v0['bodies']:271 # get the center272 m = np.mean(b.get_paths()[0].vertices[:, 0])273 # modify the paths to not go further right than the center274 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], -np.inf, m)275 b.set_color('#0D72BA')276 b.set_edgecolor('black')277 b.set_alpha(.8)278v1 = ax3.violinplot(env[(df['RCP']==26)&(df['MODEL']==1)],positions=[1],showextrema=False)279for b in v1['bodies']:280 # get the center281 m = np.mean(b.get_paths()[0].vertices[:, 0])282 # modify the paths to not go further left than the center283 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)284 b.set_color('peru')285 b.set_edgecolor('black')286 b.set_alpha(.4)287v2 = ax3.violinplot(env[(df['RCP']==26)&(df['MODEL']==2)],positions=[1],showextrema=False)288for b in v2['bodies']:289 # get the center290 m = np.mean(b.get_paths()[0].vertices[:, 0])291 # modify the paths to not go further left than the center292 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)293 b.set_color('turquoise')294 b.set_edgecolor('black')295 b.set_alpha(.4)296 297v3 = ax3.violinplot(env[(df['RCP']==26)&(df['MODEL']==3)],positions=[1],showextrema=False)298for b in v3['bodies']:299 # get the center300 m = np.mean(b.get_paths()[0].vertices[:, 0])301 # modify the paths to not go further left than the center302 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)303 b.set_color('slateblue')304 b.set_edgecolor('black')305 b.set_alpha(.4)306 307# RCP45308v0 = ax3.violinplot(env[df['RCP']==45],positions=[2],showextrema=False)309for b in v0['bodies']:310 # get the center311 m = np.mean(b.get_paths()[0].vertices[:, 0])312 # modify the paths to not go further right than the center313 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], -np.inf, m)314 b.set_color('#76AC42')315 b.set_edgecolor('black')316 b.set_alpha(.8)317v1 = ax3.violinplot(env[(df['RCP']==45)&(df['MODEL']==1)],positions=[2],showextrema=False)318for b in v1['bodies']:319 # get the center320 m = np.mean(b.get_paths()[0].vertices[:, 0])321 # modify the paths to not go further left than the center322 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)323 b.set_color('peru')324 b.set_edgecolor('black')325 b.set_alpha(.4)326v2 = ax3.violinplot(env[(df['RCP']==45)&(df['MODEL']==2)],positions=[2],showextrema=False)327for b in v2['bodies']:328 # get the center329 m = np.mean(b.get_paths()[0].vertices[:, 0])330 # modify the paths to not go further left than the center331 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)332 b.set_color('turquoise')333 b.set_edgecolor('black')334 b.set_alpha(.4)335 336v3 = ax3.violinplot(env[(df['RCP']==45)&(df['MODEL']==3)],positions=[2],showextrema=False)337for b in v3['bodies']:338 # get the center339 m = np.mean(b.get_paths()[0].vertices[:, 0])340 # modify the paths to not go further left than the center341 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)342 b.set_color('slateblue')343 b.set_edgecolor('black')344 b.set_alpha(.4)345 346# RCP85347v0 = ax3.violinplot(env[df['RCP']==85],positions=[3],showextrema=False)348for b in v0['bodies']:349 # get the center350 m = np.mean(b.get_paths()[0].vertices[:, 0])351 # modify the paths to not go further right than the center352 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], -np.inf, m)353 b.set_color('#A21D31')354 b.set_edgecolor('black')355 b.set_alpha(.8)356 357v1 = ax3.violinplot(env[(df['RCP']==85)&(df['MODEL']==1)],positions=[3],showextrema=False)358for b in v1['bodies']:359 # get the center360 m = np.mean(b.get_paths()[0].vertices[:, 0])361 # modify the paths to not go further left than the center362 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)363 b.set_color('peru')364 b.set_edgecolor('black')365 b.set_alpha(.4)366v2 = ax3.violinplot(env[(df['RCP']==85)&(df['MODEL']==2)],positions=[3],showextrema=False)367for b in v2['bodies']:368 # get the center369 m = np.mean(b.get_paths()[0].vertices[:, 0])370 # modify the paths to not go further left than the center371 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)372 b.set_color('turquoise')373 b.set_edgecolor('black')374 b.set_alpha(.4)375 376v3 = ax3.violinplot(env[(df['RCP']==85)&(df['MODEL']==3)],positions=[3],showextrema=False)377for b in v3['bodies']:378 # get the center379 m = np.mean(b.get_paths()[0].vertices[:, 0])380 # modify the paths to not go further left than the center381 b.get_paths()[0].vertices[:, 0] = np.clip(b.get_paths()[0].vertices[:, 0], m, np.inf)382 b.set_color('slateblue')383 b.set_edgecolor('black')384 b.set_alpha(.4)385# add medians386m26 = np.percentile(env[df['RCP']==26], 50)387m45 = np.percentile(env[df['RCP']==45], 50)388m85 = np.percentile(env[df['RCP']==85], 50)389ax3.scatter([1,2,3], [m26, m45, m85], marker='o', color='black', edgecolor='black', s=75, zorder=3)390# set labels, legend391ax1.set_ylabel('hydropower production (TWh/y)')392ax2.set_ylabel('irrigation deficit (m3/s)')393ax3.set_ylabel('environmental deficit (m3/s)')394ax1.set_axisbelow(True)395ax2.set_axisbelow(True)...

Full Screen

Full Screen

train_race_test.py

Source:train_race_test.py Github

copy

Full Screen

...4 5 def test_01_empty(self):6 7 tr = TrainRace([],[]) 8 self.assertEqual(tr.get_paths(), [])9 tr.step()10 self.assertEqual(tr.get_paths(), [])11 12 def test_02_neg(self):13 14 with self.assertRaises(ValueError):15 TrainRace([-1],[3])16 17 with self.assertRaises(ValueError):18 TrainRace([2],[-2])19 20 def test_03_zero(self):21 22 with self.assertRaises(ValueError):23 TrainRace([4,2],[6,0])24 with self.assertRaises(ValueError):25 TrainRace([4,2],[0,3])26 27 with self.assertRaises(ValueError):28 TrainRace([2,0],[5,6])29 30 31 def test_04_mismatch(self):32 33 with self.assertRaises(ValueError):34 TrainRace([4,2],[6,1,3])35 with self.assertRaises(ValueError):36 TrainRace([6,4,3,2],[6,2,4]) 37 def test_05_1_1(self):38 39 tr = TrainRace([1],[1])40 paths = tr.get_paths()41 42 self.assertEqual(len(paths), 1)43 44 self.assertEqual(''.join(paths[0]), '*') 45 46 tr.step()47 paths = tr.get_paths()48 49 self.assertEqual(''.join(paths[0]), '-*')50 51 tr.step()52 paths = tr.get_paths()53 54 self.assertEqual(''.join(paths[0]), '--*')55 56 57 def test_06_2_1(self):58 59 tr = TrainRace([2],[1])60 paths = tr.get_paths()61 62 self.assertEqual(len(paths), 1)63 self.assertEqual(''.join(paths[0]), '**')64 65 tr.step()66 paths = tr.get_paths()67 68 self.assertEqual(''.join(paths[0]), '-**')69 70 tr.step()71 paths = tr.get_paths()72 73 self.assertEqual(''.join(paths[0]), '--**')74 75 def test_07_2_2(self):76 77 tr = TrainRace([2],[2])78 paths = tr.get_paths()79 80 self.assertEqual(len(paths), 1)81 82 self.assertEqual(''.join(paths[0]), '**')83 84 tr.step()85 paths = tr.get_paths()86 87 self.assertEqual(''.join(paths[0]), '--**')88 89 tr.step()90 paths = tr.get_paths()91 92 self.assertEqual(''.join(paths[0]), '----**')93 94 def test_08_4_3_1_2(self):95 96 tr = TrainRace([4,3],[1,2])97 98 paths = tr.get_paths()99 100 self.assertEqual(len(paths), 2) 101 self.assertEqual(''.join(paths[0]), '****')102 self.assertEqual(''.join(paths[1]), '***')103 104 tr.step()105 paths = tr.get_paths()106 107 self.assertEqual(''.join(paths[0]), '-****') 108 self.assertEqual(''.join(paths[1]), '--***')109 110 tr.step()111 paths = tr.get_paths()112 113 self.assertEqual(''.join(paths[0]), '--****') 114 self.assertEqual(''.join(paths[1]), '----***')115 116 def test_09_complex(self):117 118 tr = TrainRace([5,3,6,3], [2,1,3,2])119 120 paths = tr.get_paths()121 122 self.assertEqual(len(paths), 4) 123 self.assertEqual(''.join(paths[0]), '*****')124 self.assertEqual(''.join(paths[1]), '***')125 self.assertEqual(''.join(paths[2]), '******')126 self.assertEqual(''.join(paths[3]), '***')127 128 tr.step() 129 paths = tr.get_paths()130 131 self.assertEqual(len(paths), 4)132 self.assertEqual(''.join(paths[0]), '--*****')133 self.assertEqual(''.join(paths[1]), '-***')134 self.assertEqual(''.join(paths[2]), '---******')135 self.assertEqual(''.join(paths[3]), '--***')136 137 tr.step() 138 paths = tr.get_paths()139 140 self.assertEqual(len(paths), 4)141 self.assertEqual(''.join(paths[0]), '----*****')142 self.assertEqual(''.join(paths[1]), '--***')143 self.assertEqual(''.join(paths[2]), '------******') 144 self.assertEqual(''.join(paths[3]), '----***')145 146 tr.step()147 paths = tr.get_paths()148 149 self.assertEqual(len(paths), 4) 150 self.assertEqual(''.join(paths[0]), '------*****')151 self.assertEqual(''.join(paths[1]), '---***')152 self.assertEqual(''.join(paths[2]), '---------******') 153 self.assertEqual(''.join(paths[3]), '------***')154# EXTRA: NOT REQUIRED TO PASS DURING THE EXAM155class VelocityGreaterThanTrainSizeTest (unittest.TestCase): 156 157 def test_01_1_2(self):158 159 tr = TrainRace([1],[2])160 paths = tr.get_paths()161 162 self.assertEqual(''.join(paths[0]), '*')163 164 tr.step()165 paths = tr.get_paths()166 167 self.assertEqual(''.join(paths[0]), '--*') 168 169 tr.step()170 paths = tr.get_paths()171 172 self.assertEqual(''.join(paths[0]), '----*')173 def test_02_2_4(self): 174 175 tr = TrainRace([2],[4])176 paths = tr.get_paths()177 178 self.assertEqual(''.join(paths[0]), '**') 179 180 tr.step()181 paths = tr.get_paths()182 183 self.assertEqual(''.join(paths[0]), '----**')184 185 tr.step() 186 paths = tr.get_paths()187 188 self.assertEqual(''.join(paths[0]), '--------**')189 def test_03_1_2_3_4(self):190 191 tr = TrainRace([1,2],[3,4])192 paths = tr.get_paths()193 194 self.assertEqual(len(paths), 2)195 self.assertEqual(''.join(paths[0]), '*')196 self.assertEqual(''.join(paths[1]), '**')197 198 tr.step() 199 paths = tr.get_paths()200 201 self.assertEqual(len(paths), 2) 202 self.assertEqual(''.join(paths[0]), '---*') 203 self.assertEqual(''.join(paths[1]), '----**')204 205 tr.step() 206 paths = tr.get_paths()207 208 self.assertEqual(len(paths), 2) 209 self.assertEqual(''.join(paths[0]), '------*') 210 self.assertEqual(''.join(paths[1]), '--------**')211 tr.step() 212 paths = tr.get_paths()213 214 self.assertEqual(len(paths), 2) 215 self.assertEqual(''.join(paths[0]), '---------*') 216 self.assertEqual(''.join(paths[1]), '------------**')...

Full Screen

Full Screen

data_io.py

Source:data_io.py Github

copy

Full Screen

...5import numpy as np6import os7import pandas as pd8import pickle9def get_paths():10 root = path.dirname(path.dirname(path.abspath(__file__)))11 paths = json.loads(open(os.path.join(root, 'SETTINGS.json')).read())12 for key in paths:13 paths[key] = os.path.expandvars(paths[key])14 paths['root'] = root15 return paths16def get_train_df():17 train_path = get_paths()["train_data_path"]18 root_path = get_paths()["root"]19 return pd.read_csv(os.path.join(root_path, train_path))20def get_test_df():21 test_path = get_paths()["test_data_path"]22 root_path = get_paths()["root"]23 return pd.read_csv(os.path.join(root_path, test_path))24def save_model(model, name='model.pkl'):25 model_dir = get_paths()["models_dir"]26 root_path = get_paths()["root"]27 pickle.dump(model, open(os.path.join(root_path, model_dir, name), 'wb'))28def load_model(name='model.pkl'):29 model_dir = get_paths()["models_dir"]30 root_path = get_paths()["root"]...

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 avocado 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