How to use measure_duration method in avocado

Best Python code snippet using avocado_python

DataGatherThread.py

Source:DataGatherThread.py Github

copy

Full Screen

1'''2Created on Jul 31, 20203@author: duicul4'''5import threading6import os7from moviepy.video.io.VideoFileClip import VideoFileClip8import traceback9class DataGatherThread (threading.Thread):10 11 def __init__(self, files,measure_duration,thread_no):12 threading.Thread.__init__(self)13 self.files = files # 0-file_name 1-fullpath 2-duration 3-size14 self.measure_duration = measure_duration15 self.thread_no=thread_no16 17 def video_len(self,path,measure_len):18 if not measure_len:19 return False20 try:21 clip = VideoFileClip(path)22 except Exception:23 #print(path)24 #print(str(traceback.format_exc()))25 return False26 if clip is None:27 return False28 len_vid=clip.duration29 #print(len_vid)30 if len_vid is None:31 return False32 clip.reader.close()33 if clip.audio is None:34 return False35 else:36 clip.audio.reader.close_proc()37 return len_vid38 39 40 def gather_data(self,file_range_search,measure_duration):41 #if range_search[len(range_search)-1]>=len(self.file_data):42 # return43 44 ret_file_data=[]45 for file in file_range_search:46 #print(self.file_data[i][1])47 file[2]=self.video_len(file[1],measure_duration)48 file[3]=os.path.getsize(file[1])49 #print(file)50 ret_file_data.append(file)51 52 self.files=ret_file_data53 #print(self.files)54 55 def run(self):56 print("Starting: "+str(len(self.files))+" files no:"+str(self.thread_no))57 self.gather_data(self.files, self.measure_duration)58 print("Finish: "+" no: "+str(self.thread_no))59if __name__ == '__main__':...

Full Screen

Full Screen

experiment_10_post_sim_plotting.py

Source:experiment_10_post_sim_plotting.py Github

copy

Full Screen

1from brian2.units import *2from echo_time import *3import pickle4import scipy.io as spio5import matplotlib.pyplot as plt6import power_spectral_density as psd7fname = "experiment_data/exp10_20sec.pickle"8echo = echo_start("Reading data from {}... ".format(fname))9try:10 with open(fname, 'rb') as f:11 DATA = pickle.load(f)12except Exception as e:13 print('Error', e)14 exit()15echo_end(echo)16X = DATA['X']17Y = DATA['Y']18duration = DATA['duration']/ms19echo = echo_start("Post-processing and plotting... \n")20MEASURE_START = 100021MEASURE_DURATION = 50022print("\t{:,} excitatory neuron spikes in total".format(len(X)))23tt = time.time()24X1, Y1 = [], []25for spike_t, spike_idx in zip(X, Y):26 if MEASURE_START <= spike_t < MEASURE_START + MEASURE_DURATION and \27 spike_idx < 3*40:28 X1.append(spike_t)29 Y1.append(spike_idx)30print('\tCollect relevant spikes: {}s'.format(time.time() - tt))31#X, Y = M.t/ms, M.i32X, Y = X1, Y133tt = time.time()34dt = 10 # ms35shift = 5 # ms36total_steps = int(duration/(shift*ms))37ma, time_scale = psd.moving_average(X, dt, shift, total_steps, True)38print('\tCalculate moving average: {}s'.format(time.time() - tt))39tt = time.time()40X2, Y2 = [], []41for ma_val, t in zip(ma, time_scale):42 if MEASURE_START <= t[0] < MEASURE_START + MEASURE_DURATION:43 Y2.append(ma_val)44 X2.append(t[0])45print('\tCollect relvant moving average data points: {}s'.format(time.time() - tt))46plt.subplot(211)47plt.plot(X1, Y1, '.b')48plt.ylabel('Neuron Index')49plt.xlabel('Simulation Time (ms)')50plt.subplot(212)51plt.plot(X2, Y2)52plt.xlabel('Simulation Time (ms)')53plt.ylabel('Mean firing rate')54echo_end(echo)55plt.show()...

Full Screen

Full Screen

main_without_esp32.py

Source:main_without_esp32.py Github

copy

Full Screen

1from imu import gy8012import time3from plot import plot_trajectory, fft, plot_trajectory_attenuated4if __name__ == '__main__':5 sensor = gy801()6 7 MEASURE_DURATION = 5 # unit: s8 df = sensor.measure_complementary(MEASURE_DURATION)9 print(df)10 freq = MEASURE_DURATION / len(df)11 plot_trajectory(df, freq)12 df = fft(df, freq)...

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