Skip to content

Commit 769e76e

Browse files
authored
Merge branch 'main' into faster_delitems
2 parents 2824700 + 4944e66 commit 769e76e

14 files changed

+57
-38
lines changed

.github/workflows/releases.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
with:
6565
name: releases
6666
path: dist
67-
- uses: pypa/[email protected].7
67+
- uses: pypa/[email protected].10
6868
with:
6969
user: __token__
7070
password: ${{ secrets.pypi_password }}

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
ci:
22
autoupdate_commit_msg: "chore: update pre-commit hooks"
33
autofix_commit_msg: "style: pre-commit fixes"
4+
autofix_prs: false
45
default_stages: [commit, push]
56
default_language_version:
67
python: python3

.pyup.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,3 @@ requirements:
1313
- requirements_dev_optional.txt:
1414
pin: True
1515
update: all
16-
- requirements_rtfd.txt:
17-
pin: False
18-
update: False

.readthedocs.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ sphinx:
1010

1111
python:
1212
install:
13-
- requirements: requirements_rtfd.txt
1413
- method: pip
1514
path: .
15+
extra_requirements:
16+
- docs

docs/contributing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ the repository, you can do something like the following::
9292
$ mkdir -p ~/pyenv/zarr-dev
9393
$ python -m venv ~/pyenv/zarr-dev
9494
$ source ~/pyenv/zarr-dev/bin/activate
95-
$ pip install -r requirements_dev_minimal.txt -r requirements_dev_numpy.txt -r requirements_rtfd.txt
96-
$ pip install -e .
95+
$ pip install -r requirements_dev_minimal.txt -r requirements_dev_numpy.txt
96+
$ pip install -e .[docs]
9797

9898
To verify that your development environment is working, you can run the unit tests::
9999

docs/release.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,23 @@ Release notes
1818
Unreleased
1919
----------
2020

21+
.. _release_2.16.1:
22+
23+
2.16.1
24+
------
25+
2126
Maintenance
2227
~~~~~~~~~~~
2328

2429
* Require ``setuptools_scm`` version ``1.5.4``\+
2530
By :user:`John A. Kirkham <jakirkham>` :issue:`1477`.
2631

32+
* Add ``docs`` requirements to ``pyproject.toml``
33+
By :user:`John A. Kirkham <jakirkham>` :issue:`1494`.
34+
35+
* Fixed caching issue in ``LRUStoreCache``.
36+
By :user:`Mads R. B. Kristensen <madsbk>` :issue:`1499`.
37+
2738
.. _release_2.16.0:
2839

2940
2.16.0

