@@ -1331,5 +1331,33 @@ def test_chunkstore_misc(chunkstore_lib):
1331
1331
1332
1332
assert ("arctic_test.TEST" in str (chunkstore_lib ))
1333
1333
assert (str (chunkstore_lib ) == repr (chunkstore_lib ))
1334
+
1335
+
1336
+ def test_unsorted_index (chunkstore_lib ):
1337
+ df = pd .DataFrame ({'date' : [dt (2016 ,9 ,1 ), dt (2016 ,8 ,31 )],
1338
+ 'vals' : range (2 )}).set_index ('date' )
1339
+ df2 = pd .DataFrame ({'date' : [dt (2016 ,9 ,2 ), dt (2016 ,9 ,1 )],
1340
+ 'vals' : range (2 )}).set_index ('date' )
1334
1341
1335
-
1342
+ chunkstore_lib .write ('test_symbol' , df )
1343
+ assert_frame_equal (df .sort_index (), chunkstore_lib .read ('test_symbol' ))
1344
+ chunkstore_lib .update ('test_symbol' , df2 )
1345
+ assert_frame_equal (chunkstore_lib .read ('test_symbol' ),
1346
+ pd .DataFrame ({'date' : pd .date_range ('2016-8-31' ,
1347
+ '2016-9-2' ),
1348
+ 'vals' : [1 ,1 ,0 ]}).set_index ('date' ))
1349
+
1350
+ def test_unsorted_date_col (chunkstore_lib ):
1351
+ df = pd .DataFrame ({'date' : [dt (2016 ,9 ,1 ), dt (2016 ,8 ,31 )],
1352
+ 'vals' : range (2 )})
1353
+ df2 = pd .DataFrame ({'date' : [dt (2016 ,9 ,2 ), dt (2016 ,9 ,1 )],
1354
+ 'vals' : range (2 )})
1355
+
1356
+ chunkstore_lib .write ('test_symbol' , df )
1357
+ assert_frame_equal (df .sort (columns = 'date' ).reset_index (drop = True ), chunkstore_lib .read ('test_symbol' ))
1358
+ chunkstore_lib .update ('test_symbol' , df2 )
1359
+ assert_frame_equal (chunkstore_lib .read ('test_symbol' ),
1360
+ pd .DataFrame ({'date' : pd .date_range ('2016-8-31' ,
1361
+ '2016-9-2' ),
1362
+ 'vals' : [1 ,1 ,0 ]}))
1363
+
0 commit comments