Skip to content

Commit

Permalink
Allow import with no dask installed
Browse files Browse the repository at this point in the history
  • Loading branch information
alexamici committed Jul 27, 2022
1 parent 6b3389c commit 27390ff
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sarsen/chunking.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import itertools
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

import dask.array as da
import numpy as np
import xarray as xr

Expand Down Expand Up @@ -101,7 +100,13 @@ def map_ovelap(
ext_chunks, ext_chunks_bounds, int_chunks = compute_chunks(
dims, chunks, bound
) # type ignore
out = xr.DataArray(da.empty_like(template.data), dims=template.dims) # type: ignore

try:
from dask.array import empty_like
except ModuleNotFoundError:
from numpy import empty_like # type: ignore

out = xr.DataArray(empty_like(template.data), dims=template.dims) # type: ignore
out.coords.update(obj.coords)
for ext_chunk, ext_chunk_bounds, int_chunk in zip(
ext_chunks, ext_chunks_bounds, int_chunks
Expand Down

0 comments on commit 27390ff

Please sign in to comment.