def should_add_up(self):
            schedule = Schedule()
            schedule.add_lesson(RandomWeeklyLesson())
            schedule.add_lesson(RandomWeeklyLesson())

            b = Bins(schedule=schedule)
            b_ = b.bins()

            expect(b[0] + b[1] + b[2] + b[3] + b[4] + b[5]).to.equal(2)
            expect(b_[0] + b_[1] + b_[2] + b_[3] + b_[4] + b_[5]).to.equal(2)
        def should_add_up(self):
            schedule = Schedule()
            schedule.add_lesson(RandomWeeklyLesson())
            schedule.add_lesson(RandomWeeklyLesson())

            b = Bins(schedule=schedule)
            b_ = b.bins()

            expect(b[0] + b[1] + b[2] + b[3] + b[4] + b[5]).to.equal(2)
            expect(b_[0] + b_[1] + b_[2] + b_[3] + b_[4] + b_[5]).to.equal(2)
    def generate_sample_schedule(self, business_forecast):
        schedule = Schedule()

        for i in business_forecast:
            for j in range(0, int(i['frequency'] * i['schedule_type'])):
                schedule.add_lesson(\
                        RandomWeeklyLesson(\
                        start_time_range=self.start_time_range,
                        day_of_week_range=self.day_of_week_range))

        return schedule
    def __init__(self, start_time_range=(0,23.75,), day_of_week_range=(0,6,)):
        self.start_time_range = start_time_range
        self.day_of_week_range = day_of_week_range

        schedule = Schedule()

        lower_limit_start_time, upper_limit_start_time = start_time_range
        lower_limit_day_of_week, upper_limit_day_of_week = day_of_week_range

        for i in np.linspace(lower_limit_start_time, upper_limit_start_time, 96):
            for j in range(lower_limit_day_of_week, upper_limit_day_of_week + 1):
                schedule.add_lesson( WeeklyLesson(start_time=i, day_of_week=j))

        self.bins = Bins(schedule=schedule).bins()
    def generate_sample_schedule(self, business_forecast):
        schedule = Schedule()

        for i in business_forecast:
            for j in range(0,int(i['frequency'])):
                fit_df = self.training_data[self.masks(i)]

                # TODO: sample from df with schedule_type, buget the distribution of timezones

                for k in range(1,int(i['schedule_type'] + 1)):
                    if fit_df.empty:
                        schedule.add_lesson(RandomWeeklyLesson(start_time_range=(8,20),
                            day_of_week_range=(0,4)))
                    else:
                        sample = fit_df.sample()
                        # TODO: make sure that two lessons for a student CANNOT happen at
                        # the same time. Leave 45 min between classes at least...
                        schedule.add_lesson(\
                                WeeklyLesson(day_of_week=sample['l{}_day'.format(k)]\
                                .values[0],
                                start_time=sample['l{}_time'.format(k)].values[0]))
        return schedule
        def by_default_should_be_6(self):
            schedule = Schedule()
            schedule.add_lesson(RandomWeeklyLesson())

            b = Bins(schedule=schedule)
            expect(b.num_bins()).to.equal(6)
        def it_should_aggregate_the_lesson_requests_per_bin(self):
            schedule = Schedule()
            schedule.add_lesson(RandomWeeklyLesson())

            b = Bins(schedule=schedule)
            expect(b.sum().sum()).to.equal(1)
        def it_should_aggregate_the_lesson_requests_per_bin(self):
            schedule = Schedule()
            schedule.add_lesson(RandomWeeklyLesson())

            b = Bins(schedule=schedule)
            expect(b.sum().sum()).to.equal(1)
        def by_default_should_be_6(self):
            schedule = Schedule()
            schedule.add_lesson(RandomWeeklyLesson())

            b = Bins(schedule=schedule)
            expect(b.num_bins()).to.equal(6)