-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unit test code for new InstCatTrimmer; delete unused GsObjectDict…
… class
- Loading branch information
Showing
3 changed files
with
58 additions
and
54 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,39 @@ | ||
""" | ||
Unit tests for InstCatTrimmer class. | ||
""" | ||
import os | ||
import unittest | ||
import desc.imsim | ||
|
||
|
||
class InstCatTrimmerTestCase(unittest.TestCase): | ||
""" | ||
TestCase class for InstCatTrimmer. | ||
""" | ||
def setUp(self): | ||
pass | ||
|
||
def tearDown(self): | ||
pass | ||
|
||
def test_InstCatTrimmer(self): | ||
"""Unit test for InstCatTrimmer class.""" | ||
instcat = os.path.join(os.environ['IMSIM_DIR'], 'tests', | ||
'tiny_instcat.txt') | ||
sensor = 'R:2,2 S:1,1' | ||
|
||
# Check the application of minsource. | ||
objs = desc.imsim.InstCatTrimmer(instcat, [sensor], minsource=10) | ||
self.assertEqual(len(objs[sensor]), 24) | ||
|
||
objs = desc.imsim.InstCatTrimmer(instcat, [sensor], minsource=12) | ||
self.assertEqual(len(objs[sensor]), 0) | ||
|
||
# Check various values of chunk_size. | ||
for chunk_size in (5, 10, 100): | ||
objs = desc.imsim.InstCatTrimmer(instcat, [sensor], minsource=None, | ||
chunk_size=chunk_size) | ||
self.assertEqual(len(objs[sensor]), 24) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |