Skip to content

Commit

Permalink
Merge pull request #64 from ocefpaf/fix_59
Browse files Browse the repository at this point in the history
check for nullness
  • Loading branch information
rabernat committed Nov 27, 2020
2 parents 17053cc + 6ca9ecf commit 7352b62
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rechunker/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def _setup_rechunk(
variables, attrs = encode_dataset_coordinates(source)
attrs = _encode_zarr_attributes(attrs)

if temp_store:
if temp_store is not None:
temp_group = zarr.group(temp_store)
else:
temp_group = None
Expand Down
23 changes: 20 additions & 3 deletions tests/test_rechunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import dask.core
import xarray
import numpy
import fsspec

from rechunker import api

Expand Down Expand Up @@ -47,11 +48,27 @@ def test_invalid_executor():
@pytest.mark.parametrize("target_chunks", [(20, 10)])
@pytest.mark.parametrize("max_mem", ["10MB"])
@pytest.mark.parametrize("executor", ["dask"])
@pytest.mark.parametrize("target_store", ["target.zarr", "mapper.target.zarr"])
@pytest.mark.parametrize("temp_store", ["temp.zarr", "mapper.temp.zarr"])
def test_rechunk_dataset(
tmp_path, shape, source_chunks, target_chunks, max_mem, executor
tmp_path,
shape,
source_chunks,
target_chunks,
max_mem,
executor,
target_store,
temp_store,
):
target_store = str(tmp_path / "target.zarr")
temp_store = str(tmp_path / "temp.zarr")
if target_store.startswith("mapper"):
target_store = fsspec.get_mapper(str(tmp_path) + target_store)
else:
target_store = str(tmp_path / target_store)

if temp_store.startswith("mapper"):
temp_store = fsspec.get_mapper(str(tmp_path) + temp_store)
else:
temp_store = str(tmp_path / temp_store)

a = numpy.arange(numpy.prod(shape)).reshape(shape).astype("f4")
a[-1] = numpy.nan
Expand Down

0 comments on commit 7352b62

Please sign in to comment.