Esempio n. 1
0
def test_YOSA():
    # subject_input_list = [
    #     Subject("알고리즘", 4, 1, 0, 0),
    #     # Subject("웹프", 3, 7, 1, 0),
    #     # Subject("직능훈", 2, 4, 2, 0),
    #     # Subject("알고리즘", 4, 5, 3, 1),
    #     Subject("C++", 4, 24, 4, 1),
    #     # Subject("웹프", 3, 3, 5, 1),
    #     # Subject("알고리즘", 4, 4, 6, 2),
    #     # Subject("데베설", 3, 5, 7, 2),
    #     # Subject("운영체제", 2, 6, 8, 2),
    # ]

    subject_input_list = [
        Subject("알고리즘", 1, 1, 0, 0),
        # Subject("웹프", 3, 7, 1, 0),
        # Subject("직능훈", 2, 4, 2, 0),
        # Subject("알고리즘", 4, 5, 3, 1),
        Subject("C++", 1, 23, 4, 1),
        # Subject("웹프", 3, 3, 5, 1),
        # Subject("알고리즘", 4, 4, 6, 2),
        # Subject("데베설", 3, 5, 7, 2),
        # Subject("운영체제", 2, 6, 8, 2),
    ]

    student_count = 2
    # for i in range(1, 40):
    #     yosa = YOSA(subject_input_list, student_count, i)
    #     yosa.run()
    yosa = YOSA(subject_input_list, student_count, 40)
    yosa.run()
    yosa = YOSA(subject_input_list, student_count, 35)
    yosa.run()
Esempio n. 2
0
    def find_maxima(self, start_sol, max_time):
        population = [Subject(i, self.evaluation(i)) for i in start_sol]

        t_end = time.time() + max_time
        while time.time() < t_end:
            strongest = self.select_strongest(population)

            for couple in strongest:

                new_genom = self.crossbreed(couple[0], couple[1])

                if new_genom in [p.genom for p in population]:
                    continue

                population.append(Subject(new_genom, self.evaluation(new_genom)) \
                                      if self.in_dict(new_genom) and self.can_assemble(new_genom) \
                                      else Subject(new_genom, 0))

            if len(population) > self.pop_count:
                population = sorted(population,
                                    key=lambda x: x.value,
                                    reverse=True)[0:self.pop_count]

        for e in population:
            print(e.genom)

        self.best_sol = sorted(population, key=lambda x: x.value,
                               reverse=True)[0].genom
        self.best_val = self.evaluation(self.best_sol)
Esempio n. 3
0
 def setUp(self):
     self.EPSILON = 0.01
     sub1 = Subject("Biologia",
                    [[3.5, 2.5, 5.0], [1, 1, 1, 1, 1, 1, 1, 1, 0]])
     sub2 = Subject("Matematyka",
                    [[2.5, 3.0, 2.5], [1, 1, 0, 1, 0, 1, 0, 1, 1]])
     self.subjects = [sub1, sub2]
     self.andrzej = Student("Andrzej Abacki", self.subjects)
     self.diary = Diary("AGH", 2016, "data.json")
Esempio n. 4
0
 def add_subject(self, subject_name, start_time, is_even, day):
     subs = self.subjects.get(day)
     s = Subject(subject_name, start_time, is_even)
     if (subs == None):
         self.subjects.update({day: [s]})
     else:
         subs.append(s)
Esempio n. 5
0
def main():
    s = Subject()
    subject = s.get_subject()
    if not (subject == ""):
        send_email_proccess(subject)
    else:
        print('You should entry the subject of email')
    def assign_new_semester(self):

        system('cls')

        id_student = int(input("Enter the student's identification: "))
        pos_student = self.__find_student(id_student)

        if pos_student != -1:
            name_subject = input("Enter the subject's name: ")
            notes = self.__load_notes()

            id_teacher = int(input("Enter the teacher's identification: "))
            pos_teacher = self.__find_teacher(id_teacher)

            if pos_teacher != -1:
                new_subject = Subject(name_subject, notes, self.teachers[pos_teacher])
                new_semester = Semestre(self.students[pos_student], new_subject)
                self.semestres.append(new_semester)

                system('cls')
                print("The assign was created successful")

            else:
                system('cls')
                print("The teacher not exists")

        else:
            print("The student not exists")

        input()
