Skip to content

Commit 08f2afe

Browse files
bhargavvadertmylk
authored andcommitted
[MRG] Static Word Tests (#742)
1 parent c00efcf commit 08f2afe

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

gensim/test/test_ldamodel.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,19 +293,25 @@ def testTermTopics(self):
293293
numpy.random.seed(0)
294294
model = self.class_(self.corpus, id2word=dictionary, num_topics=2, passes=100)
295295

296-
# check with id
296+
# check with word_type
297297
result = model.get_term_topics(2)
298-
expected = [(1, 0.1066)]
299-
# FIXME: fails on win and osx
300-
# self.assertEqual(result[0][0], expected[0][0])
301-
# self.assertAlmostEqual(result[0][1], expected[0][1], places=2)
298+
for topic_no, probability in result:
299+
self.assertTrue(isinstance(topic_no, int))
300+
self.assertTrue(isinstance(probability, float))
301+
302+
# checks if topic '1' is in the result list
303+
self.assertTrue(1 in result[0])
304+
302305

303306
# if user has entered word instead, check with word
304307
result = model.get_term_topics(str(model.id2word[2]))
305-
expected = [(1, 0.1066)]
306-
# FIXME: fails on win and osx
307-
# self.assertEqual(result[0][0], expected[0][0])
308-
# self.assertAlmostEqual(result[0][1], expected[0][1], places=2)
308+
for topic_no, probability in result:
309+
self.assertTrue(isinstance(topic_no, int))
310+
self.assertTrue(isinstance(probability, float))
311+
312+
# checks if topic '1' is in the result list
313+
self.assertTrue(1 in result[0])
314+
309315

310316
def testPasses(self):
311317
# long message includes the original error message with a custom one

0 commit comments

Comments
 (0)