@classmethod
    def cohorts(cls, end_date, length, retention_periods,
                period_class=Period):
        if hasattr(end_date, 'date'):
            end_date = end_date.date()  # Convert to a datetime.date
        # The end date falls on the last day of the shortest retention period
        retention_periods = sort_retention_periods(retention_periods)
        min_period = retention_periods[0] if retention_periods else 0
        end_date -= timedelta(days=min_period)
        # The start date 
        one_day = timedelta(days=1)
        start_date = timedelta(days=length) + one_day - end_date
        # Generate the stream of cohorts, walking backwards
        try:
            while True:
                yield cls(start_date=start_date, end_date=end_date,
                          retention_periods=retention_periods)
                # Walk backwards
                start_date -= one_day
                end_date -= one_day
        except OverflowError:
            raise StopIteration    # We cannot go further back in time
dataset/ETHPy150Open MontmereLimited/django-lean/django_lean/lean_retention/reports.py/Cohort.cohorts/swapped operands of `-`