def update(self): target_set = model.find(lambda x: isinstance(x, Prey)) eaten_set = model.find( lambda x: self.contains(x) and isinstance(x, Prey)) for ball in eaten_set: model.remove(ball) alist = [(i, i.distance(self.get_location())) for i in target_set if i.distance(self.get_location()) < Special.valid_distance] alist = sorted(alist, key=lambda x: x[1]) if alist == []: self.set_speed(5) pass else: close_one = alist[0][0] y_differ = close_one.get_location()[1] - self.get_location()[1] x_differ = close_one.get_location()[0] - self.get_location()[0] new_angle = atan2(y_differ, x_differ) self.set_angle(new_angle) self.set_speed(40) self.move()
def update(self): if random.random() <= 0.2: model.add(Ball(self._x, self._y)) self.change_dimension(2, 2) else: self.change_dimension(-1, -1) if self.get_dimension() == (0, 0): model.remove(self)
def update(self): blackhole_can_eat = model.find(lambda temp: isinstance(temp, Prey) and temp.contains((self._x, self._y))) for each in blackhole_can_eat: model.remove(each) return blackhole_can_eat
def mouse_click(x, y): if current_object == '': pass elif current_object == 'Remove': for s in list(placed_objects): if s.contains((x, y)): model.remove(s) else: placed_objects.add(eval(current_object + '({},{})'.format(x, y)))
def update(self): eaten_1= model.find(lambda x:isinstance(x, Prey)) eaten=set() for i in eaten_1: if self.contains(i.get_location()): eaten.add(i) for i in eaten: model.remove(i) return eaten
def remove_item(): if not session.get('logged_in'): abort(401) try: model.remove(db_items(), request.form['item']) except model.DataError as error: return make_response(jsonify({'error': str(error)}), 400) return jsonify({'result': True})
def remove_kid(self): if self.validate_input(): model.remove(self.kid_id.text) print("Child removed") self.kid_id.text = "" else: error_pop = ErrorPopup() error_pop.ids.error.text = "Failed to remove student in database.try again" error_pop.title = "Removing Error" error_pop.open()
def update( self): #,model):#:,model):# model): #,model):#, model): #,model): #variable = 10 # self.set_location(self._new_x, self._new_y) #v = ((self._new_x, self._new_y)) new_items = model.find( lambda u: isinstance(u, Prey) and self.contains(u.get_location())) for x in new_items: model.remove(x) return new_items
def update(self): eaten = set() def p(arg): return isinstance(arg, Prey) and self.contains(arg) eatable = model.find(p) for i in eatable: model.remove(i) eaten.add(i) return eaten
def update(self): eaten=Black_Hole.update(self) self._counter+=1 if len(eaten)!=0: self.change_dimension(len(eaten), len(eaten)) self._counter=0 if self._counter == Pulsator.counter_constant: self.change_dimension(-1, -1) self._counter=0 if self.get_dimension() == (0,0): model.remove(self) return eaten
def update(self, model): self.counter += 1 eaten = Black_Hole.update(self, model) if eaten: self.counter = 0 self.change_dimension(len(eaten), len(eaten)) elif self.counter == Pulsator.counter: self.change_dimension(-1, -1) if self._width == 0: model.remove(self) self.counter = 0 return eaten
def mouse_click(x, y): global objs, select obj_rem = None if select == 'Remove': for ob in objs: if ob.contains((x, y)): obj_rem = ob model.remove(obj_rem) else: exec('global sim\nsim = ' + select + str((x, y))) #print(sim) model.add(sim)
def update_all(): global cycle_count, objs if running: cycle_count += 1 ret = set() for ob in objs: if ob.update() != None: ret = ret.union(ob.update()) #print(ret) #asynchronously remove destroyed simultons to not urin update all iteration if ret != set(): for r in ret: model.remove(r)
def remove_close_parasites(self): all_parasites = model.find(self.is_parasite) for i in all_parasites: if self.distance(i.get_location()) <= self._width/2: #print(i.immunity) if i.immunity == False: #print('removing') ######################## model.remove(i) if i.target == self.target1: self.target1 = None elif i.target == self.target2: self.target2 = None if i.success == True: self.change_dimension(1,1)
def update(self): eaten = Black_Hole.update(self) if len(eaten) != 0: self.change_dimension(len(eaten), len(eaten)) self.counter = 0 else: if self.counter + 1 == 30: self.counter = 0 self.change_dimension(-1, -1) if self.get_dimension() == (0, 0): model.remove(self) else: self.counter += 1 return eaten
def update(self): ate = Black_Hole.update(self) if ate: self.change_dimension(len(ate), len(ate)) self._counter = 0 else: self._counter +=1 if self._counter == 30: self._counter = 0 self.change_dimension(-1,-1) if self.get_dimension() == (0,0): model.remove(self) return ate
def remove_spot(): if 'user_id' in session: if 'user_admin' not in session or session['user_admin'] is False: return redirect(url_for('status')) else: return redirect(url_for('admin')) if request.method == 'POST': data = request.form.to_dict(flat=True) model.remove(data['spot_id']) return router['remove_spot'](['success'], data=model.garages()) return router['remove_spot']([], data=model.garages())
def update(self): self._pulse_count += 1 inside = model.find(lambda x: self.contains(x.get_location()) and isinstance(x, Prey)) for i in inside: model.remove(i) if len(inside) > 0: self._width += len(inside) self._height += len(inside) self._pulse_count = 0 if self._pulse_count == Pulsator.shrink_timer: self._height -= 1 self._width -= 1 self._pulse_count = 0 if self._width == 0: model.remove(self)
def update(self): self.pulsator_counter += 1 Eaten_item_set = Black_Hole.update(self) if self.get_dimension() == (0,0): model.remove(self) if self.pulsator_counter == Pulsator.counter_constant: Black_Hole.change_dimension(self,-1,-1) self.pulsator_counter = 0 for item in Eaten_item_set: Black_Hole.change_dimension(self,1,1) self.pulsator_counter = 0 return Eaten_item_set
def update(self): #,model):#,model):#,model):#model): subtract_one = -1 self._counting_object += 1 new_variable = Black_Hole.update(self) #,model)#model)#model)#,model) #deleted_object = Black_Hole.update(self,model) if new_variable: # self._counting_object = 0 self.change_dimension(len(new_variable), len(new_variable)) self._counting_object = 0 elif self._counting_object == 30: self.change_dimension(subtract_one, subtract_one) if self.get_dimension()[0] == 0: model.remove(self) self._counting_object = 0 return new_variable
def callback_gender_handler(callback_query): message = callback_query.message status = get_state(message) text = callback_query.data # gender if status == GENDER: info_about_user['gender'] = text bot.answer_callback_query(callback_query_id=callback_query.id) bot.send_message( chat_id=message.chat.id, text= "Отлично! Теперь введите свой вес в киллограммах(округлите до целых)." ) update_state(message, WEIGHT) if status == DONE: if text == '1) Запустить бота': bot_on(message) current_time = datetime.now(timezone.utc) time = str(current_time).split()[-1].split(':') reminder_time = round(float(f'{time[0]}.{time[1]}') + 1, 2) add_reminder_time(message, reminder_time) bot.send_message( chat_id=message.chat.id, text= "Бот запущен, теперь он будет напоминать пить воду каждый час!" ) if text == '2) Изменить данные о себе': status = check_bot_status(message) if status == 'on': bot.send_message(chat_id=message.chat.id, text='Сначала необходимо остановить бота!') control_the_bot(message) else: remove(message) update_state(message, START) bot.send_message( chat_id=message.chat.id, text='Кликнете на ---> /start в данном сообщении.') if text == '3) Остановить бота': bot_off(message) bot.send_message(chat_id=message.chat.id, text='Бот остановлен!') control_the_bot(message)
def update(self): if self.radius - 1 != 0: something_is_eaten = Black_Hole.update(self) if something_is_eaten: self.change_dimension(1, 1) self.count = 0 else: self.count += 1 if self.count == Pulsator.disappear: if self.radius - 1 == 0: model.remove(self) self.count == 0 else: self.change_dimension(-1, -1) self.count = 0 return something_is_eaten else: model.remove(self)
def update(self): temp = model.find(lambda o: o != None) if self.check == True: if self.target not in temp and self.immunity == True: self.immunity = False self.success = False self.check = False if self.immunity == True and self.target in temp: self._angle = atan2((self.target.get_location()[1] - self._y), (self.target.get_location()[0] - self._x)) if self.distance(self.target.get_location()) <= 5: model.remove(self.target) self.immunity = False self.check = False else: self._angle = atan2((self.mothership.get_location()[1] - self._y), (self.mothership.get_location()[0] - self._x)) self.move()
def update(self): self.counter += 1 target_set = model.find(lambda x: isinstance(x, Prey)) alist = [(i, i.distance(self.get_location())) for i in target_set if i.distance(self.get_location()) < Hunter.valid_distance] alist = sorted(alist, key=lambda x: x[1]) if alist == []: pass else: close_one = alist[0][0] y_differ = close_one.get_location()[1] - self.get_location()[1] x_differ = close_one.get_location()[0] - self.get_location()[0] new_angle = atan2(y_differ, x_differ) self.set_angle(new_angle) eaten_set = model.find( lambda x: self.contains(x) and isinstance(x, Prey)) for ball in eaten_set: model.remove(ball) if len(eaten_set) != 0: self.change_dimension(len(eaten_set), len(eaten_set)) self.counter = 0 else: if self.counter == Pulsator.counter_constant: self.change_dimension(-1, -1) self.counter = 0 if self.get_dimension() == (0, 0): model.remove(self) self.move()
def self_destruct(self): model.remove(self)
def delete_eaten(self): for i in model.find(lambda x: isinstance(x, Prey)): if self.contains(i): model.remove(i)
def update(self): inside = model.find(lambda x: self.contains(x.get_location()) and isinstance(x, Prey)) for i in inside: model.remove(i) return inside
def test_raises_error_when_no_id(self): d = {'a': 1, 'b': 2} model = self.ModelTest(d) self.assertFalse(hasattr(model, '_id')) with self.assertRaises(ValueError): model.remove()
import pickle import model text_to_list = [] pred_class = [] output_class = [] max_seq_len = 1000 loaded_model = pickle.load(open('rnn_model.sav', 'rb')) indexed_type = pickle.load(open('indexed_type.sav', 'rb')) with open('tokenizer.pickle', 'rb') as handle: tokenizer = pickle.load(handle) text = BeautifulSoup(input("Enter the text to be classified...")) text = model.remove(str(text.get_text().encode())) text_to_list.append(text) sequence = tokenizer.texts_to_sequences(text_to_list) data = pad_sequences(sequence, maxlen=max_seq_len) print('Shape of Data Tensor:', data.shape) y_pred = loaded_model.predict(data) for row in y_pred: rows = list(row) pred_class.append(rows.index(max(rows))) for i in pred_class: output_class.append(list(indexed_type.keys())[list(indexed_type.values()).index(i)])
def update(self): objects_eaten = model.find( lambda x: self.contains(x)) # find(p) where p is predicate for each_object in objects_eaten: if each_object in model.all_objects: model.remove(each_object)
def seppuku(self): model.remove(self)
def update(self): temp = model.find(self.contains_obj) for i in temp: model.remove(i) return temp
def update(self): eaten = model.find(lambda x: isinstance(x, Prey) and self.contains(x)) for e in eaten: model.remove(e) return eaten
def self_destruct_parasites(self): all_parasites = model.find(self.is_parasite) for i in all_parasites: if i.target == self.target1 or i.target == self.target2: model.remove(i)