How to use add_args method in autotest

Best Python code snippet using autotest_python

all_graphs.py

Source:all_graphs.py Github

copy

Full Screen

1import base642from matplotlib import pyplot as plt3import seaborn as sns4import io5import os678def base64img():9 # https://stackoverflow.com/questions/37225035/serialize-in-json-a-base64-encoded-data10 my_stringIObytes = io.BytesIO()1112 plt.savefig(my_stringIObytes, format='png', dpi=200)13 plt.close()1415 my_stringIObytes.seek(0)16 imdata_bytes = base64.b64encode(my_stringIObytes.read())17 imdata_string = imdata_bytes.decode('utf-8')18 return imdata_string192021def empty2none(args):22 for k, v in args.items():23 if type(v) == str:24 args[k] = None if v == '' else v25 if type(v) == int:26 args[k] = None if v == -999 else v27 return args282930def set_fig_size(g, fig_size):31 w, h = fig_size.split(';')32 g.figure.set_figwidth(float(w))33 g.figure.set_figheight(float(h))343536def clean_args(args):37 rm_list = ['add_args', 'ax_args', 'despine', 'fig_size']38 # remove optional args39 try:40 [args.pop(k) for k in rm_list]41 except:42 pass4344 args = empty2none(args)4546 return args4748def example_data(data_base_name='iris'):49 # https://seaborn.pydata.org/generated/seaborn.load_dataset.html#seaborn.load_dataset50 sns.load_dataset(data_base_name).to_csv(index=False, line_terminator='@')515253# ---------------------------------54# RELATIONAL PLOTS555657def rel(data, x, y, hue, size, style, row, col, col_wrap, kind='scatter', palette='deep', fig_size ='', despine={}, add_args={}, ax_args={}):58 # https://seaborn.pydata.org/generated/seaborn.relplot.html#seaborn.relplot5960 args = clean_args(locals())6162 g = sns.relplot(**args, **add_args)63 g.set(**ax_args)6465 if fig_size:66 set_fig_size(g, fig_size)6768 if despine:69 sns.despine(**despine)7071 # tight layout72 plt.tight_layout()7374 return base64img()757677def scatter(data, x, y, hue, palette, fig_size, despine={}, add_args={}, ax_args={}):78 # https://seaborn.pydata.org/generated/seaborn.scatterplot.html#seaborn.scatterplot7980 args = clean_args(locals())8182 g = sns.scatterplot(**args, **add_args)83 g.set(**ax_args)8485 if fig_size:86 set_fig_size(g, fig_size)8788 if despine:89 sns.despine(**despine)9091 # tight layout92 plt.tight_layout()9394 return base64img()959697def line(data, x, y, hue, palette, fig_size, despine={}, add_args={}, ax_args={}):98 # https://seaborn.pydata.org/generated/seaborn.lineplot.html#seaborn.lineplot99100 args = clean_args(locals())101102 g = sns.lineplot(**args, **add_args)103 g.set(**ax_args)104105 if fig_size:106 set_fig_size(g, fig_size)107108 if despine:109 sns.despine(**despine)110111 # tight layout112 plt.tight_layout()113114 return base64img()115116117# -------------------------------------------------118# DISTRIBUTION PLOTS119120def dis(data, x, y, hue, row, col, col_wrap, kind, rug, legend, palette, fig_size, despine={}, add_args={}, ax_args={}):121122 # https://seaborn.pydata.org/generated/seaborn.displot.html#seaborn.displot123124 args = clean_args(locals())125126 g = sns.displot(**args, **add_args)127 g.set(**ax_args)128129 if fig_size:130 set_fig_size(g, fig_size)131132 if despine:133 sns.despine(**despine)134135 # tight layout136 plt.tight_layout()137138 return base64img()139140141def hist(data, x, y, hue, stat, cumulative, multiple, element, fill, shrink, kde, legend,142 palette, fig_size, despine={}, add_args={}, ax_args={}):143 # https://seaborn.pydata.org/generated/seaborn.histplot.html#seaborn.histplot144145 args = clean_args(locals())146147 g = sns.histplot(**args, **add_args)148 g.set(**ax_args)149150 if fig_size:151 set_fig_size(g, fig_size)152153 if despine:154 sns.despine(**despine)155156 # tight layout157 plt.tight_layout()158159 return base64img()160161162def kde(data, x, y, hue, cut, cumulative, multiple, common_norm, common_grid, levels, thresh,163 alpha, fill, legend, palette, fig_size, despine={}, add_args={}, ax_args={}):164 # https://seaborn.pydata.org/generated/seaborn.kdeplot.html#seaborn.kdeplot165166 args = clean_args(locals())167168 g = sns.kdeplot(**args, **add_args)169 g.set(**ax_args)170171 if fig_size:172 set_fig_size(g, fig_size)173174 if despine:175 sns.despine(**despine)176177 # tight layout178 plt.tight_layout()179180 return base64img()181182183def ecdf():184 # https://seaborn.pydata.org/generated/seaborn.ecdfplot.html#seaborn.ecdfplot185 pass186187188def rug():189 # https://seaborn.pydata.org/generated/seaborn.rugplot.html#seaborn.rugplot190 pass191192193# -------------------------------------------------194# CATEGORICAL PLOTS195196197def cat(data, x, y, hue, row, col, col_wrap, ci, seed, kind, palette, fig_size, despine={}, add_args={}, ax_args={}):198 # https://seaborn.pydata.org/generated/seaborn.catplot.html#seaborn.catplot199200 args = clean_args(locals())201202 g = sns.catplot(**args, **add_args)203 g.set(**ax_args)204205 if fig_size:206 set_fig_size(g, fig_size)207208 if despine:209 sns.despine(**despine)210211 # tight layout212 plt.tight_layout()213214 return base64img()215216217def strip(data, x, y, hue, jitter, size, palette, fig_size, despine={}, add_args={}, ax_args={}):218 # https://seaborn.pydata.org/generated/seaborn.stripplot.html#seaborn.stripplot219220 args = clean_args(locals())221222 g = sns.stripplot(**args, **add_args)223 g.set(**ax_args)224225 if fig_size:226 set_fig_size(g, fig_size)227228 if despine:229 sns.despine(**despine)230231 # tight layout232 plt.tight_layout()233234 return base64img()235236237def swarm(data, x, y, hue, dodge, size, palette, fig_size, despine={}, add_args={}, ax_args={}):238 # https://seaborn.pydata.org/generated/seaborn.swarmplot.html#seaborn.swarmplot239240 args = clean_args(locals())241242 g = sns.swarmplot(**args, **add_args)243 g.set(**ax_args)244245 if fig_size:246 set_fig_size(g, fig_size)247248 if despine:249 sns.despine(**despine)250251 # tight layout252 plt.tight_layout()253254 return base64img()255256257def box(data, x, y, hue, palette, fig_size, despine={}, add_args={}, ax_args={}):258 # https://seaborn.pydata.org/generated/seaborn.boxplot.html#seaborn.boxplot259 # get all local arguments and check if = ''260261 args = clean_args(locals())262263 g = sns.boxplot(**args, **add_args)264 g.set(**ax_args)265266 if fig_size:267 set_fig_size(g, fig_size)268269 if despine:270 sns.despine(**despine)271272 # tight layout273 plt.tight_layout()274275 return base64img()276277278def violin(data, x, y, hue, bw, inner, split, dodge, palette, fig_size, despine={}, add_args={}, ax_args={}):279 # https://seaborn.pydata.org/generated/seaborn.violinplot.html#seaborn.violinplot280281 args = clean_args(locals())282283 g = sns.violinplot(**args, **add_args)284 g.set(**ax_args)285286 if fig_size:287 set_fig_size(g, fig_size)288289 if despine:290 sns.despine(**despine)291292 # tight layout293 plt.tight_layout()294295 return base64img()296297298def boxen(data, x, y, hue, dodge, k_depth, showfliers, palette, fig_size, despine={}, add_args={}, ax_args={}):299 # https://seaborn.pydata.org/generated/seaborn.boxenplot.html#seaborn.boxenplot300301 args = clean_args(locals())302303 g = sns.boxenplot(**args, **add_args)304 g.set(**ax_args)305306 if fig_size:307 set_fig_size(g, fig_size)308309 if despine:310 sns.despine(**despine)311312 # tight layout313 plt.tight_layout()314315 return base64img()316317318def point(data, x, y, hue, dodge, join, scale, errwidth, palette, fig_size, despine={}, add_args={}, ax_args={}):319 # https://seaborn.pydata.org/generated/seaborn.pointplot.html#seaborn.pointplot320321 args = clean_args(locals())322323 g = sns.pointplot(**args, **add_args)324 g.set(**ax_args)325326 if fig_size:327 set_fig_size(g, fig_size)328329 if despine:330 sns.despine(**despine)331332 # tight layout333 plt.tight_layout()334335 return base64img()336337338def bar(data, x, y, hue, ci, errwidth, palette, fig_size, despine={}, add_args={}, ax_args={}):339 # https://seaborn.pydata.org/generated/seaborn.barplot.html#seaborn.barplot340341 args = clean_args(locals())342343 g = sns.barplot(**args, **add_args)344 g.set(**ax_args)345346 if fig_size:347 set_fig_size(g, fig_size)348349 if despine:350 sns.despine(**despine)351352 # tight layout353 plt.tight_layout()354355 return base64img()356357358def count(data, x, hue, dodge, palette, fig_size, despine={}, add_args={}, ax_args={}):359 # https://seaborn.pydata.org/generated/seaborn.countplot.html#seaborn.countplot360361 args = clean_args(locals())362363 g = sns.countplot(**args, **add_args)364 g.set(**ax_args)365366 if fig_size:367 set_fig_size(g, fig_size)368369 if despine:370 sns.despine(**despine)371372 # tight layout373 plt.tight_layout()374375 return base64img()376 ...

