Skip to content

Commit

Permalink
Fix null temp (#74)
Browse files Browse the repository at this point in the history
* Fix empty temp_store problem

* Add test for mapper source target and temp
  • Loading branch information
lsetiawan committed Dec 30, 2020
1 parent 15f7e31 commit f55a475
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion rechunker/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def _setup_rechunk(
"You must specify ``target-chunks`` as a dict when rechunking a group."
)

if temp_store:
if temp_store is not None:
temp_group = zarr.group(temp_store)
else:
temp_group = None
Expand Down
18 changes: 13 additions & 5 deletions tests/test_rechunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,19 @@ def test_rechunk_dask_array(
requires_pywren("pywren"),
],
)
def test_rechunk_group(tmp_path, executor):
store_source = str(tmp_path / "source.zarr")
@pytest.mark.parametrize("source_store", ["source.zarr", "mapper.source.zarr"])
@pytest.mark.parametrize("target_store", ["target.zarr", "mapper.target.zarr"])
@pytest.mark.parametrize("temp_store", ["temp.zarr", "mapper.temp.zarr"])
def test_rechunk_group(tmp_path, executor, source_store, target_store, temp_store):
if source_store.startswith("mapper"):
store_source = fsspec.get_mapper(str(tmp_path) + source_store)
target_store = fsspec.get_mapper(str(tmp_path) + target_store)
temp_store = fsspec.get_mapper(str(tmp_path) + temp_store)
else:
store_source = str(tmp_path / source_store)
target_store = str(tmp_path / target_store)
temp_store = str(tmp_path / temp_store)

group = zarr.group(store_source)
group.attrs["foo"] = "bar"
# 800 byte chunks
Expand All @@ -251,9 +262,6 @@ def test_rechunk_group(tmp_path, executor):
b = group.ones("b", shape=(20,), chunks=(10,), dtype="f4")
b.attrs["foo"] = "bar"

target_store = str(tmp_path / "target.zarr")
temp_store = str(tmp_path / "temp.zarr")

max_mem = 1600 # should force a two-step plan for a
target_chunks = {"a": (5, 10, 4), "b": (20,)}

Expand Down

0 comments on commit f55a475

Please sign in to comment.