Skip to content

Commit e49f0ae

Browse files
committed
Merge branch 'main' of https://github.com/zarr-developers/zarr-python into api/private-core
2 parents 7215121 + 0c1aad5 commit e49f0ae

File tree

15 files changed

+86
-42
lines changed

15 files changed

+86
-42
lines changed

docs/user-guide/arrays.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ prints additional diagnostics, e.g.::
209209
Serializer : BytesCodec(endian=<Endian.little: 'little'>)
210210
Compressors : (BloscCodec(typesize=4, cname=<BloscCname.zstd: 'zstd'>, clevel=3, shuffle=<BloscShuffle.bitshuffle: 'bitshuffle'>, blocksize=0),)
211211
No. bytes : 400000000 (381.5M)
212-
No. bytes stored : 9696302
212+
No. bytes stored : 9696520
213213
Storage ratio : 41.3
214214
Chunks Initialized : 100
215215

@@ -611,7 +611,7 @@ Sharded arrays can be created by providing the ``shards`` parameter to :func:`za
611611
Serializer : BytesCodec(endian=<Endian.little: 'little'>)
612612
Compressors : (ZstdCodec(level=0, checksum=False),)
613613
No. bytes : 100000000 (95.4M)
614-
No. bytes stored : 3981060
614+
No. bytes stored : 3981552
615615
Storage ratio : 25.1
616616
Shards Initialized : 100
617617

docs/user-guide/groups.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ property. E.g.::
113113
Serializer : BytesCodec(endian=<Endian.little: 'little'>)
114114
Compressors : (ZstdCodec(level=0, checksum=False),)
115115
No. bytes : 8000000 (7.6M)
116-
No. bytes stored : 1432
117-
Storage ratio : 5586.6
116+
No. bytes stored : 1614
117+
Storage ratio : 4956.6
118118
Chunks Initialized : 0
119119
>>> baz.info
120120
Type : Array

docs/user-guide/performance.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ ratios, depending on the correlation structure within the data. E.g.::
131131
Serializer : BytesCodec(endian=<Endian.little: 'little'>)
132132
Compressors : (ZstdCodec(level=0, checksum=False),)
133133
No. bytes : 400000000 (381.5M)
134-
No. bytes stored : 342588717
134+
No. bytes stored : 342588911
135135
Storage ratio : 1.2
136136
Chunks Initialized : 100
137137
>>> with zarr.config.set({'array.order': 'F'}):
@@ -150,7 +150,7 @@ ratios, depending on the correlation structure within the data. E.g.::
150150
Serializer : BytesCodec(endian=<Endian.little: 'little'>)
151151
Compressors : (ZstdCodec(level=0, checksum=False),)
152152
No. bytes : 400000000 (381.5M)
153-
No. bytes stored : 342588717
153+
No. bytes stored : 342588911
154154
Storage ratio : 1.2
155155
Chunks Initialized : 100
156156

docs/user-guide/v3_migration.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,5 @@ of Zarr-Python, please open (or comment on) a
206206
* Object dtypes (:issue:`2617`)
207207
* Ragged arrays (:issue:`2618`)
208208
* Groups and Arrays do not implement ``__enter__`` and ``__exit__`` protocols (:issue:`2619`)
209+
* Big Endian dtypes (:issue:`2324`)
210+
* Default filters for object dtypes for Zarr format 2 arrays (:issue:`2627`)

src/zarr/api/asynchronous.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@
2727
from zarr.core.metadata import ArrayMetadataDict, ArrayV2Metadata, ArrayV3Metadata
2828
from zarr.core.metadata.v2 import _default_compressor, _default_filters
2929
from zarr.errors import NodeTypeValidationError
30-
from zarr.storage import (
31-
StoreLike,
32-
make_store_path,
33-
)
30+
from zarr.storage._common import make_store_path
3431

3532
if TYPE_CHECKING:
3633
from collections.abc import Iterable
3734

3835
from zarr.abc.codec import Codec
3936
from zarr.core.chunk_key_encodings import ChunkKeyEncoding
37+
from zarr.storage import StoreLike
4038

4139
# TODO: this type could use some more thought
4240
ArrayLike = AsyncArray[ArrayV2Metadata] | AsyncArray[ArrayV3Metadata] | Array | npt.NDArray[Any]

src/zarr/core/array.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@
112112
_parse_bytes_bytes_codec,
113113
get_pipeline_class,
114114
)
115-
from zarr.storage import StoreLike, make_store_path
116-
from zarr.storage._common import StorePath, ensure_no_existing_node
115+
from zarr.storage import StoreLike
116+
from zarr.storage._common import StorePath, ensure_no_existing_node, make_store_path
117117

118118
if TYPE_CHECKING:
119119
from collections.abc import Iterator, Sequence
@@ -122,6 +122,7 @@
122122
from zarr.abc.codec import CodecPipeline
123123
from zarr.codecs.sharding import ShardingCodecIndexLocation
124124
from zarr.core.group import AsyncGroup
125+
from zarr.storage import StoreLike
125126

126127

127128
# Array and AsyncArray are defined in the base ``zarr`` namespace

src/zarr/core/group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
from zarr.core.metadata.v3 import V3JsonEncoder
5151
from zarr.core.sync import SyncMixin, sync
5252
from zarr.errors import MetadataValidationError
53-
from zarr.storage import StoreLike, StorePath, make_store_path
54-
from zarr.storage._common import ensure_no_existing_node
53+
from zarr.storage import StoreLike, StorePath
54+
from zarr.storage._common import ensure_no_existing_node, make_store_path
5555

5656
if TYPE_CHECKING:
5757
from collections.abc import AsyncGenerator, Generator, Iterable, Iterator

src/zarr/core/metadata/v3.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from zarr.core.buffer.core import default_buffer_prototype
88

99
if TYPE_CHECKING:
10+
from collections.abc import Callable
1011
from typing import Self
1112

1213
from zarr.core.buffer import Buffer, BufferPrototype
@@ -143,9 +144,30 @@ def parse_storage_transformers(data: object) -> tuple[dict[str, JSON], ...]:
143144

144145

145146
class V3JsonEncoder(json.JSONEncoder):
146-
def __init__(self, *args: Any, **kwargs: Any) -> None:
147-
self.indent = kwargs.pop("indent", config.get("json_indent"))
148-
super().__init__(*args, **kwargs)
147+
def __init__(
148+
self,
149+
*,
150+
skipkeys: bool = False,
151+
ensure_ascii: bool = True,
152+
check_circular: bool = True,
153+
allow_nan: bool = True,
154+
sort_keys: bool = False,
155+
indent: int | None = None,
156+
separators: tuple[str, str] | None = None,
157+
default: Callable[[object], object] | None = None,
158+
) -> None:
159+
if indent is None:
160+
indent = config.get("json_indent")
161+
super().__init__(
162+
skipkeys=skipkeys,
163+
ensure_ascii=ensure_ascii,
164+
check_circular=check_circular,
165+
allow_nan=allow_nan,
166+
sort_keys=sort_keys,
167+
indent=indent,
168+
separators=separators,
169+
default=default,
170+
)
149171

150172
def default(self, o: object) -> Any:
151173
if isinstance(o, np.dtype):

src/zarr/core/sync.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ def _get_executor() -> ThreadPoolExecutor:
5454
global _executor
5555
if not _executor:
5656
max_workers = config.get("threading.max_workers", None)
57-
print(max_workers)
58-
# if max_workers is not None and max_workers > 0:
59-
# raise ValueError(max_workers)
57+
logger.debug("Creating Zarr ThreadPoolExecutor with max_workers=%s", max_workers)
6058
_executor = ThreadPoolExecutor(max_workers=max_workers, thread_name_prefix="zarr_pool")
6159
_get_loop().set_default_executor(_executor)
6260
return _executor
@@ -118,6 +116,9 @@ def sync(
118116
# NB: if the loop is not running *yet*, it is OK to submit work
119117
# and we will wait for it
120118
loop = _get_loop()
119+
if _executor is None and config.get("threading.max_workers", None) is not None:
120+
# trigger executor creation and attach to loop
121+
_ = _get_executor()
121122
if not isinstance(loop, asyncio.AbstractEventLoop):
122123
raise TypeError(f"loop cannot be of type {type(loop)}")
123124
if loop.is_closed():
@@ -153,6 +154,7 @@ def _get_loop() -> asyncio.AbstractEventLoop:
153154
# repeat the check just in case the loop got filled between the
154155
# previous two calls from another thread
155156
if loop[0] is None:
157+
logger.debug("Creating Zarr event loop")
156158
new_loop = asyncio.new_event_loop()
157159
loop[0] = new_loop
158160
iothread[0] = threading.Thread(target=new_loop.run_forever, name="zarr_io")

src/zarr/storage/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from types import ModuleType
44
from typing import Any
55

6-
from zarr.storage._common import StoreLike, StorePath, make_store_path
6+
from zarr.storage._common import StoreLike, StorePath
77
from zarr.storage._fsspec import FsspecStore
88
from zarr.storage._local import LocalStore
99
from zarr.storage._logging import LoggingStore
@@ -21,7 +21,6 @@
2121
"StorePath",
2222
"WrapperStore",
2323
"ZipStore",
24-
"make_store_path",
2524
]
2625

2726

0 commit comments

Comments
 (0)