Full Screen

Full Screen

intel_iommu.py

Source:intel_iommu.py Github

copy

Full Screen

...25 initrd_path = None26 kernel_params = None27 def set_up_boot(self):28 path = self.download_boot()29 self.vm.add_args('-device', 'virtio-blk-pci,bus=pcie.0,scsi=off,' +30 'drive=drv0,id=virtio-disk0,bootindex=1,'31 'werror=stop,rerror=stop' + self.IOMMU_ADDON)32 self.vm.add_args('-device', 'virtio-gpu-pci' + self.IOMMU_ADDON)33 self.vm.add_args('-drive',34 'file=%s,if=none,cache=writethrough,id=drv0' % path)35 def setUp(self):36 super(IntelIOMMU, self).setUp(None, 'virtio-net-pci' + self.IOMMU_ADDON)37 def add_common_args(self):38 self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')39 self.vm.add_args('-object',40 'rng-random,id=rng0,filename=/dev/urandom')41 def common_vm_setup(self, custom_kernel=None):42 self.require_accelerator("kvm")43 self.add_common_args()44 self.vm.add_args("-accel", "kvm")45 if custom_kernel is None:46 return47 kernel_url = self.distro.pxeboot_url + 'vmlinuz'48 initrd_url = self.distro.pxeboot_url + 'initrd.img'49 self.kernel_path = self.fetch_asset(kernel_url)50 self.initrd_path = self.fetch_asset(initrd_url)51 def run_and_check(self):52 if self.kernel_path:53 self.vm.add_args('-kernel', self.kernel_path,54 '-append', self.kernel_params,55 '-initrd', self.initrd_path)56 self.launch_and_wait()57 self.ssh_command('cat /proc/cmdline')58 self.ssh_command('dmesg | grep -e DMAR -e IOMMU')59 self.ssh_command('find /sys/kernel/iommu_groups/ -type l')60 self.ssh_command('dnf -y install numactl-devel')61 def test_intel_iommu(self):62 """63 :avocado: tags=intel_iommu_intremap64 """65 self.common_vm_setup(True)66 self.vm.add_args('-device', 'intel-iommu,intremap=on')67 self.vm.add_args('-machine', 'kernel_irqchip=split')68 self.kernel_params = (self.distro.default_kernel_params +69 ' quiet intel_iommu=on')70 self.run_and_check()71 def test_intel_iommu_strict(self):72 """73 :avocado: tags=intel_iommu_strict74 """75 self.common_vm_setup(True)76 self.vm.add_args('-device', 'intel-iommu,intremap=on')77 self.vm.add_args('-machine', 'kernel_irqchip=split')78 self.kernel_params = (self.distro.default_kernel_params +79 ' quiet intel_iommu=on,strict')80 self.run_and_check()81 def test_intel_iommu_strict_cm(self):82 """83 :avocado: tags=intel_iommu_strict_cm84 """85 self.common_vm_setup(True)86 self.vm.add_args('-device', 'intel-iommu,intremap=on,caching-mode=on')87 self.vm.add_args('-machine', 'kernel_irqchip=split')88 self.kernel_params = (self.distro.default_kernel_params +89 ' quiet intel_iommu=on,strict')90 self.run_and_check()91 def test_intel_iommu_pt(self):92 """93 :avocado: tags=intel_iommu_pt94 """95 self.common_vm_setup(True)96 self.vm.add_args('-device', 'intel-iommu,intremap=on')97 self.vm.add_args('-machine', 'kernel_irqchip=split')98 self.kernel_params = (self.distro.default_kernel_params +99 ' quiet intel_iommu=on iommu=pt')...

