7
7
import pytest
8
8
import pytz
9
9
10
- from arctic import arctic as m
11
10
from arctic .date import DateRange , mktz , CLOSED_CLOSED , CLOSED_OPEN , OPEN_CLOSED , OPEN_OPEN
12
- from arctic .exceptions import OverlappingDataException , NoDataFoundException
11
+ from arctic .exceptions import NoDataFoundException
13
12
14
13
15
14
def test_read (tickstore_lib ):
@@ -356,11 +355,11 @@ def test_read_longs(tickstore_lib):
356
355
def test_read_with_image (tickstore_lib ):
357
356
DUMMY_DATA = [
358
357
{'a' : 1. ,
359
- 'index' : dt (2013 , 6 , 1 , 12 , 00 , tzinfo = mktz ('Europe/London' ))
358
+ 'index' : dt (2013 , 1 , 1 , 11 , 00 , tzinfo = mktz ('Europe/London' ))
360
359
},
361
360
{
362
361
'b' : 4. ,
363
- 'index' : dt (2013 , 6 , 1 , 13 , 00 , tzinfo = mktz ('Europe/London' ))
362
+ 'index' : dt (2013 , 1 , 1 , 12 , 00 , tzinfo = mktz ('Europe/London' ))
364
363
},
365
364
]
366
365
# Add an image
@@ -371,21 +370,38 @@ def test_read_with_image(tickstore_lib):
371
370
{'a' : 37. ,
372
371
'c' : 2. ,
373
372
},
374
- 't' : dt (2013 , 6 , 1 , 11 , 0 )
373
+ 't' : dt (2013 , 1 , 1 , 10 , tzinfo = mktz ( 'Europe/London' ) )
375
374
}
376
375
}
377
376
}
378
377
)
379
378
380
- tickstore_lib .read ('SYM' , columns = None )
381
- read = tickstore_lib .read ('SYM' , columns = None , date_range = DateRange (dt (2013 , 6 , 1 ), dt (2013 , 6 , 2 )))
382
- assert read ['a' ][0 ] == 1
379
+ dr = DateRange (dt (2013 , 1 , 1 ), dt (2013 , 1 , 2 ))
380
+ # tickstore_lib.read('SYM', columns=None)
381
+ df = tickstore_lib .read ('SYM' , columns = None , date_range = dr )
382
+ assert df ['a' ][0 ] == 1
383
383
384
384
# Read with the image as well
385
- read = tickstore_lib .read ('SYM' , columns = None , date_range = DateRange (dt (2013 , 6 , 1 ), dt (2013 , 6 , 2 )),
386
- include_images = True )
387
- assert read ['a' ][0 ] == 37
388
- assert read ['a' ][1 ] == 1
389
- assert np .isnan (read ['b' ][0 ])
390
- assert read ['b' ][2 ] == 4
391
- assert read .index [0 ] == dt (2013 , 6 , 1 , 11 )
385
+ df = tickstore_lib .read ('SYM' , columns = None , date_range = dr , include_images = True )
386
+ assert set (df .columns ) == set (('a' , 'b' , 'c' ))
387
+ assert_array_equal (df ['a' ].values , np .array ([37 , 1 , np .nan ]))
388
+ assert_array_equal (df ['b' ].values , np .array ([np .nan , np .nan , 4 ]))
389
+ assert_array_equal (df ['c' ].values , np .array ([2 , np .nan , np .nan ]))
390
+ assert df .index [0 ] == dt (2013 , 1 , 1 , 10 )
391
+ assert df .index [1 ] == dt (2013 , 1 , 1 , 11 )
392
+ assert df .index [2 ] == dt (2013 , 1 , 1 , 12 )
393
+
394
+ df = tickstore_lib .read ('SYM' , columns = ('a' , 'b' ), date_range = dr , include_images = True )
395
+ assert set (df .columns ) == set (('a' , 'b' ))
396
+ assert_array_equal (df ['a' ].values , np .array ([37 , 1 , np .nan ]))
397
+ assert_array_equal (df ['b' ].values , np .array ([np .nan , np .nan , 4 ]))
398
+ assert df .index [0 ] == dt (2013 , 1 , 1 , 10 )
399
+ assert df .index [1 ] == dt (2013 , 1 , 1 , 11 )
400
+ assert df .index [2 ] == dt (2013 , 1 , 1 , 12 )
401
+
402
+ df = tickstore_lib .read ('SYM' , columns = ['c' ], date_range = dr , include_images = True )
403
+ assert set (df .columns ) == set (['c' ])
404
+ assert_array_equal (df ['c' ].values , np .array ([2 , np .nan , np .nan ]))
405
+ assert df .index [0 ] == dt (2013 , 1 , 1 , 10 )
406
+ assert df .index [1 ] == dt (2013 , 1 , 1 , 11 )
407
+ assert df .index [2 ] == dt (2013 , 1 , 1 , 12 )
0 commit comments