Exemplo n.º 1
0
def test_many_roots_same_filename():
    roots = ['tests/test_data/many_roots/dir' + str(index) for index in [1, 4]]
    many_roots = bazefetcher(roots)
    with pytest.raises(ValueError) as excinfo:
        many_roots("root_tag", t1_1, t1_5)
    assert ('files [\'root_tag_2030-01-03T00.00.00+00.00_2030-01-04T00.00.00'
            '+00.00.json.gz\'] are not unique' in str(excinfo.value))
Exemplo n.º 2
0
def test_many_roots():
    baze_and_authored = bazefetcher(
        ['tests/test_data/authored', 'tests/test_data/baze'])

    sin_b = baze_and_authored('Sin-T60s-SR01hz', t1_2, t1_4)
    assert len(sin_b) == 17280

    i04_status_b = authored('installation-04-status', t12_31_23, t1_5_1)
    assert len(i04_status_b) == 5
Exemplo n.º 3
0
def test_many_roots_same_tag():
    roots = [
        'tests/test_data/many_roots/dir' + str(index) for index in [3, 1, 2]
    ]
    many_roots = bazefetcher(roots)
    tag = "root_tag"
    root = many_roots(tag, t1_1, t1_5)
    assert len(root) == 7

    root = many_roots(tag, t1_3, t1_3_21)
    assert len(root) == 1

    root = many_roots(tag, t1_3, t1_3_21, snap='right')
    assert len(root) == 2
Exemplo n.º 4
0
#!/usr/bin/env python3
from camille.source import bazefetcher
from datetime import datetime, timedelta
from math import pi
from pytz import utc
import numpy as np
import pandas as pd
import pytest


authored = bazefetcher('tests/test_data/authored')
baze = bazefetcher('tests/test_data/baze')

t12_31_22 = datetime(2029, 12, 31, 22, tzinfo=utc)
t12_31_23 = datetime(2029, 12, 31, 23, tzinfo=utc)
t1_1 = datetime(2030, 1, 1, tzinfo=utc)
t1_2 = datetime(2030, 1, 2, tzinfo=utc)
t1_4 = datetime(2030, 1, 4, tzinfo=utc)
t1_1_1 = datetime(2030, 1, 1, 1, tzinfo=utc)
t1_3 = datetime(2030, 1, 3, tzinfo=utc)
t1_3_15 = datetime(2030, 1, 3, 15, tzinfo=utc)
t1_3_21 = datetime(2030, 1, 3, 21, tzinfo=utc)
t1_4_3 = datetime(2030, 1, 4, 3, tzinfo=utc)
t1_4_23 = datetime(2030, 1, 4, 23, tzinfo=utc)
t1_5 = datetime(2030, 1, 5, tzinfo=utc)
t1_5_1 = datetime(2030, 1, 5, 1, tzinfo=utc)

trng = pd.date_range(t1_1, t1_5, freq="S", name='time', closed='left')
t = trng.map(lambda t: (t - t1_1).total_seconds())

_sin = pd.Series(np.sin(t * pi / 60), index=trng, name='value')
Exemplo n.º 5
0
#!/usr/bin/env python3
from camille.source import bazefetcher
from camille.util import BazeIter
from datetime import datetime, timedelta
from math import pi
from pytz import utc
import pytest
import pandas as pd
import numpy as np


baze = bazefetcher('tests/test_data/baze')
sin_tag = 'Sin-T60s-SR01hz'
cos_tag = 'Cos-T60s-SR01hz'

t1 = datetime(2030, 1, 1, tzinfo=utc)
t2 = datetime(2030, 1, 2, tzinfo=utc)
t3 = datetime(2030, 1, 3, tzinfo=utc)
t4 = datetime(2030, 1, 4, tzinfo=utc)
eps = timedelta(microseconds=1)

invalid_date = datetime(2030, 1, 1, 10, tzinfo=utc)
invalid_interval = timedelta(1.5)

trng = pd.date_range(t1, t4, freq="10S", name='time', closed='left')
t = trng.map(lambda t: (t - t1).total_seconds())

_sin = pd.Series(np.sin(t * pi / 6), index=trng, name='value')
#sin data are spaced per every 10 seconds
day_data_length = 24 * 60 * 6
_cos = pd.Series(np.cos(t * pi / 6), index=trng, name='value')
Exemplo n.º 6
0
def test_no_directories():
    with pytest.raises(ValueError) as excinfo:
        bazefetcher('tests/test_data/baze/perling')
    assert ('no file in [\'tests/test_data/baze/perling\'] is a directory'
            in str(excinfo.value))