From aa8abf3c9db6da423ec7da6add3eb70b78e92b64 Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Tue, 21 Jun 2022 16:49:45 -0700 Subject: [PATCH] update --- error.py | 1 + scheduleGenerator/generator.py | 20 +++++++------------- tinker.py | 2 +- util/generateCourses.py | 2 +- util/mockStudents.py | 4 ++-- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/error.py b/error.py index b75e1be..72e7e28 100644 --- a/error.py +++ b/error.py @@ -1,3 +1,4 @@ +#! python import json f = open('./output/students.json') diff --git a/scheduleGenerator/generator.py b/scheduleGenerator/generator.py index 1b038f1..30a491f 100644 --- a/scheduleGenerator/generator.py +++ b/scheduleGenerator/generator.py @@ -1,6 +1,5 @@ -#!/usr/bin/env python3 +#! python import json -import math import random from inspect import currentframe @@ -79,7 +78,7 @@ running = { # These are the codes for Flex (spare) blocks # Semester 1 and 2 -flex = ["XAT--12A-S", "XAT--12B-S"] +flex = ("XAT--12A-S", "XAT--12B-S") # V3 differs a lot by V1/2 as it does not focus on fitting the classes # into the time table first. @@ -118,7 +117,7 @@ def generateScheduleV3( for i in range(len(activeCourses)): index = list(activeCourses)[i] if index not in emptyClasses: emptyClasses[index] = {} - classRunCount = math.floor(activeCourses[index]["Requests"] / median) + classRunCount = activeCourses[index]["Requests"] // median remaining = activeCourses[index]["Requests"] % median # Put # of classRunCount classes in emptyClasses @@ -269,14 +268,10 @@ def generateScheduleV3( # Step 4 - Attempt to fit classes into timetable def stepIndex(offset: int, stepType: int) -> int: # stepType 0 is for stepping between first and second semester - if stepType == 0: - if offset == 0 or offset == -4: return 5 - else: return -4 + if stepType == 0: return 5 if offset == 0 or offset == -4 else -4 # stepType 1 is for stepping between second and first semester - elif stepType == 1: - if offset == 0 or offset == 6: return -5 - else: return 6 + elif stepType == 1: return -5 if offset == 0 or offset == 6 else 6 # Return Error if code is altered to cause error else: raise SystemExit(f"Invalid 'stepType' in func 'stepIndex' line {getLineNumber()}") @@ -331,7 +326,6 @@ def generateScheduleV3( semBlocks = [] offset = 1 - if sem1 <= sem2: for block in sem1List: semBlocks.append(len(block)) @@ -404,14 +398,14 @@ def generateScheduleV3( # Check if conflicts have been resolved blocks = [student["schedule"][block] for block in student["schedule"]] # If there is exceptions, make them look normal in blocks - # list to ginore them when looking for clashes, and not to + # list to ignore them when looking for clashes, and not to # accidently overwrite while evaluating other classes if len(exceptions) > 0: for i in range(len(blocks)): if i in exceptions: blocks[i] = ['EXPT'] conflicts = sum(1 for b in blocks if len(b)>1) - if conflicts == 0: hasConflicts = False + if conflicts == 0: break elif conflicts > 0: diff --git a/tinker.py b/tinker.py index 274e7f2..106df56 100644 --- a/tinker.py +++ b/tinker.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#! python from prettytable import PrettyTable from typing import Tuple import json diff --git a/util/generateCourses.py b/util/generateCourses.py index d2b64a8..8f19e48 100644 --- a/util/generateCourses.py +++ b/util/generateCourses.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#! python import json import csv diff --git a/util/mockStudents.py b/util/mockStudents.py index a3f4de2..034c9cf 100644 --- a/util/mockStudents.py +++ b/util/mockStudents.py @@ -1,8 +1,8 @@ -#!/usr/bin/env python3 +#! python import json import csv -flex= ["XAT--12A-S", "XAT--12B-S"] +flex= ("XAT--12A-S", "XAT--12B-S") mockStudents: list[dict] = []