Skip to content

Commit

Permalink
Merge branch 'main' into ome-ngff
Browse files Browse the repository at this point in the history
  • Loading branch information
pattonw authored Dec 31, 2024
2 parents 3628830 + 0b67093 commit 0154da1
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/black.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Python Black
name: black

on: [push, pull_request]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mypy.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Python mypy
name: mypy

on: [push, pull_request]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish
name: pypi

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: tests

on:
push:
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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]`

7 changes: 7 additions & 0 deletions funlib/persistence/arrays/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
15 changes: 8 additions & 7 deletions tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 0154da1

Please sign in to comment.