Esempio n. 7
0
    def update_protocols(self):
        """
        If we change the protocol file, update the stored version in subject files
        """
        #
        # get list of protocol files
        protocols = os.listdir(prefs.PROTOCOLDIR)
        protocols = [p for p in protocols if p.endswith('.json')]

        subjects = self.list_subjects()
        for subject in subjects:
            if subject not in self.subjects.keys():
                self.subjects[subject] = Subject(subject)

            protocol_bool = [
                self.subjects[subject].protocol_name == p.rstrip('.json')
                for p in protocols
            ]
            if any(protocol_bool):
                which_prot = np.where(protocol_bool)[0][0]
                protocol = protocols[which_prot]
                self.subjects[subject].assign_protocol(
                    os.path.join(prefs.PROTOCOLDIR, protocol),
                    step_n=self.subjects[subject].step)

        msgbox = QtGui.QMessageBox()
        msgbox.setText("Subject Protocols Updated")
        msgbox.exec_()
 def reducer(acc, term):
     subj = Subject(subject_id)
     score = term["score"][regno][subject_id]
     gradings = term["gradings"]
     ratio = term["ratio"]
     grade = subj.scoreToGrade(score, gradings)
     acc["score"] += score * ratio
     acc["grade"] += grade * ratio
     return acc
Esempio n. 9
0
    def reassign_protocols(self):
        """
        Batch reassign protocols and steps.

        Opens a :class:`.gui.Reassign` window after getting protocol data,
        and applies any changes made in the window.
        """
        # get list of protocol files
        protocols = os.listdir(prefs.PROTOCOLDIR)
        protocols = [
            os.path.splitext(p)[0] for p in protocols if p.endswith('.json')
        ]

        # get subjects and current protocols
        subjects = self.list_subjects()
        subjects_protocols = {}
        for subject in subjects:
            if subject not in self.subjects.keys():
                self.subjects[subject] = Subject(subject)

            subjects_protocols[subject] = [
                self.subjects[subject].protocol_name,
                self.subjects[subject].step
            ]

        reassign_window = Reassign(subjects_protocols, protocols)
        reassign_window.exec_()

        if reassign_window.result() == 1:
            subject_protocols = reassign_window.subjects

            for subject, protocol in subject_protocols.items():
                step = protocol[1]
                protocol = protocol[0]

                # since assign_protocol also changes the step, stash the step number here to tell if it's changed
                subject_orig_step = self.subjects[subject].step

                if self.subjects[subject].protocol_name != protocol:
                    self.logger.info(
                        'Setting {} protocol from {} to {}'.format(
                            subject, self.subjects[subject].protocol_name,
                            protocol))
                    protocol_file = os.path.join(prefs.PROTOCOLDIR,
                                                 protocol + '.json')
                    self.subjects[subject].assign_protocol(protocol_file, step)

                if subject_orig_step != step:
                    self.logger.info('Setting {} step from {} to {}'.format(
                        subject, subject_orig_step, step))
                    step_name = self.subjects[subject].current[step][
                        'step_name']
                    #update history also flushes current - aka it also actually changes the step number
                    self.subjects[subject].update_history(
                        'step', step_name, step)
Esempio n. 10
0
 def parse_data(self):
     for row in self.__information:
         lesson = Lesson(row[0], row[1], row[5], row[6], row[7])
         subject = Subject(row[4], row[9], lesson)
         student = Student(row[3], row[2], row[8], row[9], subject)
         if self.check_student(student):
             self.__student_list.append(student)
         else:
             for stud in self.__student_list:
                 if stud.get_surname() == student.get_surname(
                 ) and stud.get_group_code() == student.get_group_code():
                     stud.get_subject_list().append(subject)
Esempio n. 11
0
    def add(self, subject_name):
        """
        Add a subject by subject name

                Parameters:
                        subject_name (str): name of the subject

                Returns:
                        subject(Subject): subject that was added
        """
        self._subjects.append(Subject(subject_name))
        return self._subjects[-1]
Esempio n. 12
0
def main():

    startTime = datetime.now()

    runList = genSubjectList('t2_circles')

    for subject in runList:

        subject = Subject(subject)
        subjectDisplay(subject)

    print 'Subject Creation: ', datetime.now() - startTime
