def timeseries(client, dataset):
    # create
    ts = TimeSeries('Human EEG')
    assert not ts.exists
    dataset.add(ts)
    assert ts.exists
    assert ts in dataset
    assert ts.type == 'TimeSeries'
    assert ts.name.startswith(
        'Human EEG')  #starts with bc duplicate names are appended
    ts2 = client.get(ts.id)
    assert ts2.id == ts.id
    assert ts2.name == ts.name
    assert ts2.type == 'TimeSeries'
    del ts2

    # provide to other tests
    yield ts

    # streaming credentials
    cred = ts.streaming_credentials()
    assert cred

    # remove
    dataset.remove(ts)
    assert not ts.exists
    assert ts not in dataset
def timeseries(client, dataset):
    # create
    ts = TimeSeries('Human EEG')
    assert not ts.exists
    dataset.add(ts)
    assert ts.exists
    assert ts in dataset
    assert ts.type == 'TimeSeries'
    assert ts.name == 'Human EEG'
    ts2 = client.get(ts.id)
    assert ts2.id == ts.id
    assert ts2.name == ts.name
    assert ts2.type == 'TimeSeries'
    del ts2

    # provide to other tests
    yield ts

    # update ts: change name
    ts.name = 'Monkey EEG'
    ts.update()
    ts2 = client.get(ts.id)
    assert ts2.id == ts.id
    assert ts2.name == ts.name
    assert ts2.type == 'TimeSeries'

    # streaming credentials
    cred = ts.streaming_credentials()
    assert cred

    # remove
    dataset.remove(ts)
    assert not ts.exists
    assert ts not in dataset
def test_search(client, dataset):
    # create
    ts = TimeSeries('Human EEG')
    assert not ts.exists
    dataset.add(ts)
    assert ts.exists
    assert ts in dataset
    assert ts.type == 'TimeSeries'
    assert ts.name == 'Human EEG'
    ts2 = client.get(ts.id)
    assert ts2.id == ts.id
    assert ts2.name == ts.name
    assert ts2.type == 'TimeSeries'
    del ts2

    t = Tabular('Some tabular data')
    assert not t.exists
    assert t.schema is None

    # create
    dataset.add(t)
    assert t.exists
    assert t.schema is None

    schema = [
        TabularSchemaColumn(name='',
                            display_name='index',
                            datatype='Integer',
                            primary_key=True,
                            internal=True),
        TabularSchemaColumn(name='',
                            display_name='email',
                            datatype='String',
                            primary_key=False,
                            internal=False),
    ]

    s = TabularSchema(name="schema", column_schema=schema)

    t.set_schema(s)
    assert t.name == 'Some tabular data'
    assert t.exists
    a = t.get_schema()
    assert a.exists

    a = client.search('email')
Beispiel #4
0
def timeseries(client, dataset):
    # create
    ts = TimeSeries("Human EEG")
    assert not ts.exists
    dataset.add(ts)
    assert ts.exists
    assert ts in dataset
    assert ts.type == "TimeSeries"
    assert ts.name.startswith(
        "Human EEG")  # starts with bc duplicate names are appended
    ts2 = client.get(ts.id)
    assert ts2.id == ts.id
    assert ts2.name == ts.name
    assert ts2.type == "TimeSeries"
    del ts2

    # provide to other tests
    yield ts

    # remove
    dataset.remove(ts)
    assert not ts.exists
    assert ts not in dataset
Beispiel #5
0
def test_stream_upload(use_dev, client, dataset):
    # can only run against dev server :-(
    if not use_dev: return

    # generate data
    freq = 100
    df = generate_dataframe(minutes=1, freq=100)

    # create timeseries
    ts = TimeSeries('My Test TimeSeries')
    dataset.add(ts)
    assert ts.exists
    print(ts)

    # create channels
    channels = [TimeSeriesChannel(c, rate=freq) for c in df.columns]
    ts.add_channels(*channels)
    for ch in channels:
        assert ch.exists
        assert ch.rate == freq
        assert ch.name in df.columns
    print("channels =", ts.channels)

    # stream data up
    ts.stream_data(df)

    # wait a bit -- let server write data
    time.sleep(10)

    # retrieve data
    for chunk in ts.get_data_iter():
        assert len(chunk) > 0
        assert chunk.columns == df.columns
    assert chunk.index[-1] == df.index[-1]

    # make sure channel times were updated
    for ch in ts.channels:
        assert ch.start_datetime == df.index[0]
        assert ch.end_datetime == df.index[-1]
Beispiel #6
0
def timeseries2(client, dataset):
    ts = TimeSeries("Animal EEG")
    dataset.add(ts)
    assert ts.exists
    yield ts
    dataset.remove(ts)