Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Update _pandas_ndarray_store.py

* Update with unit test

* change assertion in unit test to check for frame equality

* Set index names and column names since artic will give them default names
  • Loading branch information
bmoscon committed May 4, 2017
1 parent f37f59e commit d0e78a1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion arctic/store/_pandas_ndarray_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _index_range(self, version, symbol, date_range=None, **kwargs):
if start > dts[-1]:
return -1, -1
idxstart = min(np.searchsorted(dts, start), len(dts) - 1)
idxend = min(np.searchsorted(dts, end), len(dts) - 1)
idxend = min(np.searchsorted(dts, end, side='right'), len(dts) - 1)
return int(index['index'][idxstart]), int(index['index'][idxend] + 1)
return super(PandasStore, self)._index_range(version, symbol, **kwargs)

Expand Down
13 changes: 13 additions & 0 deletions tests/integration/store/test_version_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
from mock import patch
import time
import pytest
import numpy as np

from arctic.exceptions import NoDataFoundException, DuplicateSnapshotException
from arctic.date import DateRange

from ...util import read_str_as_pandas
from arctic.date._mktz import mktz
Expand Down Expand Up @@ -942,3 +944,14 @@ def test_list_symbols_regex(library):
assert 'furble' not in library.list_symbols(a=1, regex='asd')
assert library.list_symbols(a={'$gt': 5}, regex='asd') == []
assert library.list_symbols(b={'$gt': 5}, regex='asd') == ['asdf']


def test_date_range_large(library):
index = [dt(2017,1,1)]*20000 + [dt(2017,1,2)]*20000
data = np.random.random((40000, 10))
df = pd.DataFrame(index=index, data=data)
df.index.name = 'index'
df.columns = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
library.write('test', df)
r = library.read('test', date_range=DateRange(dt(2017,1,1), dt(2017,1,2)))
assert_frame_equal(df, r.data)

0 comments on commit d0e78a1

Please sign in to comment.