Best JavaScript code snippet using ladle
regression_linear_model.py
Source:regression_linear_model.py
1#!/usr/bin/env python2# Regression Stuff3from sklearn.datasets import fetch_olivetti_faces4from sklearn.utils.validation import check_random_state5from sklearn.ensemble import ExtraTreesRegressor6from sklearn.neighbors import KNeighborsRegressor7from sklearn.linear_model import LinearRegression8from sklearn.linear_model import RidgeCV9from sklearn.linear_model import BayesianRidge10from sklearn.linear_model import Lasso11from sklearn.linear_model import TheilSenRegressor12# Python Stuff13import glob14import copy15import itertools16import numpy as np17import matplotlib.pyplot as plt18import math19# ROS Stuff20import actionlib21from actionlib import SimpleActionClient22from geometry_msgs.msg import Pose, PoseStamped, Quaternion, TransformStamped, \23 Point, PointStamped, Vector3, Transform24from interactive_markers.interactive_marker_server import InteractiveMarkerServer25from manipulation_msgs.srv import GraspPlanning, GraspPlanningRequest26from manipulation_msgs.msg import GraspPlanningAction, GraspPlanningGoal27import moveit_commander28from moveit_msgs.msg import AttachedCollisionObject, CollisionObject, PlanningScene, PlanningSceneComponents29from moveit_msgs.srv import GetPlanningScene, GetPositionFK, GetPositionIK30from pr2_controllers_msgs.msg import JointTrajectoryAction, JointTrajectoryGoal31import rosbag32import rospy33from sensor_msgs.msg import PointCloud234import sensor_msgs.point_cloud2 as pc235from shape_msgs.msg import SolidPrimitive36from std_msgs.msg import Header37import tf38from trajectory_msgs.msg import JointTrajectory, JointTrajectoryPoint39from visualization_msgs.msg import Marker40# Local Stuff41from joint_states_listener.srv import ReturnJointStates42from pr2_pick_contest.msg import Trial, Record43from pr2_pick_contest.srv import GetItems, SetItems, GetTargetItems44from pr2_pick_contest.srv import LookupItem45from pr2_pick_main import publish_gripper, publish_bounding_box, publish_cluster46from pr2_pick_perception.msg import Object, BoundingBox47from pr2_pick_perception.srv import CropShelf, CropShelfResponse, \48 DeleteStaticTransform, FindCentroid, LocalizeShelf, LocalizeShelfResponse, \49 SetStaticTransform, PlanarPrincipalComponents, GetItemDescriptor, ClassifyTargetItem50from pr2_gripper_grasp_planner_cluster.srv import SetPointClusterGraspParams, SetPointClusterGraspParamsRequest51from object_recognition_clusters.srv import FindClusterBoundingBox, FindClusterBoundingBoxRequest52class TrialAnalyser:53 def __init__(self):54 self._x_before = {}55 self._y_before = {}56 self._yaw_before = {}57 self._x_after = {}58 self._y_after = {}59 self._yaw_after = {}60 self.markers = rospy.Publisher('pr2_pick_visualization', Marker)61 def get_bounding_box_diff(self, trial):62 action = trial.params.action.data63 #rospy.loginfo("Action: " + str(action))64 if not self._x_before.has_key(action):65 self._x_before[action] = []66 self._y_before[action] = []67 self._yaw_before[action] = []68 self._x_after[action] = []69 self._y_after[action] = []70 self._yaw_after[action] = []71 before_box = trial.before.boundingbox72 after_box = trial.after.boundingbox73 self._x_after[action].append(after_box.pose.pose.position.x)74 self._x_before[action].append(before_box.pose.pose.position.x)75 self._y_after[action].append(after_box.pose.pose.position.y)76 self._y_before[action].append(before_box.pose.pose.position.y)77 q_before = (78 before_box.pose.pose.orientation.x,79 before_box.pose.pose.orientation.y,80 before_box.pose.pose.orientation.z,81 before_box.pose.pose.orientation.w)82 q_after = (83 after_box.pose.pose.orientation.x,84 after_box.pose.pose.orientation.y,85 after_box.pose.pose.orientation.z,86 after_box.pose.pose.orientation.w)87 euler_before = tf.transformations.euler_from_quaternion(q_before)88 euler_after = tf.transformations.euler_from_quaternion(q_after)89 yaw_before = euler_before[2]90 yaw_after = euler_after[2]91 yaw_diff = yaw_after - yaw_before92 # rospy.loginfo("Before: {}".format(before_box))93 # rospy.loginfo("Before yaw: {}".format(yaw_before*180/math.pi))94 # rospy.loginfo("After: {}".format(after_box))95 # rospy.loginfo("After yaw: {}".format(yaw_after*180/math.pi))96 if (math.fabs(after_box.dimensions.x - before_box.dimensions.x) > 0.02) and (math.fabs(after_box.dimensions.y - before_box.dimensions.y) > 0.02):97 rospy.loginfo("Wrong axes")98 yaw_before -= math.pi/2.099 100 if yaw_before < 0:101 if (math.fabs(yaw_after - (yaw_before + math.pi))) < (math.fabs(yaw_after - yaw_before)):102 rospy.loginfo("Flipped")103 yaw_before = (yaw_before + math.pi)104 else:105 if (math.fabs(yaw_after - (yaw_before - math.pi))) < (math.fabs(yaw_after - yaw_before)):106 rospy.loginfo("Flipped")107 yaw_before = (yaw_before - math.pi)108 rospy.loginfo("Yaw diff: {}".format(yaw_diff*180/math.pi))109 self._yaw_before[action].append(copy.copy(yaw_before))110 self._yaw_after[action].append(copy.copy(yaw_after))111 def get_test_data(self, trial):112 action = trial.params.action.data113 #rospy.loginfo("Action: " + str(action))114 x_before = {}115 y_before = {}116 _yaw_before = {}117 x_after = {}118 y_after = {}119 _yaw_after = {}120 if not x_before.has_key(action):121 x_before[action] = []122 y_before[action] = []123 _yaw_before[action] = []124 x_after[action] = []125 y_after[action] = []126 _yaw_after[action] = []127 before_box = trial.before.boundingbox128 after_box = trial.after.boundingbox129 x_after[action].append(after_box.pose.pose.position.x)130 x_before[action].append(before_box.pose.pose.position.x)131 y_after[action].append(after_box.pose.pose.position.y)132 y_before[action].append(before_box.pose.pose.position.y)133 q_before = (134 before_box.pose.pose.orientation.x,135 before_box.pose.pose.orientation.y,136 before_box.pose.pose.orientation.z,137 before_box.pose.pose.orientation.w)138 q_after = (139 after_box.pose.pose.orientation.x,140 after_box.pose.pose.orientation.y,141 after_box.pose.pose.orientation.z,142 after_box.pose.pose.orientation.w)143 euler_before = tf.transformations.euler_from_quaternion(q_before)144 euler_after = tf.transformations.euler_from_quaternion(q_after)145 yaw_before = euler_before[2]146 yaw_after = euler_after[2]147 yaw_diff = yaw_after - yaw_before148 # rospy.loginfo("Before: {}".format(before_box))149 # rospy.loginfo("Before yaw: {}".format(yaw_before*180/math.pi))150 # rospy.loginfo("After: {}".format(after_box))151 # rospy.loginfo("After yaw: {}".format(yaw_after*180/math.pi))152 if (math.fabs(after_box.dimensions.x - before_box.dimensions.x) > 0.02) and (math.fabs(after_box.dimensions.y - before_box.dimensions.y) > 0.02):153 rospy.loginfo("Wrong axes")154 yaw_before -= math.pi/2.0155 156 if yaw_before < 0:157 if (math.fabs(yaw_after - (yaw_before + math.pi))) < (math.fabs(yaw_after - yaw_before)):158 rospy.loginfo("Flipped")159 yaw_before = (yaw_before + math.pi)160 else:161 if (math.fabs(yaw_after - (yaw_before - math.pi))) < (math.fabs(yaw_after - yaw_before)):162 rospy.loginfo("Flipped")163 yaw_before = (yaw_before - math.pi)164 rospy.loginfo("Yaw diff: {}".format(yaw_diff*180/math.pi))165 _yaw_before[action].append(copy.copy(yaw_before))166 _yaw_after[action].append(copy.copy(yaw_after))167 return x_before, x_after, y_before, y_after, _yaw_before, _yaw_after168 # self._action_names.append(trial.params.action)169 # self._item_names.append(trial.params.item_name) 170 def estimate(self):171 # plot x_diffs172 file_name = raw_input("Please enter the path to a test bag file: ")173 174 # rospy.loginfo("Current file: " + file_name)175 bag = rosbag.Bag(file_name)176 trial = None177 for topic, trial_msg, t in bag.read_messages():178 _x_before, _x_after, _y_before, _y_after, _yaw_before, _yaw_after = self.get_test_data(trial_msg)179 trial = trial_msg180 bag.close()181 action = _x_before.keys()[0]182 train_x_before = self._x_before[action]183 train_y_before = self._y_before[action]184 train_yaw_before = self._yaw_before[action]185 train_x_after = self._x_after[action]186 train_y_after = self._y_after[action]187 train_yaw_after = self._yaw_after[action]188 test_x_before = _x_before[action]189 test_y_before = _y_before[action]190 test_yaw_before = _yaw_before[action]191 test_x_after = _x_after[action]192 test_y_after = _y_after[action]193 test_yaw_after = _yaw_after[action]194 rospy.loginfo("Train x before: {}".format(train_x_before))195 rospy.loginfo("Train y before: {}".format(train_y_before))196 rospy.loginfo("Train yaw before: {}".format(train_yaw_before))197 rospy.loginfo("Test x before: {}".format(test_x_before))198 rospy.loginfo("Test y before: {}".format(test_y_before))199 rospy.loginfo("Test yaw before: {}".format(test_yaw_before))200 rospy.loginfo("Test x after: {}".format(test_x_after))201 rospy.loginfo("Test y after: {}".format(test_y_after))202 rospy.loginfo("Test yaw after: {}".format(test_yaw_after))203 # # Load the faces datasets204 # data = fetch_olivetti_faces()205 # targets = data.target206 # data = data.images.reshape((len(data.images), -1))207 # train = data[targets < 30]208 # test = data[targets >= 30] # Test on independent people209 # # Test on a subset of people210 # n_faces = 5211 # rng = check_random_state(4)212 # face_ids = rng.randint(test.shape[0], size=(n_faces, ))213 # test = test[face_ids, :]214 # n_pixels = data.shape[1]215 # X_train = train[:, :np.ceil(0.5 * n_pixels)] # Upper half of the faces216 # y_train = train[:, np.floor(0.5 * n_pixels):] # Lower half of the faces217 # X_test = test[:, :np.ceil(0.5 * n_pixels)]218 # y_test = test[:, np.floor(0.5 * n_pixels):]219 # Fit estimators220 ESTIMATORS = {221 # "Extra trees": ExtraTreesRegressor(n_estimators=10, max_features=32,222 # random_state=0),223 # "K-nn": KNeighborsRegressor(),224 "Linear Regression": LinearRegression(),225 "Ridge": RidgeCV(),226 # "Bayesian Ridge": BayesianRidge(),227 # "Theil-Sen Regressor": TheilSenRegressor(),228 "Lasso": Lasso(),229 }230 y_test_predict = dict()231 for name, estimator in ESTIMATORS.items():232 estimator.fit(zip(train_x_before, train_y_before, train_yaw_before), zip(train_x_after, train_y_after, train_yaw_after))233 y_test_predict[name] = estimator.predict(zip(test_x_before, test_y_before, test_yaw_before))234 rospy.loginfo("Predictions: {}".format(y_test_predict))235 rospy.loginfo("Pose: {}".format(trial.before.boundingbox.pose))236 # First publish original bounding box237 publish_bounding_box(self.markers, trial.before.boundingbox.pose, 238 (trial.before.boundingbox.dimensions.x), 239 (trial.before.boundingbox.dimensions.y), 240 (trial.before.boundingbox.dimensions.z),241 1.0, 1.0, 0.0, 0.5, 20)242 # And true result243 publish_bounding_box(self.markers, trial.after.boundingbox.pose, 244 (trial.after.boundingbox.dimensions.x), 245 (trial.after.boundingbox.dimensions.y), 246 (trial.after.boundingbox.dimensions.z),247 0.0, 1.0, 0.0, 0.5, 21)248 # Now one for each estimator249 colour = [{"r": 1.0, "g": 0.0, "b": 0.0}, {"r": 0.0, "g": 0.0, "b": 1.0}, 250 {"r": 1.0, "g": 0.0, "b": 1.0}, {"r": 0.0, "g": 1.0, "b": 1.0}]251 for j, est in enumerate(sorted(ESTIMATORS)):252 x = y_test_predict[est][0][0]253 y = y_test_predict[est][0][1]254 yaw = y_test_predict[est][0][2]255 pose = PoseStamped()256 pose.header.frame_id = "bin_K"257 pose.pose.position.x = x258 pose.pose.position.y = y259 pose.pose.position.z = trial.before.boundingbox.pose.pose.position.z260 quaternion = tf.transformations.quaternion_from_euler(0, 0, yaw)261 #type(pose) = geometry_msgs.msg.Pose262 pose.pose.orientation.x = quaternion[0]263 pose.pose.orientation.y = quaternion[1]264 pose.pose.orientation.z = quaternion[2]265 pose.pose.orientation.w = quaternion[3]266 publish_bounding_box(self.markers, pose, 267 (trial.after.boundingbox.dimensions.x), 268 (trial.after.boundingbox.dimensions.y), 269 (trial.after.boundingbox.dimensions.z),270 colour[j]["r"], colour[j]["g"], colour[j]["b"], 0.5, j + 30)271if __name__ == '__main__':272 rospy.init_node('trial_analyser')273 ta = TrialAnalyser()274 path = raw_input("Please enter the path to folder with the bag files: ")275 file_list = glob.glob( path + '/*.bag')276 for file_name in file_list:277 if not file_name[-13:] == 'evaluated.bag':278 continue279 # rospy.loginfo("Current file: " + file_name)280 bag = rosbag.Bag(file_name)281 for topic, trial_msg, t in bag.read_messages():282 ta.get_bounding_box_diff(trial_msg)283 bag.close()...
Retry.py
Source:Retry.py
1#!/usr/bin/evn python2# -*- coding:utf-8 -*-3# FileName Retry.py4# Author: HeyNiu5# Created Time: 201608096"""7éè¯æºå¶ >> é»è®¤3次81.å¾
å
¨é¨æ¥å£éååï¼è¯»ååå
¥æ¬å°çæ°æ®ï¼ååºå·²éåçæ¥å£å92.读åéååçå
¨é¨æ¥å£åï¼ä¸ä¸ä¸æ¥çæ°æ®æ±diff103.diffæ¥å£åä»éååçæ¥å£ä¸ååºç¸å
³æ°æ®ï¼å å
¥éè¯éå114.éè¯ä¸è¿°æ¥éª¤ï¼ç´è³diffä¸åå¨æéè¯æ¬¡æ°èå°½12"""13import os14import base.Request15import sessions.ReadSessions16import utils.FileUtil17import utils.Consts18def retry11(app_type, retry=3):19 """20 éè¯æºå¶ï¼é»è®¤3次21 :param app_type: 1 >> åå; 2 >> 家å¨; 3 >> è£
ä¿®22 :param retry: éè¯æ¬¡æ°23 :return:24 """25 r1 = Retry(retry)26 if len(r1.get_diff()) > 0:27 print('åç°diffæ¥å£ï¼éè¯æºå¶å¯å¨...')28 r1.retry1(app_type)29class Retry(object):30 def __init__(self, retry):31 """32 åå§å33 :param retry:34 """35 self.retry = retry36 self.after_normal_sessions_path = '%s%s%s' % (37 utils.Consts.SESSIONS_PATH, "\\Sessions\\", utils.Consts.HOST)38 def __get_normal_after_sessions(self):39 """40 è·åéååæ£å¸¸ï¼æ¥å£éè¿ï¼çæ¥å£å表41 :return:42 """43 return utils.FileUtil.get_file_list(self.after_normal_sessions_path)44 def __get_not_normal_after_sessions(self):45 """46 è·åéè¦äººå·¥éªè¯çæ¥å£VerifyRequest47 :return:48 """49 return self.__get_check_after_sessions('VerifyRequest')50 def __get_crash_after_sessions(self):51 """52 è·åç¨åºå¼å¸¸æ¥å£ProgramCrash53 :return:54 """55 return self.__get_check_after_sessions('ProgramCrash')56 def __get_unexpected_after_sessions(self):57 """58 è·åéé¢ææ¥å£Unexpected59 :return:60 """61 return self.__get_check_after_sessions('Unexpected')62 def __get_field_change_after_sessions(self):63 """64 è·åå段æ¹åæ¥å£FieldChange65 :return:66 """67 return self.__get_check_after_sessions('FieldChange')68 def __get_check_after_sessions(self, sessions_type):69 """70 è·åéè¦æ£æ¥çæ¥å£å表ï¼å·²å»é71 :param sessions_type:72 :return:73 """74 path = '%s\\Check\\%s.txt' % (self.after_normal_sessions_path, sessions_type)75 if os.path.exists(path):76 l = open(path, encoding='utf-8').readlines()77 sessions1 = ('%s.txt' % (i.replace('\n', '')[::-1].split('/', 1)[0][::-1]) for i in l if78 i.startswith('Request url: '))79 return list(set(sessions1))80 return ()81 def get_diff(self):82 """83 è·ådiffæ¥å£84 diff æ¥å£å
å«ç±»å85 1.response ååºç é200çæ¥å£86 2.请æ±è¶
æ¶çæ¥å£87 3.å
¶ä»æªç¥æ
åµçæ¥å£ï¼å¦ 代ç å¼å¸¸å¯¼è´ï¼88 :return:89 """90 before_sessions = utils.Consts.BEFORE_SESSIONS91 after_sessions = []92 normal_after_sessions = self.__get_normal_after_sessions()93 not_normal_after_sessions = self.__get_not_normal_after_sessions()94 unexpected_after_sessions = self.__get_unexpected_after_sessions()95 field_change_after_sessions = self.__get_field_change_after_sessions()96 crash_after_sessions = self.__get_crash_after_sessions()97 if normal_after_sessions is not None:98 after_sessions.extend(normal_after_sessions)99 if not_normal_after_sessions is not None:100 after_sessions.extend(not_normal_after_sessions)101 if crash_after_sessions is not None:102 after_sessions.extend(crash_after_sessions)103 if unexpected_after_sessions is not None:104 after_sessions.extend(unexpected_after_sessions)105 if field_change_after_sessions is not None:106 after_sessions.extend(field_change_after_sessions)107 return list(set(before_sessions).difference(set(after_sessions)))108 def __get_diff_sessions(self):109 """110 ä»æ¬å°ç£ç读ådiffæ¥å£sessions(request url; request header; ...)111 pass: ä¸ä¸ªæ¥å£å¤æ¡session112 :return:113 """114 diff = self.get_diff()115 for d in diff:116 print('diff sessions: %s' % (d, ))117 total_session = sessions.ReadSessions.ReadSessions().get_single_session(d)118 if len(total_session) == 0:119 print('åç°å½å¶å¼å¸¸æ¥å£ï¼' + d)120 print('æ§è¡ç§»é¤æä½ï¼ç§»é¤éè¯éå')121 # 移é¤å½å¶å¼å¸¸çæ¥å£122 os.remove('%s\\Api\\%s\\%s' % (utils.Consts.SESSIONS_PATH, utils.Consts.HOST, d))123 # å
¨å±åééååçå
¨é¨æ¥å£ä¹éè¦ç§»é¤124 utils.Consts.BEFORE_SESSIONS.remove(d)125 else:126 yield sessions.ReadSessions.ReadSessions().get_single_session(d)127 def __will_request_sessions(self):128 """129 å°è¦éè·çsessionsï¼æå¤ä¸ªæ¥å£çå¤ä¸ªsessionå并为ä¸ä¸ªå表130 :return:131 """132 s = self.__get_diff_sessions()133 return (j for i in s for j in i)134 def __request_sessions(self, app_type):135 """136 请æ±æ¥å£137 :return:138 """139 s = self.__will_request_sessions()140 base.Request.thread_pool(app_type, s)141 def retry1(self, app_type):142 """143 éè¯çæ¥å£ç±»å144 1.response ååºç é200çæ¥å£145 2.请æ±è¶
æ¶çæ¥å£146 3.å
¶ä»æªç¥æ
åµçæ¥å£ï¼å¦ 代ç å¼å¸¸å¯¼è´ï¼147 注æï¼å·²ç»ç¥é失败çæ¥å£ä¸ä¼åéè¯ï¼ç®åæ¯è¿æ ·èèç148 :return:149 """150 temp = self.retry151 while self.retry > 0:152 self.retry -= 1153 # 请æ±æ¥å£154 print('第%d次å°è¯è¯·æ±diff...' % (temp - self.retry,))155 self.__request_sessions(app_type)156 # å次æ±å·®å¼åæ件ï¼è¿ædiff继ç»ï¼å¦ååæ¢157 if len(self.get_diff()) > 0 and self.retry > 0:158 print('åç°diffåå¨ï¼ç»§ç»å°è¯è¯·æ±...')159 continue160 else:161 break162 print('diffæºå¶éåº...')163 # éè¯æºå¶å®æï¼å对æ¯ä¸æ¬¡æ°æ®ï¼ç¨äºçææ¥å164 self.get_diff()165if __name__ == "__main__":...
plugin.py
Source:plugin.py
1from Screens.Screen import Screen2from Screens.MessageBox import MessageBox3from Plugins.Plugin import PluginDescriptor4from Components.ConfigList import ConfigListScreen5from Components.ActionMap import ActionMap6from Components.config import config7from Components.NimManager import nimmanager as nimmgr8class SecParameterSetup(Screen, ConfigListScreen):9 skin = """10 <screen position="center,center" size="620,455" title="Satellite equipment setup" >11 <widget name="config" position="10,10" size="600,450" />12 </screen>"""13 def __init__(self, session):14 self.skin = SecParameterSetup.skin15 self["actions"] = ActionMap(["SetupActions", "MenuActions"],16 {17 "ok": self.keySave,18 "cancel": self.keyCancel,19 "menu": self.setDefault,20 }, -2)21 Screen.__init__(self, session)22 self.setTitle(_("Satellite equipment setup"))23 list = [24 (_("Delay after diseqc reset command"), config.sec.delay_after_diseqc_reset_cmd),25 (_("Delay after diseqc peripherial poweron command"), config.sec.delay_after_diseqc_peripherial_poweron_cmd),26 (_("Delay after continuous tone disable before diseqc"), config.sec.delay_after_continuous_tone_disable_before_diseqc),27 (_("Delay after final continuous tone change"), config.sec.delay_after_final_continuous_tone_change),28 (_("Delay after last voltage change"), config.sec.delay_after_final_voltage_change),29 (_("Delay between diseqc commands"), config.sec.delay_between_diseqc_repeats),30 (_("Delay after last diseqc command"), config.sec.delay_after_last_diseqc_command),31 (_("Delay after toneburst"), config.sec.delay_after_toneburst),32 (_("Delay after change voltage before switch command"), config.sec.delay_after_change_voltage_before_switch_command),33 (_("Delay after enable voltage before switch command"), config.sec.delay_after_enable_voltage_before_switch_command),34 (_("Delay between switch and motor command"), config.sec.delay_between_switch_and_motor_command),35 (_("Delay after set voltage before measure motor power"), config.sec.delay_after_voltage_change_before_measure_idle_inputpower),36 (_("Delay after enable voltage before motor command"), config.sec.delay_after_enable_voltage_before_motor_command),37 (_("Delay after motor stop command"), config.sec.delay_after_motor_stop_command),38 (_("Delay after voltage change before motor command"), config.sec.delay_after_voltage_change_before_motor_command),39 (_("Delay before sequence repeat"), config.sec.delay_before_sequence_repeat),40 (_("Motor running timeout"), config.sec.motor_running_timeout),41 (_("Motor command retries"), config.sec.motor_command_retries),42 (_("Unicable delay after enable voltage before switch command"), config.sec.unicable_delay_after_enable_voltage_before_switch_command),43 (_("Unicable delay after change voltage before switch command"), config.sec.unicable_delay_after_change_voltage_before_switch_command),44 (_("Unicable delay after last diseqc command"), config.sec.unicable_delay_after_last_diseqc_command) ]45 ConfigListScreen.__init__(self, list)46 def setDefault(self):47 self.session.openWithCallback(self.setDefaultCallback, MessageBox, _("Set default settings?"), MessageBox.TYPE_YESNO)48 def setDefaultCallback(self, answer):49 if answer:50 config.sec.delay_after_diseqc_reset_cmd.value = 5051 config.sec.delay_after_diseqc_peripherial_poweron_cmd.value = 15052 config.sec.delay_after_continuous_tone_disable_before_diseqc.value = 2553 config.sec.delay_after_final_continuous_tone_change.value = 1054 config.sec.delay_after_final_voltage_change.value = 1055 config.sec.delay_between_diseqc_repeats.value = 12056 config.sec.delay_after_last_diseqc_command.value = 5057 config.sec.delay_after_toneburst.value = 5058 config.sec.delay_after_change_voltage_before_switch_command.value = 2059 config.sec.delay_after_enable_voltage_before_switch_command.value = 20060 config.sec.delay_between_switch_and_motor_command.value = 70061 config.sec.delay_after_voltage_change_before_measure_idle_inputpower.value = 50062 config.sec.delay_after_enable_voltage_before_motor_command.value = 90063 config.sec.delay_after_motor_stop_command.value = 50064 config.sec.delay_after_voltage_change_before_motor_command.value = 50065 config.sec.delay_before_sequence_repeat.value = 7066 config.sec.motor_running_timeout.value = 36067 config.sec.motor_command_retries.value = 168 config.sec.delay_after_diseqc_reset_cmd.save()69 config.sec.delay_after_diseqc_peripherial_poweron_cmd.save()70 config.sec.delay_after_continuous_tone_disable_before_diseqc.save()71 config.sec.delay_after_final_continuous_tone_change.save()72 config.sec.delay_after_final_voltage_change.save()73 config.sec.delay_between_diseqc_repeats.save()74 config.sec.delay_after_last_diseqc_command.save()75 config.sec.delay_after_toneburst.save()76 config.sec.delay_after_change_voltage_before_switch_command.save()77 config.sec.delay_after_enable_voltage_before_switch_command.save()78 config.sec.delay_between_switch_and_motor_command.save()79 config.sec.delay_after_voltage_change_before_measure_idle_inputpower.save()80 config.sec.delay_after_enable_voltage_before_motor_command.save()81 config.sec.delay_after_motor_stop_command.save()82 config.sec.delay_after_voltage_change_before_motor_command.save()83 config.sec.delay_before_sequence_repeat.save()84 config.sec.motor_running_timeout.save()85 config.sec.motor_command_retries.save()86 self.close(True)87session = None88def confirmed(answer):89 global session90 if answer:91 session.open(SecParameterSetup)92def SecSetupMain(Session, **kwargs):93 global session94 session = Session95 session.openWithCallback(confirmed, MessageBox, _("Please do not change any values unless you know what you are doing!"), MessageBox.TYPE_INFO)96def SecSetupStart(menuid):97 show = False98 # other menu than "scan"?99 if menuid != "scan":100 return [ ]101 # only show if DVB-S frontends are available102 for slot in nimmgr.nim_slots:103 if slot.isCompatible("DVB-S"):104 return [(_("Satellite equipment setup"), SecSetupMain, "satellite_equipment_setup", None)]105 return [ ]106def Plugins(**kwargs):107 if (nimmgr.hasNimType("DVB-S")):108 return PluginDescriptor(name=_("Satellite equipment setup"), description=_("Setup your satellite equipment"), where = PluginDescriptor.WHERE_MENU, needsRestart = False, fnc=SecSetupStart)109 else:...
moodRatingTime.py
Source:moodRatingTime.py
1import pandas2import matplotlib.pyplot as plt3import numpy as np4import math5import cv26from PIL import Image7import datetime8df = pandas.read_csv('../data/moodLogFinal.csv')9df2after = pandas.read_csv('../data/moodLogFinalAfter.csv')10# 22. april 16.46 shift from no light control to light control11getEnergy = True12def reverse(n): 13 return 160 - n14timestamps = df["Timestamp"]15if(getEnergy):16 energyLevel = df["y"]17 energyLevel = map(reverse, energyLevel)18else:19 energyLevel = df["x"]20minutes = []21timestampsAfter = df2after["Timestamp"]22if(getEnergy):23 energyLevelAfter = df2after["y"]24 energyLevelAfter = map(reverse, energyLevelAfter)25else:26 energyLevelAfter = df2after["x"]27minutesAfter = []28for i in range(len(df)):29 date = datetime.datetime.fromtimestamp(df['Timestamp'][i] / 1e3)30 thisMinute = int(date.strftime("%M"))31 thisHour = int(date.strftime("%H"))32 minute = thisHour * 60 + thisMinute33 minutes.append(minute)34for i in range(len(df2after)):35 date = datetime.datetime.fromtimestamp(df['Timestamp'][i] / 1e3)36 thisMinute = int(date.strftime("%M"))37 thisHour = int(date.strftime("%H"))38 minute = thisHour * 60 + thisMinute39 minutesAfter.append(minute)40# AVG morning before41avgMorningBefore = 042avgMorningBeforeEnergy = 043counter = 044counter2 = 045while(counter < len(minutes)):46 if(minutes[counter] < 800):47 avgMorningBefore = avgMorningBefore + minutes[counter]48 avgMorningBeforeEnergy = avgMorningBeforeEnergy + energyLevel[counter]49 counter2 = counter2 + 150 counter = counter + 151avgMorningBefore = avgMorningBefore / counter252avgMorningBeforeEnergy = avgMorningBeforeEnergy / counter253# AVG evening before54avgEveningBefore = 055avgEveningBeforeEnergy = 056counter = 057counter2 = 058while(counter < len(minutes)):59 if(minutes[counter] > 800):60 avgEveningBefore = avgEveningBefore + minutes[counter]61 avgEveningBeforeEnergy = avgEveningBeforeEnergy + energyLevel[counter]62 counter2 = counter2 + 163 counter = counter + 164 print(counter2)65avgEveningBefore = avgEveningBefore / counter266avgEveningBeforeEnergy = avgEveningBeforeEnergy / counter267print(avgMorningBefore, avgMorningBeforeEnergy)68 69# AVG morning after70avgMorningAfter = 071avgMorningAfterEnergy = 072counter = 073counter2 = 074while(counter < len(minutesAfter)):75 if(minutes[counter] < 800):76 avgMorningAfter = avgMorningAfter + minutesAfter[counter]77 avgMorningAfterEnergy = avgMorningAfterEnergy + energyLevelAfter[counter]78 counter2 = counter2 + 179 counter = counter + 180avgMorningAfter = avgMorningAfter / counter281avgMorningAfterEnergy = avgMorningAfterEnergy / counter282# AVG evening after83avgEveningAfter = 084avgEveningAfterEnergy = 085counter = 086counter2 = 087while(counter < len(minutesAfter)):88 if(minutes[counter] > 800):89 avgEveningAfter = avgEveningAfter + minutesAfter[counter]90 avgEveningAfterEnergy = avgEveningAfterEnergy + energyLevelAfter[counter]91 counter2 = counter2 + 192 counter = counter + 193avgEveningAfter = avgEveningAfter / counter294avgEveningAfterEnergy = avgEveningAfterEnergy / counter295# From 0 to 16096area = np.pi*597# Plot98plt.grid(color='#eeeeee', linestyle='-', linewidth=1)99plt.scatter(minutes, energyLevel, s=area, color="#ff4040", label="Before")100plt.scatter(minutesAfter, energyLevelAfter, s=area, color="#4040ff", label="After")101#plt.scatter(avgMorningBefore, avgMorningBeforeEnergy, s=area, color="#00ff00", label="Before avg")102#plt.scatter(avgEveningBefore, avgEveningBeforeEnergy, s=area, color="#00ff00", label="Before avg")103#plt.scatter(avgMorningAfter, avgMorningAfterEnergy, s=area, color="#ffff00", label="After avg")104#plt.scatter(avgEveningAfter, avgEveningAfterEnergy, s=area, color="#ffff00", label="After avg")105plt.plot([avgMorningBefore, avgEveningBefore], [avgMorningBeforeEnergy, avgEveningBeforeEnergy], color="#ff4040", label="Before (avg)")106plt.plot([avgMorningAfter, avgEveningAfter], [avgMorningAfterEnergy, avgEveningAfterEnergy], color="#4040ff", label="After (avg)")107plt.title('Time of mood rating and energy level')108plt.xlabel('Time of day in minutes')109if(getEnergy):110 plt.ylabel('Energy level')111else:112 plt.ylabel('Happiness')113plt.ylim(0, 160)114plt.legend()...
moodBoxPlot.py
Source:moodBoxPlot.py
1import pandas2import matplotlib.pyplot as plt3import numpy as np4import math5import cv26from PIL import Image7import datetime8df = pandas.read_csv('../data/moodLogFinal.csv')9df2after = pandas.read_csv('../data/moodLogFinalAfter.csv')10# 22. april 16.46 shift from no light control to light control11getEnergy = True12def reverse(n): 13 return 160 - n14timestamps = df["Timestamp"]15energyLevel = df["y"]16energyLevel = map(reverse, energyLevel)17happinessLevel = df["x"]18minutes = []19timestampsAfter = df2after["Timestamp"]20energyLevelAfter = df2after["y"]21energyLevelAfter = map(reverse, energyLevelAfter)22happinessLevelAfter = df2after["x"]23minutesAfter = []24for i in range(len(df)):25 date = datetime.datetime.fromtimestamp(df['Timestamp'][i] / 1e3)26 thisMinute = int(date.strftime("%M"))27 thisHour = int(date.strftime("%H"))28 minute = thisHour * 60 + thisMinute29 minutes.append(minute)30for i in range(len(df2after)):31 date = datetime.datetime.fromtimestamp(df['Timestamp'][i] / 1e3)32 thisMinute = int(date.strftime("%M"))33 thisHour = int(date.strftime("%H"))34 minute = thisHour * 60 + thisMinute35 minutesAfter.append(minute)36# AVG morning before37avgMorningBefore = 038avgMorningBeforeEnergy = 039counter = 040counter2 = 041while(counter < len(minutes)):42 if(minutes[counter] < 800):43 avgMorningBefore = avgMorningBefore + minutes[counter]44 avgMorningBeforeEnergy = avgMorningBeforeEnergy + energyLevel[counter]45 counter2 = counter2 + 146 counter = counter + 147avgMorningBefore = avgMorningBefore / counter248avgMorningBeforeEnergy = avgMorningBeforeEnergy / counter249# AVG evening before50avgEveningBefore = 051avgEveningBeforeEnergy = 052counter = 053counter2 = 054while(counter < len(minutes)):55 if(minutes[counter] > 800):56 avgEveningBefore = avgEveningBefore + minutes[counter]57 avgEveningBeforeEnergy = avgEveningBeforeEnergy + energyLevel[counter]58 counter2 = counter2 + 159 counter = counter + 160 print(counter2)61avgEveningBefore = avgEveningBefore / counter262avgEveningBeforeEnergy = avgEveningBeforeEnergy / counter263print(avgMorningBefore, avgMorningBeforeEnergy)64 65# AVG morning after66avgMorningAfter = 067avgMorningAfterEnergy = 068counter = 069counter2 = 070while(counter < len(minutesAfter)):71 if(minutes[counter] < 800):72 avgMorningAfter = avgMorningAfter + minutesAfter[counter]73 avgMorningAfterEnergy = avgMorningAfterEnergy + energyLevelAfter[counter]74 counter2 = counter2 + 175 counter = counter + 176avgMorningAfter = avgMorningAfter / counter277avgMorningAfterEnergy = avgMorningAfterEnergy / counter278# AVG evening after79avgEveningAfter = 080avgEveningAfterEnergy = 081counter = 082counter2 = 083while(counter < len(minutesAfter)):84 if(minutes[counter] > 800):85 avgEveningAfter = avgEveningAfter + minutesAfter[counter]86 avgEveningAfterEnergy = avgEveningAfterEnergy + energyLevelAfter[counter]87 counter2 = counter2 + 188 counter = counter + 189avgEveningAfter = avgEveningAfter / counter290avgEveningAfterEnergy = avgEveningAfterEnergy / counter291box_plot_data=[energyLevel, energyLevelAfter, happinessLevel, happinessLevelAfter]92plt.boxplot(box_plot_data, labels=['Energy before', 'Energy after', 'Happiness before', 'Happiness after'])...
blacklist_filter.py
Source:blacklist_filter.py
1# coding=utf-82"""3@author: xing4@contact: 1059252359@qq.com5@file: blacklist_filter.py6@date: 2021/3/3 10:067@desc: 8"""9import re10from pre_processing.prepro_utils import *11from pre_processing.email_sender import *12def removeDross(dir_path, source_db_path, before_uglifyjs_db_path, after_uglifyjs_db_path):13 # 读åæ°æ®14 total_data = read_data_from_db_files(source_db_path)15 # 1. åå»æä¸é¨åè¶
é¿çæ°æ®16 after_too_long_data = [i for i in total_data if not len(i) > 100000]17 logging.info(f'·After removing the data with rows greater than 10W, remaining: {len(after_too_long_data)}')18 # 2. è¿æ»¤ææænockç±»æ°æ®ï¼è¯¥ç±»æ°æ®æ²¡æä»ä¹æä¹19 after_nock_data = [i for i in after_too_long_data if not i.startswith('function(nock')]20 logging.info(f'·After removing the Nock data, remaining: {len(after_nock_data)}')21 # 3. è¿æ»¤æå½¢å¦ function(...) {}çæ°æ®22 after_immediate_data = []23 discarded_functions = []24 pattern_1 = re.compile('^function(.*?){}$')25 for function in after_nock_data:26 if re.match(pattern_1, function) is not None:27 discarded_functions.append(function)28 else:29 after_immediate_data.append(function)30 logging.info(f'After removing the function(...), remaining: {len(after_immediate_data)}')31 # 4. è¿æ»¤æå
¶ä¸ææéè±ææ°æ®32 after_english_data = filter_english_data(after_immediate_data)33 logging.info(f'·After removing all non-English data, remaining: {len(after_english_data)}')34 # 5. æé»ååå
容è¿æ»¤35 after_blacklist_filter_data = filter_blacklist_data(after_english_data)36 logging.info(f'·After removing the data in the blacklist, remaining: {len(after_blacklist_filter_data)}')37 # 5.5 æåä¸ä¸38 if not os.path.exists(dir_path):39 os.mkdir(dir_path)40 list2db(after_too_long_data, os.path.join(dir_path, before_uglifyjs_db_path)) # total_data_guolvhou.dbï¼å
±288665æ¡ãuglifyjsç¾ååå©ä½288564æ¡41 # 6. å©ç¨uglifyjså»é¤æ³¨é以åç¾åï¼æ ¼å¼åï¼,åå
¥æ°æ®åºå¤ä»½42 # æ¤å¤åºå½æ³¨æ uglifyjså®è£
çè·¯å¾ï¼å¿
è¦æ¶éè¦è¿å
¥uglifyjs_filterä¸ä¿®æ¹43 after_uglifyjs_data = uglifyjs_filter(after_blacklist_filter_data, 32)44 after_uglifyjs_data = deduplicate(after_uglifyjs_data) # éç¨ä¸ç¨³å®å»é45 list2db(after_uglifyjs_data, os.path.join(dir_path, after_uglifyjs_db_path))46 logging.info(f'·After deannotating, beautifying, and deduplicating, remaining: {len(after_uglifyjs_data)}')47 # # æ§è¡å®æåé®ä»¶åç¥48 # EmailSender = email_sender('1059252359@qq.com')...
main_spanish.py
Source:main_spanish.py
1# Dependencies2import os3from sentiment_analysis_spanish import sentiment_analysis4# Select political leader5leader = "lula"6# Get rise and fall text files as single strings7file_path = os.path.join(os.getcwd(), "data", leader, "spanish", "rise.txt")8with open(file_path, 'r', encoding = "utf-8") as file:9 str_before = file.read()10file_path = os.path.join(os.getcwd(), "data", leader, "spanish", "fall.txt")11with open(file_path, 'r', encoding = "utf-8") as file:12 str_after = file.read()13# Sentiment analysis, see https://pypi.org/project/sentiment-analysis-spanish/14# Initialize sentiment analysis class15sentiment = sentiment_analysis.SentimentAnalysisSpanish()16print("--- PARAGRAPH BY PARAGRAPH ANALYSIS ---")17# Make rise article into paragraph-based list and do sentiment analysis18para_before = str_before.split("\n")19before_sentiment = list()20for i in range(len(para_before)):21 before_sentiment.append(sentiment.sentiment(para_before[i]))22print("Average sentiment for rise article is {:.4f}".format(23 sum(before_sentiment)/len(before_sentiment), 2))24# Make fall article into paragraph-based list and do sentiment analysis25para_after = str_after.split("\n")26after_sentiment = list()27for i in range(len(para_after)):28 after_sentiment.append(sentiment.sentiment(para_after[i]))29print("Average sentiment for fall article is {:.4f}".format(30 sum(after_sentiment)/len(after_sentiment), 2))31# Get ratio based result to see fall/rise sentiment32print("Ratio of fall/rise sentiment is thus {:.4f}".format(33 (sum(after_sentiment)/len(after_sentiment))/(sum(before_sentiment)/len(before_sentiment))))34print("--- SENTENCE BY SENTENCE ANALYSIS ---")35# Now do this per sentence36sen_before = str_before.replace("\n", "").split(".")37before_sentiment = list()38for i in range(len(sen_before)):39 before_sentiment.append(sentiment.sentiment(sen_before[i]))40print("Average sentiment for rise article is {:.4f}".format(41 sum(before_sentiment)/len(before_sentiment), 2))42sen_after = str_after.replace("\n", "").split(".")43after_sentiment = list()44for i in range(len(sen_after)):45 after_sentiment.append(sentiment.sentiment(sen_after[i]))46print("Average sentiment for fall article is {:.4f}".format(47 sum(after_sentiment)/len(after_sentiment), 2))48# Get ratio based result to see fall/rise sentiment49print("Ratio of fall/rise sentiment is thus {:.4f}".format(...
79.py
Source:79.py
1with open("p079_keylog.txt") as f:2 content = [line.rstrip('\n') for line in f]34after = {}5#print(after)6for c in content:7 if int(c[0]) not in after.keys():8 after[int(c[0])] = []9 if int(c[1]) not in after.keys():10 after[int(c[1])] = []11 if int(c[2]) not in after.keys():12 after[int(c[2])] = []13 if int(c[1]) not in after[int(c[0])]:14 after[int(c[0])].append(int(c[1]))15 if int(c[2]) not in after[int(c[0])]:16 after[int(c[0])].append(int(c[2]))17 if int(c[2]) not in after[int(c[1])]:18 after[int(c[1])].append(int(c[2]))19k = list(after.keys())20k.sort(key=lambda x: len(after[x]), reverse=True)
...
Using AI Code Generation
1ladle.after(function(){2});3ladle.before(function(){4});5ladle.beforeEach(function(){6});7ladle.afterEach(function(){8});9ladle.describe('description of test', function(){10});11ladle.it('description of test', function(){12});13ladle.expect('value').to.be('value');14ladle.expect('value').to.equal('value');15ladle.expect('value').to.not.be('value');16ladle.expect('value').to.not.equal('value');17ladle.expect('value').to.be.an('object');18ladle.expect('value').to.be.a('string');19ladle.expect('value').to.be.a('number');20ladle.expect('value').to.be.a('boolean');21ladle.expect('value').to.be.a('function');22ladle.expect('value').to.be.a('array');23ladle.expect('value').to.not.be.an('object');24ladle.expect('value').to.not.be.a('string');
Using AI Code Generation
1ladle.around('method', function() { console.log('around method'); });2ladle.before('method', function() { console.log('before method'); });3ladle.after('method', function() { console.log('after method'); });4ladle.around('method', function() { console.log('around method'); });5ladle.before('method', function() { console.log('before method'); });6ladle.after('method', function() { console.log('after method'); });7ladle.around('method', function() { console.log('around
Using AI Code Generation
1var ladle = require('ladle');2var ladleOptions = {3};4var redisServer = ladle.start(ladleOptions, function(err, server) {5 if (err) {6 console.log('Error starting redis server');7 process.exit();8 }9 console.log('Redis server started on port ' + server.port);10 server.stop(function(err) {11 if (err) {12 console.log('Error stopping redis server');13 process.exit();14 }15 });16});
Using AI Code Generation
1ladle.after(function(err, res, next) {2 if (err) return next(err);3 console.log('After method called');4 next();5});6ladle.before(function(req, next) {7 console.log('Before method called');8 next();9});10ladle.error(function(err, res, next) {11 console.log('Error method called');12 next();13});14ladle.finally(function(err, res, next) {15 console.log('Finally method called');16 next();17});18ladle.before(function(req, next) {19 console.log('Before method called');20 next();21});22ladle.error(function(err, res, next) {23 console.log('Error method called');24 next();25});26ladle.finally(function(err, res, next) {27 console.log('Finally method called');28 next();29});30ladle.before(function(req, next) {31 console.log('Before method called');32 next();33});34ladle.error(function(err, res, next) {35 console.log('Error method called');36 next();37});38ladle.finally(function(err, res, next) {39 console.log('Finally method called');40 next();41});42ladle.before(function(req, next) {43 console.log('Before method called');44 next();45});46ladle.error(function(err, res, next) {47 console.log('Error method called');48 next();49});50ladle.finally(function(err, res, next) {51 console.log('Finally method called');52 next();53});54ladle.before(function(req, next) {55 console.log('Before method called');56 next();57});58ladle.error(function(err, res, next) {59 console.log('Error method called');60 next();61});
Using AI Code Generation
1var ladle = require('ladle');2var db = ladle.createClient();3db.after('set', function (err, result) {4 console.log('set finished');5});6db.after('get', function (err, result) {7 console.log('get finished');8});9db.set('test', 'testval');10db.get('test');11var ladle = require('ladle');12var db = ladle.createClient();13db.before('set', function (key, value) {14 console.log('set started');15});16db.before('get', function (key) {17 console.log('get started');18});19db.set('test', 'testval');20db.get('test');21var ladle = require('ladle');22var db = ladle.createClient();23db.around('set', function (key, value, next) {24 console.log('set started');25 next();26 console.log('set finished');27});28db.around('get', function (key, next) {29 console.log('get started');30 next();31 console.log('get finished');32});33db.set('test', 'testval');34db.get('test');35var ladle = require('ladle');36var db = ladle.createClient();37db.around('set', function (key, value, next) {38 console.log('set started');39 next();40 console.log('set finished');41});42db.around('get', function (key, next) {43 console.log('get started');44 next();45 console.log('get finished');46});47db.set('test', 'testval');48db.get('test');49var ladle = require('ladle');50var db = ladle.createClient();51db.around('set', function (key, value, next) {52 console.log('set started');53 next();
Using AI Code Generation
1var ladle = require('ladle');2var ladleOptions = {3};4var server = ladle.spawn(ladleOptions, function(err, server) {5 if (err) throw err;6 console.log('Mongodb server started on port: ' + ladleOptions.port);7 server.after(function() {8 console.log('Mongodb server stopped');9 });10});
Using AI Code Generation
1var ladle = require('ladle');2var ladleOptions = {3};4var ladleInstance = ladle.create(ladleOptions);5ladleInstance.start(function(err, server) {6 if (err) {7 console.error(err);8 } else {9 console.log('Ladle server started');10 server.stop(function(err) {11 if (err) {12 console.error(err);13 } else {14 console.log('Ladle server stopped');15 }16 });17 }18});
Using AI Code Generation
1var ladle = require('ladle');2var ladle = ladle.createLadle();3ladle.after('test', function (err, res) {4 if(err) {5 console.log(err);6 } else {7 console.log(res);8 }9});10ladle.before('test', function (err, res) {11 if(err) {12 console.log(err);13 } else {14 console.log(res);15 }16});17ladle.around('test', function (err, res) {18 if(err) {19 console.log(err);20 } else {21 console.log(res);22 }23});24ladle.beforeAll('test', function (err, res) {25 if(err) {26 console.log(err);27 } else {28 console.log(res);29 }30});31ladle.afterAll('test', function (err, res) {32 if(err) {33 console.log(err);34 } else {35 console.log(res);36 }37});38ladle.aroundAll('test', function (err, res) {39 if(err) {40 console.log(err);41 } else {42 console.log(res);43 }44});45ladle.beforeAll('test', function (err, res) {46 if(err) {47 console.log(err);48 } else {49 console.log(res);50 }51});52ladle.afterAll('test', function (err, res) {53 if(err) {54 console.log(err);55 } else {56 console.log(res);57 }58});59ladle.aroundAll('test', function (err, res) {60 if(err) {61 console.log(err);62 } else {63 console.log(res);64 }65});66ladle.afterAll('test', function (err, res) {67 if(err) {68 console.log(err);69 } else {70 console.log(res);71 }72});73ladle.aroundAll('test', function (err
Using AI Code Generation
1const ladle = require('./ladle');2const ladleObj = ladle.newLadle();3ladleObj.after('test', function (data, next) {4 console.log('after method called');5 next();6});7ladleObj.test('test data');8const ladle = require('./ladle');9const ladleObj = ladle.newLadle();10ladleObj.before('test', function (data, next) {11 console.log('before method called');12 next();13});14ladleObj.test('test data');15const ladle = require('./ladle');16const ladleObj = ladle.newLadle();17ladleObj.around('test', function (data, next) {18 console.log('around method called');19 next();20});21ladleObj.test('test data');22const ladle = require('./ladle');23const ladleObj = ladle.newLadle();24ladleObj.before('test', function (data, next) {25 console.log('before method called');26 next();27});28ladleObj.after('test', function (data, next) {29 console.log('after method called');30 next();31});32ladleObj.test('test data');33const ladle = require('./ladle');34const ladleObj = ladle.newLadle();35ladleObj.before('test', function (data, next) {36 console.log('before method called');37 next();38});39ladleObj.after('test', function (data, next) {40 console.log('after method called');41 next();42});43ladleObj.test('test data');
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!!