pyproject.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ maintainers = [
1313
requires-python = ">=3.8"
1414
dependencies = [
1515
'asciitree',
16-
'numpy>=1.20',
16+
'numpy>=1.20,!=1.21.0',
1717
'fasteners',
1818
'numcodecs>=0.10.0',
1919
]
@@ -43,6 +43,16 @@ jupyter = [
4343
'ipytree>=0.2.2',
4444
'ipywidgets>=8.0.0',
4545
]
46+
docs = [
47+
'sphinx',
48+
'sphinx_design',
49+
'sphinx-issues',
50+
'sphinx-copybutton',
51+
'sphinx-rtd-theme',
52+
'pydata-sphinx-theme',
53+
'numpydoc',
54+
'numcodecs[msgpack]',
55+
]
4656

4757
[project.urls]
4858
"Bug Tracker" = "https://github.com/zarr-developers/zarr-python/issues"

requirements_dev_optional.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
lmdb==1.4.1; sys_platform != 'win32'
44
# optional library requirements for Jupyter
55
ipytree==0.2.2
6-
ipywidgets==8.0.7
6+
ipywidgets==8.1.0
77
# optional library requirements for services
88
# don't let pyup change pinning for azure-storage-blob, need to pin to older
99
# version to get compatibility with azure storage emulator on appveyor (FIXME)
1010
azure-storage-blob==12.16.0 # pyup: ignore
11-
redis==4.5.5
11+
redis==4.6.0
1212
types-redis
1313
types-setuptools
1414
pymongo==4.4.0

requirements_rtfd.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.

zarr/_storage/v3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ def __init__(self, store, max_size: int):
509509
self._max_size = max_size
510510
self._current_size = 0
511511
self._keys_cache = None
512-
self._contains_cache = None
512+
self._contains_cache = {}
513513
self._listdir_cache: Dict[Path, Any] = dict()
514514
self._values_cache: Dict[Path, Any] = OrderedDict()
515515
self._mutex = Lock()

zarr/hierarchy.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,8 @@ def group(
13601360
synchronizer=None,
13611361
path=None,
13621362
*,
1363-
zarr_version=None
1363+
zarr_version=None,
1364+
meta_array=None
13641365
):
13651366
"""Create a group.
13661367
@@ -1382,6 +1383,11 @@ def group(
13821383
Array synchronizer.
13831384
path : string, optional
13841385
Group path within store.
1386+
meta_array : array-like, optional
1387+
An array instance to use for determining arrays to create and return
1388+
to users. Use `numpy.empty(())` by default.
1389+
1390+
.. versionadded:: 2.16.1
13851391
13861392
Returns
13871393
-------
@@ -1432,6 +1438,7 @@ def group(
14321438
synchronizer=synchronizer,
14331439
path=path,
14341440
zarr_version=zarr_version,
1441+
meta_array=meta_array,
14351442
)
14361443

14371444

zarr/storage.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2403,7 +2403,7 @@ def __init__(self, store: StoreLike, max_size: int):
24032403
self._max_size = max_size
24042404
self._current_size = 0
24052405
self._keys_cache = None
2406-
self._contains_cache = None
2406+
self._contains_cache: Dict[Any, Any] = {}
24072407
self._listdir_cache: Dict[Path, Any] = dict()
24082408
self._values_cache: Dict[Path, Any] = OrderedDict()
24092409
self._mutex = Lock()
@@ -2444,9 +2444,9 @@ def __iter__(self):
24442444

24452445
def __contains__(self, key):
24462446
with self._mutex:
2447-
if self._contains_cache is None:
2448-
self._contains_cache = set(self._keys())
2449-
return key in self._contains_cache
2447+
if key not in self._contains_cache:
2448+
self._contains_cache[key] = key in self._store
2449+
return self._contains_cache[key]
24502450

24512451
def clear(self):
24522452
self._store.clear()
@@ -2516,7 +2516,7 @@ def invalidate_keys(self):
25162516

25172517
def _invalidate_keys(self):
25182518
self._keys_cache = None
2519-
self._contains_cache = None
2519+
self._contains_cache.clear()
25202520
self._listdir_cache.clear()
25212521

25222522
def _invalidate_value(self, key):

zarr/tests/test_meta_array.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import zarr.codecs
1010
from zarr.core import Array
1111
from zarr.creation import array, empty, full, ones, open_array, zeros
12-
from zarr.hierarchy import open_group
12+
from zarr.hierarchy import open_group, group
1313
from zarr.storage import DirectoryStore, MemoryStore, Store, ZipStore
1414

1515

@@ -234,12 +234,13 @@ def test_full(module, compressor):
234234
assert np.all(np.isnan(z[:]))
235235

236236

237+
@pytest.mark.parametrize("group_create_function", [group, open_group])
237238
@pytest.mark.parametrize("module, compressor", param_module_and_compressor)
238239
@pytest.mark.parametrize("store_type", [None, DirectoryStore, MemoryStore, ZipStore])
239-
def test_group(tmp_path, module, compressor, store_type):
240+
def test_group(tmp_path, group_create_function, module, compressor, store_type):
240241
xp = ensure_module(module)
241242
store = init_store(tmp_path, store_type)
242-
g = open_group(store, meta_array=xp.empty(()))
243+
g = group_create_function(store, meta_array=xp.empty(()))
243244
g.ones("data", shape=(10, 11), dtype=int, compressor=compressor)
244245
a = g["data"]
245246
assert a.shape == (10, 11)

zarr/tests/test_storage.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2196,7 +2196,10 @@ def test_cache_keys(self):
21962196
assert keys == sorted(cache.keys())
21972197
assert 1 == store.counter["keys"]
21982198
assert foo_key in cache
2199-
assert 0 == store.counter["__contains__", foo_key]
2199+
assert 1 == store.counter["__contains__", foo_key]
2200+
# the next check for `foo_key` is cached
2201+
assert foo_key in cache
2202+
assert 1 == store.counter["__contains__", foo_key]
22002203
assert keys == sorted(cache)
22012204
assert 0 == store.counter["__iter__"]
22022205
assert 1 == store.counter["keys"]
@@ -2215,23 +2218,23 @@ def test_cache_keys(self):
22152218
keys = sorted(cache.keys())
22162219
assert keys == [bar_key, baz_key, foo_key]
22172220
assert 3 == store.counter["keys"]
2218-
assert 0 == store.counter["__contains__", foo_key]
2221+
assert 1 == store.counter["__contains__", foo_key]
22192222
assert 0 == store.counter["__iter__"]
22202223
cache.invalidate_keys()
22212224
keys = sorted(cache)
22222225
assert keys == [bar_key, baz_key, foo_key]
22232226
assert 4 == store.counter["keys"]
2224-
assert 0 == store.counter["__contains__", foo_key]
2227+
assert 1 == store.counter["__contains__", foo_key]
22252228
assert 0 == store.counter["__iter__"]
22262229
cache.invalidate_keys()
22272230
assert foo_key in cache
2228-
assert 5 == store.counter["keys"]
2229-
assert 0 == store.counter["__contains__", foo_key]
2231+
assert 4 == store.counter["keys"]
2232+
assert 2 == store.counter["__contains__", foo_key]
22302233
assert 0 == store.counter["__iter__"]
22312234

22322235
# check these would get counted if called directly
22332236
assert foo_key in store
2234-
assert 1 == store.counter["__contains__", foo_key]
2237+
assert 3 == store.counter["__contains__", foo_key]
22352238
assert keys == sorted(store)
22362239
assert 1 == store.counter["__iter__"]
22372240

0 commit comments

Comments
 (0)