Esempio n. 13
0
def add_test_data(subjects, students):
    subjects.append(Subject("German"))

    students.append(Student("Donald", "Duck"))
    students[len(students) - 1].add_score(subjects[1], "01.01.2019",
                                          Student.ABSENT)
    students[len(students) - 1].add_score(subjects[2], "01.01.2019",
                                          Student.ABSENT)

    students.append(Student("Test", "Student"))
    students[len(students) - 1].add_score(subjects[0], "01.06.2030", 90)
    students[len(students) - 1].add_score(subjects[2], "0w.07.2023", 44)

    students.append(Student("Klaus", "Muster"))
    students[len(students) - 1].add_score(subjects[0], "01.04.2019", 77)
    students[len(students) - 1].add_score(subjects[2], "03.03.2019",
                                          Student.ABSENT)
    students[len(students) - 1].add_score(subjects[2], "10.03.2019", 64)
    students[len(students) - 1].add_score(subjects[2], "17.03.2019", 20)

    students.append(Student("Test", "Studentin"))
    students[len(students) - 1].add_score(subjects[0], "01.06.2030", 90)
    students[len(students) - 1].add_score(subjects[2], "0w.07.2023", 44)

    students.append(Student("Muster", "Studentin"))
    students[len(students) - 1].add_score(subjects[0], "01.06.2030", 90)
    students[len(students) - 1].add_score(subjects[2], "0w.07.2023", 44)

    students.append(Student("Muster", "Student"))
    students[len(students) - 1].add_score(subjects[0], "01.06.2030", 91)
    students[len(students) - 1].add_score(subjects[2], "0w.07.2023", 33)

    students.append(Student("Debug", "Studentin"))
    students[len(students) - 1].add_score(subjects[0], "01.06.2030", 90)
    students[len(students) - 1].add_score(subjects[0], "0w.07.2023", 44)

    students.append(Student("Debug", "Studentin"))
    students[len(students) - 1].add_score(subjects[1], "01.06.2030", 90)
    students[len(students) - 1].add_score(subjects[2], "0w.07.2023", 44)

    students.append(Student("Debug", "Student"))
    students[len(students) - 1].add_score(subjects[0], "01.06.2030", 91)
    students[len(students) - 1].add_score(subjects[1], "0w.07.2023", 33)

    students.append(Student("Thomas", "Muster"))
    students[len(students) - 1].add_score(subjects[0], "01.04.2019", 77)
    students[len(students) - 1].add_score(subjects[2], "03.03.2019",
                                          Student.ABSENT)
    students[len(students) - 1].add_score(subjects[2], "10.03.2019", 64)
    students[len(students) - 1].add_score(subjects[2], "17.03.2019", 20)

    return subjects, students
 def make_student_real_subject_list(self):
     real_subject_list = []
     for idx, best_subject_study_time in enumerate(
             self.best_solo_subject_study_case):
         if best_subject_study_time > 0:
             real_subject = copy.deepcopy(self.subject_list[idx])
             real_subject.bt = best_subject_study_time
             real_subject.remain_bt = real_subject.bt
             real_subject_list.append(real_subject)
     if self.best_each_team_play_time > 0:
         real_subject_list.append(
             Subject("팀프", 3, self.best_each_team_play_time, 14, -1), )
     return real_subject_list
Esempio n. 15
0
def getSynthesis():
    try:
        id_str = (request.form['subject'] + str(time())).replace(' ', '-')
        if request.form.get('wikipedia'):
            useWikipedia = True
        else:
            useWikipedia = False
        subject = Subject(request.form['subject'],
                          summaryLength=int(request.form['lines']),
                          useWikipedia=useWikipedia)
        q.enqueue(subject.build, job_id=id_str, timeout=600)
    except Exception as e:
        return '<h1>Error</h1>' + str(e)
    return render_template('working.html', url='/status/' + id_str)
Esempio n. 16
0
 def mapping_to_subject(datum):
     return Subject(datum['subject_id'],
                    datum['name'],
                    datum['region'],
                    datum['section'],
                    datum['kind'],
                    datum['price'],
                    datum['location'],
                    datum['sub_type'],
                    datum['pattern'],
                    datum['size'],
                    datum['floor'],
                    datum['contact_person'],
                    datum['url'])
