Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cf/data/dask_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import dask.array as da
import numpy as np
from dask.core import flatten

from ..cfdatetime import dt2rt, rt2dt
from ..functions import atol as cf_atol
Expand Down Expand Up @@ -83,7 +84,13 @@ def allclose(a_blocks, b_blocks, rtol=rtol, atol=atol):
if not isinstance(b_blocks, list):
b_blocks = (b_blocks,)

for a, b in zip(a_blocks, b_blocks):
# Note: If a_blocks or b_blocks has more than one chunk in
# more than one dimension they will comprise a nested
# sequence of sequences, that needs to be flattened so
# that we can safely iterate through the actual numpy
# array elements.

for a, b in zip(flatten(a_blocks), flatten(b_blocks)):
result &= np.ma.allclose(
a,
b,
Expand Down
7 changes: 7 additions & 0 deletions cf/test/test_Data.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,13 @@ def test_Data_equals(self):
# Test ignore_data_type parameter
self.assertTrue(d2.equals(d, ignore_data_type=True))

# Test all possible chunk combinations
for j, i in itertools.product([1, 2], [1, 2, 3]):
d = cf.Data(np.arange(6).reshape(2, 3), "m", chunks=(j, i))
for j, i in itertools.product([1, 2], [1, 2, 3]):
e = cf.Data(np.arange(6).reshape(2, 3), "m", chunks=(j, i))
self.assertTrue(d.equals(e))

@unittest.skipIf(TEST_DASKIFIED_ONLY, "hits unexpected kwarg 'ndim'")
def test_Data_halo(self):
if self.test_only and inspect.stack()[0][3] not in self.test_only:
Expand Down