-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kaihui-intel <kaihui.tang@intel.com>
- Loading branch information
1 parent
7bf89eb
commit fb61428
Showing
5 changed files
with
205 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"""Tests for common components. | ||
!!! Please do not import any framework-specific modules in this file. !!! | ||
* Note, we may need to add some auto check mechanisms to ensure this. | ||
These tests aim to assess the fundamental functionalities of common utils and enhance code coverage. | ||
All tests will be included for each framework CI. | ||
""" | ||
import unittest | ||
|
||
from neural_compressor.common import options | ||
from neural_compressor.common.utils import set_random_seed, set_resume_from, set_tensorboard, set_workspace | ||
|
||
|
||
class TestOptions(unittest.TestCase): | ||
def test_set_random_seed(self): | ||
seed = 12345 | ||
set_random_seed(seed) | ||
self.assertEqual(options.random_seed, seed) | ||
|
||
# non int type | ||
seed = "12345" | ||
with self.assertRaises(AssertionError): | ||
set_random_seed(seed) | ||
|
||
def test_set_workspace(self): | ||
workspace = "/path/to/workspace" | ||
set_workspace(workspace) | ||
self.assertEqual(options.workspace, workspace) | ||
|
||
# non String type | ||
workspace = 12345 | ||
with self.assertRaises(AssertionError): | ||
set_workspace(workspace) | ||
|
||
def test_set_resume_from(self): | ||
resume_from = "/path/to/resume" | ||
set_resume_from(resume_from) | ||
self.assertEqual(options.resume_from, resume_from) | ||
|
||
# non String type | ||
resume_from = 12345 | ||
with self.assertRaises(AssertionError): | ||
set_resume_from(resume_from) | ||
|
||
def test_set_tensorboard(self): | ||
tensorboard = True | ||
set_tensorboard(tensorboard) | ||
self.assertEqual(options.tensorboard, tensorboard) | ||
|
||
# non bool type | ||
tensorboard = 123 | ||
with self.assertRaises(AssertionError): | ||
set_tensorboard(tensorboard) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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