def __init__(self, name='Analysis1', session_dir='/export/data/mri/Neurometrics', permute=False, **kwargs): SubWorkflow.__init__(self, name=name, output_fields=[ 'frame_scores', 'block_scores', 'halfrun_scores', 'run_scores' ], **kwargs) subjects = [ Subject('a', [ Session('020211el', base_path=session_dir, permute=permute), Session('021611el', base_path=session_dir, permute=permute) ]), Subject('b', [ Session('020511bn', base_path=session_dir, permute=permute), Session('021211bn', base_path=session_dir, permute=permute) ]), Subject('c', [ Session('021911ar', base_path=session_dir, permute=permute), Session('090210ar1', base_path=session_dir, permute=permute) ]), Subject('d', [ Session('080612af', base_path=session_dir, permute=permute), Session('091912af', base_path=session_dir, permute=permute) ]), Subject('e', [ Session('101812rm', base_path=session_dir, permute=permute), Session('011513rm', base_path=session_dir, permute=permute) ]) ] self.subject_workflows = [SubjectWorkflow(u) for u in subjects] self.merge_nodes = dict() self.aggregate_nodes = dict() for name in ('frame', 'block', 'halfrun', 'run'): mn = pe.Node(name=name + '_merge', interface=util.Merge(len(subjects))) self.merge_nodes[name] = mn an = pe.Node(name=name + '_aggregate', interface=AggregateScores()) for i, uw in enumerate(self.subject_workflows): self.connect(uw, 'output.' + name + '_scores', mn, 'in' + str(i + 1)) self.connect(mn, 'out', an, 'scores') self.connect(an, 'scores', self.output_node, name + '_scores')
def ld_subjects(cls, file_name): """Загрузка данных о предметах""" with codecs.open(file_name, encoding='utf-8') as fl: data = fl.readlines() for subject in data: name, sub_type, teacher = subject.strip().split(';') subject = Subject(name, teacher, sub_type) cls.lst_subjects.append(subject)
def convert_to_subjects(): subjects = [] if os.path.isfile(subjects_file): with open(subjects_file, "r") as csv_file: csv_reader = csv.reader(csv_file) for line in csv_reader: subject = Subject(line[0], line[1], line[2]) subjects.append(subject) return subjects
def generate(config): subjects = [] teachers = [] for round in range(config.rounds): semester = 1 + round % 2 # alterante between 1 and 2 print("Entering round %d/%d (Semester: %d, maxDiff: %d)" % (round + 1, config.rounds, semester, config.maxDiff)) # create the main subject that defines how this round will occur roundSubject = Subject.generateSubject(config, semester) # create the main teacher for (at least) the theoretical of roundSubject currentTeacher = Teacher.generateTeacher(config, roundSubject.field) # add the theoretical hours to this teacher (clears the roundSubject.tHours) currentTeacher.addTHours(roundSubject) # create teachers until the roundSubject's practical hours are filled roundTeachers = [] # until there are no hours to fill in the roundSubject while True: # do-while roundTeachers.append(currentTeacher) # print("Old: %d" % roundSubject.pHours) currentTeacher.addPHoursMax(config, roundSubject) #add as many hours as possible # print("New: %d" % roundSubject.pHours) if roundSubject.pHours == 0: # enough teachers found to fill the practical hours break currentTeacher = Teacher.generateTeacher(config) # generate as many extra teachers (any field) as necessary # calculate debt of this round (hours each teacher needs to respect the maxDiff) and generate a subject to fill them debtSubject = Subject.generateDebtSubject(config, roundTeachers, semester) # add the subjects created in this round to the final results lists subjects.append(roundSubject) if debtSubject: # if debt == 0 then this is None subjects.append(debtSubject) # add the teachers created in this round to the final results lists teachers.extend(roundTeachers) return subjects, teachers
def get_subject(): print("~~~~~~~~~~ Add New Subject ~~~~~~~~~~") print() question_pattern_subject = ["Subject", "Description"] sep = " > " id = utility.get_id() category = get_result(question_pattern_subject[0] + sep) description = get_result(question_pattern_subject[1] + sep) subject = Subject(id, category, description) data_access.create_subject(subject) print() print("---------- New subject created! ----------")
def load(): debug("Start global loading...") Subject.load() Departament.load() debug("Global loading done!")
def test(): # ======== print("Проверка на создание объектов:") s1 = Subject("Название дисциплины", 1, 1, "форма контроля") d1 = Departament("Название Кафедры", 1, s1) print(s1, d1) print("Вывод через атрибут:", s1.name, sep='\t') print("Вывод через ключ:", s1['name'], sep='\t') s1.name += " 2" print("Вывод изменённого имени:", s1.name, sep='\t') print("-========-") # ======== print("Проверка на запись данных в CSV:") save() for f in ('subject.csv', 'departament.csv'): print("===", f, "===") with open(f, 'r', newline='\n', encoding='utf-8') as data: print(*data.readlines(), sep='') print("=========\n") print("-========-") # ======== print("Проверка на удаление дисциплины:") print(Subject[1]) del Subject[1] print("Удалено") print(Subject[1] is None) print("-========-") # ======== try: print("Проверка на отсутствие данных в переменной:") print(s1) except ValueError: print("Проверка прошла успешно!") # ======== print("-========-") print("Проверка на отсутствие данных дисциплины на кафедре:") print(d1["subject"]) print("-========-") print("Проверка на каскадное удаление объектов:") s2 = Subject("Название новой дисциплины", 1, 1, "форма контроля") d2 = Departament("Название Кафедры 2", 1, s2) print(s2, d2) print("-========-") print("Удаление кафедры") del Departament[2] print("Проверка на отсутсвие дисциплины и направления:") print(Departament[2] is None) print(s2.is_exist() is False) print("-========-") # ======== print("Проверка на чтение данных из CSV:") load() for e in (Subject, Departament): print("===", e.__name__, "===") for entity in e._entity_dict.values(): print("%r:" % entity) for k, v in entity.items(): print(" %s = %r" % (k, v)) print("=========\n") print("-========-")
def save(): debug("Start global saving...") Subject.save() Departament.save() debug("Global saving done!")
subject_code_list.append('1'+str(year)+str(branch_name)+str(semester+1)+str(i)) # Generate Subject Names for i in range(8): sem_subjects.append(_branches[branch_name][i][0][0]) # Empty Student List student_list = [] # For number of students for i in range(0, 120): result_class = "PASS" subject_list = [] student_total_marks = 0 for j in range(0,8): subject = Subject(sem_subjects[j], randint(0, 25), randint(0, 100), subject_code_list[j], theory='true'if _branches[branch_name][1] == 'theory' else 'false') subject.totalMarks = subject.internalMarks + subject.externalMarks student_total_marks += subject.totalMarks if subject.totalMarks < 35: subject.result = "FAIL" result_class = "FAIL" else: subject.result = "PASS" subject_list.append(subject) if result_class == "PASS": if (pass_per * student_final_marks) <= student_total_marks < (student_final_marks * second_class_per): result_class = "PASS" elif (student_final_marks * second_class_per) <= student_total_marks < (student_final_marks * first_class_per): result_class = "SECOND CLASS" elif (student_final_marks * first_class_per) <= student_total_marks < (student_final_marks * fcd_per): result_class = "FIRST CLASS"