code: def by_cat(self):
          
          for value in np.unique(self.category):
              cat_fm = self.filter(self.category == value)
              if self._categories:
                  yield (cat_fm, self._categories[value])
              else:
                  yield (cat_fm, None)
docs: Iterates over categories and returns a filtered datamat.
  
          If a categories object is attached, the images object for the given
          category is returned as well (else None is returned).
  
          Returns:
              (datamat, categories) : A tuple that contains first the filtered
                  datamat (has only one category) and second the associated
                  categories object (if it is available, None otherwise)