Skip to content

Commit

Permalink
Made test docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
devashishd12 committed May 26, 2016
1 parent b626326 commit 2676bb6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gensim/models/normmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Normmodel(interfaces.TransformationABC):
The main methods are:
1. Constructor which normalizes the terms in the given corpus document-wise.
2. The [] method which normalizes a simple count representation.
2. The normalize() method which normalizes a simple count representation.
>>> norm_l2 = Normmodel(corpus)
>>> print(norm_l2[some_doc])
Expand Down
14 changes: 7 additions & 7 deletions gensim/test/test_normmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ def setUp(self):
self.model_l2 = normmodel.Normmodel(self.corpus, norm='l2')

def test_tupleInput_l1(self):
# Test tuple input for l1 transformation
"""Test tuple input for l1 transformation"""
normalized = self.model_l1.normalize(self.doc)
expected = [(1, 0.25), (5, 0.5), (8, 0.25)]
self.assertTrue(numpy.allclose(normalized, expected))

def test_sparseCSRInput_l1(self):
# Test sparse csr matrix input for l1 transformation
"""Test sparse csr matrix input for l1 transformation"""
row = numpy.array([0, 0, 1, 2, 2, 2])
col = numpy.array([0, 2, 2, 0, 1, 2])
data = numpy.array([1, 2, 3, 4, 5, 6])
Expand All @@ -67,7 +67,7 @@ def test_sparseCSRInput_l1(self):
self.assertTrue(numpy.allclose(normalized.toarray(), expected))

def test_numpyndarrayInput_l1(self):
# Test for numpy ndarray input for l1 transformation
"""Test for numpy ndarray input for l1 transformation"""
ndarray_matrix = numpy.array([[1, 0, 2],
[0, 0, 3],
[4, 5, 6]])
Expand All @@ -86,13 +86,13 @@ def test_numpyndarrayInput_l1(self):
self.assertRaises(ValueError, lambda model, doc: model.normalize(doc), self.model_l1, [1, 2, 3])

def test_tupleInput_l2(self):
# Test tuple input for l2 transformation
"""Test tuple input for l2 transformation"""
normalized = self.model_l2.normalize(self.doc)
expected = [(1, 0.4082482904638631), (5, 0.8164965809277261), (8, 0.4082482904638631)]
self.assertTrue(numpy.allclose(normalized, expected))

def test_sparseCSRInput_l2(self):
# Test sparse csr matrix input for l2 transformation
"""Test sparse csr matrix input for l2 transformation"""
row = numpy.array([0, 0, 1, 2, 2, 2])
col = numpy.array([0, 2, 2, 0, 1, 2])
data = numpy.array([1, 2, 3, 4, 5, 6])
Expand All @@ -110,7 +110,7 @@ def test_sparseCSRInput_l2(self):
self.assertTrue(numpy.allclose(normalized.toarray(), expected))

def test_numpyndarrayInput_l2(self):
# Test for numpy ndarray input for l2 transformation
"""Test for numpy ndarray input for l2 transformation"""
ndarray_matrix = numpy.array([[1, 0, 2],
[0, 0, 3],
[4, 5, 6]])
Expand All @@ -129,7 +129,7 @@ def test_numpyndarrayInput_l2(self):
self.assertRaises(ValueError, lambda model, doc: model.normalize(doc), self.model_l2, [1, 2, 3])

def testInit(self):
# Test if error messages raised on unsupported norm
"""Test if error messages raised on unsupported norm"""
self.assertRaises(ValueError, normmodel.Normmodel, self.corpus, 'l0')

def testPersistence(self):
Expand Down

0 comments on commit 2676bb6

Please sign in to comment.