# Path: alphaware/base/factor_container.py
# def ensure_factor_container(func, argname, arg):
#     if isinstance(arg, FactorContainer):
#         return arg
#     else:
#         fc = FactorContainer(tiaocang_date=arg.trade_date_list)
#         fc.add_factor(arg)
#         return fc


import copy
import numpy as np
import pandas as pd
from sklearn.base import (BaseEstimator,
                          TransformerMixin)
from argcheck import (preprocess,
                      expect_types)
from .factor_container import ensure_factor_container
# -*- coding: utf-8 -*-



class FactorTransformer(BaseEstimator, TransformerMixin):
    def __init__(self, copy=True, out_container=False):
        self.copy = copy
        self.df_mapper = None
        self.out_container = out_container

    @expect_types(out=bool)
    def set_out_container(self, out):
        self.out_container = out

    @preprocess(factor_container=ensure_factor_container)
    def fit(self, factor_container, **kwargs):
        self.df_mapper = self._build_mapper(factor_container)
        return self

    def _build_mapper(self, factor_container):
        raise NotImplementedError


# Path: alphaware/base/factor_container.py
# def ensure_factor_container(func, argname, arg):
#     if isinstance(arg, FactorContainer):
#         return arg
#     else:
#         fc = FactorContainer(tiaocang_date=arg.trade_date_list)
#         fc.add_factor(arg)
#         return fc


# Path: alphaware/base/factor_transformer.py
import copy
import numpy as np
import pandas as pd
from sklearn.base import (BaseEstimator,
                          TransformerMixin)
from argcheck import (preprocess,
                      expect_types)
from .factor_container import ensure_factor_container

# -*- coding: utf-8 -*-



class FactorTransformer(BaseEstimator, TransformerMixin):
    def __init__(self, copy=True, out_container=False):
        self.copy = copy
        self.df_mapper = None
        self.out_container = out_container

    @expect_types(out=bool)
    def set_out_container(self, out):
        self.out_container = out

    @preprocess(factor_container=ensure_factor_container)
    def fit(self, factor_container, **kwargs):
        self.df_mapper = self._build_mapper(factor_container)
        return self

    def _build_mapper(self, factor_container):
        raise NotImplementedError


    @preprocess(factor_container=ensure_factor_container)