Exemplo n.º 1
0
def table():

    peaks_0 = np.arange(20.0).reshape(-1, 2)
    peaks_1 = np.arange(30.0).reshape(-1, 2)

    spec_0 = Spectrum(peaks_0[:], 30.0, 1, "+")
    spec_1 = Spectrum(peaks_1[:], 30.0, 2, "+", [(10, 1000)])
    spec_2 = Spectrum(peaks_1[:], 40.0, 1, "+")

    pm = PeakMap([spec_0, spec_1, spec_2])

    t0 = toTable("int", (1, 2, 3, 3, None), type_=int)
    t0.addColumn("float", (1.0, 2.0, 4.0, 3.0, None), type_=float)
    t0.addColumn("bool", (True, False, None, True, False), type_=bool)
    t0.addColumn("str", ("1", "2" * 100, None, "a", "b"), type_=str)
    t0.addColumn("object", ({1}, dict(a=2), None, (1,), [1, 2]), type_=object)
    t0.addColumn("peakmap", pm, type_=object)

    n = 10
    ts_0 = TimeSeries(map(datetime.fromordinal, range(1, n + 1)), range(n), "label1")
    ts_0.x[3] = None
    ts_0.y[3] = np.nan

    n = 10
    ts_1 = TimeSeries(map(datetime.fromordinal, range(1000,  n + 1000)),
                      range(1000, 1000 + n), "label2", [bool(i % 4) for i in range(n)])

    t0.addColumn("time_series", [ts_0, ts_0, ts_1, ts_1, None], type_=TimeSeries)

    t0.meta = {"a": "b"}
    return t0
Exemplo n.º 2
0
def test_ts(regtest_redirect):
    t = emzed.utils.toTable("id", [1, 1, 2])
    # peakmap unique id already tested by compression of peakmap:
    x = [None, 1, 2, 3, 4, None, None, 4, None]
    y = [None, 11, 12, 14, 13, None, None, 100, None]
    ts = TimeSeries(x, y)
    t.addColumn("ts", ts, format_="%s")

    with regtest_redirect():
        for xi, yi in ts.for_plotting():
            print(xi, yi)
        print(TimeSeries([], []))
        print(t)
        print(t.ts[0].uniqueId())
        print(t.uniqueId())
Exemplo n.º 3
0
def test_ts(regtest_redirect):
    t = emzed.utils.toTable("id", [1, 1, 2])
    # peakmap unique id already tested by compression of peakmap:
    x = [None, 1, 2, 3, 4, None, None, 4, None]
    y = [None, 11, 12, 14, 13, None, None, 100, None]
    ts = TimeSeries(x, y)
    t.addColumn("ts", ts, format_="%s")

    with regtest_redirect():
        for xi, yi in ts.for_plotting():
            print(xi, yi)
        print(TimeSeries([], []))
        print(t)
        print(t.ts[0].uniqueId())
        print(t.uniqueId())
Exemplo n.º 4
0
def test_ts(regtest_redirect):
    t = emzed.utils.toTable("id", [1, 1, 2])

    x = [None, 1, 2, 3, 4, None, None, 4, None]
    x = [None if xi is None else datetime.fromordinal(xi) for xi in x]

    y = [None, 11, 12, 14, 13, None, None, 100, None]
    ts = TimeSeries(x, y)
    t.addColumn("ts", ts, format_="%s")

    with regtest_redirect():
        for xi, yi in ts.for_plotting():
            print(xi, yi)
        print(TimeSeries([], []))
        print(t)
        print(t.ts[0].uniqueId())
        print(t.uniqueId())
Exemplo n.º 5
0
def test_ts(regtest_redirect):
    t = emzed.utils.toTable("id", [1, 1, 2])

    x = [None, 1, 2, 3, 4, None, None, 4, None]
    x = [None if xi is None else datetime.fromordinal(xi) for xi in x]

    y = [None, 11, 12, 14, 13, None, None, 100, None]
    ts = TimeSeries(x, y)
    t.addColumn("ts", ts, format_="%s")

    with regtest_redirect():
        for xi, yi in ts.for_plotting():
            print(xi, yi)
        print(TimeSeries([], []))
        print(t)
        print(t.ts[0].uniqueId())
        print(t.uniqueId())