From 78a035459cd5b46977f2a476b69110a081cb0316 Mon Sep 17 00:00:00 2001 From: G POORNA PRUDHVI Date: Fri, 27 Oct 2017 14:50:05 +0530 Subject: [PATCH 1/9] Fix Deprecation Warning AssertEquals to AssertEqual --- gensim/test/test_fasttext.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/gensim/test/test_fasttext.py b/gensim/test/test_fasttext.py index 0a016231b5..a5d9527328 100644 --- a/gensim/test/test_fasttext.py +++ b/gensim/test/test_fasttext.py @@ -184,14 +184,14 @@ def test_load_fasttext_format(self): ] self.assertTrue(np.allclose(model["rejection"], expected_vec_oov, atol=1e-4)) - self.assertEquals(model.min_count, 5) - self.assertEquals(model.window, 5) - self.assertEquals(model.iter, 5) - self.assertEquals(model.negative, 5) - self.assertEquals(model.sample, 0.0001) - self.assertEquals(model.bucket, 1000) - self.assertEquals(model.wv.max_n, 6) - self.assertEquals(model.wv.min_n, 3) + self.assertEqual(model.min_count, 5) + self.assertEqual(model.window, 5) + self.assertEqual(model.iter, 5) + self.assertEqual(model.negative, 5) + self.assertEqual(model.sample, 0.0001) + self.assertEqual(model.bucket, 1000) + self.assertEqual(model.wv.max_n, 6) + self.assertEqual(model.wv.min_n, 3) self.assertEqual(model.wv.syn0.shape, (len(model.wv.vocab), model.vector_size)) self.assertEqual(model.wv.syn0_ngrams.shape, (model.num_ngram_vectors, model.vector_size)) @@ -235,14 +235,14 @@ def test_load_fasttext_new_format(self): ] self.assertTrue(np.allclose(new_model["rejection"], expected_vec_oov, atol=1e-4)) - self.assertEquals(new_model.min_count, 5) - self.assertEquals(new_model.window, 5) - self.assertEquals(new_model.iter, 5) - self.assertEquals(new_model.negative, 5) - self.assertEquals(new_model.sample, 0.0001) - self.assertEquals(new_model.bucket, 1000) - self.assertEquals(new_model.wv.max_n, 6) - self.assertEquals(new_model.wv.min_n, 3) + self.assertEqual(new_model.min_count, 5) + self.assertEqual(new_model.window, 5) + self.assertEqual(new_model.iter, 5) + self.assertEqual(new_model.negative, 5) + self.assertEqual(new_model.sample, 0.0001) + self.assertEqual(new_model.bucket, 1000) + self.assertEqual(new_model.wv.max_n, 6) + self.assertEqual(new_model.wv.min_n, 3) self.assertEqual(new_model.wv.syn0.shape, (len(new_model.wv.vocab), new_model.vector_size)) self.assertEqual(new_model.wv.syn0_ngrams.shape, (new_model.num_ngram_vectors, new_model.vector_size)) From d3c9e9731043ed716ec73124c944b14b7879be9c Mon Sep 17 00:00:00 2001 From: G POORNA PRUDHVI Date: Fri, 27 Oct 2017 14:51:11 +0530 Subject: [PATCH 2/9] Fix Deprecation Warning Asser Equals to Assert Equal --- gensim/test/test_fasttext_wrapper.py | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/gensim/test/test_fasttext_wrapper.py b/gensim/test/test_fasttext_wrapper.py index 9d7bb22f56..77e10bdf99 100644 --- a/gensim/test/test_fasttext_wrapper.py +++ b/gensim/test/test_fasttext_wrapper.py @@ -158,14 +158,14 @@ def testLoadFastTextFormat(self): ] self.assertTrue(numpy.allclose(model["rejection"], expected_vec_oov, atol=1e-4)) - self.assertEquals(model.min_count, 5) - self.assertEquals(model.window, 5) - self.assertEquals(model.iter, 5) - self.assertEquals(model.negative, 5) - self.assertEquals(model.sample, 0.0001) - self.assertEquals(model.bucket, 1000) - self.assertEquals(model.wv.max_n, 6) - self.assertEquals(model.wv.min_n, 3) + self.assertEqual(model.min_count, 5) + self.assertEqual(model.window, 5) + self.assertEqual(model.iter, 5) + self.assertEqual(model.negative, 5) + self.assertEqual(model.sample, 0.0001) + self.assertEqual(model.bucket, 1000) + self.assertEqual(model.wv.max_n, 6) + self.assertEqual(model.wv.min_n, 3) self.model_sanity(model) def testLoadFastTextNewFormat(self): @@ -209,14 +209,14 @@ def testLoadFastTextNewFormat(self): ] self.assertTrue(numpy.allclose(new_model["rejection"], expected_vec_oov, atol=1e-4)) - self.assertEquals(new_model.min_count, 5) - self.assertEquals(new_model.window, 5) - self.assertEquals(new_model.iter, 5) - self.assertEquals(new_model.negative, 5) - self.assertEquals(new_model.sample, 0.0001) - self.assertEquals(new_model.bucket, 1000) - self.assertEquals(new_model.wv.max_n, 6) - self.assertEquals(new_model.wv.min_n, 3) + self.assertEqual(new_model.min_count, 5) + self.assertEqual(new_model.window, 5) + self.assertEqual(new_model.iter, 5) + self.assertEqual(new_model.negative, 5) + self.assertEqual(new_model.sample, 0.0001) + self.assertEqual(new_model.bucket, 1000) + self.assertEqual(new_model.wv.max_n, 6) + self.assertEqual(new_model.wv.min_n, 3) self.model_sanity(new_model) def testLoadFileName(self): From 0b419cd586175482c54315f8d9593302f14d3529 Mon Sep 17 00:00:00 2001 From: G POORNA PRUDHVI Date: Sat, 28 Oct 2017 13:44:14 +0530 Subject: [PATCH 3/9] Fix Deprecation Warning AssertEquals to AssertEqual --- gensim/test/test_corpora.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gensim/test/test_corpora.py b/gensim/test/test_corpora.py index 0456ea94f5..a990c6be94 100644 --- a/gensim/test/test_corpora.py +++ b/gensim/test/test_corpora.py @@ -133,7 +133,7 @@ def test_serialize(self): # after deserialisation if isinstance(corpus, indexedcorpus.IndexedCorpus): idx = [1, 3, 5, 7] - self.assertEquals(corpus[idx], corpus2[idx]) + self.assertEqual(corpus[idx], corpus2[idx]) def test_serialize_compressed(self): corpus = self.TEST_CORPUS @@ -202,10 +202,10 @@ def _get_slice(corpus, slice_): # check sliced corpora that use fancy indexing c = corpus[[1, 3, 4]] - self.assertEquals([d for i, d in enumerate(docs) if i in [1, 3, 4]], list(c)) - self.assertEquals([d for i, d in enumerate(docs) if i in [1, 3, 4]], list(c)) - self.assertEquals(len(corpus[[0, 1, -1]]), 3) - self.assertEquals(len(corpus[np.asarray([0, 1, -1])]), 3) + self.assertEqual([d for i, d in enumerate(docs) if i in [1, 3, 4]], list(c)) + self.assertEqual([d for i, d in enumerate(docs) if i in [1, 3, 4]], list(c)) + self.assertEqual(len(corpus[[0, 1, -1]]), 3) + self.assertEqual(len(corpus[np.asarray([0, 1, -1])]), 3) # check that TransformedCorpus supports indexing when the underlying # corpus does, and throws an error otherwise @@ -214,7 +214,7 @@ def _get_slice(corpus, slice_): self.assertEqual(corpus_[0][0][1], docs[0][0][1] + 1) self.assertRaises(ValueError, _get_slice, corpus_, {1}) transformed_docs = [val + 1 for i, d in enumerate(docs) for _, val in d if i in [1, 3, 4]] - self.assertEquals(transformed_docs, list(v for doc in corpus_[[1, 3, 4]] for _, v in doc)) + self.assertEqual(transformed_docs, list(v for doc in corpus_[[1, 3, 4]] for _, v in doc)) self.assertEqual(3, len(corpus_[[1, 3, 4]])) else: self.assertRaises(RuntimeError, _get_slice, corpus_, [1, 3, 4]) From afe8c1360735134a1a6623927df8d0340cdea559 Mon Sep 17 00:00:00 2001 From: G POORNA PRUDHVI Date: Sat, 28 Oct 2017 13:45:52 +0530 Subject: [PATCH 4/9] Fix Deprecation Warning AssertEquals to AssertEqual --- gensim/test/test_lsimodel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gensim/test/test_lsimodel.py b/gensim/test/test_lsimodel.py index 1abeaa7f9a..ed537feaa8 100644 --- a/gensim/test/test_lsimodel.py +++ b/gensim/test/test_lsimodel.py @@ -81,8 +81,8 @@ def testTransformFloat32(self): # make sure the decomposition is enough accurate u, s, vt = scipy.linalg.svd(matutils.corpus2dense(self.corpus, self.corpus.num_terms), full_matrices=False) self.assertTrue(np.allclose(s[:2], model.projection.s)) # singular values must match - self.assertEquals(model.projection.u.dtype, np.float32) - self.assertEquals(model.projection.s.dtype, np.float32) + self.assertEqual(model.projection.u.dtype, np.float32) + self.assertEqual(model.projection.s.dtype, np.float32) # transform one document doc = list(self.corpus)[0] From 493ef83cbd7c49e05e527462f3f2366c23e68203 Mon Sep 17 00:00:00 2001 From: G POORNA PRUDHVI Date: Sat, 28 Oct 2017 16:12:25 +0530 Subject: [PATCH 5/9] Deprecation Warning Fix --- gensim/test/test_summarization.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gensim/test/test_summarization.py b/gensim/test/test_summarization.py index b20a59e512..ad9a27030c 100644 --- a/gensim/test/test_summarization.py +++ b/gensim/test/test_summarization.py @@ -99,13 +99,13 @@ def test_corpus_summarization_is_not_empty_list_on_short_input_text(self): self.assertNotEqual(summarize_corpus(corpus), []) def test_empty_text_summarization_is_empty_string(self): - self.assertEquals(summarize(""), u"") + self.assertEqual(summarize(""), u"") def test_empty_text_summarization_with_split_is_empty_list(self): - self.assertEquals(summarize("", split=True), []) + self.assertEqual(summarize("", split=True), []) def test_empty_corpus_summarization_is_empty_list(self): - self.assertEquals(summarize_corpus([]), []) + self.assertEqual(summarize_corpus([]), []) def test_corpus_summarization_ratio(self): text = self._get_text_from_test_data("mihalcea_tarau.txt") From 071104d08658e1402e96bdcb2a472b9f162e1c70 Mon Sep 17 00:00:00 2001 From: G POORNA PRUDHVI Date: Sat, 28 Oct 2017 16:14:12 +0530 Subject: [PATCH 6/9] Update test_summarization.py --- gensim/test/test_summarization.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gensim/test/test_summarization.py b/gensim/test/test_summarization.py index ad9a27030c..9b628f04d5 100644 --- a/gensim/test/test_summarization.py +++ b/gensim/test/test_summarization.py @@ -157,15 +157,15 @@ def test_low_distinct_words_corpus_summarization_is_empty_list(self): dictionary = Dictionary(tokens) corpus = [dictionary.doc2bow(sentence_tokens) for sentence_tokens in tokens] - self.assertEquals(summarize_corpus(corpus), []) + self.assertEqual(summarize_corpus(corpus), []) def test_low_distinct_words_summarization_is_empty_string(self): text = self._get_text_from_test_data("testlowdistinctwords.txt") - self.assertEquals(summarize(text), u"") + self.assertEqual(summarize(text), u"") def test_low_distinct_words_summarization_with_split_is_empty_list(self): text = self._get_text_from_test_data("testlowdistinctwords.txt") - self.assertEquals(summarize(text, split=True), []) + self.assertEqual(summarize(text, split=True), []) if __name__ == '__main__': From 8e1c01c842d7c708d4d30e8ba716c4cbecb4cb8d Mon Sep 17 00:00:00 2001 From: G POORNA PRUDHVI Date: Sat, 28 Oct 2017 16:15:28 +0530 Subject: [PATCH 7/9] Update test_utils.py --- gensim/test/test_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gensim/test/test_utils.py b/gensim/test/test_utils.py index e98c6a635e..240900129c 100644 --- a/gensim/test/test_utils.py +++ b/gensim/test/test_utils.py @@ -82,7 +82,7 @@ def test_decode_entities(self): # create a string that fails to decode with unichr on narrow python builds body = u'It’s the Year of the Horse. YES VIN DIESEL 🙌 💯' expected = u'It\x92s the Year of the Horse. YES VIN DIESEL \U0001f64c \U0001f4af' - self.assertEquals(utils.decode_htmlentities(body), expected) + self.assertEqual(utils.decode_htmlentities(body), expected) class TestSampleDict(unittest.TestCase): @@ -184,12 +184,12 @@ def test_iter_windows_with_copy(self): def test_flatten_nested(self): nested_list = [[[1, 2, 3], [4, 5]], 6] expected = [1, 2, 3, 4, 5, 6] - self.assertEquals(utils.flatten(nested_list), expected) + self.assertEqual(utils.flatten(nested_list), expected) def test_flatten_not_nested(self): not_nested = [1, 2, 3, 4, 5, 6] expected = [1, 2, 3, 4, 5, 6] - self.assertEquals(utils.flatten(not_nested), expected) + self.assertEqual(utils.flatten(not_nested), expected) if __name__ == '__main__': From 0e27256ccc6e13f2d51f0749b154782326192086 Mon Sep 17 00:00:00 2001 From: G POORNA PRUDHVI Date: Sat, 28 Oct 2017 16:30:35 +0530 Subject: [PATCH 8/9] Update test_tmdiff.py --- gensim/test/test_tmdiff.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gensim/test/test_tmdiff.py b/gensim/test/test_tmdiff.py index d6b60e8721..67ba174361 100644 --- a/gensim/test/test_tmdiff.py +++ b/gensim/test/test_tmdiff.py @@ -36,14 +36,14 @@ def testBasic(self): mdiff, annotation = self.model.diff(self.model, n_ann_terms=self.n_ann_terms) self.assertEqual(mdiff.shape, (self.num_topics, self.num_topics)) - self.assertEquals(len(annotation), self.num_topics) - self.assertEquals(len(annotation[0]), self.num_topics) + self.assertEqual(len(annotation), self.num_topics) + self.assertEqual(len(annotation[0]), self.num_topics) # test for diagonal case mdiff, annotation = self.model.diff(self.model, n_ann_terms=self.n_ann_terms, diagonal=True) self.assertEqual(mdiff.shape, (self.num_topics,)) - self.assertEquals(len(annotation), self.num_topics) + self.assertEqual(len(annotation), self.num_topics) def testIdentity(self): for dist_name in ["hellinger", "kullback_leibler", "jaccard"]: @@ -52,8 +52,8 @@ def testIdentity(self): for row in annotation: for (int_tokens, diff_tokens) in row: - self.assertEquals(diff_tokens, []) - self.assertEquals(len(int_tokens), self.n_ann_terms) + self.assertEqual(diff_tokens, []) + self.assertEqual(len(int_tokens), self.n_ann_terms) self.assertTrue(np.allclose(np.diag(mdiff), np.zeros(mdiff.shape[0], dtype=mdiff.dtype))) @@ -64,8 +64,8 @@ def testIdentity(self): mdiff, annotation = self.model.diff(self.model, n_ann_terms=self.n_ann_terms, distance=dist_name, diagonal=True) for (int_tokens, diff_tokens) in annotation: - self.assertEquals(diff_tokens, []) - self.assertEquals(len(int_tokens), self.n_ann_terms) + self.assertEqual(diff_tokens, []) + self.assertEqual(len(int_tokens), self.n_ann_terms) self.assertTrue(np.allclose(mdiff, np.zeros(mdiff.shape, dtype=mdiff.dtype))) From 66ce11ca16db8ece858fb96a2642978c2d921546 Mon Sep 17 00:00:00 2001 From: G POORNA PRUDHVI Date: Sat, 28 Oct 2017 16:32:58 +0530 Subject: [PATCH 9/9] Update test_word2vec.py --- gensim/test/test_word2vec.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gensim/test/test_word2vec.py b/gensim/test/test_word2vec.py index 20fb26ce4b..4c642ce5d2 100644 --- a/gensim/test/test_word2vec.py +++ b/gensim/test/test_word2vec.py @@ -291,11 +291,11 @@ def testPersistenceWord2VecFormat(self): self.assertFalse(np.allclose(model['human'], norm_only_model['human'])) self.assertTrue(np.allclose(model.wv.syn0norm[model.wv.vocab['human'].index], norm_only_model['human'])) limited_model_kv = keyedvectors.KeyedVectors.load_word2vec_format(testfile(), binary=True, limit=3) - self.assertEquals(len(limited_model_kv.syn0), 3) + self.assertEqual(len(limited_model_kv.syn0), 3) half_precision_model_kv = keyedvectors.KeyedVectors.load_word2vec_format( testfile(), binary=True, datatype=np.float16 ) - self.assertEquals(binary_model_kv.syn0.nbytes, half_precision_model_kv.syn0.nbytes * 2) + self.assertEqual(binary_model_kv.syn0.nbytes, half_precision_model_kv.syn0.nbytes * 2) def testNoTrainingCFormat(self): model = word2vec.Word2Vec(sentences, min_count=1)