<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> from collections import OrderedDict <EOL> from datetime import timedelta , time <EOL> from itertools import product , chain <EOL> from unittest import TestCase <EOL> import warnings <EOL> import blaze as bz <EOL> from datashape import dshape , var , Record <EOL> from nose_parameterized import parameterized <EOL> import numpy as np <EOL> from numpy . testing . utils import assert_array_almost_equal <EOL> from odo import odo <EOL> import pandas as pd <EOL> from pandas . util . testing import assert_frame_equal <EOL> from toolz import keymap , valmap , concatv <EOL> from toolz . curried import operator as op <EOL> from zipline . assets . synthetic import make_simple_equity_info <EOL> from zipline . pipeline import Pipeline , CustomFactor <EOL> from zipline . pipeline . data import DataSet , BoundColumn <EOL> from zipline . pipeline . engine import SimplePipelineEngine <EOL> from zipline . pipeline . loaders . blaze import ( <EOL> from_blaze , <EOL> BlazeLoader , <EOL> NoDeltasWarning , <EOL> ) <EOL> from zipline . pipeline . loaders . blaze . core import ( <EOL> NonNumpyField , <EOL> NonPipelineField , <EOL> no_deltas_rules , <EOL> ) <EOL> from zipline . utils . numpy_utils import ( <EOL> float64_dtype , <EOL> int64_dtype , <EOL> repeat_last_axis , <EOL> ) <EOL> from zipline . testing import tmp_asset_finder <EOL> nameof = op . attrgetter ( '<STR_LIT:name>' ) <EOL> dtypeof = op . attrgetter ( '<STR_LIT>' ) <EOL> asset_infos = ( <EOL> ( make_simple_equity_info ( <EOL> tuple ( map ( ord , '<STR_LIT>' ) ) , <EOL> pd . Timestamp ( <NUM_LIT:0> ) , <EOL> pd . Timestamp ( '<STR_LIT>' ) , <EOL> ) , ) , <EOL> ( make_simple_equity_info ( <EOL> tuple ( map ( ord , '<STR_LIT>' ) ) , <EOL> pd . Timestamp ( <NUM_LIT:0> ) , <EOL> pd . Timestamp ( '<STR_LIT>' ) , <EOL> ) , ) , <EOL> ) <EOL> with_extra_sid = parameterized . expand ( asset_infos ) <EOL> with_ignore_sid = parameterized . expand ( <EOL> product ( chain . from_iterable ( asset_infos ) , [ True , False ] ) <EOL> ) <EOL> def _utc_localize_index_level_0 ( df ) : <EOL> """<STR_LIT>""" <EOL> idx = df . index <EOL> df . index = pd . MultiIndex . from_product ( <EOL> ( idx . levels [ <NUM_LIT:0> ] . tz_localize ( '<STR_LIT>' ) , idx . levels [ <NUM_LIT:1> ] ) , <EOL> names = idx . names , <EOL> ) <EOL> return df <EOL> class BlazeToPipelineTestCase ( TestCase ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> cls . dates = dates = pd . date_range ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> dates = cls . dates . repeat ( <NUM_LIT:3> ) <EOL> cls . sids = sids = ord ( '<STR_LIT:A>' ) , ord ( '<STR_LIT:B>' ) , ord ( '<STR_LIT:C>' ) <EOL> cls . df = df = pd . DataFrame ( { <EOL> '<STR_LIT>' : sids * <NUM_LIT:3> , <EOL> '<STR_LIT:value>' : ( <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT> , <NUM_LIT:1.> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , <EOL> '<STR_LIT>' : ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ) , <EOL> '<STR_LIT>' : dates , <EOL> '<STR_LIT>' : dates , <EOL> } ) <EOL> cls . dshape = dshape ( """<STR_LIT>""" ) <EOL> cls . macro_df = df [ df . sid == <NUM_LIT> ] . drop ( '<STR_LIT>' , axis = <NUM_LIT:1> ) <EOL> dshape_ = OrderedDict ( cls . dshape . measure . fields ) <EOL> del dshape_ [ '<STR_LIT>' ] <EOL> cls . macro_dshape = var * Record ( dshape_ ) <EOL> cls . garbage_loader = BlazeLoader ( ) <EOL> cls . missing_values = { '<STR_LIT>' : <NUM_LIT:0> } <EOL> def test_tabular ( self ) : <EOL> name = '<STR_LIT>' <EOL> expr = bz . data ( self . df , name = name , dshape = self . dshape ) <EOL> ds = from_blaze ( <EOL> expr , <EOL> loader = self . garbage_loader , <EOL> no_deltas_rule = no_deltas_rules . ignore , <EOL> missing_values = self . missing_values , <EOL> ) <EOL> self . assertEqual ( ds . __name__ , name ) <EOL> self . assertTrue ( issubclass ( ds , DataSet ) ) <EOL> self . assertIs ( ds . value . dtype , float64_dtype ) <EOL> self . assertIs ( ds . int_value . dtype , int64_dtype ) <EOL> self . assertTrue ( np . isnan ( ds . value . missing_value ) ) <EOL> self . assertEqual ( ds . int_value . missing_value , <NUM_LIT:0> ) <EOL> invalid_type_fields = ( '<STR_LIT>' , ) <EOL> for field in invalid_type_fields : <EOL> with self . assertRaises ( AttributeError ) as e : <EOL> getattr ( ds , field ) <EOL> self . assertIn ( "<STR_LIT>" % field , str ( e . exception ) ) <EOL> self . assertIn ( "<STR_LIT>" , str ( e . exception ) ) <EOL> self . assertIs ( <EOL> from_blaze ( <EOL> expr , <EOL> loader = self . garbage_loader , <EOL> no_deltas_rule = no_deltas_rules . ignore , <EOL> missing_values = self . missing_values , <EOL> ) , <EOL> ds , <EOL> ) <EOL> def test_column ( self ) : <EOL> exprname = '<STR_LIT>' <EOL> expr = bz . data ( self . df , name = exprname , dshape = self . dshape ) <EOL> value = from_blaze ( <EOL> expr . value , <EOL> loader = self . garbage_loader , <EOL> no_deltas_rule = no_deltas_rules . ignore , <EOL> missing_values = self . missing_values , <EOL> ) <EOL> self . assertEqual ( value . name , '<STR_LIT:value>' ) <EOL> self . assertIsInstance ( value , BoundColumn ) <EOL> self . assertIs ( value . dtype , float64_dtype ) <EOL> self . assertIs ( <EOL> from_blaze ( <EOL> expr . value , <EOL> loader = self . garbage_loader , <EOL> no_deltas_rule = no_deltas_rules . ignore , <EOL> missing_values = self . missing_values , <EOL> ) , <EOL> value , <EOL> ) <EOL> self . assertIs ( <EOL> from_blaze ( <EOL> expr , <EOL> loader = self . garbage_loader , <EOL> no_deltas_rule = no_deltas_rules . ignore , <EOL> missing_values = self . missing_values , <EOL> ) . value , <EOL> value , <EOL> ) <EOL> self . assertIs ( <EOL> from_blaze ( <EOL> expr , <EOL> loader = self . garbage_loader , <EOL> no_deltas_rule = no_deltas_rules . ignore , <EOL> missing_values = self . missing_values , <EOL> ) , <EOL> value . dataset , <EOL> ) <EOL> self . assertEqual ( value . dataset . __name__ , exprname ) <EOL> def test_missing_asof ( self ) : <EOL> expr = bz . data ( <EOL> self . df . loc [ : , [ '<STR_LIT>' , '<STR_LIT:value>' , '<STR_LIT>' ] ] , <EOL> name = '<STR_LIT>' , <EOL> dshape = """<STR_LIT>""" , <EOL> ) <EOL> with self . assertRaises ( TypeError ) as e : <EOL> from_blaze ( <EOL> expr , <EOL> loader = self . garbage_loader , <EOL> no_deltas_rule = no_deltas_rules . ignore , <EOL> ) <EOL> self . assertIn ( "<STR_LIT>" , str ( e . exception ) ) <EOL> self . assertIn ( repr ( str ( expr . dshape . measure ) ) , str ( e . exception ) ) <EOL> def test_auto_deltas ( self ) : <EOL> expr = bz . data ( <EOL> { '<STR_LIT>' : self . df , <EOL> '<STR_LIT>' : pd . DataFrame ( columns = self . df . columns ) } , <EOL> dshape = var * Record ( ( <EOL> ( '<STR_LIT>' , self . dshape . measure ) , <EOL> ( '<STR_LIT>' , self . dshape . measure ) , <EOL> ) ) , <EOL> ) <EOL> loader = BlazeLoader ( ) <EOL> ds = from_blaze ( <EOL> expr . ds , <EOL> loader = loader , <EOL> missing_values = self . missing_values , <EOL> ) <EOL> self . assertEqual ( len ( loader ) , <NUM_LIT:1> ) <EOL> exprdata = loader [ ds ] <EOL> self . assertTrue ( exprdata . expr . isidentical ( expr . ds ) ) <EOL> self . assertTrue ( exprdata . deltas . isidentical ( expr . ds_deltas ) ) <EOL> def test_auto_deltas_fail_warn ( self ) : <EOL> with warnings . catch_warnings ( record = True ) as ws : <EOL> warnings . simplefilter ( '<STR_LIT>' ) <EOL> loader = BlazeLoader ( ) <EOL> expr = bz . data ( self . df , dshape = self . dshape ) <EOL> from_blaze ( <EOL> expr , <EOL> loader = loader , <EOL> no_deltas_rule = no_deltas_rules . warn , <EOL> missing_values = self . missing_values , <EOL> ) <EOL> self . assertEqual ( len ( ws ) , <NUM_LIT:1> ) <EOL> w = ws [ <NUM_LIT:0> ] . message <EOL> self . assertIsInstance ( w , NoDeltasWarning ) <EOL> self . assertIn ( str ( expr ) , str ( w ) ) <EOL> def test_auto_deltas_fail_raise ( self ) : <EOL> loader = BlazeLoader ( ) <EOL> expr = bz . data ( self . df , dshape = self . dshape ) <EOL> with self . assertRaises ( ValueError ) as e : <EOL> from_blaze ( <EOL> expr , <EOL> loader = loader , <EOL> no_deltas_rule = no_deltas_rules . raise_ , <EOL> ) <EOL> self . assertIn ( str ( expr ) , str ( e . exception ) ) <EOL> def test_non_numpy_field ( self ) : <EOL> expr = bz . data ( <EOL> [ ] , <EOL> dshape = """<STR_LIT>""" , <EOL> ) <EOL> ds = from_blaze ( <EOL> expr , <EOL> loader = self . garbage_loader , <EOL> no_deltas_rule = no_deltas_rules . ignore , <EOL> ) <EOL> with self . assertRaises ( AttributeError ) : <EOL> ds . a <EOL> self . assertIsInstance ( object . __getattribute__ ( ds , '<STR_LIT:a>' ) , NonNumpyField ) <EOL> def test_non_pipeline_field ( self ) : <EOL> expr = bz . data ( <EOL> [ ] , <EOL> dshape = """<STR_LIT>""" , <EOL> ) <EOL> ds = from_blaze ( <EOL> expr , <EOL> loader = self . garbage_loader , <EOL> no_deltas_rule = no_deltas_rules . ignore , <EOL> ) <EOL> with self . assertRaises ( AttributeError ) : <EOL> ds . a <EOL> self . assertIsInstance ( <EOL> object . __getattribute__ ( ds , '<STR_LIT:a>' ) , <EOL> NonPipelineField , <EOL> ) <EOL> def test_complex_expr ( self ) : <EOL> expr = bz . data ( self . df , dshape = self . dshape ) <EOL> expr_with_add = bz . transform ( expr , value = expr . value + <NUM_LIT:1> ) <EOL> from_blaze ( <EOL> expr_with_add , <EOL> deltas = None , <EOL> loader = self . garbage_loader , <EOL> missing_values = self . missing_values , <EOL> ) <EOL> with self . assertRaises ( TypeError ) : <EOL> from_blaze ( <EOL> expr . value + <NUM_LIT:1> , <EOL> deltas = None , <EOL> loader = self . garbage_loader , <EOL> missing_values = self . missing_values , <EOL> ) <EOL> deltas = bz . data ( <EOL> pd . DataFrame ( columns = self . df . columns ) , <EOL> dshape = self . dshape , <EOL> ) <EOL> with self . assertRaises ( TypeError ) : <EOL> from_blaze ( <EOL> expr_with_add , <EOL> deltas = deltas , <EOL> loader = self . garbage_loader , <EOL> missing_values = self . missing_values , <EOL> ) <EOL> with self . assertRaises ( TypeError ) : <EOL> from_blaze ( <EOL> expr . value + <NUM_LIT:1> , <EOL> deltas = deltas , <EOL> loader = self . garbage_loader , <EOL> missing_values = self . missing_values , <EOL> ) <EOL> def _test_id ( self , df , dshape , expected , finder , add ) : <EOL> expr = bz . data ( df , name = '<STR_LIT>' , dshape = dshape ) <EOL> loader = BlazeLoader ( ) <EOL> ds = from_blaze ( <EOL> expr , <EOL> loader = loader , <EOL> no_deltas_rule = no_deltas_rules . ignore , <EOL> missing_values = self . missing_values , <EOL> ) <EOL> p = Pipeline ( ) <EOL> for a in add : <EOL> p . add ( getattr ( ds , a ) . latest , a ) <EOL> dates = self . dates <EOL> with tmp_asset_finder ( ) as finder : <EOL> result = SimplePipelineEngine ( <EOL> loader , <EOL> dates , <EOL> finder , <EOL> ) . run_pipeline ( p , dates [ <NUM_LIT:0> ] , dates [ - <NUM_LIT:1> ] ) <EOL> assert_frame_equal ( <EOL> result , <EOL> _utc_localize_index_level_0 ( expected ) , <EOL> check_dtype = False , <EOL> ) <EOL> def test_custom_query_time_tz ( self ) : <EOL> df = self . df . copy ( ) <EOL> df [ '<STR_LIT>' ] = ( <EOL> pd . DatetimeIndex ( df [ '<STR_LIT>' ] , tz = '<STR_LIT>' ) + <EOL> timedelta ( hours = <NUM_LIT:8> , minutes = <NUM_LIT> ) <EOL> ) . tz_convert ( '<STR_LIT>' ) . tz_localize ( None ) <EOL> df . ix [ <NUM_LIT:3> : <NUM_LIT:5> , '<STR_LIT>' ] = pd . Timestamp ( '<STR_LIT>' ) <EOL> expr = bz . data ( df , name = '<STR_LIT>' , dshape = self . dshape ) <EOL> loader = BlazeLoader ( data_query_time = time ( <NUM_LIT:8> , <NUM_LIT> ) , data_query_tz = '<STR_LIT>' ) <EOL> ds = from_blaze ( <EOL> expr , <EOL> loader = loader , <EOL> no_deltas_rule = no_deltas_rules . ignore , <EOL> missing_values = self . missing_values , <EOL> ) <EOL> p = Pipeline ( ) <EOL> p . add ( ds . value . latest , '<STR_LIT:value>' ) <EOL> p . add ( ds . int_value . latest , '<STR_LIT>' ) <EOL> dates = self . dates <EOL> with tmp_asset_finder ( ) as finder : <EOL> result = SimplePipelineEngine ( <EOL> loader , <EOL> dates , <EOL> finder , <EOL> ) . run_pipeline ( p , dates [ <NUM_LIT:0> ] , dates [ - <NUM_LIT:1> ] ) <EOL> expected = df . drop ( '<STR_LIT>' , axis = <NUM_LIT:1> ) <EOL> expected [ '<STR_LIT>' ] = expected [ '<STR_LIT>' ] . dt . normalize ( ) . astype ( <EOL> '<STR_LIT>' , <EOL> ) . dt . tz_localize ( '<STR_LIT>' ) <EOL> expected . ix [ <NUM_LIT:3> : <NUM_LIT:5> , '<STR_LIT>' ] += timedelta ( days = <NUM_LIT:1> ) <EOL> expected . set_index ( [ '<STR_LIT>' , '<STR_LIT>' ] , inplace = True ) <EOL> expected . index = pd . MultiIndex . from_product ( ( <EOL> expected . index . levels [ <NUM_LIT:0> ] , <EOL> finder . retrieve_all ( expected . index . levels [ <NUM_LIT:1> ] ) , <EOL> ) ) <EOL> assert_frame_equal ( result , expected , check_dtype = False ) <EOL> def test_id ( self ) : <EOL> """<STR_LIT>""" <EOL> with tmp_asset_finder ( ) as finder : <EOL> expected = self . df . drop ( '<STR_LIT>' , axis = <NUM_LIT:1> ) . set_index ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> ) <EOL> expected . index = pd . MultiIndex . from_product ( ( <EOL> expected . index . levels [ <NUM_LIT:0> ] , <EOL> finder . retrieve_all ( expected . index . levels [ <NUM_LIT:1> ] ) , <EOL> ) ) <EOL> self . _test_id ( <EOL> self . df , self . dshape , expected , finder , ( '<STR_LIT>' , '<STR_LIT:value>' , ) <EOL> ) <EOL> def test_id_ffill_out_of_window ( self ) : <EOL> """<STR_LIT>""" <EOL> dates = self . dates . repeat ( <NUM_LIT:3> ) - timedelta ( days = <NUM_LIT:10> ) <EOL> df = pd . DataFrame ( { <EOL> '<STR_LIT>' : self . sids * <NUM_LIT:3> , <EOL> '<STR_LIT:value>' : ( <NUM_LIT:0> , <NUM_LIT:1> , np . nan , <NUM_LIT:1> , np . nan , <NUM_LIT:3> , np . nan , <NUM_LIT:3> , <NUM_LIT:4> ) , <EOL> '<STR_LIT>' : ( <NUM_LIT:0> , np . nan , <NUM_LIT:2> , np . nan , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:3> , np . nan ) , <EOL> '<STR_LIT>' : dates , <EOL> '<STR_LIT>' : dates , <EOL> } ) <EOL> fields = OrderedDict ( self . dshape . measure . fields ) <EOL> fields [ '<STR_LIT>' ] = fields [ '<STR_LIT:value>' ] <EOL> with tmp_asset_finder ( ) as finder : <EOL> expected = pd . DataFrame ( <EOL> np . array ( [ [ <NUM_LIT:2> , <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:3> , <NUM_LIT:3> ] , <EOL> [ <NUM_LIT:3> , <NUM_LIT:4> ] , <EOL> [ <NUM_LIT:2> , <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:3> , <NUM_LIT:3> ] , <EOL> [ <NUM_LIT:3> , <NUM_LIT:4> ] , <EOL> [ <NUM_LIT:2> , <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:3> , <NUM_LIT:3> ] , <EOL> [ <NUM_LIT:3> , <NUM_LIT:4> ] ] ) , <EOL> columns = [ '<STR_LIT>' , '<STR_LIT:value>' ] , <EOL> index = pd . MultiIndex . from_product ( <EOL> ( self . dates , finder . retrieve_all ( self . sids ) ) , <EOL> ) , <EOL> ) <EOL> self . _test_id ( <EOL> df , <EOL> var * Record ( fields ) , <EOL> expected , <EOL> finder , <EOL> ( '<STR_LIT:value>' , '<STR_LIT>' ) , <EOL> ) <EOL> def test_id_multiple_columns ( self ) : <EOL> """<STR_LIT>""" <EOL> df = self . df . copy ( ) <EOL> df [ '<STR_LIT>' ] = df . value + <NUM_LIT:1> <EOL> fields = OrderedDict ( self . dshape . measure . fields ) <EOL> fields [ '<STR_LIT>' ] = fields [ '<STR_LIT:value>' ] <EOL> with tmp_asset_finder ( ) as finder : <EOL> expected = df . drop ( '<STR_LIT>' , axis = <NUM_LIT:1> ) . set_index ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> ) . sort_index ( axis = <NUM_LIT:1> ) <EOL> expected . index = pd . MultiIndex . from_product ( ( <EOL> expected . index . levels [ <NUM_LIT:0> ] , <EOL> finder . retrieve_all ( expected . index . levels [ <NUM_LIT:1> ] ) , <EOL> ) ) <EOL> self . _test_id ( <EOL> df , <EOL> var * Record ( fields ) , <EOL> expected , <EOL> finder , <EOL> ( '<STR_LIT:value>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ) <EOL> def test_id_macro_dataset ( self ) : <EOL> """<STR_LIT>""" <EOL> asset_info = asset_infos [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> nassets = len ( asset_info ) <EOL> with tmp_asset_finder ( ) as finder : <EOL> expected = pd . DataFrame ( <EOL> list ( concatv ( [ <NUM_LIT:0> ] * nassets , [ <NUM_LIT:1> ] * nassets , [ <NUM_LIT:2> ] * nassets ) ) , <EOL> index = pd . MultiIndex . from_product ( ( <EOL> self . macro_df . timestamp , <EOL> finder . retrieve_all ( asset_info . index ) , <EOL> ) ) , <EOL> columns = ( '<STR_LIT:value>' , ) , <EOL> ) <EOL> self . _test_id ( <EOL> self . macro_df , <EOL> self . macro_dshape , <EOL> expected , <EOL> finder , <EOL> ( '<STR_LIT:value>' , ) , <EOL> ) <EOL> def test_id_ffill_out_of_window_macro_dataset ( self ) : <EOL> """<STR_LIT>""" <EOL> dates = self . dates - timedelta ( days = <NUM_LIT:10> ) <EOL> df = pd . DataFrame ( { <EOL> '<STR_LIT:value>' : ( <NUM_LIT:0> , np . nan , np . nan ) , <EOL> '<STR_LIT>' : ( np . nan , <NUM_LIT:1> , np . nan ) , <EOL> '<STR_LIT>' : dates , <EOL> '<STR_LIT>' : dates , <EOL> } ) <EOL> fields = OrderedDict ( self . macro_dshape . measure . fields ) <EOL> fields [ '<STR_LIT>' ] = fields [ '<STR_LIT:value>' ] <EOL> with tmp_asset_finder ( ) as finder : <EOL> expected = pd . DataFrame ( <EOL> np . array ( [ [ <NUM_LIT:0> , <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:0> , <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:0> , <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:0> , <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:0> , <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:0> , <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:0> , <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:0> , <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:0> , <NUM_LIT:1> ] ] ) , <EOL> columns = [ '<STR_LIT:value>' , '<STR_LIT>' ] , <EOL> index = pd . MultiIndex . from_product ( <EOL> ( self . dates , finder . retrieve_all ( self . sids ) ) , <EOL> ) , <EOL> ) . sort_index ( axis = <NUM_LIT:1> ) <EOL> self . _test_id ( <EOL> df , <EOL> var * Record ( fields ) , <EOL> expected , <EOL> finder , <EOL> ( '<STR_LIT:value>' , '<STR_LIT>' ) , <EOL> ) <EOL> def test_id_macro_dataset_multiple_columns ( self ) : <EOL> """<STR_LIT>""" <EOL> df = self . macro_df . copy ( ) <EOL> df [ '<STR_LIT>' ] = df . value + <NUM_LIT:1> <EOL> fields = OrderedDict ( self . macro_dshape . measure . fields ) <EOL> fields [ '<STR_LIT>' ] = fields [ '<STR_LIT:value>' ] <EOL> asset_info = asset_infos [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> with tmp_asset_finder ( equities = asset_info ) as finder : <EOL> expected = pd . DataFrame ( <EOL> np . array ( [ [ <NUM_LIT:0> , <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:1> , <NUM_LIT:2> ] , <EOL> [ <NUM_LIT:2> , <NUM_LIT:3> ] ] ) . repeat ( <NUM_LIT:3> , axis = <NUM_LIT:0> ) , <EOL> index = pd . MultiIndex . from_product ( ( <EOL> df . timestamp , <EOL> finder . retrieve_all ( asset_info . index ) , <EOL> ) ) , <EOL> columns = ( '<STR_LIT:value>' , '<STR_LIT>' ) , <EOL> ) . sort_index ( axis = <NUM_LIT:1> ) <EOL> self . _test_id ( <EOL> df , <EOL> var * Record ( fields ) , <EOL> expected , <EOL> finder , <EOL> ( '<STR_LIT:value>' , '<STR_LIT>' ) , <EOL> ) <EOL> def test_id_take_last_in_group ( self ) : <EOL> T = pd . Timestamp <EOL> df = pd . DataFrame ( <EOL> columns = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:value>' ] , <EOL> data = [ <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , <NUM_LIT:1> , np . nan ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , np . nan , np . nan ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , np . nan , <NUM_LIT:1> ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , <NUM_LIT:2> , np . nan ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , np . nan , np . nan ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , np . nan , np . nan ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , np . nan , <NUM_LIT:1> ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , np . nan , np . nan ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , <NUM_LIT:2> , np . nan ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:3> ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:3> ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , <NUM_LIT:2> , np . nan ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , <NUM_LIT:2> , np . nan ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:3> ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , np . nan , np . nan ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , np . nan , np . nan ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT> , np . nan , <NUM_LIT:4> ] , <EOL> ] , <EOL> ) <EOL> fields = OrderedDict ( self . dshape . measure . fields ) <EOL> fields [ '<STR_LIT>' ] = fields [ '<STR_LIT:value>' ] <EOL> with tmp_asset_finder ( ) as finder : <EOL> expected = pd . DataFrame ( <EOL> columns = [ '<STR_LIT>' , '<STR_LIT:value>' ] , <EOL> data = [ <EOL> [ <NUM_LIT:1> , <NUM_LIT:0> ] , <EOL> [ np . nan , <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:2> , np . nan ] , <EOL> [ <NUM_LIT:1> , <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:2> , <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:3> , <NUM_LIT:3> ] , <EOL> [ <NUM_LIT:2> , <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:3> , <NUM_LIT:3> ] , <EOL> [ <NUM_LIT:3> , <NUM_LIT:3> ] , <EOL> ] , <EOL> index = pd . MultiIndex . from_product ( <EOL> ( self . dates , finder . retrieve_all ( self . sids ) ) , <EOL> ) , <EOL> ) <EOL> self . _test_id ( <EOL> df , <EOL> var * Record ( fields ) , <EOL> expected , <EOL> finder , <EOL> ( '<STR_LIT:value>' , '<STR_LIT>' ) , <EOL> ) <EOL> def test_id_take_last_in_group_macro ( self ) : <EOL> """<STR_LIT>""" <EOL> T = pd . Timestamp <EOL> df = pd . DataFrame ( <EOL> columns = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:value>' ] , <EOL> data = [ <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , np . nan , <NUM_LIT:1> ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , np . nan , np . nan ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT:1> , np . nan ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , np . nan , <NUM_LIT:2> ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT:2> , np . nan ] , <EOL> [ T ( '<STR_LIT>' ) , T ( '<STR_LIT>' ) , <NUM_LIT:3> , <NUM_LIT:3> ] , <EOL> ] , <EOL> ) <EOL> fields = OrderedDict ( self . macro_dshape . measure . fields ) <EOL> fields [ '<STR_LIT>' ] = fields [ '<STR_LIT:value>' ] <EOL> with tmp_asset_finder ( ) as finder : <EOL> expected = pd . DataFrame ( <EOL> columns = [ <EOL> '<STR_LIT>' , '<STR_LIT:value>' , <EOL> ] , <EOL> data = [ <EOL> [ np . nan , <NUM_LIT:1> ] , <EOL> [ np . nan , <NUM_LIT:1> ] , <EOL> [ np . nan , <NUM_LIT:1> ] , <EOL> [ <NUM_LIT:1> , <NUM_LIT:2> ] , <EOL> [ <NUM_LIT:1> , <NUM_LIT:2> ] , <EOL> [ <NUM_LIT:1> , <NUM_LIT:2> ] , <EOL> [ <NUM_LIT:2> , <NUM_LIT:2> ] , <EOL> [ <NUM_LIT:2> , <NUM_LIT:2> ] , <EOL> [ <NUM_LIT:2> , <NUM_LIT:2> ] , <EOL> ] , <EOL> index = pd . MultiIndex . from_product ( <EOL> ( self . dates , finder . retrieve_all ( self . sids ) ) , <EOL> ) , <EOL> ) <EOL> self . _test_id ( <EOL> df , <EOL> var * Record ( fields ) , <EOL> expected , <EOL> finder , <EOL> ( '<STR_LIT:value>' , '<STR_LIT>' ) , <EOL> ) <EOL> def _run_pipeline ( self , <EOL> expr , <EOL> deltas , <EOL> expected_views , <EOL> expected_output , <EOL> finder , <EOL> calendar , <EOL> start , <EOL> end , <EOL> window_length , <EOL> compute_fn ) : <EOL> loader = BlazeLoader ( ) <EOL> ds = from_blaze ( <EOL> expr , <EOL> deltas , <EOL> loader = loader , <EOL> no_deltas_rule = no_deltas_rules . raise_ , <EOL> missing_values = self . missing_values , <EOL> ) <EOL> p = Pipeline ( ) <EOL> window_length_ = window_length <EOL> class TestFactor ( CustomFactor ) : <EOL> inputs = ds . value , <EOL> window_length = window_length_ <EOL> def compute ( self , today , assets , out , data ) : <EOL> assert_array_almost_equal ( data , expected_views [ today ] ) <EOL> out [ : ] = compute_fn ( data ) <EOL> p . add ( TestFactor ( ) , '<STR_LIT:value>' ) <EOL> result = SimplePipelineEngine ( <EOL> loader , <EOL> calendar , <EOL> finder , <EOL> ) . run_pipeline ( p , start , end ) <EOL> assert_frame_equal ( <EOL> result , <EOL> _utc_localize_index_level_0 ( expected_output ) , <EOL> check_dtype = False , <EOL> ) <EOL> @ with_ignore_sid <EOL> def test_deltas ( self , asset_info , add_extra_sid ) : <EOL> df = self . df . copy ( ) <EOL> if add_extra_sid : <EOL> extra_sid_df = pd . DataFrame ( { <EOL> '<STR_LIT>' : self . dates , <EOL> '<STR_LIT>' : self . dates , <EOL> '<STR_LIT>' : ( ord ( '<STR_LIT:E>' ) , ) * <NUM_LIT:3> , <EOL> '<STR_LIT:value>' : ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , ) , <EOL> '<STR_LIT>' : ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ) , <EOL> } ) <EOL> df = df . append ( extra_sid_df , ignore_index = True ) <EOL> expr = bz . data ( df , name = '<STR_LIT>' , dshape = self . dshape ) <EOL> deltas = bz . data ( df , dshape = self . dshape ) <EOL> deltas = bz . data ( <EOL> odo ( <EOL> bz . transform ( <EOL> deltas , <EOL> value = deltas . value + <NUM_LIT:10> , <EOL> timestamp = deltas . timestamp + timedelta ( days = <NUM_LIT:1> ) , <EOL> ) , <EOL> pd . DataFrame , <EOL> ) , <EOL> name = '<STR_LIT>' , <EOL> dshape = self . dshape , <EOL> ) <EOL> expected_views = keymap ( pd . Timestamp , { <EOL> '<STR_LIT>' : np . array ( [ [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:1.0> , <NUM_LIT> , <NUM_LIT> ] ] ) , <EOL> '<STR_LIT>' : np . array ( [ [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] ) , <EOL> '<STR_LIT>' : np . array ( [ [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] ) , <EOL> } ) <EOL> nassets = len ( asset_info ) <EOL> if nassets == <NUM_LIT:4> : <EOL> expected_views = valmap ( <EOL> lambda view : np . c_ [ view , [ np . nan , np . nan ] ] , <EOL> expected_views , <EOL> ) <EOL> with tmp_asset_finder ( equities = asset_info ) as finder : <EOL> expected_output = pd . DataFrame ( <EOL> list ( concatv ( [ <NUM_LIT:12> ] * nassets , [ <NUM_LIT> ] * nassets , [ <NUM_LIT> ] * nassets ) ) , <EOL> index = pd . MultiIndex . from_product ( ( <EOL> sorted ( expected_views . keys ( ) ) , <EOL> finder . retrieve_all ( asset_info . index ) , <EOL> ) ) , <EOL> columns = ( '<STR_LIT:value>' , ) , <EOL> ) <EOL> dates = self . dates <EOL> dates = dates . insert ( len ( dates ) , dates [ - <NUM_LIT:1> ] + timedelta ( days = <NUM_LIT:1> ) ) <EOL> self . _run_pipeline ( <EOL> expr , <EOL> deltas , <EOL> expected_views , <EOL> expected_output , <EOL> finder , <EOL> calendar = dates , <EOL> start = dates [ <NUM_LIT:1> ] , <EOL> end = dates [ - <NUM_LIT:1> ] , <EOL> window_length = <NUM_LIT:2> , <EOL> compute_fn = np . nanmax , <EOL> ) <EOL> @ with_extra_sid <EOL> def test_deltas_only_one_delta_in_universe ( self , asset_info ) : <EOL> expr = bz . data ( self . df , name = '<STR_LIT>' , dshape = self . dshape ) <EOL> deltas = pd . DataFrame ( { <EOL> '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> ] , <EOL> '<STR_LIT>' : [ self . dates [ <NUM_LIT:1> ] , self . dates [ <NUM_LIT:0> ] ] , <EOL> '<STR_LIT>' : [ self . dates [ <NUM_LIT:2> ] , self . dates [ <NUM_LIT:1> ] ] , <EOL> '<STR_LIT:value>' : [ <NUM_LIT:10> , <NUM_LIT:11> ] , <EOL> } ) <EOL> deltas = bz . data ( deltas , name = '<STR_LIT>' , dshape = self . dshape ) <EOL> expected_views = keymap ( pd . Timestamp , { <EOL> '<STR_LIT>' : np . array ( [ [ <NUM_LIT:0.0> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:1.0> , <NUM_LIT> , <NUM_LIT> ] ] ) , <EOL> '<STR_LIT>' : np . array ( [ [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] ) , <EOL> '<STR_LIT>' : np . array ( [ [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] ) , <EOL> } ) <EOL> nassets = len ( asset_info ) <EOL> if nassets == <NUM_LIT:4> : <EOL> expected_views = valmap ( <EOL> lambda view : np . c_ [ view , [ np . nan , np . nan ] ] , <EOL> expected_views , <EOL> ) <EOL> with tmp_asset_finder ( equities = asset_info ) as finder : <EOL> expected_output = pd . DataFrame ( <EOL> columns = [ <EOL> '<STR_LIT:value>' , <EOL> ] , <EOL> data = np . array ( [ <NUM_LIT:11> , <NUM_LIT:10> , <NUM_LIT:4> ] ) . repeat ( len ( asset_info . index ) ) , <EOL> index = pd . MultiIndex . from_product ( ( <EOL> sorted ( expected_views . keys ( ) ) , <EOL> finder . retrieve_all ( asset_info . index ) , <EOL> ) ) , <EOL> ) <EOL> dates = self . dates <EOL> dates = dates . insert ( len ( dates ) , dates [ - <NUM_LIT:1> ] + timedelta ( days = <NUM_LIT:1> ) ) <EOL> self . _run_pipeline ( <EOL> expr , <EOL> deltas , <EOL> expected_views , <EOL> expected_output , <EOL> finder , <EOL> calendar = dates , <EOL> start = dates [ <NUM_LIT:1> ] , <EOL> end = dates [ - <NUM_LIT:1> ] , <EOL> window_length = <NUM_LIT:2> , <EOL> compute_fn = np . nanmax , <EOL> ) <EOL> def test_deltas_macro ( self ) : <EOL> asset_info = asset_infos [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> expr = bz . data ( self . macro_df , name = '<STR_LIT>' , dshape = self . macro_dshape ) <EOL> deltas = bz . data ( <EOL> self . macro_df . iloc [ : - <NUM_LIT:1> ] , <EOL> name = '<STR_LIT>' , <EOL> dshape = self . macro_dshape , <EOL> ) <EOL> deltas = bz . transform ( <EOL> deltas , <EOL> value = deltas . value + <NUM_LIT:10> , <EOL> timestamp = deltas . timestamp + timedelta ( days = <NUM_LIT:1> ) , <EOL> ) <EOL> nassets = len ( asset_info ) <EOL> expected_views = keymap ( pd . Timestamp , { <EOL> '<STR_LIT>' : repeat_last_axis ( np . array ( [ <NUM_LIT> , <NUM_LIT:1.0> ] ) , nassets ) , <EOL> '<STR_LIT>' : repeat_last_axis ( np . array ( [ <NUM_LIT> , <NUM_LIT> ] ) , nassets ) , <EOL> } ) <EOL> with tmp_asset_finder ( equities = asset_info ) as finder : <EOL> expected_output = pd . DataFrame ( <EOL> list ( concatv ( [ <NUM_LIT:10> ] * nassets , [ <NUM_LIT:11> ] * nassets ) ) , <EOL> index = pd . MultiIndex . from_product ( ( <EOL> sorted ( expected_views . keys ( ) ) , <EOL> finder . retrieve_all ( asset_info . index ) , <EOL> ) ) , <EOL> columns = ( '<STR_LIT:value>' , ) , <EOL> ) <EOL> dates = self . dates <EOL> self . _run_pipeline ( <EOL> expr , <EOL> deltas , <EOL> expected_views , <EOL> expected_output , <EOL> finder , <EOL> calendar = dates , <EOL> start = dates [ <NUM_LIT:1> ] , <EOL> end = dates [ - <NUM_LIT:1> ] , <EOL> window_length = <NUM_LIT:2> , <EOL> compute_fn = np . nanmax , <EOL> ) <EOL> @ with_extra_sid <EOL> def test_novel_deltas ( self , asset_info ) : <EOL> base_dates = pd . DatetimeIndex ( [ <EOL> pd . Timestamp ( '<STR_LIT>' ) , <EOL> pd . Timestamp ( '<STR_LIT>' ) <EOL> ] ) <EOL> repeated_dates = base_dates . repeat ( <NUM_LIT:3> ) <EOL> baseline = pd . DataFrame ( { <EOL> '<STR_LIT>' : self . sids * <NUM_LIT:2> , <EOL> '<STR_LIT:value>' : ( <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT> , <NUM_LIT:1.> , <NUM_LIT> , <NUM_LIT> ) , <EOL> '<STR_LIT>' : ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) , <EOL> '<STR_LIT>' : repeated_dates , <EOL> '<STR_LIT>' : repeated_dates , <EOL> } ) <EOL> expr = bz . data ( baseline , name = '<STR_LIT>' , dshape = self . dshape ) <EOL> deltas = bz . data ( <EOL> odo ( <EOL> bz . transform ( <EOL> expr , <EOL> value = expr . value + <NUM_LIT:10> , <EOL> timestamp = expr . timestamp + timedelta ( days = <NUM_LIT:1> ) , <EOL> ) , <EOL> pd . DataFrame , <EOL> ) , <EOL> name = '<STR_LIT>' , <EOL> dshape = self . dshape , <EOL> ) <EOL> expected_views = keymap ( pd . Timestamp , { <EOL> '<STR_LIT>' : np . array ( [ [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] ) , <EOL> '<STR_LIT>' : np . array ( [ [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] ) , <EOL> } ) <EOL> if len ( asset_info ) == <NUM_LIT:4> : <EOL> expected_views = valmap ( <EOL> lambda view : np . c_ [ view , [ np . nan , np . nan , np . nan ] ] , <EOL> expected_views , <EOL> ) <EOL> expected_output_buffer = [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> , np . nan , <NUM_LIT:11> , <NUM_LIT:12> , <NUM_LIT> , np . nan ] <EOL> else : <EOL> expected_output_buffer = [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> , <NUM_LIT:11> , <NUM_LIT:12> , <NUM_LIT> ] <EOL> cal = pd . DatetimeIndex ( [ <EOL> pd . Timestamp ( '<STR_LIT>' ) , <EOL> pd . Timestamp ( '<STR_LIT>' ) , <EOL> pd . Timestamp ( '<STR_LIT>' ) , <EOL> pd . Timestamp ( '<STR_LIT>' ) , <EOL> ] ) <EOL> with tmp_asset_finder ( equities = asset_info ) as finder : <EOL> expected_output = pd . DataFrame ( <EOL> expected_output_buffer , <EOL> index = pd . MultiIndex . from_product ( ( <EOL> sorted ( expected_views . keys ( ) ) , <EOL> finder . retrieve_all ( asset_info . index ) , <EOL> ) ) , <EOL> columns = ( '<STR_LIT:value>' , ) , <EOL> ) <EOL> self . _run_pipeline ( <EOL> expr , <EOL> deltas , <EOL> expected_views , <EOL> expected_output , <EOL> finder , <EOL> calendar = cal , <EOL> start = cal [ <NUM_LIT:2> ] , <EOL> end = cal [ - <NUM_LIT:1> ] , <EOL> window_length = <NUM_LIT:3> , <EOL> compute_fn = op . itemgetter ( - <NUM_LIT:1> ) , <EOL> ) <EOL> def test_novel_deltas_macro ( self ) : <EOL> asset_info = asset_infos [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> base_dates = pd . DatetimeIndex ( [ <EOL> pd . Timestamp ( '<STR_LIT>' ) , <EOL> pd . Timestamp ( '<STR_LIT>' ) <EOL> ] ) <EOL> baseline = pd . DataFrame ( { <EOL> '<STR_LIT:value>' : ( <NUM_LIT:0> , <NUM_LIT:1> ) , <EOL> '<STR_LIT>' : base_dates , <EOL> '<STR_LIT>' : base_dates , <EOL> } ) <EOL> expr = bz . data ( baseline , name = '<STR_LIT>' , dshape = self . macro_dshape ) <EOL> deltas = bz . data ( baseline , name = '<STR_LIT>' , dshape = self . macro_dshape ) <EOL> deltas = bz . transform ( <EOL> deltas , <EOL> value = deltas . value + <NUM_LIT:10> , <EOL> timestamp = deltas . timestamp + timedelta ( days = <NUM_LIT:1> ) , <EOL> ) <EOL> nassets = len ( asset_info ) <EOL> expected_views = keymap ( pd . Timestamp , { <EOL> '<STR_LIT>' : repeat_last_axis ( <EOL> np . array ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) , <EOL> nassets , <EOL> ) , <EOL> '<STR_LIT>' : repeat_last_axis ( <EOL> np . array ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) , <EOL> nassets , <EOL> ) , <EOL> } ) <EOL> cal = pd . DatetimeIndex ( [ <EOL> pd . Timestamp ( '<STR_LIT>' ) , <EOL> pd . Timestamp ( '<STR_LIT>' ) , <EOL> pd . Timestamp ( '<STR_LIT>' ) , <EOL> pd . Timestamp ( '<STR_LIT>' ) , <EOL> ] ) <EOL> with tmp_asset_finder ( equities = asset_info ) as finder : <EOL> expected_output = pd . DataFrame ( <EOL> list ( concatv ( [ <NUM_LIT:10> ] * nassets , [ <NUM_LIT:11> ] * nassets ) ) , <EOL> index = pd . MultiIndex . from_product ( ( <EOL> sorted ( expected_views . keys ( ) ) , <EOL> finder . retrieve_all ( asset_info . index ) , <EOL> ) ) , <EOL> columns = ( '<STR_LIT:value>' , ) , <EOL> ) <EOL> self . _run_pipeline ( <EOL> expr , <EOL> deltas , <EOL> expected_views , <EOL> expected_output , <EOL> finder , <EOL> calendar = cal , <EOL> start = cal [ <NUM_LIT:2> ] , <EOL> end = cal [ - <NUM_LIT:1> ] , <EOL> window_length = <NUM_LIT:3> , <EOL> compute_fn = op . itemgetter ( - <NUM_LIT:1> ) , <EOL> ) </s>
