Untitled


Create a student list


In [2]:
from timetable.people import Student, Instructor
from timetable.studentlist import StudentList
import names
import numpy as np

In [4]:
required = ["math", "english"]
electives = ["art", "band", "woodshop"]
np.choose

In [2]:
s = Student(
    name="Zach", 
    required=["math", "english"], 
    desired=["art"])

s2 = Student(
    name="Bob", 
    required=["math", "english"], 
    desired=["art"]
)

In [3]:
studentlist = StudentList(s, s2)

In [8]:
studentlist.STU000000.addattr(age=22)

In [11]:
instructor1 = Instructor("Jill")

In [12]:
studentlist.add(instructor1)


---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-12-d7de3fcc6836> in <module>()
----> 1 studentlist.add(instructor1)

/Users/Zsailer/github/timetable/timetable/base.py in add(self, *items)
     81         """
     82         for item in items:
---> 83             self._assign_id(item)
     84             setattr(self, item.id, item)
     85             self._contents[item.id] = item

/Users/Zsailer/github/timetable/timetable/base.py in _assign_id(self, item)
     63         """
     64         # Check that argument is an expected object
---> 65         self._check_type(item)
     66         # If the object doesn't already have an ID, give it one
     67         if hasattr(item, "id") is False:

/Users/Zsailer/github/timetable/timetable/base.py in _check_type(self, item)
     57         if item.__class__ != self._child_type:
     58             raise Exception("Argument must be a(n) `" + \
---> 59                 self._child_type.__name__ + "` object!")
     60 
     61     def _assign_id(self, item):

Exception: Argument must be a(n) `Student` object!

In [18]:
studentlist.students


Out[18]:
{'STU000000': <timetable.people.Student at 0x106b7bf98>,
 'STU000001': <timetable.people.Student at 0x106b7bf60>}

Create a timetable


In [13]:
from timetable.timetable import TimeTable
from timetable.day import Day
from timetable.period import Period
from timetable.course import Course

In [14]:
instructor2 = Instructor("Alice")
instructor3 = Instructor("Bob")
instructor4 = Instructor("Todd")

In [15]:
course1 = Course("math 7", instructor1)
course2 = Course("math 8", instructor2)
course3 = Course("english 7",instructor3)
course4 = Course("english 7",instructor4)

In [16]:
period1 = Period("9am", course1, course2)
period2 = Period("10am", course3, course4)

In [17]:
day = Day("Monday", period1, period2)

In [18]:
timetable = TimeTable(day)

In [19]:
timetable.DAY000000.PER000000.COU000000.attrs


Out[19]:
{'id': 'COU000000', 'name': 'math 7'}

In [ ]: