How to use run_1 method in SeleniumBase

Best Python code snippet using SeleniumBase

run-analysis.py

Source: run-analysis.py Github

copy

Full Screen

1import matplotlib.pyplot as plt2import numpy as np3import pandas as pd4import seaborn as sns5def ra_plot(run_1, run_2, run_3, run_4, window=10):6 run_avg_1 = run_1['average'].rolling(window).mean()7 run_avg_2 = run_2['average'].rolling(window).mean()8 run_avg_3 = run_3['average'].rolling(window).mean()9 run_avg_4 = run_4['average'].rolling(window).mean()10 run_avg_combo = pd.concat([run_avg_1,11 run_avg_2.reindex(run_avg_1.index),12 run_avg_3.reindex(run_avg_1.index),13 run_avg_4 .reindex(run_avg_1.index)], axis=1)14 run_avg_combo.set_axis(['average_1', 'average_2', 'average_3', 'average_4'], axis=1, inplace=True)15 run_avg_combo['min'] = run_avg_combo.min(axis=1)16 run_avg_combo['max'] = run_avg_combo.max(axis=1)17 run_avg_combo['average'] = run_avg_combo.mean(axis=1)18 plt.plot(run_avg_combo['average_1'], label='Run 1')19 plt.plot(run_avg_combo['average_2'], label='Run 2')20 plt.plot(run_avg_combo['average_3'], label='Run 3')21 plt.plot(run_avg_combo['average_4'], label='Run 4')22 plt.plot(run_avg_combo['average'], color='black', label='Average', linestyle='dashed')23 plt.fill_between(run_avg_combo.index, run_avg_combo['min'], run_avg_combo['max'], alpha=0.5, label='Range')24 plt.xlabel('Episode')25 plt.ylabel('Reward')26 # plt.title('Total Average Episode Reward')27 plt.legend()28 plt.savefig('graphs/​total-average-episode-reward-window{}-new.png'.format(window))29 plt.show()30def sd_plot(run_1, run_2, run_3, run_4):31 run_1 = run_1.drop([' distance_to_target'], axis=1)32 run_combo = pd.concat([run_1,33 run_2['average'].reindex(run_1.index),34 run_3['average'].reindex(run_1.index),35 run_4['average'].reindex(run_1.index)], axis=1)36 run_combo.set_axis(['average_1', 'average_2', 'average_3', 'average_4'], axis=1, inplace=True)37 run_combo['min'] = run_combo.min(axis=1)38 run_combo['max'] = run_combo.max(axis=1)39 run_combo['average'] = run_combo.mean(axis=1)40 plt.plot(run_combo['average_1'], label='Run 1')41 plt.plot(run_combo['average_2'], label='Run 2')42 plt.plot(run_combo['average_3'], label='Run 3')43 plt.plot(run_combo['average_4'], label='Run 4')44 plt.plot(run_combo['average'], color='black', label='Average', linestyle='dashed')45 plt.fill_between(run_combo.index, run_combo['min'], run_combo['max'], alpha=0.5, label='Range')46 plt.xlabel('Episode')47 plt.ylabel('Reward')48 # plt.title('Total Average Episode Reward')49 plt.legend(loc='lower right')50 plt.savefig('graphs/​total-average-episode-reward-minmax.png')51 plt.show()52def sd_plot_2(run_1, run_2, run_3, run_4):53 run_1 = run_1.drop(['episode'], axis=1)54 run_combo = pd.concat([run_1,55 run_2['average'].reindex(run_1.index),56 run_3['average'].reindex(run_1.index),57 run_4['average'].reindex(run_1.index)], axis=1)58 run_combo.set_axis(['average_1', 'average_2', 'average_3', 'average_4'], axis=1, inplace=True)59 run_combo['min'] = run_combo.min(axis=1)60 run_combo['max'] = run_combo.max(axis=1)61 run_combo['average'] = run_combo.mean(axis=1)62 plt.plot(run_combo['average_1'], label='Run 1')63 plt.plot(run_combo['average_2'], label='Run 2')64 plt.plot(run_combo['average_3'], label='Run 3')65 plt.plot(run_combo['average_4'], label='Run 4')66 plt.plot(run_combo['average'], color='black', label='Average', linestyle='dashed')67 plt.fill_between(run_combo.index, run_combo['min'], run_combo['max'], alpha=0.5, label='Range')68 plt.xlabel('Episode')69 plt.ylabel('Reward')70 # plt.title('Total Average Episode Reward')71 plt.legend(loc='lower right')72 plt.savefig('graphs/​total-average-episode-reward-minmax-new.png')73 plt.show()74if __name__ == "__main__":75 sns.set()76 sns.set_style('whitegrid')77 run1 = pd.read_csv('data-files/​run1a.csv')78 run2 = pd.read_csv('data-files/​run2a.csv')79 run3 = pd.read_csv('data-files/​run3a.csv')80 run4 = pd.read_csv('data-files/​run4a.csv')81 runs = [run1, run2, run3, run4]82 run1 = run1.drop(['Steps_In_Episode',83 'Total_Steps',84 'Mean_Episode_Reward',85 'Mean_Reward_All',86 ' Memory_used',87 'Time_Elapsed',88 'Solved',89 'Solved.1'], axis=1)90 run1.set_axis(['episode', 'average'], axis=1, inplace=True)91 run2 = run2.drop(['Steps_In_Episode',92 'Total_Steps',93 'Mean_Episode_Reward',94 'Mean_Reward_All',95 ' Memory_used',96 'Time_Elapsed',97 'Solved',98 'Solved.1'], axis=1)99 run2.set_axis(['episode', 'average'], axis=1, inplace=True)100 run3 = run3.drop(['Steps_In_Episode',101 'Total_Steps',102 'Mean_Episode_Reward',103 'Mean_Reward_All',104 ' Memory_used',105 'Time_Elapsed',106 'Solved',107 'Solved.1'], axis=1)108 run3.set_axis(['episode', 'average'], axis=1, inplace=True)109 run4 = run4.drop(['Steps_In_Episode',110 'Total_Steps',111 'Mean_Episode_Reward',112 'Mean_Reward_All',113 ' Memory_used',114 'Time_Elapsed',115 'Solved',116 'Solved.1'], axis=1)117 run4.set_axis(['episode', 'average'], axis=1, inplace=True)118 sd_plot_2(run1, run2, run3, run4)119 ra_plot(run1, run2, run3, run4)120 ra_plot(run1, run2, run3, run4, window=100)121 '''122 run1 = pd.read_csv('data-files/​run1.csv')123 run2 = pd.read_csv('data-files/​run2.csv')124 run3 = pd.read_csv('data-files/​run3.csv')125 run4 = pd.read_csv('data-files/​run4.csv')126 frames = [run1, run2, run3, run4]127 long_file = pd.concat(frames)128 columns = long_file.columns129 mean = long_file[columns[2]].mean()130 print(mean)131 std = long_file[columns[2]].std()132 print(std)133 min = long_file[columns[2]].min()134 print(min)135 run1 = run1.drop(['total_timesteps'], axis=1)136 run1 = run1.groupby('episode').mean()137 run1['average'] = run1.expanding().mean()138 run2 = run2.drop(['total_timesteps'], axis=1)139 run2 = run2.groupby('episode').mean()140 run2['average'] = run2.expanding().mean()141 run3 = run3.drop(['total_timesteps'], axis=1)142 run3 = run3.groupby('episode').mean()143 run3['average'] = run3.expanding().mean()144 run4 = run4.drop(['total_timesteps'], axis=1)145 run4 = run4.groupby('episode').mean()146 run4['average'] = run4.expanding().mean()147 # ra_plot(run1, run2, run3, run4)148 # ra_plot(run1, run2, run3, run4, window=100)149 # sd_plot(run1, run2, run3, run4)...

