-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests, correct return type to float
- Loading branch information
1 parent
4db76c1
commit dcae059
Showing
3 changed files
with
41 additions
and
3 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
Empty file.
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,34 @@ | ||
import unittest | ||
|
||
import numpy as np | ||
|
||
from mDeepFRI.predict import seq2onehot | ||
|
||
|
||
class TestSeq2OneHot(unittest.TestCase): | ||
def test_empty_sequence(self): | ||
seq = "" | ||
result = seq2onehot(seq) | ||
self.assertEqual(result.shape, (0, 26)) | ||
self.assertEqual(result.dtype, np.float32) | ||
self.assertTrue(np.all(result == np.array([]).reshape(0, 26))) | ||
|
||
def test_single_character_sequence(self): | ||
seq = "D" | ||
result = seq2onehot(seq) | ||
self.assertEqual(result.shape, (1, 26)) | ||
self.assertTrue(np.all(result == np.array([[0, 1] + [0] * 24]))) | ||
|
||
def test_sequence(self): | ||
seq = "-DGU" | ||
result = seq2onehot(seq) | ||
self.assertEqual(result.shape, (4, 26)) | ||
self.assertTrue( | ||
np.all(result == np.array([[1, 0, 0, 0] + [0] * 22, [0, 1, 0, 0] + | ||
[0] * 22, [0, 0, 1, 0] + | ||
[0] * 22, [0, 0, 0, 1] + [0] * 22]))) | ||
|
||
def test_invalid_character(self): | ||
seq = "J" | ||
with self.assertRaises(ValueError): | ||
seq2onehot(seq) |