Esempio n. 1
0
def test_fromfunction():
    def f(x, y):
        return x + y
    d = da.fromfunction(f, shape=(5, 5), chunks=(2, 2), dtype='f8')

    assert_eq(d, np.fromfunction(f, shape=(5, 5)))
    assert same_keys(d, da.fromfunction(f, shape=(5, 5), chunks=(2, 2), dtype='f8'))
Esempio n. 2
0
def test_fromfunction(func, dtype, kwargs):
    a = np.fromfunction(func, shape=(5, 5), dtype=dtype, **kwargs)
    d = da.fromfunction(func, shape=(5, 5), chunks=(2, 2), dtype=dtype, **kwargs)

    assert_eq(d, a)

    d2 = da.fromfunction(func, shape=(5, 5), chunks=(2, 2), dtype=dtype, **kwargs)

    assert same_keys(d, d2)
Esempio n. 3
0
def test_fromfunction(func, dtype, kwargs):
    a = np.fromfunction(func, shape=(5, 5), dtype=dtype, **kwargs)
    d = da.fromfunction(
        func, shape=(5, 5), chunks=(2, 2), dtype=dtype, **kwargs
    )

    assert_eq(d, a)

    d2 = da.fromfunction(
        func, shape=(5, 5), chunks=(2, 2), dtype=dtype, **kwargs
    )

    assert same_keys(d, d2)
def complex_big_data():
    return DataArray(da.fromfunction(lambda y, x, E, T, t: (y + x) * np.cos(E/10) + T + t ** 2,
                                     shape=(size, size, size, size, size),
                                     chunks=10,
                                     dtype=float),
                     dims=['y (μm)', 'x (μm)', 'E (eV)', 'T (K)', 't (s)'],
                     coords=[np.arange(size) / 10.,
                             np.arange(size) / 10.,
                             np.arange(size) * 100,
                             np.arange(size) / 10.,
                             np.arange(size) / 10.])
Esempio n. 5
0
def da_date_idx(start, N, freq, chunks):
    return da.fromfunction(IdxToDate(start, freq),
                           shape=(N, ),
                           chunks=chunks,
                           dtype='M8[ns]')