-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docstring and unit tests for make voxels array task
- Loading branch information
1 parent
4dc2058
commit e2813e1
Showing
5 changed files
with
116 additions
and
5 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
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,84 @@ | ||
import unittest | ||
|
||
import numpy as np | ||
|
||
from abm_colony_collection.make_voxels_array import make_voxels_array | ||
|
||
|
||
class TestMakeVoxelsArray(unittest.TestCase): | ||
def test_make_voxels_array_no_locations(self): | ||
locations = [ | ||
{ | ||
"id": 1, | ||
"location": [ | ||
{ | ||
"region": "A", | ||
"voxels": [], | ||
}, | ||
], | ||
}, | ||
{ | ||
"id": 2, | ||
"location": [ | ||
{ | ||
"region": "A", | ||
"voxels": [], | ||
}, | ||
], | ||
}, | ||
] | ||
|
||
expected_array = np.zeros((1, 1, 1)) | ||
|
||
array = make_voxels_array(locations) | ||
|
||
self.assertTrue((expected_array == array).all()) | ||
|
||
def test_make_voxels_array(self): | ||
locations = [ | ||
{ | ||
"id": 1, | ||
"location": [ | ||
{ | ||
"region": "A", | ||
"voxels": [ | ||
[1, 1, 1], | ||
[1, 2, 1], | ||
[1, 1, 2], | ||
], | ||
}, | ||
{ | ||
"region": "B", | ||
"voxels": [ | ||
[1, 2, 2], | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
"id": 2, | ||
"location": [ | ||
{ | ||
"region": "A", | ||
"voxels": [ | ||
[2, 5, 2], | ||
[2, 5, 3], | ||
[2, 6, 2], | ||
[2, 6, 3], | ||
], | ||
}, | ||
], | ||
}, | ||
] | ||
|
||
expected_array = np.zeros((5, 8, 4)) | ||
expected_array[1:3, 1:3, 1] = 1 | ||
expected_array[2:4, 5:7, 2] = 2 | ||
|
||
array = make_voxels_array(locations) | ||
|
||
self.assertTrue((expected_array == array).all()) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |