|
9 | 9 | from numcodecs import Adler32, Zlib
|
10 | 10 | from numpy.testing import assert_array_equal
|
11 | 11 |
|
12 |
| -from zarr.convenience import (consolidate_metadata, copy, copy_store, load, |
13 |
| - open, open_consolidated, save, save_group) |
| 12 | +import zarr |
| 13 | +from zarr.convenience import ( |
| 14 | + consolidate_metadata, |
| 15 | + copy, |
| 16 | + copy_store, |
| 17 | + load, |
| 18 | + open, |
| 19 | + open_consolidated, |
| 20 | + save, |
| 21 | + save_group, |
| 22 | + copy_all, |
| 23 | +) |
14 | 24 | from zarr.core import Array
|
15 | 25 | from zarr.errors import CopyError
|
16 | 26 | from zarr.hierarchy import Group, group
|
@@ -421,6 +431,31 @@ def check_copied_group(original, copied, without_attrs=False, expect_props=None,
|
421 | 431 | assert sorted(original.attrs.items()) == sorted(copied.attrs.items())
|
422 | 432 |
|
423 | 433 |
|
| 434 | +def test_copy_all(): |
| 435 | + """ |
| 436 | + https://github.com/zarr-developers/zarr-python/issues/269 |
| 437 | +
|
| 438 | + copy_all used to not copy attributes as `.keys()` does not return hidden `.zattrs`. |
| 439 | +
|
| 440 | + """ |
| 441 | + original_group = zarr.group(store=MemoryStore(), overwrite=True) |
| 442 | + original_group.attrs["info"] = "group attrs" |
| 443 | + original_subgroup = original_group.create_group("subgroup") |
| 444 | + original_subgroup.attrs["info"] = "sub attrs" |
| 445 | + |
| 446 | + destination_group = zarr.group(store=MemoryStore(), overwrite=True) |
| 447 | + |
| 448 | + # copy from memory to directory store |
| 449 | + copy_all( |
| 450 | + original_group, |
| 451 | + destination_group, |
| 452 | + dry_run=False, |
| 453 | + ) |
| 454 | + |
| 455 | + assert destination_group.attrs["info"] == "group attrs" |
| 456 | + assert destination_group.subgroup.attrs["info"] == "sub attrs" |
| 457 | + |
| 458 | + |
424 | 459 | # noinspection PyAttributeOutsideInit
|
425 | 460 | class TestCopy(unittest.TestCase):
|
426 | 461 |
|
|
0 commit comments