courses module
- class courses.Course(code: str, name: str, weight: float = 1, activities: Optional[pandas.core.frame.DataFrame] = None)
Bases:
object
A course aims to represent one or more courses. It contains its events and is represented with a name and a code.
- Parameters
code (str) – the code of the course
name (str) – the full name of the course
weight (float) – the weight attributed to the course
activities (Optional[pd.Dataframe]) – a structure of all the events indexed by code, type and id
- Example
>>> course = Course('LMECA2732', 'Robotics')
- add_activity(events: List[backend.events.AcademicalEvent])
Adds an activity to the current course’s activities. An activity is a set of events with the same id.
- Parameters
events (List[AcademicalEvent]) – list of academical events coming from the same activity
- get_activities(view: Optional[Union[List[str], Set[str], Dict[int, str]]] = None, reverse: bool = False) pandas.core.frame.DataFrame
Returns a table of all activities that optionally match correct ids.
- Parameters
view (Optional[View]) – if present, list of ids or dict {week_number : ids}
reverse (bool) – if True, the activities in View will be removed
- Returns
table containing all the activities and their events
- Return type
pd.DataFrame
- get_events(**kwargs) Iterable[backend.events.AcademicalEvent]
Returns a list of events that optionally matches correct ids.
- Parameters
kwargs (Any) – parameters that will be passed to
Course.get_activities()
- Returns
list of events
- Return type
Iterable[AcademicalEvent]
- get_summary() Dict[str, Set[str]]
Returns the summary of all activities in the course.
- Returns
dict of activity codes, ordered by activity type (CM, TP, etc.)
- Return type
Dict[str, Set[str]]
- set_weights(percentage: float = 50, event_type: Optional[backend.events.AcademicalEvent] = None)
Modifies this course’s events weight.
- Parameters
percentage (float) – the “priority” required for this course in (0-100)%, default is 50%
event_type (Optional[AcademicalEvent]) – if present, modify the weight of a certain type of event only
- courses.generate_empty_dataframe()
- courses.merge_courses(courses: Iterable[courses.Course], code: str = '0000', name: str = 'merged', weight: float = 1, views: Optional[Dict[str, Union[List[str], Set[str], Dict[int, str]]]] = None, **kwargs: Any) courses.Course
Merges multiple courses into one.
- Parameters
courses (Iterable[Courses]) – multiple courses
code (str) – the new code
name (str) – the new name
weight (float) – the new weight
views (Optional[Dict[str, View]]) – map of views that will be passed to
Course.get_activities()
kwargs (Any) – additional parameters that will be passed to
Course.get_activities()
- Returns
the new course
- Return type