| 
 | 1 | +import dataclasses  | 
1 | 2 | import json  | 
2 | 3 | import math  | 
3 | 4 | import pickle  | 
@@ -474,6 +475,87 @@ def test_info_v3(self) -> None:  | 
474 | 475 |         )  | 
475 | 476 |         assert result == expected  | 
476 | 477 | 
 
  | 
 | 478 | +    def test_info_complete(self) -> None:  | 
 | 479 | +        arr = zarr.create(shape=(4, 4), chunks=(2, 2), zarr_format=3)  | 
 | 480 | +        result = arr.info_complete()  | 
 | 481 | +        expected = ArrayInfo(  | 
 | 482 | +            _zarr_format=3,  | 
 | 483 | +            _data_type=DataType.parse("float64"),  | 
 | 484 | +            _shape=(4, 4),  | 
 | 485 | +            _chunk_shape=(2, 2),  | 
 | 486 | +            _order="C",  | 
 | 487 | +            _read_only=False,  | 
 | 488 | +            _store_type="MemoryStore",  | 
 | 489 | +            _codecs=[BytesCodec()],  | 
 | 490 | +            _count_bytes=128,  | 
 | 491 | +            _count_chunks_initialized=0,  | 
 | 492 | +            _count_bytes_stored=373,  # the metadata?  | 
 | 493 | +        )  | 
 | 494 | +        assert result == expected  | 
 | 495 | + | 
 | 496 | +        arr[:2, :2] = 10  | 
 | 497 | +        result = arr.info_complete()  | 
 | 498 | +        expected = dataclasses.replace(  | 
 | 499 | +            expected, _count_chunks_initialized=1, _count_bytes_stored=405  | 
 | 500 | +        )  | 
 | 501 | +        assert result == expected  | 
 | 502 | + | 
 | 503 | +    async def test_info_v2_async(self) -> None:  | 
 | 504 | +        arr = await zarr.api.asynchronous.create(shape=(4, 4), chunks=(2, 2), zarr_format=2)  | 
 | 505 | +        result = arr.info  | 
 | 506 | +        expected = ArrayInfo(  | 
 | 507 | +            _zarr_format=2,  | 
 | 508 | +            _data_type=np.dtype("float64"),  | 
 | 509 | +            _shape=(4, 4),  | 
 | 510 | +            _chunk_shape=(2, 2),  | 
 | 511 | +            _order="C",  | 
 | 512 | +            _read_only=False,  | 
 | 513 | +            _store_type="MemoryStore",  | 
 | 514 | +            _count_bytes=128,  | 
 | 515 | +        )  | 
 | 516 | +        assert result == expected  | 
 | 517 | + | 
 | 518 | +    async def test_info_v3_async(self) -> None:  | 
 | 519 | +        arr = await zarr.api.asynchronous.create(shape=(4, 4), chunks=(2, 2), zarr_format=3)  | 
 | 520 | +        result = arr.info  | 
 | 521 | +        expected = ArrayInfo(  | 
 | 522 | +            _zarr_format=3,  | 
 | 523 | +            _data_type=DataType.parse("float64"),  | 
 | 524 | +            _shape=(4, 4),  | 
 | 525 | +            _chunk_shape=(2, 2),  | 
 | 526 | +            _order="C",  | 
 | 527 | +            _read_only=False,  | 
 | 528 | +            _store_type="MemoryStore",  | 
 | 529 | +            _codecs=[BytesCodec()],  | 
 | 530 | +            _count_bytes=128,  | 
 | 531 | +        )  | 
 | 532 | +        assert result == expected  | 
 | 533 | + | 
 | 534 | +    async def test_info_complete_async(self) -> None:  | 
 | 535 | +        arr = await zarr.api.asynchronous.create(shape=(4, 4), chunks=(2, 2), zarr_format=3)  | 
 | 536 | +        result = await arr.info_complete()  | 
 | 537 | +        expected = ArrayInfo(  | 
 | 538 | +            _zarr_format=3,  | 
 | 539 | +            _data_type=DataType.parse("float64"),  | 
 | 540 | +            _shape=(4, 4),  | 
 | 541 | +            _chunk_shape=(2, 2),  | 
 | 542 | +            _order="C",  | 
 | 543 | +            _read_only=False,  | 
 | 544 | +            _store_type="MemoryStore",  | 
 | 545 | +            _codecs=[BytesCodec()],  | 
 | 546 | +            _count_bytes=128,  | 
 | 547 | +            _count_chunks_initialized=0,  | 
 | 548 | +            _count_bytes_stored=373,  # the metadata?  | 
 | 549 | +        )  | 
 | 550 | +        assert result == expected  | 
 | 551 | + | 
 | 552 | +        await arr.setitem((slice(2), slice(2)), 10)  | 
 | 553 | +        result = await arr.info_complete()  | 
 | 554 | +        expected = dataclasses.replace(  | 
 | 555 | +            expected, _count_chunks_initialized=1, _count_bytes_stored=405  | 
 | 556 | +        )  | 
 | 557 | +        assert result == expected  | 
 | 558 | + | 
477 | 559 | 
 
  | 
478 | 560 | @pytest.mark.parametrize("store", ["memory"], indirect=True)  | 
479 | 561 | @pytest.mark.parametrize("zarr_format", [2, 3])  | 
 | 
0 commit comments