forked from piskvorky/gensim
-
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.
returning correct dtype from unitvec
matutils.unitvec currently returns a unitvector of a different dtype from the input vector if the input dtype isn't np.float. we should make the return type consistent with the input type. fixes piskvorky#1722
- Loading branch information
Showing
2 changed files
with
28 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
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,27 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Licensed under the GNU LGPL v2.1 - http://www.gnu.org/licenses/lgpl.html | ||
|
||
""" | ||
Automated tests for checking various matutils functions. | ||
""" | ||
|
||
import logging | ||
import unittest | ||
|
||
import numpy as np | ||
|
||
from gensim import matutils | ||
|
||
|
||
class TestMatutils(unittest.TestCase): | ||
def test_unitvec(self): | ||
input_vector = np.random.uniform(size=(100,)).astype(np.float32) | ||
unit_vector = matutils.unitvec(input_vector) | ||
self.assertEqual(input_vector.dtype, unit_vector.dtype) | ||
|
||
|
||
if __name__ == '__main__': | ||
logging.root.setLevel(logging.WARNING) | ||
unittest.main() |