Full Screen

Full Screen

boot_linux.py

Source:boot_linux.py Github

copy

Full Screen

...19 :avocado: tags=machine:pc20 :avocado: tags=accel:tcg21 """22 self.require_accelerator("tcg")23 self.vm.add_args("-accel", "tcg")24 self.launch_and_wait(set_up_ssh_connection=False)25 def test_pc_i440fx_kvm(self):26 """27 :avocado: tags=machine:pc28 :avocado: tags=accel:kvm29 """30 self.require_accelerator("kvm")31 self.vm.add_args("-accel", "kvm")32 self.launch_and_wait(set_up_ssh_connection=False)33 def test_pc_q35_tcg(self):34 """35 :avocado: tags=machine:q3536 :avocado: tags=accel:tcg37 """38 self.require_accelerator("tcg")39 self.vm.add_args("-accel", "tcg")40 self.launch_and_wait(set_up_ssh_connection=False)41 def test_pc_q35_kvm(self):42 """43 :avocado: tags=machine:q3544 :avocado: tags=accel:kvm45 """46 self.require_accelerator("kvm")47 self.vm.add_args("-accel", "kvm")48 self.launch_and_wait(set_up_ssh_connection=False)49class BootLinuxAarch64(LinuxTest):50 """51 :avocado: tags=arch:aarch6452 :avocado: tags=machine:virt53 :avocado: tags=machine:gic-version=254 """55 def add_common_args(self):56 self.vm.add_args('-bios',57 os.path.join(BUILD_DIR, 'pc-bios',58 'edk2-aarch64-code.fd'))59 self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')60 self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom')61 def test_virt_tcg_gicv2(self):62 """63 :avocado: tags=accel:tcg64 :avocado: tags=cpu:max65 :avocado: tags=device:gicv266 """67 self.require_accelerator("tcg")68 self.vm.add_args("-accel", "tcg")69 self.vm.add_args("-cpu", "max,lpa2=off")70 self.vm.add_args("-machine", "virt,gic-version=2")71 self.add_common_args()72 self.launch_and_wait(set_up_ssh_connection=False)73 def test_virt_tcg_gicv3(self):74 """75 :avocado: tags=accel:tcg76 :avocado: tags=cpu:max77 :avocado: tags=device:gicv378 """79 self.require_accelerator("tcg")80 self.vm.add_args("-accel", "tcg")81 self.vm.add_args("-cpu", "max,lpa2=off")82 self.vm.add_args("-machine", "virt,gic-version=3")83 self.add_common_args()84 self.launch_and_wait(set_up_ssh_connection=False)85 def test_virt_kvm(self):86 """87 :avocado: tags=accel:kvm88 :avocado: tags=cpu:host89 """90 self.require_accelerator("kvm")91 self.vm.add_args("-accel", "kvm")92 self.vm.add_args("-machine", "virt,gic-version=host")93 self.add_common_args()94 self.launch_and_wait(set_up_ssh_connection=False)95class BootLinuxPPC64(LinuxTest):96 """97 :avocado: tags=arch:ppc6498 """99 def test_pseries_tcg(self):100 """101 :avocado: tags=machine:pseries102 :avocado: tags=accel:tcg103 """104 self.require_accelerator("tcg")105 self.vm.add_args("-accel", "tcg")106 self.launch_and_wait(set_up_ssh_connection=False)107class BootLinuxS390X(LinuxTest):108 """109 :avocado: tags=arch:s390x110 """111 @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')112 def test_s390_ccw_virtio_tcg(self):113 """114 :avocado: tags=machine:s390-ccw-virtio115 :avocado: tags=accel:tcg116 """117 self.require_accelerator("tcg")118 self.vm.add_args("-accel", "tcg")...

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