Full Screen

Full Screen

test_unit.py

Source: test_unit.py Github

copy

Full Screen

1# -----------------------------------------------------------2# Unit tests for overflow problem utilising pytest3# email jozsef.la.kepes@gmail.com4# -----------------------------------------------------------5from problem import Problem6def test_unit():7 """Perform unit tests for water overflow problem"""8 # Test 1: Use 2.4 litres as an input9 run_1 = Problem()10 run_1.pour(2.4)11 # Test 2.4L input for all final glass volumes12 assert run_1.get_glass_content(0, 0) == 25013 assert run_1.get_glass_content(1, 0) == 25014 assert run_1.get_glass_content(1, 1) == 25015 assert run_1.get_glass_content(2, 0) == 25016 assert run_1.get_glass_content(2, 1) == 25017 assert run_1.get_glass_content(2, 2) == 25018 assert run_1.get_glass_content(3, 0) == 112.519 assert run_1.get_glass_content(3, 1) == 25020 assert run_1.get_glass_content(3, 2) == 25021 assert run_1.get_glass_content(3, 3) == 112.522 assert run_1.get_glass_content(4, 0) == 023 assert run_1.get_glass_content(4, 1) == 43.7524 assert run_1.get_glass_content(4, 2) == 87.525 assert run_1.get_glass_content(4, 3) == 43.7526 assert run_1.get_glass_content(4, 4) == 027 # Test final total glass volume is the same is the input volume28 assert run_1.sum_glass_content() == 2.429 # Test 2: Use 15 litres as an input30 run_2 = Problem()31 run_2.pour(15)32 assert run_2.sum_glass_content() == 1533 # Test 3: Use a float as an input34 run_3 = Problem()35 run_3.pour(15.01)...

Full Screen

Full Screen

workouts.py

Source: workouts.py Github

copy

Full Screen

1import os2from typing import TextIO3from app.models import Track, User, Workout, db4def seed_workouts():5 base_dir = os.path.dirname(__file__)6 # Read GPX files from the 'gpx_files' directory7 run_1: TextIO = open(os.path.join(base_dir, 'gpx_files', 'run_1.gpx'))8 run_2: TextIO = open(os.path.join(base_dir, 'gpx_files', 'boulder.gpx'))9 # Find a user10 demo_user = User.query.filter_by(username='demo').first()11 # Create workout objects12 workout_1 = Workout.create_workout_from_gpx(13 run_1, "First Run", demo_user.id)14 track_1 = Track.create_track_from_gpx_track(15 run_2, "Boulder Skyline", demo_user.id)16 # Commit the session17 db.session.add(workout_1)18 db.session.add(track_1)19 db.session.commit()20def undo_workouts():21 db.session.execute(22 'TRUNCATE track_points, tracks, workouts RESTART IDENTITY;')...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Why Agile Is Great for Your Business

Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.

Best 13 Tools To Test JavaScript Code

Unit and functional testing are the prime ways of verifying the JavaScript code quality. However, a host of tools are available that can also check code before or during its execution in order to test its quality and adherence to coding standards. With each tool having its unique features and advantages contributing to its testing capabilities, you can use the tool that best suits your need for performing JavaScript testing.

Test strategy and how to communicate it

I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.

The Art of Testing the Untestable

It’s strange to hear someone declare, “This can’t be tested.” In reply, I contend that everything can be tested. However, one must be pleased with the outcome of testing, which might include failure, financial loss, or personal injury. Could anything be tested when a claim is made with this understanding?

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