How to use test_conversion method in tavern

Best Python code snippet using tavern

test_ms_conversion.py

Source:test_ms_conversion.py Github

copy

Full Screen

1# requires a data/refimager directory2# obtain from https://drive.google.com/file/d/1LfEtb5POmAS3Qv-CZ1_01RNtPCltTAMD/view?usp=sharing3import os4import time5import numpy as np6from cngi.conversion import convert_ms, read_ms, describe_ms7from cngi.dio import write_vis8def compare_xds(xds1, xds2):9 match = True10 if not xds1.equals(xds2):11 for col in xds1.data_vars:12 if xds1[col].equals(xds2[col]): # and xds1[col].equals(xds3[col]):13 #print('- MATCH %s' % col)14 continue15 if (xds1[col].dtype == np.int32) or (xds1[col].dtype == np.int64):16 diff = np.max(np.abs(xds1[col].clip(0) - xds2[col].clip(0)))17 #diff = max(diff, np.max(np.abs(xds2[col].values.clip(0) - xds3[col].values.clip(0))))18 elif xds1[col].dtype == np.bool:19 diff = np.max(np.abs(xds1[col] != xds2[col]))20 #diff = float(max(diff, np.max(np.abs(xds2[col].values != xds3[col].values))))21 else:22 diff = np.max(np.abs(np.nan_to_num(xds1[col]) - np.nan_to_num(xds2[col])))23 #diff = max(diff, np.max(np.abs(np.nan_to_num(xds2[col].values) - np.nan_to_num(xds3[col].values))))24 if diff > 1e-8:25 print('+++++ difference found in col %s = %f +++++' % (col, diff))26 match = False27 else:28 #print('- MANUAL MATCH %s' % col)29 pass30 if match: print('+++++ MATCH +++++')31ms_list = [ms for ms in os.listdir('data/refimager') if ms.endswith('.ms')]32for ms in ms_list:33 print('Converting %s...' % ms.split('/')[-1])34 xds1 = convert_ms('data/refimager/'+ms, ddis=[0]).xds035 xds2 = read_ms('data/refimager/' + ms, ddis=[0]).xds036 compare_xds(xds1, xds2)37 mxds2 = read_ms('data/refimager/'+ms)38xds1 = convert_ms('data/sis14_twhya_calibrated_flagged.ms', ddis=[0]).xds039xds2 = read_ms('data/sis14_twhya_calibrated_flagged.ms', ddis=[0]).xds040compare_xds(xds1, xds2)41mxds = read_ms('data/sis14_twhya_calibrated_flagged.ms')42write_vis(mxds, 'data/test_conversion.vis.zarr')43os.system('rm -fr data/test_conversion.vis.zarr')44xds1 = convert_ms('data/M100.ms', ddis=[0], chunks=(100,60,16,2)).xds045xds2 = read_ms('data/M100.ms', ddis=[0], chunks=(100,60,16,2)).xds046compare_xds(xds1, xds2)47describe_ms('data/M100.ms')48mxds = read_ms('data/M100.ms', ddis=[0,1,2,3], chunks=(100,60,16,2))49write_vis(mxds, 'data/test_conversion.vis.zarr')50xds1 = convert_ms('data/IRAS16293_Band9.ms', ddis=[0], chunks=(100, 100, 300, 2)).xds051xds2 = read_ms('data/IRAS16293_Band9.ms', ddis=[0], chunks=(100, 100, 300, 2)).xds052compare_xds(xds1, xds2)53mxds = read_ms('data/IRAS16293_Band9.ms')54write_vis(mxds, 'data/test_conversion.vis.zarr')55xds1 = convert_ms('data/VLASS_J1448_1620.ms', ddis=[2]).xds256xds2 = read_ms('data/VLASS_J1448_1620.ms', ddis=[2]).xds257compare_xds(xds1, xds2)58mxds = read_ms('data/VLASS_J1448_1620.ms')59write_vis(mxds, 'data/test_conversion.vis.zarr')60xds1 = convert_ms('data/3c391_ctm_mosaic_10s_spw0.ms', ddis=[0]).xds061xds2 = read_ms('data/3c391_ctm_mosaic_10s_spw0.ms', ddis=[0]).xds062compare_xds(xds1, xds2)63mxds = read_ms('data/3c391_ctm_mosaic_10s_spw0.ms')64write_vis(mxds, 'data/test_conversion.vis.zarr')65xds1 = convert_ms('data/uid___A002_Xc3032e_X27c3.ms', ddis=[0], chunks=(1000,400,-1,-1)).xds066xds2 = read_ms('data/uid___A002_Xc3032e_X27c3.ms', ddis=[0], chunks=(1000,400,1,2)).xds067compare_xds(xds1, xds2)68describe_ms('data/uid___A002_Xc3032e_X27c3.ms')69start = time.time()70mxds = read_ms('data/uid___A002_Xc3032e_X27c3.ms', chunks=(600,100,400,2))71#xds = read_ms('data/uid___A002_Xc3032e_X27c3.ms', ddis=[25], chunks=(600,100,400,2)).xds2572print('read complete in %s seconds' % str(time.time()-start))73write_vis(mxds, 'data/test_conversion.vis.zarr')74start = time.time()75mxds = read_ms(infile, chunks=(1000,64,1000,2))...

Full Screen

Full Screen

views.py

Source:views.py Github

copy

Full Screen

1from collections import Counter2from django.shortcuts import render3counter_show = Counter()4counter_click = Counter()5def index(request):6 param = request.GET.get('from-landing')7 counter_click[param] += 18 return render(request, 'index.html')9def landing(request):10 param = request.GET.get('ab-test-arg', 'original')11 if param == 'test':12 template = 'landing_alternate.html'13 else:14 template = 'landing.html'15 counter_show[param] += 116 return render(request, template)17def stats(request):18 try:19 test_conversion = counter_click['test']/counter_show['test']20 except ZeroDivisionError:21 test_conversion = 'Нет данных'22 try:23 original_conversion = counter_click['original']/counter_show['original']24 except ZeroDivisionError:25 original_conversion = 'Нет данных'26 return render(request, 'stats.html', context={27 'test_conversion': test_conversion,28 'original_conversion': original_conversion,...

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