From c7e6ce3f28f6e6fc743f6ee48f12f918ae0ad7b1 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Thu, 22 Oct 2020 10:32:03 -0700 Subject: [PATCH] Checking that the store is an instance of dict seem incorrect. Indeed MemoryStore is an instance of mutable mapping that have the same property as dict, but woudl not be seen as as instance of dict. --- zarr/core.py | 3 ++- zarr/storage.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/zarr/core.py b/zarr/core.py index 8727a5deb5..651775e3a3 100644 --- a/zarr/core.py +++ b/zarr/core.py @@ -5,6 +5,7 @@ import operator import re from functools import reduce +from collections.abc import MutableMapping import numpy as np from numcodecs.compat import ensure_bytes, ensure_ndarray @@ -1821,7 +1822,7 @@ def _encode_chunk(self, chunk): cdata = chunk # ensure in-memory data is immutable and easy to compare - if isinstance(self.chunk_store, dict): + if isinstance(self.chunk_store, MutableMapping): cdata = ensure_bytes(cdata) return cdata diff --git a/zarr/storage.py b/zarr/storage.py index 89f85f8eec..2b60c749ee 100644 --- a/zarr/storage.py +++ b/zarr/storage.py @@ -176,7 +176,7 @@ def getsize(store, path: Path = None) -> int: if hasattr(store, 'getsize'): # pass through return store.getsize(path) - elif isinstance(store, dict): + elif isinstance(store, MutableMapping): # compute from size of values if path in store: v = store[path]