Skip to content

Commit

Permalink
Don't allow incompatible specs
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwhite committed Aug 17, 2022
1 parent 47d9043 commit 8245675
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cubed/core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ def blockwise(
extra_required_mem = kwargs.pop("extra_required_mem", 0)

name = gensym()
specs = [a.spec for a in arrays]
if not all(s == specs[0] for s in specs):
raise ValueError(
f"Arrays must have same spec to be combined in blockwise. Specs: {specs}"
)
spec = arrays[0].spec
if target_store is None:
target_store = new_temp_store(name=name, spec=spec)
Expand Down
9 changes: 9 additions & 0 deletions cubed/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,15 @@ def test_default_spec_max_mem_exceeded():
xp.negative(a)


def test_different_specs(tmp_path):
spec1 = cubed.Spec(tmp_path, max_mem=100000)
spec2 = cubed.Spec(tmp_path, max_mem=200000)
a = xp.ones((3, 3), chunks=(2, 2), spec=spec1)
b = xp.ones((3, 3), chunks=(2, 2), spec=spec2)
with pytest.raises(ValueError):
xp.add(a, b)


def test_reduction_multiple_rounds(tmp_path, executor):
spec = cubed.Spec(tmp_path, max_mem=1000)
a = xp.ones((100, 10), dtype=np.uint8, chunks=(1, 10), spec=spec)
Expand Down

0 comments on commit 8245675

Please sign in to comment.