#NEWLINE# def test_read_with_adjustments( self ) : #NEWLINE# #INDENT# columns = [ USEquityPricing . high , USEquityPricing . volume ] #NEWLINE# query_days = self . calendar_days_between ( TEST_QUERY_START , TEST_QUERY_STOP ) #NEWLINE# shifted_query_days = self . calendar_days_between ( TEST_QUERY_START , TEST_QUERY_STOP , shift = ( - 1 ) ) #NEWLINE# pricing_loader = USEquityPricingLoader ( self . bcolz_daily_bar_reader , self . adjustment_reader ) #NEWLINE# results = pricing_loader . load_adjusted_array ( columns , dates = query_days , assets = Int64Index ( arange ( 1 , 7 ) ) , mask = ones ( ( len ( query_days ) , 6 ) , dtype = bool ) ) #NEWLINE# ( highs , volumes ) = map ( getitem ( results ) , columns ) #NEWLINE# expected_baseline_highs = expected_daily_bar_values_2d ( shifted_query_days , self . asset_info , 'high' ) #NEWLINE# expected_baseline_volumes = expected_daily_bar_values_2d ( shifted_query_days , self . asset_info , 'volume' ) #NEWLINE# for windowlen in range ( 1 , ( len ( query_days ) + 1 ) ) : #NEWLINE# #INDENT# for ( offset , window ) in enumerate ( highs . traverse ( windowlen ) ) : #NEWLINE# #INDENT# baseline = expected_baseline_highs [ offset : ( offset + windowlen ) ] #NEWLINE# baseline_dates = query_days [ offset : ( offset + windowlen ) ] #NEWLINE# expected_adjusted_highs = self . apply_adjustments ( baseline_dates , self . assets , baseline , concat ( [ SPLITS , MERGERS , DIVIDENDS_EXPECTED ] , ignore_index = True ) ) #NEWLINE# assert_allclose ( expected_adjusted_highs , window ) #NEWLINE# #UNINDENT# for ( offset , window ) in enumerate ( volumes . traverse ( windowlen ) ) : #NEWLINE# #INDENT# baseline = expected_baseline_volumes [ offset : ( offset + windowlen ) ] #NEWLINE# baseline_dates = query_days [ offset : ( offset + windowlen ) ] #NEWLINE# adjustments = SPLITS . copy ( ) #NEWLINE# adjustments . ratio = ( 1 / adjustments . ratio ) #NEWLINE# expected_adjusted_volumes = self . apply_adjustments ( baseline_dates , self . assets , baseline , adjustments ) #NEWLINE# assert_array_equal ( expected_adjusted_volumes , window . astype ( uint32 ) ) #NEWLINE# #UNINDENT# #UNINDENT# with self . assertRaises ( WindowLengthTooLong ) : #NEWLINE# #INDENT# highs . traverse ( ( windowlen + 1 ) ) #NEWLINE# #UNINDENT# with self . assertRaises ( WindowLengthTooLong ) : #NEWLINE# #INDENT# volumes . traverse ( ( windowlen + 1 ) )