Skip to content

Commit b02edc2

Browse files
authored
1 parent f619d1f commit b02edc2

File tree

4 files changed

+39
-15
lines changed

4 files changed

+39
-15
lines changed

arctic/chunkstore/chunkstore.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,15 @@ def delete(self, symbol, chunk_range=None, audit=None):
149149
self._collection.delete_many(query)
150150
self._symbols.delete_many(query)
151151
self._mdata.delete_many(query)
152-
152+
153153
if audit is not None:
154154
audit['symbol'] = symbol
155155
if chunk_range is not None:
156156
audit['rows_deleted'] = row_adjust
157157
audit['action'] = 'range delete'
158158
else:
159159
audit['action'] = 'symbol delete'
160-
160+
161161
self._audit.insert_one(audit)
162162

163163
def list_symbols(self, partial_match=None):
@@ -215,7 +215,7 @@ def rename(self, from_symbol, to_symbol, audit=None):
215215
audit['action'] = 'symbol rename'
216216
audit['old_symbol'] = from_symbol
217217
self._audit.insert_one(audit)
218-
218+
219219

220220
def read(self, symbol, chunk_range=None, filter_data=True, **kwargs):
221221
"""
@@ -245,7 +245,7 @@ def read(self, symbol, chunk_range=None, filter_data=True, **kwargs):
245245
raise NoDataFoundException('No data found for %s' % (symbol))
246246

247247
spec = {SYMBOL: symbol,
248-
}
248+
}
249249

250250
if chunk_range is not None:
251251
spec.update(CHUNKER_MAP[sym[CHUNKER]].to_mongo(chunk_range))
@@ -270,16 +270,16 @@ def read(self, symbol, chunk_range=None, filter_data=True, **kwargs):
270270
if not filter_data or chunk_range is None:
271271
return data
272272
return CHUNKER_MAP[sym[CHUNKER]].filter(data, chunk_range)
273-
273+
274274
def read_audit_log(self, symbol=None):
275275
"""
276276
Reads the audit log
277-
277+
278278
Parameters
279279
----------
280280
symbol: str
281281
optionally only retrieve specific symbol's audit information
282-
282+
283283
Returns
284284
-------
285285
list of dicts
@@ -578,12 +578,12 @@ def get_info(self, symbol):
578578
def read_metadata(self, symbol):
579579
'''
580580
Reads user defined metadata out for the given symbol
581-
581+
582582
Parameters
583583
----------
584584
symbol: str
585585
symbol for the given item in the DB
586-
586+
587587
Returns
588588
-------
589589
?
@@ -720,7 +720,7 @@ def stats(self):
720720
res['metadata'] = db.command('collstats', self._mdata.name)
721721
res['totals'] = {'count': res['chunks']['count'],
722722
'size': res['chunks']['size'] + res['symbols']['size'] + res['metadata']['size'],
723-
}
723+
}
724724
return res
725725

726726
def has_symbol(self, symbol):

arctic/chunkstore/date_chunker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def chunk_to_str(self, chunk_id):
6969
-------
7070
string
7171
"""
72-
return chunk_id.strftime("%Y-%m-%d").encode('ascii')
72+
return str(chunk_id).encode('ascii')
7373

7474
def to_mongo(self, range_obj):
7575
"""

tests/integration/chunkstore/test_chunkstore.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,9 +1133,9 @@ def test_get_chunk_range(chunkstore_lib):
11331133
chunkstore_lib.write('test_df', df, chunk_size='D')
11341134
x = list(chunkstore_lib.get_chunk_ranges('test_df'))
11351135
assert(len(x) == 3)
1136-
assert((b'2016-01-01', b'2016-01-01') in x)
1137-
assert((b'2016-01-02', b'2016-01-02') in x)
1138-
assert((b'2016-01-03', b'2016-01-03') in x)
1136+
assert((b'2016-01-01 00:00:00', b'2016-01-01 23:59:59.999000') in x)
1137+
assert((b'2016-01-02 00:00:00', b'2016-01-02 23:59:59.999000') in x)
1138+
assert((b'2016-01-03 00:00:00', b'2016-01-03 23:59:59.999000') in x)
11391139

11401140

11411141
def test_iterators(chunkstore_lib):
@@ -1324,7 +1324,7 @@ def test_audit(chunkstore_lib):
13241324

13251325

13261326
def test_chunkstore_misc(chunkstore_lib):
1327-
1327+
13281328
p = pickle.dumps(chunkstore_lib)
13291329
c = pickle.loads(p)
13301330
assert(chunkstore_lib._arctic_lib.get_name() == c._arctic_lib.get_name())
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
Unit tests for bugfixes
3+
"""
4+
5+
from datetime import datetime
6+
7+
import pandas as pd
8+
from pandas import DataFrame, DatetimeIndex
9+
10+
11+
# Issue 384
12+
def test_write_dataframe(chunkstore_lib):
13+
# Create dataframe of time measurements taken every 6 hours
14+
date_range = pd.date_range(start=datetime(2017, 5, 1, 1), periods=8, freq='6H')
15+
16+
df = DataFrame(data={'something': [100, 200, 300, 400, 500, 600, 700, 800]},
17+
index=DatetimeIndex(date_range, name='date'))
18+
19+
20+
chunkstore_lib.write('test', df, chunk_size='D')
21+
22+
# Iterate
23+
for chunk in chunkstore_lib.iterator('test'):
24+
assert(len(chunk) > 0)

0 commit comments

Comments
 (0)