Skip to content

Commit

Permalink
Merge pull request pandas-dev#4 from jamesblackburn/circleci_build_an…
Browse files Browse the repository at this point in the history
…d_cov

Circleci build and tests
  • Loading branch information
jamesblackburn committed Jun 5, 2015
2 parents 2307ed9 + 5af2ce3 commit dc7be90
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 16 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# [Arctic TimeSeries and Tick store](https://github.com/ahlmss/arctic)

[![Circle CI](https://circleci.com/gh/ahlmss/arctic.svg?style=shield)](https://circleci.com/gh/ahlmss/arctic)

Arctic is a high performance datastore for numeric data. It supports [Pandas](http://pandas.pydata.org/),
[numpy](http://www.numpy.org/) arrays and pickled objects out-of-the-box, with pluggable support for
other data types and optional versioning.
Expand Down
7 changes: 6 additions & 1 deletion arctic/_compression.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from .logging import logger
import _compress as clz4

try:
from . import _compress as clz4
except ImportError:
logger.warn("Couldn't import cython lz4")
import lz4 as clz4


USE_LZ4HC = True # switch to use LZ4HC. Default True
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/store/test_pickle_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_get_info_bson_object(library):

def test_bson_large_object(library):
blob = {'foo': dt(2015, 1, 1), 'object': Arctic,
'large_thing': np.random.rand(2.1 * 1024 * 1024).tostring()}
'large_thing': np.random.rand(int(2.1 * 1024 * 1024)).tostring()}
assert len(blob['large_thing']) > 16 * 1024 * 1024
library.write('BLOB', blob)
saved_blob = library.read('BLOB').data
Expand Down
15 changes: 8 additions & 7 deletions tests/unit/date/test_datetime_to_ms_roundtrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from datetime import datetime as dt
import pytz
from arctic.date import mktz, datetime_to_ms, ms_to_datetime
from arctic.date._mktz import DEFAULT_TIME_ZONE_NAME


def assert_roundtrip(tz):
Expand Down Expand Up @@ -33,7 +34,7 @@ def test_UTC_roundtrip():
assert_roundtrip(tz)


def test_weird_get_tz_London():
def test_weird_get_tz_local():
tz = get_tz()
assert_roundtrip(tz)

Expand All @@ -50,7 +51,7 @@ def test_mktz_London():
assert_roundtrip(tz)


def test_datetime_roundtrip_lon_no_tz():
def test_datetime_roundtrip_local_no_tz():
pdt = datetime.datetime(2012, 6, 12, 12, 12, 12, 123000)
pdt2 = ms_to_datetime(datetime_to_ms(pdt))
assert pdt2 == pdt
Expand All @@ -60,21 +61,21 @@ def test_datetime_roundtrip_lon_no_tz():
assert pdt2 == pdt


def test_datetime_roundtrip_lon_tz():
pdt = datetime.datetime(2012, 6, 12, 12, 12, 12, 123000, tzinfo=mktz('Europe/London'))
def test_datetime_roundtrip_local_tz():
pdt = datetime.datetime(2012, 6, 12, 12, 12, 12, 123000, tzinfo=mktz(DEFAULT_TIME_ZONE_NAME))
pdt2 = ms_to_datetime(datetime_to_ms(pdt))
assert pdt2 == pdt.replace(tzinfo=None)

pdt = datetime.datetime(2012, 1, 12, 12, 12, 12, 123000, tzinfo=mktz('Europe/London'))
pdt = datetime.datetime(2012, 1, 12, 12, 12, 12, 123000, tzinfo=mktz(DEFAULT_TIME_ZONE_NAME))
pdt2 = ms_to_datetime(datetime_to_ms(pdt))
assert pdt2 == pdt.replace(tzinfo=None)


def test_datetime_roundtrip_est_tz():
pdt = datetime.datetime(2012, 6, 12, 12, 12, 12, 123000, tzinfo=mktz('EST'))
pdt2 = ms_to_datetime(datetime_to_ms(pdt))
assert pdt2.replace(tzinfo=mktz('Europe/London')) == pdt
assert pdt2.replace(tzinfo=mktz(DEFAULT_TIME_ZONE_NAME)) == pdt

pdt = datetime.datetime(2012, 1, 12, 12, 12, 12, 123000, tzinfo=mktz('EST'))
pdt2 = ms_to_datetime(datetime_to_ms(pdt))
assert pdt2.replace(tzinfo=mktz('Europe/London')) == pdt
assert pdt2.replace(tzinfo=mktz(DEFAULT_TIME_ZONE_NAME)) == pdt
8 changes: 7 additions & 1 deletion tests/unit/date/test_mktz.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from pytest import raises

from arctic.date import mktz, TimezoneError
from arctic.date._mktz import DEFAULT_TIME_ZONE_NAME


def test_mktz():
tz = mktz()
tz = mktz("Europe/London")
d = dt(2012, 2, 2, tzinfo=tz)
assert d.tzname() == 'GMT'
d = dt(2012, 7, 2, tzinfo=tz)
Expand All @@ -19,6 +20,11 @@ def test_mktz():
assert d.tzname() == 'UTC' # --------replace_empty_timezones_with_default -----------------


def test_mktz_noarg():
tz = mktz()
assert DEFAULT_TIME_ZONE_NAME in str(tz)


def test_mktz_zone():
tz = mktz('UTC')
assert tz.zone == "UTC"
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/date/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from datetime import datetime as dt
from arctic.date import datetime_to_ms, ms_to_datetime, mktz, to_pandas_closed_closed, DateRange, OPEN_OPEN, CLOSED_CLOSED
from arctic.date._mktz import DEFAULT_TIME_ZONE_NAME


@pytest.mark.parametrize('pdt', [
Expand All @@ -23,7 +24,7 @@ def test_datetime_to_ms_and_back(pdt):


def test_datetime_to_ms_and_back_microseconds():
pdt = dt(2012, 8, 1, 12, 34, 56, 999999, tzinfo=mktz('Europe/London'))
pdt = dt(2012, 8, 1, 12, 34, 56, 999999, tzinfo=mktz(DEFAULT_TIME_ZONE_NAME))
i = datetime_to_ms(pdt)
pdt = pdt.replace(tzinfo=None)
pdt2 = ms_to_datetime(i)
Expand Down
12 changes: 7 additions & 5 deletions tests/unit/store/test_version_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,21 @@ def test_delete_version_version_not_found():
logger.error.assert_called_once_with("Can't delete sentinel.symbol:sentinel.version as not found in DB")


def test_list_versions_LondonTime():
def test_list_versions_localTime():
# Object ID's are stored in UTC. We need to ensure that the returned times
# for versions are in the local London TimeZone
# for versions are in the local TimeZone
vs = create_autospec(VersionStore, instance=True,
_versions=Mock())
vs._find_snapshots.return_value = 'snap'
vs._versions.find.return_value = [{'_id': bson.ObjectId.from_datetime(dt(2013, 4, 1, 9, 0)),
'symbol': 's', 'version': 10}]
date = dt(2013, 4, 1, 9, 0)
vs._versions.find.return_value = [{'_id': bson.ObjectId.from_datetime(date),
'symbol': 's', 'version': 10}]

version = list(VersionStore.list_versions(vs, "symbol"))[0]
local_date = date.replace(tzinfo=mktz("UTC")).astimezone(mktz()).replace(tzinfo=None)
assert version == {'symbol': version['symbol'], 'version': version['version'],
# We return naive datetimes in 'default' time, which is London for us
'date': dt(2013, 4, 1, 10, 0),
'date': local_date,
'snapshots': 'snap'}


Expand Down

0 comments on commit dc7be90

Please sign in to comment.