Repository: quantopian/zipline
File: zipline/pipeline/data/dataset.py (Python)

Code before:
        The name of the column.
    """
    def __init__(self, column_name):
        self.column_name = column_name

    def __get__(self, instance, owner):
        raise DataSetFamilyLookupError(
            owner.__name__,
            self.column_name,
        )


class DataSetFamilyMeta(abc.ABCMeta):

    def __new__(cls, name, bases, dict_):
        columns = {}
        for k, v in dict_.items():
            if isinstance(v, Column):
                # capture all the columns off the DataSetFamily class
                # and replace them with a descriptor that will raise a helpful
                # error message. The columns will get added to the BaseSlice
                # for this type.
                columns[k] = v
                dict_[k] = _DataSetFamilyColumn(k)

        is_abstract = dict_.pop('__abstract__', False)

        self = super(DataSetFamilyMeta, cls).__new__(
            cls,
            name,
            bases,
            dict_,
        )

        if not is_abstract:
            self.extra_dims = extra_dims = OrderedDict([
                (k, frozenset(v))
                for k, v in OrderedDict(self.extra_dims).items()
            ])
            if not extra_dims:
                raise ValueError(
                    'DataSetFamily must be defined with non-empty'
                    ' extra_dims, or with `__abstract__ = True`',
                )

            class BaseSlice(self._SliceType):
                dataset_family = self

                ndim = self.slice_ndim
                domain = self.domain


Review comment (refactor):
`__{}__` is reserved for the implementation of Python. I would assume this interacts with `ABCMeta, not part of our code. We should use something like `_abstract`.

Code after:
        The name of the column.
    """
    def __init__(self, column_name):
        self.column_name = column_name

    def __get__(self, instance, owner):
        raise DataSetFamilyLookupError(
            owner.__name__,
            self.column_name,
        )


class DataSetFamilyMeta(abc.ABCMeta):

    def __new__(cls, name, bases, dict_):
        columns = {}
        for k, v in dict_.items():
            if isinstance(v, Column):
                # capture all the columns off the DataSetFamily class
                # and replace them with a descriptor that will raise a helpful
                # error message. The columns will get added to the BaseSlice
                # for this type.
                columns[k] = v
                dict_[k] = _DataSetFamilyColumn(k)

        is_abstract = dict_.pop('_abstract', False)

        self = super(DataSetFamilyMeta, cls).__new__(
            cls,
            name,
            bases,
            dict_,
        )

        if not is_abstract:
            self.extra_dims = extra_dims = OrderedDict([
                (k, frozenset(v))
                for k, v in OrderedDict(self.extra_dims).items()
            ])
            if not extra_dims:
                raise ValueError(
                    'DataSetFamily must be defined with non-empty'
                    ' extra_dims, or with `_abstract = True`',
                )

            class BaseSlice(self._SliceType):
                dataset_family = self

                ndim = self.slice_ndim
                domain = self.domain