Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
MstrPikachu
2021-10-03 16:32:32 -04:00
3 changed files with 11 additions and 15 deletions
Binary file not shown.
+7 -11
View File
@@ -241,41 +241,39 @@ def test_section_compatible() -> None:
""" """
Test is_section_compatible with compatible sections Test is_section_compatible with compatible sections
""" """
# TODO: Create a test assert a2_courses.is_section_compatible(SCHEDULE_1, CON123_LEC0123)
def test_section_not_compatible() -> None: def test_section_not_compatible() -> None:
""" """
Test is_section_compatible with incompatible sections Test is_section_compatible with incompatible sections
""" """
# TODO: Create a test assert not a2_courses.is_section_compatible(SCHEDULE_1, TMP000_LEC0000)
assert not a2_courses.is_section_compatible(SCHEDULE_3, CON333_LEC2001)
def test_course_compatible() -> None: def test_course_compatible() -> None:
""" """
Test is_course_compatible with compatible course Test is_course_compatible with compatible course
""" """
# TODO: Create a test assert a2_courses.is_course_compatible(SCHEDULE_1, CON123)
def test_course_not_compatible() -> None: def test_course_not_compatible() -> None:
""" """
Test is_course_compatible with incompatible course Test is_course_compatible with incompatible course
""" """
# TODO: Create a test assert not a2_courses.is_course_compatible(SCHEDULE_1, TMP000)
assert not a2_courses.is_course_compatible(SCHEDULE_1, CON333)
def test_compatible_sections() -> None: def test_compatible_sections() -> None:
""" """
Test compatible_sections with compatible sections Test compatible_sections with compatible sections
""" """
actual = a2_courses.compatible_sections(SCHEDULE_1, CON123) == {CON123_LEC0123} assert a2_courses.compatible_sections(SCHEDULE_1, CON123) == {CON123_LEC0123}
expected = True
assert actual == expected
# TODO: Create more tests
################################################################################################### ###################################################################################################
# Part 4 # Part 4
################################################################################################### ###################################################################################################
@@ -306,7 +304,5 @@ def test_transform_meeting_time_data() -> None:
assert actual == expected assert actual == expected
# TODO: Create more tests
if __name__ == "__main__": if __name__ == "__main__":
pytest.main(['a2_example_tests.py']) pytest.main(['a2_example_tests.py'])
+4 -4
View File
@@ -45,7 +45,7 @@ def num_lecture_hours(section: tuple[str, str, tuple]) -> int:
Hint: you can use ".hour" to access the hour attribute of a datetime.time value. Hint: you can use ".hour" to access the hour attribute of a datetime.time value.
""" """
return sum([t[2].hour - t[1].hour for t in section[2]]) return sum(t[2].hour - t[1].hour for t in section[2])
def sections_in_semester(schedule: dict[str, tuple[str, str, tuple]], semester: str) \ def sections_in_semester(schedule: dict[str, tuple[str, str, tuple]], semester: str) \
@@ -124,7 +124,7 @@ def sections_conflict(s1: tuple[str, str, tuple], s2: tuple[str, str, tuple]) \
# Cannot conflict if they aren't in overlapping term # Cannot conflict if they aren't in overlapping term
# Conflicts when at least one meeting times conflict # Conflicts when at least one meeting times conflict
return (term1 == term2 or term1 == 'Y' or term2 == 'Y') and \ return (term1 == term2 or term1 == 'Y' or term2 == 'Y') and \
any([times_conflict(m1, m2) for m1 in times1 for m2 in times2]) any(times_conflict(m1, m2) for m1 in times1 for m2 in times2)
def is_valid(schedule: dict[str, tuple[str, str, tuple]]) -> bool: def is_valid(schedule: dict[str, tuple[str, str, tuple]]) -> bool:
@@ -248,7 +248,7 @@ def is_section_compatible(schedule: dict[str, tuple[str, str, tuple]],
- section matches the format for a section described by the assignment handout. - section matches the format for a section described by the assignment handout.
- schedule matches the format for a schedule described by the assignment handout. - schedule matches the format for a schedule described by the assignment handout.
""" """
return all([not sections_conflict(section, s) for s in schedule.values()]) return all(not sections_conflict(section, s) for s in schedule.values())
def is_course_compatible(schedule: dict[str, tuple[str, str, tuple]], def is_course_compatible(schedule: dict[str, tuple[str, str, tuple]],
@@ -264,7 +264,7 @@ def is_course_compatible(schedule: dict[str, tuple[str, str, tuple]],
- schedule matches the format for a schedule described by the assignment handout. - schedule matches the format for a schedule described by the assignment handout.
- course[0] not in schedule - course[0] not in schedule
""" """
return any([is_section_compatible(schedule, section) for section in course[2]]) return any(is_section_compatible(schedule, section) for section in course[2])
def compatible_sections(schedule: dict[str, tuple[str, str, tuple]], def compatible_sections(schedule: dict[str, tuple[str, str, tuple]],