How to use compare_matrices method in avocado

Best Python code snippet using avocado_python

check_results.py

Source:check_results.py Github

copy

Full Screen

...24 ls=l.strip().split()25 genes.append(ls[0])26 data.append([float(x) for x in ls[1:]])27 return numpy.array(data),genes28def compare_matrices(localdata,remotedata,infile,atol=1e-04,rtol=1e-04):29 if numpy.allclose(localdata,remotedata,rtol,atol):30 print 'PASS:',infile31 else:32 maxdiff=numpy.max(localdata - remotedata)33 print 'FAIL:',infile,'maxdiff =',maxdiff34 35def check_text_file(infile):36 local=numpy.loadtxt(os.path.join(basedir,infile))37 remote=load_dataframe('%s/%s'%(dataurl,infile),thresh=1.01)38 if not len(local)==len(remote):39 print 'size mismatch for ',infile40 return41 localdata=numpy.zeros((len(local),4))42 remotedata=numpy.zeros((len(remote),4))43 keys=local.keys()44 for k in range(len(keys)):45 if not remote.has_key(keys[k]):46 print 'remote missing matching key',keys[k]47 localdata[k,:]=local[keys[k]]48 remotedata[k,:]=remote[keys[k]]49 if numpy.allclose(localdata,remotedata,rtol,atol):50 print 'PASS:',infile51 else:52 maxdiff=numpy.max(localdata - remotedata,0)53 print 'FAIL:',infile,'maxdiff =',maxdiff54def usage():55 """Print the docstring and exit with error."""56 sys.stdout.write(__doc__)57 sys.exit(2)58def parse_arguments():59 # parse command line arguments60 # setting testing flag to true will turn off required flags61 # to allow manually running without command line flags62 parser = argparse.ArgumentParser(description='check_results')63 parser.add_argument('-b', dest='basedir',64 default=os.environ['MYCONNECTOME_DIR'],help='local base dir')65 parser.add_argument('-r',dest='remotebase',66 default='myconnectome-vm',help='remote base')67 return parser.parse_args()68 69basedir=os.environ['MYCONNECTOME_DIR']70dataurl='https://s3.amazonaws.com/openfmri/ds031/myconnectome-vm'71args=parse_arguments()72basedir=args.basedir73dataurl='https://s3.amazonaws.com/openfmri/ds031/'+args.remotebase74print 'BASEDIR:',basedir75print 'REMOTEBASE:',dataurl76# first load download log and get list of downloaded files77try:78 downloads=[i.strip().split('\t')[0] for i in open(os.path.join(basedir,'logs/data_downloads.log')).readlines()]79except:80 downloads=[]81 82print 'checking local results against benchmark data (computed on Ubuntu VM)'83print '#### Variance stabilized expression data'84if not 'rna-seq/varstab_data_prefiltered_rin_3PC_regressed.txt' in downloads:85 local,local_genes=load_varstab_data(os.path.join(basedir,'rna-seq/varstab_data_prefiltered_rin_3PC_regressed.txt'))86 remote,remote_genes=load_varstab_data('%s/%s'%(dataurl,'rna-seq/varstab_data_prefiltered_rin_3PC_regressed.txt'))87 compare_matrices(local,remote,'rna-seq/varstab_data_prefiltered_rin_3PC_regressed.txt')88else:89 print 'SKIPPING DOWNLOADED FILE: rna-seq/varstab_data_prefiltered_rin_3PC_regressed.txt'90 91print '### WGCNA'92if not'rna-seq/WGCNA/MEs-thr8-prefilt-rinPCreg-48sess.txt' in downloads:93 local=numpy.genfromtxt(os.path.join(basedir,'rna-seq/WGCNA/MEs-thr8-prefilt-rinPCreg-48sess.txt'),skip_header=1)94 remote=numpy.genfromtxt('%s/rna-seq/WGCNA/MEs-thr8-prefilt-rinPCreg-48sess.txt'%dataurl,skip_header=1)95 compare_matrices(local,remote,'rna-seq/WGCNA/MEs-thr8-prefilt-rinPCreg-48sess.txt')96else:97 print 'SKIPPING DOWNLOADED FILE: rna-seq/WGCNA/MEs-thr8-prefilt-rinPCreg-48sess.txt' 98 99if not 'rna-seq/WGCNA/module_assignments_thr8_prefilt_rinPCreg.txt' in downloads:100 local,local_genes=load_wgcna_module_assignments(os.path.join(basedir,'rna-seq/WGCNA/module_assignments_thr8_prefilt_rinPCreg.txt'))101 remote,remote_genes=load_wgcna_module_assignments('%s/rna-seq/WGCNA/module_assignments_thr8_prefilt_rinPCreg.txt'%dataurl)102 compare_matrices(local,remote,'rna-seq/WGCNA/module_assignments_thr8_prefilt_rinPCreg.txt')103else:104 print 'SKIPPING DOWNLOADED FILE: rna-seq/WGCNA/module_assignments_thr8_prefilt_rinPCreg.txt' 105print '#### Metabolomics data'106if not 'metabolomics/apclust_eigenconcentrations.txt' in downloads:107 local,local_subs=load_varstab_data(os.path.join(basedir,'metabolomics/apclust_eigenconcentrations.txt'))108 remote,remote_subs=load_varstab_data('%s/metabolomics/apclust_eigenconcentrations.txt'%dataurl)109 compare_matrices(local,remote,'metabolomics/apclust_eigenconcentrations.txt')110else:111 print 'SKIPPING DOWNLOADED FILE: metabolomics/apclust_eigenconcentrations.txt'112print '#### BCT analyses'113for f in ['PIpos_weighted_louvain_bct.txt','modularity_weighted_louvain_bct.txt','geff_pos.txt']:114 local=numpy.genfromtxt(os.path.join(basedir,'rsfmri',f))115 remote=numpy.genfromtxt('%s/rsfmri/%s'%(dataurl,f))116 compare_matrices(local,remote,'rsfmri/%s'%f)117 118print '#### Timeseries analysis Results'119tsresults=glob.glob(os.path.join(basedir,'timeseries/out*.txt'))120if len(tsresults)==0:121 print 'no timeseries results found - somethign went wrong'122else:123 for ts in tsresults:124 f=ts.replace(basedir+'/','')125 126 if ts in downloads:127 print 'SKIPPING DOWNLOADED FILE:',f128 else:129 local=load_dataframe(os.path.join(basedir,f),thresh=1.01)130 remote=load_dataframe('%s/%s'%(dataurl,f),thresh=1.01)...

