Skip to content

Commit 5315399

Browse files
authored
Merge pull request #46 from zacharyburnett/deprecate/copy_arrays
replace usages of ``copy_arrays`` with ``memmap``
2 parents 089dfd3 + 4d29caa commit 5315399

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
0.1.0 (unreleased)
22
------------------
33

4-
-
4+
- replace usages of ``copy_arrays`` with ``memmap`` [#46]
55

66
0.0.4 (2024-06-28)
77
------------------

asdf_zarr/tests/test_zarr.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ def create_zarray(shape=None, chunks=None, dtype="f8", store=None, chunk_store=N
2626
return arr
2727

2828

29-
@pytest.mark.parametrize("copy_arrays", [True, False])
29+
@pytest.mark.parametrize("memmap", [True, False])
3030
@pytest.mark.parametrize("lazy_load", [True, False])
3131
@pytest.mark.parametrize("compression", ["input", "zlib"])
3232
@pytest.mark.parametrize("store_type", [DirectoryStore, KVStore, MemoryStore, NestedDirectoryStore, TempStore])
3333
@pytest.mark.parametrize("to_internal", [True, False])
3434
@pytest.mark.parametrize("meta_store", [True, False])
35-
def test_write_to(tmp_path, copy_arrays, lazy_load, compression, store_type, to_internal, meta_store):
35+
def test_write_to(tmp_path, memmap, lazy_load, compression, store_type, to_internal, meta_store):
3636
if store_type in (DirectoryStore, NestedDirectoryStore):
3737
store1 = store_type(tmp_path / "zarr_array_1")
3838
store2 = store_type(tmp_path / "zarr_array_2")
@@ -66,7 +66,7 @@ def test_write_to(tmp_path, copy_arrays, lazy_load, compression, store_type, to_
6666
af = asdf.AsdfFile(tree)
6767
af.write_to(fn, all_array_compression=compression)
6868

69-
with asdf.open(fn, mode="r", copy_arrays=copy_arrays, lazy_load=lazy_load) as af:
69+
with asdf.open(fn, mode="r", memmap=memmap, lazy_load=lazy_load) as af:
7070
for n, a in (("arr1", arr1), ("arr2", arr2)):
7171
assert isinstance(af[n], zarr.core.Array)
7272
if to_internal or store_type in (KVStore, MemoryStore, TempStore):
@@ -76,10 +76,10 @@ def test_write_to(tmp_path, copy_arrays, lazy_load, compression, store_type, to_
7676
assert numpy.allclose(af[n], a)
7777

7878

79-
@pytest.mark.parametrize("copy_arrays", [True, False])
79+
@pytest.mark.parametrize("memmap", [True, False])
8080
@pytest.mark.parametrize("lazy_load", [True, False])
8181
@pytest.mark.parametrize("with_update", [True, False])
82-
def test_modify(tmp_path, with_update, copy_arrays, lazy_load):
82+
def test_modify(tmp_path, with_update, memmap, lazy_load):
8383
# make a file
8484
store = DirectoryStore(tmp_path / "zarr_array")
8585
arr = create_zarray(store=store)
@@ -89,7 +89,7 @@ def test_modify(tmp_path, with_update, copy_arrays, lazy_load):
8989
af.write_to(fn)
9090

9191
# open the file, modify the array
92-
with asdf.open(fn, mode="rw", copy_arrays=copy_arrays, lazy_load=lazy_load) as af:
92+
with asdf.open(fn, mode="rw", memmap=memmap, lazy_load=lazy_load) as af:
9393
assert af["arr"][0, 0] != 42
9494
af["arr"][0, 0] = 42
9595
# now modify
@@ -100,7 +100,7 @@ def test_modify(tmp_path, with_update, copy_arrays, lazy_load):
100100
af.update()
101101

102102
# reopen the file, check for the modification
103-
with asdf.open(fn, mode="rw", copy_arrays=copy_arrays, lazy_load=lazy_load) as af:
103+
with asdf.open(fn, mode="rw", memmap=memmap, lazy_load=lazy_load) as af:
104104
assert af["arr"][0, 0] == 42
105105

106106

notebooks/ASDF_array_storage_intro.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@
623623
"\n",
624624
"For local files, asdf will memory map arrays allowing the operating system to read only the portion of the array that is requested.\n",
625625
"\n",
626-
"Note that array memory mapping can be disabled by setting the keyword argument `copy_arrays` to `True` in `asdf.open`."
626+
"Note that array memory mapping can be disabled by setting the keyword argument `memmap` to `False` in `asdf.open`."
627627
]
628628
},
629629
{
@@ -641,15 +641,15 @@
641641
"name": "stdout",
642642
"output_type": "stream",
643643
"text": [
644-
"With default copy_arrays=False\n",
644+
"With default memmap=True\n",
645645
"\tarray 0 base array type = <class 'numpy.memmap'>\n"
646646
]
647647
}
648648
],
649649
"source": [
650650
"# open our example file with memory mapping (enabled by default)\n",
651651
"with asdf.open(example_fn) as af:\n",
652-
" print(\"With default copy_arrays=False\") \n",
652+
" print(\"With default memmap=True\") \n",
653653
" # the array data has a base array that is of type numpy.memmap\n",
654654
" print(f\"\\tarray 0 base array type = {type(af['array0'].base)}\")"
655655
]
@@ -669,15 +669,15 @@
669669
"name": "stdout",
670670
"output_type": "stream",
671671
"text": [
672-
"With copy_arrays=True\n",
672+
"With memmap=False\n",
673673
"\tarray 0 base array type = <class 'numpy.ndarray'>\n"
674674
]
675675
}
676676
],
677677
"source": [
678678
"# open our example file with memory mapping disabled\n",
679-
"with asdf.open(example_fn, copy_arrays=True) as af:\n",
680-
" print(\"With copy_arrays=True\")\n",
679+
"with asdf.open(example_fn, memmap=False) as af:\n",
680+
" print(\"With memmap=False\")\n",
681681
" print(f\"\\tarray 0 base array type = {type(af['array0'].base)}\")"
682682
]
683683
},

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dynamic = [
1919
'version',
2020
]
2121
dependencies = [
22-
"asdf >= 3.0.0",
22+
"asdf >= 3.1.0",
2323
"zarr >= 2.14, < 3.0.0",
2424
"fsspec",
2525
]

0 commit comments

Comments
 (0)