def test_indices_dimensions_chunks(): chunks = ((1, 4, 2, 3), (5, 5)) darr = da.indices((10, 10), chunks=chunks) assert darr.chunks == ((1, 1), ) + chunks with dask.config.set({"array.chunk-size": "50 MiB"}): shape = (10000, 10000) expected = normalize_chunks("auto", shape=shape, dtype=int) result = da.indices(shape, chunks="auto") # indices prepends a dimension actual = result.chunks[1:] assert expected == actual
def test_indicies(): darr = da.indices((1, ), chunks=(1, )) nparr = np.indices((1, )) assert_eq(darr, nparr) darr = da.indices((1, ), float, chunks=(1, )) nparr = np.indices((1, ), float) assert_eq(darr, nparr) darr = da.indices((2, 1), chunks=(2, 1)) nparr = np.indices((2, 1)) assert_eq(darr, nparr) darr = da.indices((2, 3), chunks=(1, 2)) nparr = np.indices((2, 3)) assert_eq(darr, nparr)
def test_indicies(): darr = da.indices((1,), chunks=(1,)) nparr = np.indices((1,)) assert_eq(darr, nparr) darr = da.indices((1,), float, chunks=(1,)) nparr = np.indices((1,), float) assert_eq(darr, nparr) darr = da.indices((2, 1), chunks=(2, 1)) nparr = np.indices((2, 1)) assert_eq(darr, nparr) darr = da.indices((2, 3), chunks=(1, 2)) nparr = np.indices((2, 3)) assert_eq(darr, nparr)
def test_empty_indicies(): darr = da.indices(tuple(), chunks=tuple()) nparr = np.indices(tuple()) assert darr.shape == nparr.shape assert darr.dtype == nparr.dtype assert_eq(darr, nparr) darr = da.indices(tuple(), float, chunks=tuple()) nparr = np.indices(tuple(), float) assert darr.shape == nparr.shape assert darr.dtype == nparr.dtype assert_eq(darr, nparr) darr = da.indices((0, ), float, chunks=(1, )) nparr = np.indices((0, ), float) assert darr.shape == nparr.shape assert darr.dtype == nparr.dtype assert_eq(darr, nparr) darr = da.indices((0, 1, 2), float, chunks=(1, 1, 2)) nparr = np.indices((0, 1, 2), float) assert darr.shape == nparr.shape assert darr.dtype == nparr.dtype assert_eq(darr, nparr)
def test_empty_indicies(): darr = da.indices(tuple(), chunks=tuple()) nparr = np.indices(tuple()) assert darr.shape == nparr.shape assert darr.dtype == nparr.dtype assert_eq(darr, nparr) darr = da.indices(tuple(), float, chunks=tuple()) nparr = np.indices(tuple(), float) assert darr.shape == nparr.shape assert darr.dtype == nparr.dtype assert_eq(darr, nparr) darr = da.indices((0,), float, chunks=(1,)) nparr = np.indices((0,), float) assert darr.shape == nparr.shape assert darr.dtype == nparr.dtype assert_eq(darr, nparr) darr = da.indices((0, 1, 2), float, chunks=(1, 1, 2)) nparr = np.indices((0, 1, 2), float) assert darr.shape == nparr.shape assert darr.dtype == nparr.dtype assert_eq(darr, nparr)
def test_indices_wrong_chunks(): with pytest.raises(ValueError): da.indices((1, ), chunks=tuple())
def test_indices_no_chunks(): with pytest.raises(ValueError): da.indices((1, ))
def test_indices_dimensions_chunks(): chunks = ((1, 4, 2, 3), (5, 5)) darr = da.indices((10, 10), chunks=chunks) assert darr.chunks == ((1, 1), ) + chunks
def test_indices_dimensions_chunks(): chunks = ((1,4,2,3), (5,5)) darr = da.indices((10, 10), chunks=chunks) assert darr.chunks == ((1,1),) + chunks
def test_indices_wrong_chunks(): with pytest.raises(ValueError): da.indices((1,), chunks=tuple())
def test_indices_no_chunks(): with pytest.raises(ValueError): da.indices((1,))