示例#1
0
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))
示例#2
0
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='f8').dask) !=\
           sorted(da.full((3, 3), 100, chunks=(2, 2)).dask)
示例#3
0
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)
示例#4
0
文件: creation.py 项目: m-rossi/dask
def ones_like(a, dtype=None, order="C", chunks=None, name=None, shape=None):
    """
    Return an array of ones with the same shape and type as a given array.

    Parameters
    ----------
    a : array_like
        The shape and data-type of `a` define these same attributes of
        the returned array.
    dtype : data-type, optional
        Overrides the data type of the result.
    order : {'C', 'F'}, optional
        Whether to store multidimensional data in C- or Fortran-contiguous
        (row- or column-wise) order in memory.
    chunks : sequence of ints
        The number of samples on each block. Note that the last block will have
        fewer samples if ``len(array) % chunks != 0``.
    name : str, optional
        An optional keyname for the array. Defaults to hashing the input
        keyword arguments.
    shape : int or sequence of ints, optional.
        Overrides the shape of the result.

    Returns
    -------
    out : ndarray
        Array of ones with the same shape and type as `a`.

    See Also
    --------
    zeros_like : Return an array of zeros with shape and type of input.
    empty_like : Return an empty array with shape and type of input.
    zeros : Return a new array setting values to zero.
    ones : Return a new array setting values to one.
    empty : Return a new uninitialized array.
    """

    a = asarray(a, name=False)
    shape, chunks = _get_like_function_shapes_chunks(a, chunks, shape)
    return ones(
        shape,
        dtype=(dtype or a.dtype),
        order=order,
        chunks=chunks,
        name=name,
        meta=a._meta,
    )
示例#5
0
def test_singleton_size():
    a = ones(10, dtype='i4', chunks=(4,))
    x = np.array(a)
    assert (x == np.ones(10, dtype='i4')).all()
示例#6
0
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()
示例#7
0
def test_can_make_really_big_array_of_ones():
    ones((1000000, 1000000), chunks=(100000, 100000))
    ones(shape=(1000000, 1000000), chunks=(100000, 100000))
示例#8
0
def test_kwargs():
    a = ones(10, dtype="i4", chunks=(4, ))
    x = np.array(a)
    assert (x == np.ones(10, dtype="i4")).all()
示例#9
0
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_like-")
示例#10
0
def test_ones():
    a = ones((10, 10), dtype='i4', blockshape=(4, 4))
    x = np.array(a)
    assert (x == np.ones((10, 10), 'i4')).all()
示例#11
0
def test_kwargs():
    a = ones(10, dtype='i4', blockshape=(4,))
    x = np.array(a)
    assert (x == np.ones(10, dtype='i4')).all()
示例#12
0
def test_singleton_size():
    a = ones(10, dtype='i4', blockshape=(4,))
    x = np.array(a)
    assert (x == np.ones(10, dtype='i4')).all()
示例#13
0
def test_size_as_list():
    a = ones([10, 10], dtype='i4', blockshape=(4, 4))
    x = np.array(a)
    assert (x == np.ones((10, 10), dtype='i4')).all()
示例#14
0
def test_kwargs():
    a = ones(10, dtype='i4', chunks=(4,))
    x = np.array(a)
    assert (x == np.ones(10, dtype='i4')).all()
示例#15
0
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()
示例#16
0
def test_can_make_really_big_array_of_ones():
    ones((1000000, 1000000), chunks=(100000, 100000))
    ones(shape=(1000000, 1000000), chunks=(100000, 100000))
示例#17
0
def test_singleton_size():
    a = ones(10, dtype="i4", chunks=(4, ))
    x = np.array(a)
    assert (x == np.ones(10, dtype="i4")).all()
示例#18
0
def test_ones():
    a = ones((10, 10), dtype='i4', chunks=(4, 4))
    x = np.array(a)
    assert (x == np.ones((10, 10), 'i4')).all()
示例#19
0
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-')