Esempio n. 17
0
def enter():
    global student, subject, room, randombox, warning_bgm, buy_bgm, font

    student = Student()
    subject = Subject()
    room = Room()
    randombox = []
    font = load_font('ENCR10B.TTF', 16)

    warning_bgm = load_music('sounds/effects/warning.mp3')
    warning_bgm.set_volume(128)

    buy_bgm = load_music('sounds/effects/buy.mp3')
    buy_bgm.set_volume(128)
Esempio n. 18
0
def main():

    root = Tk()
    subject = Subject()
    _views = []

    for i in range(5):
        _views.append(Note(root, i, 'View %i' % i))

    for v in _views:
        subject.attach(v)

    my_gui = MainView(root, subject)
    root.mainloop()
Esempio n. 19
0
    def set_species(self, dat):
        ''' Set the species list '''

        if dat != None:
            self.species = []
            dat.sort(key=itemgetter(self.key))

            temp_set = set()  # to avoid duplicates from observations
            for e in dat:
                temp_name = e[1] + e[2]
                subject = Subject(e[0], e[1], e[2], e[3], e[4], e[5], e[6])

                if not (temp_name in temp_set):
                    temp_set.add(temp_name)
                    self.species.append(subject)
Esempio n. 20
0
    def __getSubjectsDirectories(self):
        """Return directories who qualified for the pipeline

        Look into each subdirectory if it meet all the requirements. If yes, the subdirectory is consider
        a subject and is register into a list

        Returns:
            subjects: a list of directory containing qualified subjects

        """
        self.info("Looking for valid subjects.")
        subjects = []

        if self.arguments.subject:
            for dir in self.arguments.subject:
                if self.__isDirAValidSubject(dir):
                    subjects.append(Subject(self.__copyConfig(dir)))
        else:
            dirs = glob.glob("{}/*".format(self.studyDir))
            for dir in dirs:
                if self.__isDirAValidSubject(dir):
                    subjects.append(Subject(self.__copyConfig(dir)))

        return subjects
Esempio n. 21
0
    def find(self, subject_name):
        """
        Find a subject by subject name

                Parameters:
                        subject_name (str): name of the subject

                Returns:
                        subjects(list): list of subjects
        """
        try:
            sub_index = self._subjects.index(Subject(subject_name))
            return self._subjects[sub_index]
        except ValueError:
            return None
Esempio n. 22
0
    def __init__(self, url=None, version=None, token=None):
        self.subject = Subject()
        self.aspect = Aspect()
        self.sample = Sample()

        if url:
            if url.endswith('/'):
                config.REFOCUS_URL = url
            else:
                config.REFOCUS_URL = url + '/'

        if config.API_VERSION or version:
            config.REFOCUS_URL += version if version else config.API_VERSION

        if token:
            config.REFOCUS_TOKEN = token
Esempio n. 23
0
    def load(self):
        data_path = os.path.join(self.path, 'DATA')
        increment = 0
        files = os.listdir(data_path)
        for i, f in enumerate(files):
            if i == self.size:
                print("aqui")
                break
            print(" Percentage : {:.2f}".format((increment / len(files)) *
                                                100) if self.size is None else
                  (increment / self.size))
            if f.endswith(".xml") and f.startswith("subject"):
                sub = Subject(ET.parse(os.path.join(data_path, f)).getroot())
                self.subjects.append(sub)
            increment += 1

        self._load_gt()
Esempio n. 24
0
def decode(data):
    subjects = []
    students = []
    for s in data["subjects"]:
        subjects.append(Subject(s["name"]))
    for s in data["students"]:
        student_append = Student(s["firstname"], s["lastname"])
        scores = s["scores"]
        score_keys = scores.keys()
        for subject_name in score_keys:
            subject_obj = None
            for o in subjects:
                if o.name == subject_name:
                    subject_obj = o
            student_append.scores[subject_obj] = scores[subject_name]
            students.append(student_append)
    return (subjects, students)
Esempio n. 25
0
    def temp(self):
        filenames = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]

        self.data = []

        cnt = 0
        for filename in filenames:

            if filename.startswith("."):
                continue

            print(str(cnt) + ". " + filename.split("-")[0])
            cnt += 1

            s = Subject()
            s.readData(os.path.join(path, filename))
            self.data.append(s)
