-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic
ArraySource
node that accepts any funlib.persistence.Array
- Loading branch information
Showing
3 changed files
with
37 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from funlib.persistence import prepare_ds | ||
from funlib.geometry import Roi | ||
from gunpowder.nodes import ArraySource | ||
from gunpowder import ArrayKey, build, BatchRequest, ArraySpec | ||
|
||
import numpy as np | ||
|
||
|
||
def test_array_source(tmpdir): | ||
array = prepare_ds( | ||
tmpdir / "data.zarr", | ||
shape=(100, 102, 108), | ||
offset=(100, 50, 0), | ||
voxel_size=(1, 2, 3), | ||
dtype="uint8", | ||
) | ||
array[:] = np.arange(100 * 102 * 108).reshape((100, 102, 108)) % 255 | ||
|
||
key = ArrayKey("TEST") | ||
|
||
source = ArraySource(key=key, array=array) | ||
|
||
with build(source): | ||
request = BatchRequest() | ||
|
||
roi = Roi((100, 100, 102), (30, 30, 30)) | ||
request[key] = ArraySpec(roi) | ||
|
||
assert np.array_equal(source.request_batch(request)[key].data, array[roi]) |