You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ORPA-pyOpenRPA/Resources/WPy64-3720/python-3.7.2.amd64/Lib/site-packages/dask/array/tests/test_wrap.py

58 lines
1.6 KiB

import pytest
pytest.importorskip('numpy')
from dask.array.wrap import ones
import dask.array as da
import numpy as np
def test_ones():
a = ones((10, 10), dtype='i4', chunks=(4, 4))
x = np.array(a)
assert (x == np.ones((10, 10), 'i4')).all()
assert a.name.startswith('ones-')
def test_size_as_list():
a = ones([10, 10], dtype='i4', chunks=(4, 4))
x = np.array(a)
assert (x == np.ones((10, 10), dtype='i4')).all()
def test_singleton_size():
a = ones(10, dtype='i4', chunks=(4,))
x = np.array(a)
assert (x == np.ones(10, dtype='i4')).all()
def test_kwargs():
a = ones(10, dtype='i4', chunks=(4,))
x = np.array(a)
assert (x == np.ones(10, dtype='i4')).all()
def test_full():
a = da.full((3, 3), 100, chunks=(2, 2), dtype='i8')
assert (a.compute() == 100).all()
assert a.dtype == a.compute(scheduler='sync').dtype == 'i8'
assert a.name.startswith('full-')
def test_can_make_really_big_array_of_ones():
ones((1000000, 1000000), chunks=(100000, 100000))
ones(shape=(1000000, 1000000), chunks=(100000, 100000))
def test_wrap_consistent_names():
assert (sorted(ones(10, dtype='i4', chunks=(4,)).dask) ==
sorted(ones(10, dtype='i4', chunks=(4,)).dask))
assert (sorted(ones(10, dtype='i4', chunks=(4,)).dask) !=
sorted(ones(10, chunks=(4,)).dask))
assert (sorted(da.full((3, 3), 100, chunks=(2, 2), dtype='f8').dask) ==
sorted(da.full((3, 3), 100, chunks=(2, 2), dtype='f8').dask))
assert (sorted(da.full((3, 3), 100, chunks=(2, 2), dtype='i2').dask) !=
sorted(da.full((3, 3), 100, chunks=(2, 2)).dask))