Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/storage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Storage (``zarr.storage``)
==========================
.. automodule:: zarr.storage

.. autoclass:: DictStore
.. autoclass:: MemoryStore
.. autoclass:: DirectoryStore
.. autoclass:: TempStore
.. autoclass:: NestedDirectoryStore
Expand Down
7 changes: 7 additions & 0 deletions docs/release.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Release notes
=============

Upcoming Release
----------------

* Rename ``DictStore`` to ``MemoryStore``.
By :user:`James Bourbeau <jrbourbeau>`; :issue:`455`


.. _release_2.3.2:

2.3.2
Expand Down
10 changes: 5 additions & 5 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ property. E.g.::
Name : /
Type : zarr.hierarchy.Group
Read-only : False
Store type : zarr.storage.DictStore
Store type : zarr.storage.MemoryStore
No. members : 1
No. arrays : 0
No. groups : 1
Expand All @@ -377,7 +377,7 @@ property. E.g.::
Name : /foo
Type : zarr.hierarchy.Group
Read-only : False
Store type : zarr.storage.DictStore
Store type : zarr.storage.MemoryStore
No. members : 2
No. arrays : 2
No. groups : 0
Expand All @@ -392,7 +392,7 @@ property. E.g.::
Order : C
Read-only : False
Compressor : Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0)
Store type : zarr.storage.DictStore
Store type : zarr.storage.MemoryStore
No. bytes : 8000000 (7.6M)
No. bytes stored : 33240 (32.5K)
Storage ratio : 240.7
Expand All @@ -407,7 +407,7 @@ property. E.g.::
Order : C
Read-only : False
Compressor : Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0)
Store type : zarr.storage.DictStore
Store type : zarr.storage.MemoryStore
No. bytes : 4000000 (3.8M)
No. bytes stored : 23943 (23.4K)
Storage ratio : 167.1
Expand Down Expand Up @@ -1333,7 +1333,7 @@ module can be pickled, as can the built-in ``dict`` class which can also be used
storage.

Note that if an array or group is backed by an in-memory store like a ``dict`` or
:class:`zarr.storage.DictStore`, then when it is pickled all of the store data will be
:class:`zarr.storage.MemoryStore`, then when it is pickled all of the store data will be
included in the pickled data. However, if an array or group is backed by a persistent
store like a :class:`zarr.storage.DirectoryStore`, :class:`zarr.storage.ZipStore` or
:class:`zarr.storage.DBMStore` then the store data **are not** pickled. The only thing
Expand Down
2 changes: 1 addition & 1 deletion zarr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from zarr.core import Array
from zarr.creation import (empty, zeros, ones, full, array, empty_like, zeros_like,
ones_like, full_like, open_array, open_like, create)
from zarr.storage import (DictStore, DirectoryStore, ZipStore, TempStore,
from zarr.storage import (DictStore, MemoryStore, DirectoryStore, ZipStore, TempStore,
NestedDirectoryStore, DBMStore, LMDBStore, SQLiteStore,
LRUStoreCache, ABSStore, RedisStore, MongoDBStore)
from zarr.hierarchy import group, open_group, Group
Expand Down
4 changes: 2 additions & 2 deletions zarr/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from zarr.attrs import Attributes
from zarr.core import Array
from zarr.storage import (contains_array, contains_group, init_group,
DictStore, group_meta_key, attrs_key, listdir, rename, rmdir)
MemoryStore, group_meta_key, attrs_key, listdir, rename, rmdir)
from zarr.creation import (array, create, empty, zeros, ones, full,
empty_like, zeros_like, ones_like, full_like,
normalize_store_arg)
Expand Down Expand Up @@ -996,7 +996,7 @@ def move(self, source, dest):


def _normalize_store_arg(store, clobber=False):
return normalize_store_arg(store, clobber=clobber, default=DictStore)
return normalize_store_arg(store, clobber=clobber, default=MemoryStore)


