From 27390ffaca3b4195e4d1f164aea4e8413ccf8117 Mon Sep 17 00:00:00 2001 From: Alessandro Amici Date: Wed, 27 Jul 2022 08:40:02 +0200 Subject: [PATCH] Allow import with no dask installed --- sarsen/chunking.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sarsen/chunking.py b/sarsen/chunking.py index 12ee39d..6f389e5 100644 --- a/sarsen/chunking.py +++ b/sarsen/chunking.py @@ -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 @@ -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