def add_subject_to_cell(self, s: Subject, cells: list[set[Subject]] = None): subject_radius = MainConfiguration().SUBJECT_SIZE + MainConfiguration( ).SUBJECT_INFECTION_RADIUS left = int( (s.get_particle_component().position_vector[0] - subject_radius) / (MainConfiguration().MAIN_CANVAS_SIZE[0] / self.columns)) right = int( (s.get_particle_component().position_vector[0] + subject_radius) / (MainConfiguration().MAIN_CANVAS_SIZE[0] / self.columns)) bottom = int( (s.get_particle_component().position_vector[1] - subject_radius) / (MainConfiguration().MAIN_CANVAS_SIZE[1] / self.rows)) top = int( (s.get_particle_component().position_vector[1] + subject_radius) / (MainConfiguration().MAIN_CANVAS_SIZE[1] / self.rows)) top = top if top < self.rows else self.rows - 1 bottom = bottom if bottom >= 0 else 0 right = right if right < self.columns else self.columns - 1 left = left if left >= 0 else 0 try: cells[top][left].add(s) cells[top][right].add(s) cells[bottom][left].add(s) cells[bottom][right].add(s) except: print("Oooops")
def __init__(self, nsubjects=6): self.__subjects = [Subject()] * nsubjects self.__age = randint(10, 20) self.__average = 0 self.__access_time = randint(0, 240) self.__normalize_value = 0 self.__calc_average()
def addSubjectsPagePost(): name = request.form["name"] subject = Subject(name) db.session.add(subject) db.session.commit() result = "Ok" subjects = Subject.query.all() return render_template("subjects.html", subjects=subjects, type="add", result=result)
from application import db from models.User import User from models.Subject import Subject from models.Project import Project from models.Document import Document Subject.query.delete() Project.query.delete() # CREATE DOMAIN OBJECTS Engineering = Subject("Engineering") DataScience = Subject("Data Science") DigitalAudioEqualizer = Project(title="Digital Audio Equalizer", academic=True, subject=Engineering) FuzzyLogicClusteringAlgorithm = Project(title="Fuzzy Logic Clustering Algorithm", academic=False, subject=DataScience) # ADD AND COMMIT db.session.add_all([Engineering, DataScience, DigitalAudioEqualizer, FuzzyLogicClusteringAlgorithm]) db.session.commit() # PRINT print(Subject.query.all())
def getSubjectByID(data_params, subjectID): subjectEle = xaf.get_Subject_info( data_params, subjectID) #[ID, Date, Class, Age, Sex, MMSE] return Subject(*subjectEle)
from application import db from models.User import User from models.Subject import Subject from models.Project import Project db.create_all() # SUBJECTS Engineering = Subject("Engineering") db.session.add(Engineering) DataScience = Subject("Data Science") db.session.add(DataScience) # PROJECTS DigitalAudioEqualizer = Project(title="Digital Audio Equalizer", academic=True, subject=Engineering) db.session.add(DigitalAudioEqualizer) FuzzyLogicClusteringAlgorithm = Project( title="Fuzzy Logic Clustering Algorithm", academic=False, subject=DataScience) db.session.add(DigitalAudioEqualizer) # COMMIT AND PRINT db.session.commit() print(Engineering) print(DataScience)
def set_direction_to_destination(self, to_be_guided: Subject, coordinate: list[float, float]) -> None: particle = to_be_guided.get_particle_component() direction_vector = coordinate - particle.position_vector direction_vector /= np.sum(direction_vector**2)**0.5 particle.velocity_vector = direction_vector * self.travelling_speed
def add_subject(self, **kwargs): subject = Subject(name=kwargs["name"]) self.db.session.add(subject) self.db.session.commit()
def calculate_future_distance_between(one: Subject, another: Subject): p1 = one.get_particle_component( ).position_vector + one.get_particle_component().velocity_vector p2 = another.get_particle_component( ).position_vector + another.get_particle_component().velocity_vector return np.sqrt(np.sum((p2 - p1)**2)), p1, p2