def main(): initx = -4 finalx = 4 numpoints = 500 error = 0.00001 rootsf = [] rootsg = [] rootsh = [] run = Functions(initx, finalx, numpoints) run.plotf() #roots by inspect; -2.5, 1.2, 3.4 run.plotg() #root by inspect; 0.7 run.ploth() #roots by inspect; 0, 1.0, 2.1, 3.1 nr = NewtonRaphson(1) rootsf.append(nr.iteratef(-2.5, 500)) rootsf.append(nr.iteratef(1.2, 500)) rootsf.append(nr.iteratef(3.4, 500)) rootsg.append(nr.iterateg(0.7, 500)) rootsh.append(nr.iterateh(0.1, 500)) rootsh.append(nr.iterateh(1.0, 500)) rootsh.append(nr.iterateh(2.1, 500)) rootsh.append(nr.iterateh(3.1, 500)) print('The roots of f(x) are ' + str(rootsf)) print('The roots of g(x) are ' + str(rootsg)) print('The roots of h(x) are ' + str(rootsh))
def setup(self): self.links = Links() self.locators = Locator() self.functions = Functions(self.driver) self.login_page = LoginPage(self.driver) self.driver.get(self.links.login)
def __init__(self, address): super().__init__(address) self.about = About(self) self.access = Access(self) self.adjustment = Adjustment(self) self.axis = Axis(self) self.displacement = Displacement(self) self.ecu = Ecu(self) self.functions = Functions(self) self.manual = Manual(self) self.network = Network(self) self.nlc = Nlc(self) self.pilotlaser = Pilotlaser(self) self.realtime = Realtime(self) self.system = System(self) self.system_service = System_service(self) self.update = Update(self) try: self.streaming = Streaming(self) except NameError as e: if "Streaming" in str(e): print("Warning: Streaming is not supported on your platform") else: raise e
def setup(self): self.links = Links() self.locators = Locator() self.functions = Functions(self.driver) self.home = Home(self.driver) self.driver.get(self.links.home)
def __init__(self, serial_port): self.scorbot = Functions(serial_port) self.pos_ini = 'ini' self.pos_end = 'end' self.pos_user = '******' self.current_x = 97 self.current_y = -1959
def setup(self): self.links = Links() self.functions = Functions(self.driver) self.signup_page = SignUpPage(self.driver) self.yandex_page = YandexLogin(self.driver) self.driver.get(self.links.sign_up)
def make_experience(fun_name, interval, mesh_type, input_d, param_name, param=None): headers = ["Num samples", "Initial num of knots", "Best num interior knots" , "Cubic tolerance", "Error between cubic and lsq spline"] fun = Functions() table = PrettyTable(headers) file_name = "results/" + mesh_type + " mesh/" + fun_name + "_" + str(param) + "_results.txt" meta_info = fun_name + " with " + param_name + "=" + str(param) + "\n" for num_samples in input_d: init_num_knots = num_samples if param is not None: if param_name == "Epsilon": fun.eps = param function = fun.parse_func_name(fun_name) num_best_knots, tolerance, cubic_spl_err = test_on_function(function, interval[0], interval[1] , mesh_type, num_samples, init_num_knots , fun.eps) table.add_row([num_samples, init_num_knots, num_best_knots, cubic_spl_err, tolerance]) write_results_txt(file_name, meta_info, table.get_string()) table.clear_rows()
def get_category_name(self, category_index): li_elements = self.take_category_elements() category_name = li_elements[category_index].text Functions(self.driver).click_dynamic_element( li_elements[category_index]) return category_name
def __init__(self): pygame.init() self.settings = Settings() self.screen = pygame.display.set_mode(self.settings.screen_size) self.display = Display(self.settings, self.screen) self.snake = Snake(self.settings, self.display) self.function = Functions(self.settings, self.screen, self.display, self.snake)
def __call__(self, seq): self.seq = seq self.seq_alt_1 = seq[::2] self.seq_alt_2 = seq[1::2] self.functions = Functions() self.detect_ratio_signal() self.detect_diff_signal()
def __init__(self): pygame.init() self.settings = Settings() self.screen = pygame.display.set_mode(self.settings.screen_size) self.data = Data() self.block = Block(self.settings, self.screen, self.data) self.functions = Functions(self.settings, self.screen, self.block, self.data)
def __init__(self): super().__init__( command_prefix = "//", description = "" ) self.config = Config() self.db: AsyncIOMotorDatabase self.functions = Functions()
def __init__(self): super().__init__( command_prefix = Config.prefix, description = "Host crowd sources Q&As directly in your Discord guild. https://github.com/wwwaffles/amabot" ) self.config = Config() self.db: AsyncIOMotorDatabase self.functions = Functions()
def __init__(self): pygame.init() self.settings = Settings() self.screen = pygame.display.set_mode(self.settings.screen_size) self.compass = Compass() self.place = Place(self.settings, self.screen, self.compass) self.form = Form(self.settings, self.screen, self.compass) self.functions = Functions(self.settings, self.screen, self.compass, self.place, self.form)
def print_in_console(self, phrase): #print("Ingresa la palabra a buscar:") #query = input() functions = Functions(self.inverted_index_mem) query_terms = functions.retrieval_cosine(phrase) tweets_list = dict() for term in query_terms: tweet = self.print_full_tweet(str(term[0])) tweets_list[tweet] = term return tweets_list
def __init__(self): super().__init__( command_prefix='!', description= "A simple yet powerful moderation bot. Written in discord.py", intents=intents) self.config = Config() self.db: AsyncIOMotorDatabase self.functions = Functions()
def setup(self): self.links = Links() self.locators = Locator() self.functions = Functions(self.driver) self.login_page = LoginPage(self.driver) self.history_page = History(self.driver) self.driver.get(self.links.login) self.login_page.login_in_account() self.driver.get(Links.recordings)
def __init__(self, symbol, function, apiKey): self.symbol = symbol self.apiKey = apiKey functionEnum = Functions() if function == 1: self.function = functionEnum.Daily elif function == 2: self.function = functionEnum.Intraday else: self.function = functionEnum.DailyAdjusted
def get_function_values(self, state): variables_values = {n: self.fg.variables[n].domain[state[self.neighbours_indecies[n]]] for n in self.neighbours_indecies} variables_values[self.name] = self.fg.variables[self.name].domain[state[0]] functions = Functions(self.fg) function_values = [] for f in self.variable.functions: function_values.append(functions.calculate(f, variables_values)) return tuple(function_values)
def setup(self): self.links = Links() self.functions = Functions(self.driver) self.signup_page = SignUpPage(self.driver) self.account_page = Account(self.driver) self.yandex_page = YandexLogin(self.driver) self.login_page = LoginPage(self.driver) self.session = requests.Session() self.driver.get(self.links.account) self.login_page.login_in_account()
def __init__(self, dimensions): # first element = input-dim, the following = layer-dims self.num_layers = len(dimensions) - 1 # -1 : subtract input-dim self.layers = [] # and now the specified layers for i in range(self.num_layers): num_in = dimensions[i] num_out = dimensions[i+1] self.layers.append(Layer(num_in, num_out)) # activation functions self.activation_str = None self.functions = Functions() return
def __init__(self): pygame.init() self.settings = Settings() self.screen = pygame.display.set_mode(self.settings.screen_size) pygame.display.set_caption("Guess Number") self.buttons = pygame.sprite.Group() self.numbers = pygame.sprite.Group() self.guess = Guess(self.settings) self.functions = Functions(self.settings, self.screen, self.buttons, self.numbers, self.guess)
def get_possible_moves(self): variable = [self.name] + [n for n in self.neighbours_indecies] index = {n:0 for n in self.neighbours_indecies} index[self.name] = 0 domain = {n:[-1, 0, +1] for n in self.neighbours_indecies} domain[self.name] = [-1, 0, +1] actions = {-1: 'dec', 0:'hold', 1:'inc'} new_points = {'dec': [], 'hold': [], 'inc': []} functions = Functions(self.fg) while index[variable[0]] < len(domain[variable[0]]): new_state = [] action_profile = [] variables_values = {} all_in_boundaries = True for v in variable: value = self.state[0] if v in self.neighbours_indecies: value = self.state[self.neighbours_indecies[v]] i = value + domain[v][index[v]] if i >= 0 and i < self.fg.variables[v].domain_size: new_state.append(i) action_profile.append(actions[domain[v][index[v]]]) variables_values[v] = self.fg.variables[v].domain[i] else: all_in_boundaries = False break if all_in_boundaries: function_values = [] for f in self.variable.functions: function_values.append(functions.calculate(f, variables_values)) # format: ((action-profile, state), function-values) new_points[action_profile[0]].append(((tuple(action_profile), tuple(new_state)), tuple(function_values))) for i in reversed(variable): if index[i] < len(domain[i]): index[i] += 1 if index[i] == len(domain[i]): if i != variable[0]: index[i] = 0 else: break return new_points
def test_upload_objects(self): self.__moto_setup() f = Functions(parameter) f.upload_objects() s3_client = boto3.client("s3") s3_bucket_object_count = 0 response = s3_client.list_objects_v2(Bucket='shivam1052061') if response: try: for _object in response['Contents']: s3_bucket_object_count = s3_bucket_object_count + 1 except KeyError: print("KeyError. No such key exists in the specified bucket") # print(s3_bucket_object_count) self.assertEqual(s3_bucket_object_count, 10)
def __init__(self, driver): self.driver = driver self.driver.implicitly_wait(30) # Обьявляем ожидания для страниц # self.driver.set_window_size(1920, 1080) # Указываем размер окна self.driver.set_window_size(1920, 1080) # Указываем размер окна self.wait = WebDriverWait(self.driver, 30) # Указываем ожидания для элементов self.functions = Functions( self.driver ) # Создаем обьект для того чтобы использовать функции в pages ####################################################### # Тут обьявляем все константы, локаторы, ссылки, данные ####################################################### self.links = Links() self.Locator = Locator() self.data = Data()
def __init__(self, num_in, num_out): self.num_in = num_in self.num_out = num_out self.num_weights = num_in * num_out # vectors and weight matrix needed for learning and running self.input = None self.output = None self.weights = None self.sum = None self.delta = None self.delta_w = None # vectors for interim values self.derived = None self.diff = None self.tmp_col = None # self.functions = Functions()
def __init__(self, data, myfuncs): npoints = len(data.time) self.model = np.zeros(npoints) self.model_sys = np.zeros(npoints) self.model_astro = np.zeros(npoints) self.norm_flux = np.zeros(npoints) self.phase = np.zeros(npoints) self.resid = np.zeros(npoints) self.norm_resid = np.zeros(npoints) self.chi2 = 0. self.chi2red = 0. self.rms = 0. self.rms_predicted = 1.0e6*np.sqrt(np.mean((data.err/data.flux)**2)) #self.rms_predicted = 1.0e6*np.sqrt(np.mean(np.sqrt((1./data.flux))**2)) #wong because we binned over several pixels self.ln_like = 0. self.bic = 0. self.params = [] self.myfuncs = Functions(data, myfuncs)
def __init__(self, data, myfuncs): npoints = len(data.time) self.model = np.zeros(npoints) self.model_sys = np.zeros(npoints) self.model_astro = np.zeros(npoints) self.model_gp = np.zeros(npoints) self.norm_flux = np.zeros(npoints) self.phase = np.zeros(npoints) self.resid = np.zeros(npoints) self.norm_resid = np.zeros(npoints) self.chi2 = 0. self.chi2red = 0. self.rms = 0. self.rms_predicted = 1.0e6*np.sqrt(np.mean((data.err/data.flux)**2)) self.ln_like = 0. self.bic = 0. self.params = [] self.myfuncs = Functions(data, myfuncs)
def __init__(self): # Set Config files self.home = os.path.expanduser("~") self.configDir = self.home + "/.config/favoritesAppsIndicator" self.iconDefault = APP_DIR + "/icon/favoritesApps.png" # Init functions class self.functions = Functions(APP_DIR, self.iconDefault) # Read Json File self.json_file = self.configDir + "/favoritesApps.json" self.json_data = self.functions.read_json_file(self.json_file) self.cmd_stat_json_file = "stat -c '%y' \"" + self.json_file + "\"" self.stats_config_file = self.functions.exec_command_get_output( self.cmd_stat_json_file) # Init other class self.path_desktop_files = DesktopFilesInterface() self.favorites_files_manager = FavoritesFilesManagerInterface( self.json_data) self.app_info = AppInfoInterface(APP_DIR, self.iconDefault) # Other self.applicationID = 'favorites_apps_indicator' self.stop_thread = False self.locale = self.functions.get_locale_code() # Keys self.key_comment_JsonFile = "INFO" self.key_app_no_menu = "EXTERNALAPP" self.key_separator = "separator_" # Define Indicator self.indicator = AppIndicator3.Indicator.new( self.applicationID, self.iconDefault, AppIndicator3.IndicatorCategory.OTHER) self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE) # start service self.start_service_update_menu() # Create Set Menu self.indicator.set_menu(self.create_menu())
def create_widgets(self): child = LabelFrame(self.parent, text="Text Box", padx=5, pady=5) child.grid(row=1, column=0, columnspan=3, padx=10, pady=10, sticky=E + W + N + S) self.parent.columnconfigure(0, weight=1) self.parent.rowconfigure(1, weight=1) child.rowconfigure(0, weight=1) child.columnconfigure(0, weight=1) self.textBox = scrolledtext.ScrolledText(child, width=50, height=20) self.textBox.grid(column=0, row=0, sticky=E + W + N + S) self.t = Functions(self.textBox) self.t.pack(fill='both', expand=1) self.textBox.config(background='black', foreground='green') self.t.config(background='black', foreground='green')