diff --git a/.github/workflows/black.yaml b/.github/workflows/black.yaml index 48a5970..c139fd0 100644 --- a/.github/workflows/black.yaml +++ b/.github/workflows/black.yaml @@ -1,4 +1,4 @@ -name: Python Black +name: black on: [push, pull_request] diff --git a/.github/workflows/mypy.yaml b/.github/workflows/mypy.yaml index 9535ed0..3f993c0 100644 --- a/.github/workflows/mypy.yaml +++ b/.github/workflows/mypy.yaml @@ -1,4 +1,4 @@ -name: Python mypy +name: mypy on: [push, pull_request] diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 05ba0a8..01586bc 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -1,4 +1,4 @@ -name: Publish +name: pypi on: push: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 09262d0..628620f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,4 +1,4 @@ -name: Test +name: tests on: push: diff --git a/README.md b/README.md index f42dd4c..1a6dc24 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,15 @@ [![tests](https://github.com/funkelab/funlib.persistence/actions/workflows/tests.yaml/badge.svg)](https://github.com/funkelab/funlib.persistence/actions/workflows/tests.yaml) [![black](https://github.com/funkelab/funlib.persistence/actions/workflows/black.yaml/badge.svg)](https://github.com/funkelab/funlib.persistence/actions/workflows/black.yaml) [![mypy](https://github.com/funkelab/funlib.persistence/actions/workflows/mypy.yaml/badge.svg)](https://github.com/funkelab/funlib.persistence/actions/workflows/mypy.yaml) +[![pypi](https://github.com/funkelab/funlib.persistence/actions/workflows/publish.yaml/badge.svg)](https://pypi.org/project/funlib.persistence/) # funlib.persistence Interfaces for data (arrays and graphs) and storage formats (databases and file formats) # installation -regular installation for usage: -`pip install .` -developer installation including pytest etc.: -`pip install ".[dev]"` +Regular installation for usage: +`pip install funlib.persistence` + +Developer installation including pytest etc.: +`pip install funlib.persistence[dev]` diff --git a/funlib/persistence/arrays/array.py b/funlib/persistence/arrays/array.py index d5173ac..fb96fc0 100644 --- a/funlib/persistence/arrays/array.py +++ b/funlib/persistence/arrays/array.py @@ -323,6 +323,13 @@ def __setitem__(self, key, value: np.ndarray): self._source_data[region_slices] = value + # If the source data is an in-memory numpy array, writing to the numpy + # array does not always result in the dask array reading the new data. + # It seems to be a caching issue. To work around this, we create a new + # dask array from the source data. + if isinstance(self._source_data, np.ndarray): + self.data = da.from_array(self._source_data) + else: raise RuntimeError( "This array is not writeable since you have applied a custom callable " diff --git a/tests/test_array.py b/tests/test_array.py index 8b16bfd..f9a9100 100644 --- a/tests/test_array.py +++ b/tests/test_array.py @@ -73,13 +73,14 @@ def test_setitem(): a = Array(np.zeros((2, 5)), (0, 0), (1, 1)) - a[Roi((0, 0), (2, 5))] = np.arange(0, 10).reshape(2, 5) - assert a[Coordinate((0, 0))] == 0 - assert a[Coordinate((0, 1))] == 1 - assert a[Coordinate((0, 2))] == 2 - assert a[Coordinate((1, 0))] == 5 - assert a[Coordinate((1, 1))] == 6 - assert a[Coordinate((1, 4))] == 9 + data = np.arange(0, 10).reshape(2, 5) + a[Roi((0, 0), (2, 5))] = data + assert a[Coordinate((0, 0))] == a._source_data[0, 0] == 0 + assert a[Coordinate((0, 1))] == a._source_data[0, 1] == 1 + assert a[Coordinate((0, 2))] == a._source_data[0, 2] == 2 + assert a[Coordinate((1, 0))] == a._source_data[1, 0] == 5 + assert a[Coordinate((1, 1))] == a._source_data[1, 1] == 6 + assert a[Coordinate((1, 4))] == a._source_data[1, 4] == 9 # set entirely with numpy array and channels