diff --git a/CHANGES.rst b/CHANGES.rst index a84b207..8ae63db 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,7 +1,7 @@ 0.1.0 (unreleased) ------------------ -- +- replace usages of ``copy_arrays`` with ``memmap`` [#46] 0.0.4 (2024-06-28) ------------------ diff --git a/asdf_zarr/tests/test_zarr.py b/asdf_zarr/tests/test_zarr.py index 74284be..2a075c0 100644 --- a/asdf_zarr/tests/test_zarr.py +++ b/asdf_zarr/tests/test_zarr.py @@ -26,13 +26,13 @@ def create_zarray(shape=None, chunks=None, dtype="f8", store=None, chunk_store=N return arr -@pytest.mark.parametrize("copy_arrays", [True, False]) +@pytest.mark.parametrize("memmap", [True, False]) @pytest.mark.parametrize("lazy_load", [True, False]) @pytest.mark.parametrize("compression", ["input", "zlib"]) @pytest.mark.parametrize("store_type", [DirectoryStore, KVStore, MemoryStore, NestedDirectoryStore, TempStore]) @pytest.mark.parametrize("to_internal", [True, False]) @pytest.mark.parametrize("meta_store", [True, False]) -def test_write_to(tmp_path, copy_arrays, lazy_load, compression, store_type, to_internal, meta_store): +def test_write_to(tmp_path, memmap, lazy_load, compression, store_type, to_internal, meta_store): if store_type in (DirectoryStore, NestedDirectoryStore): store1 = store_type(tmp_path / "zarr_array_1") 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_ af = asdf.AsdfFile(tree) af.write_to(fn, all_array_compression=compression) - with asdf.open(fn, mode="r", copy_arrays=copy_arrays, lazy_load=lazy_load) as af: + with asdf.open(fn, mode="r", memmap=memmap, lazy_load=lazy_load) as af: for n, a in (("arr1", arr1), ("arr2", arr2)): assert isinstance(af[n], zarr.core.Array) 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_ assert numpy.allclose(af[n], a) -@pytest.mark.parametrize("copy_arrays", [True, False]) +@pytest.mark.parametrize("memmap", [True, False]) @pytest.mark.parametrize("lazy_load", [True, False]) @pytest.mark.parametrize("with_update", [True, False]) -def test_modify(tmp_path, with_update, copy_arrays, lazy_load): +def test_modify(tmp_path, with_update, memmap, lazy_load): # make a file store = DirectoryStore(tmp_path / "zarr_array") arr = create_zarray(store=store) @@ -89,7 +89,7 @@ def test_modify(tmp_path, with_update, copy_arrays, lazy_load): af.write_to(fn) # open the file, modify the array - with asdf.open(fn, mode="rw", copy_arrays=copy_arrays, lazy_load=lazy_load) as af: + with asdf.open(fn, mode="rw", memmap=memmap, lazy_load=lazy_load) as af: assert af["arr"][0, 0] != 42 af["arr"][0, 0] = 42 # now modify @@ -100,7 +100,7 @@ def test_modify(tmp_path, with_update, copy_arrays, lazy_load): af.update() # reopen the file, check for the modification - with asdf.open(fn, mode="rw", copy_arrays=copy_arrays, lazy_load=lazy_load) as af: + with asdf.open(fn, mode="rw", memmap=memmap, lazy_load=lazy_load) as af: assert af["arr"][0, 0] == 42 diff --git a/notebooks/ASDF_array_storage_intro.ipynb b/notebooks/ASDF_array_storage_intro.ipynb index d2408d7..25488b2 100644 --- a/notebooks/ASDF_array_storage_intro.ipynb +++ b/notebooks/ASDF_array_storage_intro.ipynb @@ -623,7 +623,7 @@ "\n", "For local files, asdf will memory map arrays allowing the operating system to read only the portion of the array that is requested.\n", "\n", - "Note that array memory mapping can be disabled by setting the keyword argument `copy_arrays` to `True` in `asdf.open`." + "Note that array memory mapping can be disabled by setting the keyword argument `memmap` to `False` in `asdf.open`." ] }, { @@ -641,7 +641,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "With default copy_arrays=False\n", + "With default memmap=True\n", "\tarray 0 base array type = \n" ] } @@ -649,7 +649,7 @@ "source": [ "# open our example file with memory mapping (enabled by default)\n", "with asdf.open(example_fn) as af:\n", - " print(\"With default copy_arrays=False\") \n", + " print(\"With default memmap=True\") \n", " # the array data has a base array that is of type numpy.memmap\n", " print(f\"\\tarray 0 base array type = {type(af['array0'].base)}\")" ] @@ -669,15 +669,15 @@ "name": "stdout", "output_type": "stream", "text": [ - "With copy_arrays=True\n", + "With memmap=False\n", "\tarray 0 base array type = \n" ] } ], "source": [ "# open our example file with memory mapping disabled\n", - "with asdf.open(example_fn, copy_arrays=True) as af:\n", - " print(\"With copy_arrays=True\")\n", + "with asdf.open(example_fn, memmap=False) as af:\n", + " print(\"With memmap=False\")\n", " print(f\"\\tarray 0 base array type = {type(af['array0'].base)}\")" ] }, diff --git a/pyproject.toml b/pyproject.toml index 1cfb0f9..977315d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ dynamic = [ 'version', ] dependencies = [ - "asdf >= 3.0.0", + "asdf >= 3.1.0", "zarr >= 2.14, < 3.0.0", "fsspec", ]