<s> from datetime import date , datetime <EOL> from stdnet . utils import test <EOL> from . main import ColumnMixin <EOL> class TestManipulate ( ColumnMixin , test . TestCase ) : <EOL> def create ( self ) : <EOL> return self . data . data1 . create ( self ) <EOL> def pop_range ( self , byrank , ts , start , end , num_popped , sl , sl2 = None ) : <EOL> all_dates , all_fields = yield ts . irange ( ) <EOL> self . assertEqual ( len ( all_fields ) , <NUM_LIT:6> ) <EOL> if byrank : <EOL> dates , fields = yield ts . irange ( start , end ) <EOL> dt , fs = yield ts . ipop_range ( start , end ) <EOL> else : <EOL> dates , fields = yield ts . range ( start , end ) <EOL> dt , fs = yield ts . pop_range ( start , end ) <EOL> self . assertEqual ( len ( dt ) , num_popped ) <EOL> size = yield ts . size ( ) <EOL> self . assertEqual ( size , len ( all_dates ) - num_popped ) <EOL> self . assertEqual ( dates , dt ) <EOL> self . assertEqual ( fields , fs ) <EOL> dates = all_dates [ sl ] <EOL> fields = dict ( ( ( f , all_fields [ f ] [ sl ] ) for f in all_fields ) ) <EOL> if sl2 : <EOL> dates . extend ( all_dates [ sl2 ] ) <EOL> for f in fields : <EOL> fields [ f ] . extend ( all_fields [ f ] [ sl2 ] ) <EOL> dt , fs = yield ts . irange ( ) <EOL> self . assertEqual ( len ( dates ) , len ( dt ) ) <EOL> self . assertEqual ( dates , dt ) <EOL> for f in fields : <EOL> self . assertEqual ( len ( fields [ f ] ) , len ( fs [ f ] ) ) <EOL> self . assertEqual ( fields , fs ) <EOL> def test_ipop_range_back ( self ) : <EOL> ts = yield self . create ( ) <EOL> yield self . pop_range ( True , ts , - <NUM_LIT:2> , - <NUM_LIT:1> , <NUM_LIT:2> , slice ( <NUM_LIT:0> , - <NUM_LIT:2> ) ) <EOL> def test_ipop_range_middle ( self ) : <EOL> ts = yield self . create ( ) <EOL> all_dates , all_fields = yield ts . irange ( ) <EOL> yield self . pop_range ( True , ts , - <NUM_LIT:10> , - <NUM_LIT:5> , <NUM_LIT:6> , slice ( <NUM_LIT:0> , - <NUM_LIT:10> ) , slice ( - <NUM_LIT:4> , None ) ) <EOL> def test_ipop_range_start ( self ) : <EOL> ts = yield self . create ( ) <EOL> yield self . pop_range ( True , ts , <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:11> , slice ( <NUM_LIT:11> , None ) ) <EOL> def test_pop_range_back ( self ) : <EOL> ts = yield self . create ( ) <EOL> start , end = yield ts . itimes ( - <NUM_LIT:2> ) <EOL> yield self . pop_range ( False , ts , start , end , <NUM_LIT:2> , slice ( <NUM_LIT:0> , - <NUM_LIT:2> ) ) <EOL> def test_contains ( self ) : <EOL> ts = yield self . create ( ) <EOL> all_dates = yield ts . itimes ( ) <EOL> dt = all_dates [ <NUM_LIT:10> ] <EOL> self . assertTrue ( dt in ts ) <EOL> v = ts . pop ( dt ) <EOL> self . assertEqual ( len ( v ) , <NUM_LIT:6> ) <EOL> self . assertFalse ( dt in ts ) <EOL> dn = datetime . now ( ) <EOL> self . assertFalse ( dn in ts ) </s>