Full Screen

Full Screen

parabolic_operator_system_test.py

Source:parabolic_operator_system_test.py Github

copy

Full Screen

...32 [[x], [y], [dt, theta]]33 )34 base_compare = compile_sympy([A, neumann], [A_bar, neumann_bar], k, [[x], [y]])35 test_pts = np.linspace(0,1,51)[:, None]36 def compare_matrices(base_key, parabolic_key):37 base_mat = base_op_system[base_key](test_pts, test_pts, fun_args)38 test_mat = parabolic_op_system[parabolic_key](test_pts, test_pts, np.array([]))39 np.testing.assert_almost_equal(base_mat, test_mat, err_msg='Failed for {} vs. {}'.format(base_key, parabolic_key))40 for theta_val in [0., 0.5, 1.]:41 dt_val = 0.142 parabolic_op_system = ParabolicOperatorSystem(base_compare, A, A_bar, theta_val, dt_val)43 association = {44 (): (),45 L_explicit: parabolic_op_system.explicit_op,46 L_bar_explicit: parabolic_op_system.explicit_op_bar,47 L_implicit: parabolic_op_system.implicit_op,48 L_bar_implicit: parabolic_op_system.implicit_op_bar,49 neumann: neumann,50 neumann_bar: neumann_bar51 }52 fun_args = np.array([dt_val, theta_val])53 for k in [(), L_explicit, L_bar_explicit, L_implicit, L_bar_implicit, neumann, neumann_bar]:54 left_key = (k,)55 right_key = (association[k], )56 compare_matrices(left_key, right_key)57 for k1, k2 in itertools.product([(), L_explicit, L_implicit, neumann], [(), L_bar_explicit, L_bar_implicit, neumann_bar]):58 left_key = (k1, k2)59 right_key = (association[k1], association[k2])...

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