-
Notifications
You must be signed in to change notification settings - Fork 48
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: ted chang <[email protected]>
- Loading branch information
1 parent
5a0cf5c
commit 863cc53
Showing
3 changed files
with
64 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install -r setup_requirements.txt | ||
- name: Run unit tests | ||
run: tox -e py |
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,33 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# https://spdx.dev/learn/handling-license-info/ | ||
|
||
# Third Party | ||
import pytest | ||
import torch | ||
|
||
# Local | ||
from tuning.utils import data_type_utils | ||
|
||
dtype_dict = { | ||
"bool": torch.bool, | ||
"double": torch.double, | ||
"float32": torch.float32, | ||
"int64": torch.int64, | ||
"long": torch.long, | ||
} | ||
|
||
|
||
def test_str_to_torch_dtype(): | ||
for t in dtype_dict.keys(): | ||
assert data_type_utils.str_to_torch_dtype(t) == dtype_dict.get(t) | ||
|
||
|
||
def test_str_to_torch_dtype_exit(): | ||
with pytest.raises(SystemExit): | ||
data_type_utils.str_to_torch_dtype("foo") | ||
|
||
|
||
def test_get_torch_dtype(): | ||
for t in dtype_dict.keys(): | ||
assert data_type_utils.get_torch_dtype(t) == dtype_dict.get(t) | ||
assert data_type_utils.get_torch_dtype(dtype_dict.get(t)) == dtype_dict.get(t) |
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