Я пытаюсь создать один dask array
из нескольких файлов. Я использую dask.array.Array
класс, чтобы сделать это. Рассмотрим следующий фрагмент кода, где я генерирую 100
случайное целое число array
размера (3, 10, 10)
и сохраняю каждое из них в отдельном файле npy
. Затем я пытаюсь создать один dask array
, чтобы объединить все эти массивы в один dask array
формы (3, 100, 100)
.
import numpy as np
from itertools import product
from dask import array as da
from dask.base import tokenize
names = list()
for i in range(100):
arr = np.random.randint(0, 9, (3, 10, 10))
fn = 'data/array_{}.npy'.format(i)
np.save(fn, arr)
names.append('Array-{}'.format(tokenize(fn)))
indices = list(product(range(10), range(10)))
dsk = {
(name, 0, *index): (np.load, name)
for name, index in zip(names, indices)
}
namex = 'Combined_Array'
dtype=int
shape = (3, 100, 100)
chunks = (3, 10, 10)
d = da.Array(dsk, namex, chunks, dtype, shape)
К сожалению, в методе normalize_chunks
выдается ошибка:
TypeError Traceback (most recent call last)
<ipython-input-4-008559464c9e> in <module>
----> 1 d = da.Array(dsk, namex, chunks, dtype, shape)
~/.conda/envs/Py3Dev/lib/python3.7/site-packages/dask/array/core.py in __new__(cls, dask, name, chunks, dtype, meta, shape)
1026 else:
1027 dt = None
-> 1028 self._chunks = normalize_chunks(chunks, shape, dtype=dt)
1029 if self._chunks is None:
1030 raise ValueError(CHUNKS_NONE_ERROR_MESSAGE)
~/.conda/envs/Py3Dev/lib/python3.7/site-packages/dask/array/core.py in normalize_chunks(chunks, shape, limit, dtype, previous_chunks)
2481 )
2482
-> 2483 return tuple(tuple(int(x) if not math.isnan(x) else x for x in c) for c in chunks)
2484
2485
~/.conda/envs/Py3Dev/lib/python3.7/site-packages/dask/array/core.py in <genexpr>(.0)
2481 )
2482
-> 2483 return tuple(tuple(int(x) if not math.isnan(x) else x for x in c) for c in chunks)
2484
2485
TypeError: 'int' object is not iterable
Я что-то здесь не так делаю?