def init_class_fixtures(cls): super(TestDownsampledRowwiseOperation, cls).init_class_fixtures() cls.pipeline_engine = SimplePipelineEngine( get_loader=lambda c: ExplodingObject(), calendar=cls.dates, asset_finder=cls.asset_finder, )
def init_class_fixtures(cls): super(TestDownsampledRowwiseOperation, cls).init_class_fixtures() cls.pipeline_engine = SimplePipelineEngine( get_loader=lambda c: ExplodingObject(), asset_finder=cls.asset_finder, default_domain=EquitySessionDomain( cls.dates, country_code=cls.ASSET_FINDER_COUNTRY_CODE, ), )
def init_class_fixtures(cls): super(WithTechnicalFactor, cls).init_class_fixtures() cls.ndays = ndays = 24 cls.nassets = nassets = len(cls.ASSET_FINDER_EQUITY_SIDS) cls.dates = dates = pd.date_range(cls.START_DATE, periods=ndays) cls.assets = pd.Index(cls.asset_finder.sids) cls.engine = SimplePipelineEngine( lambda column: ExplodingObject(), dates, cls.asset_finder, ) cls.asset_exists = exists = np.full((ndays, nassets), True, dtype=bool) cls.asset_exists_masked = masked = exists.copy() masked[:, -1] = False
def run_graph(self, graph, initial_workspace, mask=None): """ Compute the given TermGraph, seeding the workspace of our engine with `initial_workspace`. Parameters ---------- graph : zipline.pipeline.graph.TermGraph Graph to run. initial_workspace : dict Initial workspace to forward to SimplePipelineEngine.compute_chunk. mask : DataFrame, optional This is a value to pass to `initial_workspace` as the mask from `AssetExists()`. Defaults to a frame of shape `self.default_shape` containing all True values. Returns ------- results : dict Mapping from termname -> computed result. """ engine = SimplePipelineEngine( lambda column: ExplodingObject(), self.nyse_sessions, self.asset_finder, ) if mask is None: mask = self.default_asset_exists_mask dates, assets, mask_values = explode(mask) initial_workspace.setdefault(AssetExists(), mask_values) initial_workspace.setdefault(InputDates(), dates) return engine.compute_chunk( graph, dates, assets, initial_workspace, )
def test_duplicate_values(self): UNIMPORTANT_VALUE = 57 panel = pd.Panel( UNIMPORTANT_VALUE, items=['a', 'b', 'b', 'a'], major_axis=['c'], minor_axis=['d'], ) unused = ExplodingObject() axis_names = ['items', 'major_axis', 'minor_axis'] for axis_order in permutations((0, 1, 2)): transposed = panel.transpose(*axis_order) with self.assertRaises(ValueError) as e: PanelBarReader(unused, transposed, 'daily') expected = ( "Duplicate entries in Panel.{name}: ['a', 'b'].".format( name=axis_names[axis_order.index(0)], )) self.assertEqual(str(e.exception), expected)