code: def iterperiods(self, start=None, end=None, value=None):
          
          start, end, mask = \
              self._check_boundaries(start, end, allow_infinite=False)
  
          value_function = self._value_function(value)
  
          # get start index and value
          start_index = self._d.bisect_right(start)
          if start_index:
              start_value = self._d[self._d.iloc[start_index - 1]]
          else:
              start_value = self.default
  
          # get last index before end of time span
          end_index = self._d.bisect_right(end)
  
          interval_t0, interval_value = start, start_value
  
          for interval_t1 in self._d.islice(start_index, end_index):
  
              if value_function(interval_t0, interval_t1, interval_value):
                  yield interval_t0, interval_t1, interval_value
  
              # set start point to the end of this interval for next
              # iteration
              interval_t0 = interval_t1
              interval_value = self[interval_t0]
  
          # yield the time, duration, and value of the final period
          if interval_t0 < end:
              if value_function(interval_t0, end, interval_value):
                  yield interval_t0, end, interval_value
docs: This iterates over the periods (optionally, within a given time
          span) and yields (interval start, interval end, value) tuples.
  
          TODO: add mask argument here.