def group(store=None, overwrite=False, chunk_store=None,
Expand Down
16 changes: 13 additions & 3 deletions zarr/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def _dict_store_keys(d, prefix='', cls=dict):
yield prefix + k


class DictStore(MutableMapping):
class MemoryStore(MutableMapping):
"""Store class that uses a hierarchy of :class:`dict` objects, thus all data
will be held in main memory.

Expand All @@ -474,7 +474,7 @@ class DictStore(MutableMapping):
>>> import zarr
>>> g = zarr.group()
>>> type(g.store)
<class 'zarr.storage.DictStore'>
<class 'zarr.storage.MemoryStore'>

Note that the default class when creating an array is the built-in
:class:`dict` class, i.e.::
Expand Down Expand Up @@ -568,7 +568,7 @@ def __contains__(self, item):

def __eq__(self, other):
return (
isinstance(other, DictStore) and
isinstance(other, MemoryStore) and
self.root == other.root and
self.cls == other.cls
)
Expand Down Expand Up @@ -656,6 +656,16 @@ def clear(self):
self.root.clear()


class DictStore(MemoryStore):

def __init__(self, *args, **kwargs):
warnings.warn("DictStore has been renamed to MemoryStore and will be "
"removed in the future. Please use MemoryStore.",
DeprecationWarning,
stacklevel=2)
super(DictStore, self).__init__(*args, **kwargs)


class DirectoryStore(MutableMapping):
"""Storage class using directories and files on a standard file system.

Expand Down
4 changes: 2 additions & 2 deletions zarr/tests/test_convenience.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from zarr.convenience import (open, save, save_group, load, copy_store, copy,
consolidate_metadata, open_consolidated)
from zarr.storage import atexit_rmtree, DictStore, getsize, ConsolidatedMetadataStore
from zarr.storage import atexit_rmtree, MemoryStore, getsize, ConsolidatedMetadataStore
from zarr.core import Array
from zarr.hierarchy import Group, group
from zarr.errors import CopyError, PermissionError
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_lazy_loader():
def test_consolidate_metadata():

# setup initial data
store = DictStore()
store = MemoryStore()
z = group(store)
z.create_group('g1')
g2 = z.create_group('g2')
Expand Down
6 changes: 3 additions & 3 deletions zarr/tests/test_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
asb = None


from zarr.storage import (DictStore, DirectoryStore, ZipStore, init_group, init_array,
from zarr.storage import (MemoryStore, DirectoryStore, ZipStore, init_group, init_array,
array_meta_key, group_meta_key, atexit_rmtree,
NestedDirectoryStore, DBMStore, LMDBStore, SQLiteStore,
ABSStore, atexit_rmglob, LRUStoreCache)
Expand Down Expand Up @@ -852,11 +852,11 @@ def test_pickle(self):
assert isinstance(g2['foo/bar'], Array)


class TestGroupWithDictStore(TestGroup):
class TestGroupWithMemoryStore(TestGroup):

@staticmethod
def create_store():
return DictStore(), None
return MemoryStore(), None


class TestGroupWithDirectoryStore(TestGroup):
Expand Down
19 changes: 15 additions & 4 deletions zarr/tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
asb = None


from zarr.storage import (init_array, array_meta_key, attrs_key, DictStore,
from zarr.storage import (init_array, array_meta_key, attrs_key, DictStore, MemoryStore,
DirectoryStore, ZipStore, init_group, group_meta_key,
getsize, migrate_1to2, TempStore, atexit_rmtree,
NestedDirectoryStore, default_compressor, DBMStore,
Expand Down Expand Up @@ -652,7 +652,7 @@ def test_set_invalid_content(self):
def setdel_hierarchy_checks(store):
# these tests are for stores that are aware of hierarchy levels; this
# behaviour is not stricly required by Zarr but these tests are included
# to define behaviour of DictStore and DirectoryStore classes
# to define behaviour of MemoryStore and DirectoryStore classes

# check __setitem__ and __delitem__ blocked by leaf

Expand Down Expand Up @@ -686,10 +686,10 @@ def setdel_hierarchy_checks(store):
assert 'r/s' not in store


class TestDictStore(StoreTests, unittest.TestCase):
class TestMemoryStore(StoreTests, unittest.TestCase):

def create_store(self):
return DictStore()
return MemoryStore()

def test_store_contains_bytes(self):
store = self.create_store()
Expand All @@ -701,6 +701,17 @@ def test_setdel(self):
setdel_hierarchy_checks(store)


class TestDictStore(StoreTests, unittest.TestCase):

def create_store(self):
return DictStore()

def test_deprecated(self):
with pytest.warns(DeprecationWarning):
store = self.create_store()
assert isinstance(store, MemoryStore)


class TestDirectoryStore(StoreTests, unittest.TestCase):

def create_store(self):
Expand Down