Esempio n. 26
0
def test_observer_pattern():
    weather_station = Subject()
    temperature_display = TemperatureDisplay()
    full_data_display = FullDataDisplay()

    weather_station.register_observer(temperature_display)
    weather_station.register_observer(full_data_display)

    for i in range(3):
        weather_station.update_data(temperature=random.uniform(10, 30),
                                    humidity=random.uniform(40, 100),
                                    pressure=random.uniform(730, 790))

    weather_station.remove_observer(full_data_display)
    for i in range(3):
        weather_station.update_data(temperature=random.uniform(10, 30),
                                    humidity=random.uniform(40, 100),
                                    pressure=random.uniform(730, 790))
Esempio n. 27
0
def main():

    startTime = datetime.now()

    outTable = r'C:\Users\jeffr_000\Desktop\Fall_2016\415\GEOG_415_Scarmazzi\Results\FinalRun_C.csv'
    writer = csvGen(outTable)

    ##
    # T1 = 134 Subjects, T2 = 133 Subjects
    ##
    subjectList = genSubjectList('t2_circles')
    errList = []
    runList = []
    for subject in subjectList:

        subjectNumber = subject
        subject = Subject(subject)

        try:
            t1Generation(subject, 't1_circles')
            t2Generation(subject, 't2_circles')

        except Exception as e:
            errList.append(subjectNumber)
            print '#' * 75
            print 'Problem: ', e.args
            print '#' * 75

        subjectDisplay(subject)

        csvWrite(writer, subject)

        runList.append(subject)

    print 'Subject Creation: ', datetime.now() - startTime
    print 'Problem Subjects: ', len(errList), errList
    print '*' * 50
    print '*' * 50

    ##
    # Console Logging
    ##
    r1Logging(runList)
    configLogging(runList)
Esempio n. 28
0
    def __init__(self,
                 experiments_json,
                 subjects_json,
                 model_dir,
                 subject_analyses,
                 group_analyses,
                 image_dir,
                 jsons_dir="./jsons",
                 model_type="english1000"):

        self.model_type = model_type

        all_exp_info = read_json(experiments_json, jsons_dir)
        # exp2 = dict()
        # exp2['Binder2005'] = all_exp_info['Binder2005']
        # all_exp_info = exp2
        #all_exp_info2 = dict()
        #all_exp_info2['Bedny2013'] = all_exp_info['Bedny2013']
        #all_exp_info = all_exp_info2
        model_holder = ModelHolder(jsons_dir)
        self.experiments = {
            key: Experiment(model_holder=model_holder,
                            name=key,
                            image_dir=image_dir,
                            model_type=self.model_type,
                            nperm=1000,
                            **info)
            for (key, info) in all_exp_info.items()
        }

        subjects_info = read_json(subjects_json, jsons_dir)

        subjects = [
            Subject(name=key,
                    model_type=self.model_type,
                    model_dir=model_dir['subject_dir'],
                    analyses=subject_analyses,
                    **info) for (key, info) in subjects_info.items()
        ]

        self.subject_group = SubjectGroup(subjects, group_analyses)
Esempio n. 29
0
    def subject_weights(self):
        """
        Gets recent weights from all :attr:`~.Terminal.subjects` and
        open a :class:`.gui.Weights` window to view or set weights.
        """
        subjects = self.list_subjects()

        # open objects if not already
        for subject in subjects:
            if subject not in self.subjects.keys():
                self.subjects[subject] = Subject(subject)

        # for each subject, get weight
        weights = []
        for subject in subjects:
            weight = self.subjects[subject].get_weight(include_baseline=True)
            weight['subject'] = subject
            weights.append(weight)

        self.weight_widget = Weights(weights, self.subjects)
        self.weight_widget.show()
    def loadDataSet(self):
        if not os.path.isfile(self.surveyDataFilePath):
            raise OSError("Could not find the survey file: {0}".format(
                self.surveyDataFilePath))

        with open(self.surveyDataFilePath, 'r') as file:
            csvReader = csv.reader(file, delimiter=',')
            for i, row in enumerate(csvReader):
                if i < 3:  # Skip header
                    pass
                else:
                    participant_id = row[COLNUM_PARTICIPANT_ID]

                    # Create new subject instance
                    s = Subject(self.jsonFilesRootPath, participant_id)
                    self.importProblemsetAnswers(row, s)
                    self.importFeaturePreferenceSurvey(row, s)
                    self.importSelfAssessmentOfLearning(row, s)
                    self.importDemographicSurvey(row, s)
                    self.importPriorExperienceSurvey(row, s)
                    self.subjects.append(s)