Best Python code snippet using pytest-benchmark
reweight_groundtruth_plotter.py
Source: reweight_groundtruth_plotter.py
...73 y_hat2_3 = lowess(y, x) # note, default frac=2/374 y_hat1_5 = lowess(y, x, frac=1/5)75 y_hat1_4 = lowess(y, x, frac=1/4)76 y_hat1_7 = lowess(y, x, frac=1/7)77 print(test_monotonic(y_hat1_4))78 print(get_LOWESS_degree_by_ratio(y_hat1_4, -3))79 80 if(input('DO YOU WANT TO PLOT THE FILTERED RESULT? (y/n)')=='y'):81 fig = px.scatter(df, x=df['Phi [deg]'], y=df['SUM-DIFF'], opacity=0.8, color_discrete_sequence=['black'])82 fig.add_traces(go.Scatter(x=y_hat2_3[:,0], y=y_hat2_3[:,1], name='LOWESS, frac=2/3', line=dict(color='red')))83 fig.add_traces(go.Scatter(x=y_hat2_3[:,0], y=y_hat1_4[:,1], name='LOWESS, frac=1/4', line=dict(color='orange')))84 fig.add_traces(go.Scatter(x=y_hat2_3[:,0], y=y_hat1_7[:,1], name='LOWESS, frac=1/7', line=dict(color='yellowgreen')))85 fig.update_layout(dict(plot_bgcolor = 'white'))86 fig.update_traces(marker=dict(size=3))87 fig.show() 88def get_LOWESS_degree_by_ratio(filtered_data, ratio):89 if(test_monotonic(filtered_data)==False):90 print("!! the data is not monotonic !!")91 return92 min_data=1093 for i in range(len(filtered_data)-1):94 if filtered_data[i][1] < min_data:95 min_data = filtered_data[i][1]96 if min(filtered_data[i][1], filtered_data[i+1][1])<ratio and ratio<max(filtered_data[i][1], filtered_data[i+1][1]):97 return interpolator(filtered_data, i, i+1, ratio)98 print("!! no data found !!")99 if ratio <= min_data:100 return 0101def interpolator(data, index1, index2, ratio): # returns degree (float)102 return data[index1][0] + (ratio-data[index1][1])/(data[index2][1]-data[index1][1])103def test_monotonic(input): # for lowess filter104 peak_num=0105 for i in range(1,len(input)-1):106 if (input[i+1][1]<input[i][1] and input[i-1][1]<input[i][1]) or (input[i+1][1]>input[i][1] and input[i-1][1]>input[i][1]): # if there is a peak107 peak_num+=1108 if peak_num!=1:109 return False110 else:111 return True112###########################################################################113################ Savitzky-Golay filter ###################################114###########################################################################115def SAVGOL_filter():116 df = pd.read_csv('ground_truth_reweight.csv', encoding='utf-8')117 x=df['Phi [deg]'].values ...
tests.py
Source: tests.py
...21 assert core.base(13, "0123456789ABCDEF", 2) == "0D"22 assert core.base(16, "0123456789ABCDEF", 2) == "10"23 assert core.base(256, "0123456789ABCDEF", 2) == "100"24 pass25 def test_monotonic(self):26 id = core.monotonic(27 resolution=core.Resolution.days,28 now=datetime.datetime(2018, 12, 31, 23, 59, 59),29 alphabet="0123456789",30 start=datetime.datetime(2018, 1, 1),31 overflow_years=1,32 )33 assert id == "999"34 pass35 def test_equivalence(self):36 hs = core.HagelSource()37 now = datetime.datetime.now()38 assert hs.monotonic(now) == core.monotonic(now=now)39 pass40 def test_random(self):41 ids = [core.random() for i in range(100)]42 assert len(set(ids)) == 10043 pass44class TestHagelSource(unittest.TestCase):45 def test_init(self):46 hs = core.HagelSource(overflow_years=42)47 assert (hs.end - hs.start).total_seconds() == hs.total_seconds48 assert hs.total_seconds == 42 * 3153600049 assert hs.B == len(hs.alphabet)50 assert hs.B ** hs.digits == hs.combinations51 assert hs.total_seconds / hs.combinations == hs.resolution52 pass53 def test_monotonic(self):54 hs = core.HagelSource(55 resolution=core.Resolution.days,56 alphabet="0123456789",57 start=datetime.datetime(2018, 1, 1),58 overflow_years=1,59 )60 id = hs.monotonic(now=datetime.datetime(2018, 12, 31, 23, 59, 59))61 assert len(id) == hs.digits62 assert id == "999"63 pass64 def test_t_0(self):65 hs = core.HagelSource()66 first = hs.monotonic(now=hs.start)67 assert set(first) == set(hs.alphabet[0]), (...
post_histogram_monotonic.py
Source: post_histogram_monotonic.py
...12 Error increases linearly as the range increases.13 See Section 3.1: https://arxiv.org/pdf/0904.0942.pdf14 """15 return np.diff(isotonic_regression(counts.cumsum()), prepend=0)16def test_monotonic():17 epsilon = .0518 sensitivity = 119 # setup20 data = np.sqrt(np.random.uniform(size=1000))21 edges = np.sort(np.sqrt(np.random.uniform(size=100)))22 edge_indexes = list(range(len(edges)))23 # make measurement24 from opendp.trans import make_find_bin, make_count_by_categories25 from opendp.meas import make_base_geometric26 trans = make_find_bin(edges) >> make_count_by_categories(edge_indexes, TIA="usize")27 meas = trans >> make_base_geometric(sensitivity / epsilon, D="VectorDomain<AllDomain<i32>>")28 # release29 # the first bin is anything below the first edge and last bin is anything after the last edge30 exact_counts = np.array(trans(data)[1:-1])31 noisy_counts = np.array(meas(data)[1:-1])32 monot_counts = postprocess_histogram_monotonic_cumsum(noisy_counts)33 import matplotlib.pyplot as plt34 midpoints = get_midpoints(edges)35 plt.plot(midpoints, exact_counts.cumsum(), label="exact")36 plt.plot(midpoints, noisy_counts.cumsum(), label="noisy")37 plt.plot(midpoints, monot_counts.cumsum(), label="consistent")38 plt.legend()39 plt.show()...
Check out the latest blogs from LambdaTest on this topic:
Coaching is a term that is now being mentioned a lot more in the leadership space. Having grown successful teams I thought that I was well acquainted with this subject.
The key to successful test automation is to focus on tasks that maximize the return on investment (ROI), ensuring that you are automating the right tests and automating them in the right way. This is where test automation strategies come into play.
Agile software development stems from a philosophy that being agile means creating and responding to change swiftly. Agile means having the ability to adapt and respond to change without dissolving into chaos. Being Agile involves teamwork built on diverse capabilities, skills, and talents. Team members include both the business and software development sides working together to produce working software that meets or exceeds customer expectations continuously.
Ever since the Internet was invented, web developers have searched for the most efficient ways to display content on web browsers.
The holidays are just around the corner, and with Christmas and New Year celebrations coming up, everyone is busy preparing for the festivities! And during this busy time of year, LambdaTest also prepped something special for our beloved developers and testers – #LambdaTestYourBusiness
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!