Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Deprecation Warning #1658

Merged
merged 9 commits into from
Oct 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions gensim/test/test_corpora.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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])
Expand Down
32 changes: 16 additions & 16 deletions gensim/test/test_fasttext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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))

Expand Down
32 changes: 16 additions & 16 deletions gensim/test/test_fasttext_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions gensim/test/test_lsimodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
12 changes: 6 additions & 6 deletions gensim/test/test_summarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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__':
Expand Down
14 changes: 7 additions & 7 deletions gensim/test/test_tmdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand All @@ -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)))

Expand All @@ -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)))

Expand Down
6 changes: 3 additions & 3 deletions gensim/test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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__':
Expand Down
4 changes: 2 additions & 2 deletions gensim/test/test_word2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down