-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
206 additions
and
26 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,52 @@ | ||
import numpy as np | ||
import unittest | ||
|
||
from adapters import ExampleSource, ExampleSink | ||
|
||
|
||
class TestSource(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.vol = np.random.randint(0, 2**32, (100, 100, 10)).astype(np.uint32) | ||
|
||
def testExampleSource(self): | ||
vol = self.vol | ||
s = ExampleSource(vol) | ||
|
||
roi = [np.zeros((len(vol.shape),)), vol.shape] | ||
newVol = np.zeros(vol.shape, dtype=np.uint32) | ||
assert s.pyReadBlock(roi, newVol) | ||
assert np.all(vol == newVol) | ||
|
||
def testRoi(self): | ||
vol = self.vol | ||
s = ExampleSource(vol) | ||
|
||
reqRoi = [(50, 50, 2), (70, 70, 4)] | ||
s.pySetRoi(reqRoi) | ||
roi = [(0, 0, 0), (20, 20, 2)] | ||
newVol = np.zeros((20, 20, 2), dtype=np.uint32) | ||
assert s.pyReadBlock(roi, newVol) | ||
assert np.all(vol[50:70, 50:70, 2:4] == newVol) | ||
|
||
def testRoi2(self): | ||
vol = self.vol | ||
s = ExampleSource(vol) | ||
roi = [(0, 0, 2), (20, 20, 4)] | ||
newVol = np.zeros((20, 20, 2), dtype=np.uint32) | ||
assert s.pyReadBlock(roi, newVol) | ||
|
||
|
||
class TestSink(unittest.TestCase): | ||
|
||
def setUp(self): | ||
pass | ||
|
||
def testExampleSink(self): | ||
s = ExampleSink() | ||
s.shape = (100, 100, 10) | ||
s.blockShape = (10, 10, 10) | ||
s.pyWriteBlock([(15, 20, 2), (30, 30, 6)], | ||
np.ones((15, 10, 4), dtype=np.uint8)) | ||
|
||
assert np.all(s.vol[15:30, 20:30, 2:6] == 1) |
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,38 @@ | ||
import numpy as np | ||
import unittest | ||
|
||
from adapters import DummySource, ExampleSource | ||
from _blockedarray import dim3 | ||
|
||
|
||
class TestConnectedComponents(unittest.TestCase): | ||
|
||
def setUp(self): | ||
shape = (100, 100, 100) | ||
self.blockShape = (10, 10, 10) | ||
vol = np.zeros(shape, dtype=np.uint8) | ||
vol[7:12, 7:12, 7:12] = 42 | ||
vol[:, :, 72:75] = 111 | ||
vol[:, 72:75, :] = 111 | ||
self.vol = vol | ||
|
||
def testBlockShape(self): | ||
CC = dim3.ConnectedComponents | ||
s = DummySource() | ||
|
||
v = (10, 10, 10) | ||
cc = CC(s, v) | ||
|
||
v = np.asarray((10, 10, 10)) | ||
cc = CC(s, v) | ||
|
||
v = np.asarray((10, 10, 10), dtype=np.long) | ||
cc = CC(s, v) | ||
|
||
v = np.asarray((10, 10, 10), dtype=np.int) | ||
cc = CC(s, v) | ||
|
||
def testCC(self): | ||
CC = dim3.ConnectedComponents | ||
s = ExampleSource(self.vol) | ||
assert CC(s, self.blockShape) |
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