diff --git a/gensim/models/keyedvectors.py b/gensim/models/keyedvectors.py index c17505cf06..b35a974f4f 100644 --- a/gensim/models/keyedvectors.py +++ b/gensim/models/keyedvectors.py @@ -198,6 +198,11 @@ def __init__(self, vector_size): self.vectors_norm = None self.index2word = [] + @property + @deprecated("Attribute will be removed in 4.0.0, use self instead") + def wv(self): + return self + @property def index2entity(self): return self.index2word diff --git a/gensim/test/test_keyedvectors.py b/gensim/test/test_keyedvectors.py index f013efa439..b3e03fb470 100644 --- a/gensim/test/test_keyedvectors.py +++ b/gensim/test/test_keyedvectors.py @@ -149,6 +149,10 @@ def test_rank(self): self.assertEqual(self.vectors.rank('war', 'war'), 1) self.assertEqual(self.vectors.rank('war', 'terrorism'), 3) + def test_wv_property(self): + """Test that the deprecated `wv` property returns `self`. To be removed in v4.0.0.""" + self.assertTrue(self.vectors is self.vectors.wv) + if __name__ == '__main__': logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.DEBUG)