<commit_before>from datetime import datetime

from timetabler.schedule import Schedule
from timetabler.ssc.course import Lecture, Discussion


def main():
    s = Schedule(["EECE 353", "CPSC 304", "EECE 381", "GEOG 122"],
                 session="2014W", terms=[2])
    # STTs are for Vantage College students
    s.courses["GEOG 122"].add_constraint(
        lambda acts: all(a.status not in [u"STT"] for a in acts)
    )
    # Default sections contained a Tutorial but that is for Vantage
    #   students, so removing that and only setting Lecture and Discussion
    s.courses["GEOG 122"].num_section_constraints = [
        (Lecture, 1), (Discussion, 1)
    ]
    return s.generate_schedules()


if __name__ == '__main__':
    start_time = datetime.now()
    scheds = main()
    print(datetime.now() - start_time)<commit_msg>Add latest starting time sorting<commit_after>import json
from datetime import datetime

from timetabler.schedule import Schedule
from timetabler.ssc.course import Lecture, Discussion


def main():
    s = Schedule(["EECE 353", "CPSC 304", "EECE 381", "GEOG 122"],
                 session="2014W", terms=[2])
    # STTs are for Vantage College students
    s.courses["GEOG 122"].add_constraint(
        lambda acts: all(a.status not in [u"STT"] for a in acts)
    )
    # Default sections contained a Tutorial but that is for Vantage
    #   students, so removing that and only setting Lecture and Discussion
    s.courses["GEOG 122"].num_section_constraints = [
        (Lecture, 1), (Discussion, 1)
    ]
    return s.generate_schedules()


if __name__ == '__main__':
    start_time = datetime.now()
    scheds = main()
    # Unwrap activities out of course-specific tuples
    scheds = [[act for crs in sched for act in crs]
               for sched in scheds]
    # Sort so that the sum of starting times for courses
    #   throughout the week are greatest
    scheds = sorted(
        scheds,
        key=lambda s: sum(int(a.start_time.replace(":", "")) for a in s),
        reverse=True
    )
    print("Schedule with latest starting times (sum): {}".format(
        json.dumps([repr(s) for s in scheds[0]], indent=4)
    ))
    print("This took {} to calculate.".format(
        datetime.now() - start_time
    ))
{'fraction_non_alphanumeric': 0.108348134991119, 'fraction_numerical': 0.023090586145648313, 'mean_word_length': 2.99468085106383, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1613548', 'n_tokens_mistral': 739, 'n_tokens_neox': 674, 'n_words': 230}