Skip to content

Commit

Permalink
Add wv property to KeyedVectors (for backward compatibility). Fix p…
Browse files Browse the repository at this point in the history
…iskvorky#1882 (piskvorky#1884)

* adds test for `wv` property

* adds `wv` property to KeyedVectors class
  • Loading branch information
manneshiva authored and sj29-innovate committed Feb 21, 2018
1 parent 804a6cc commit fd9041e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gensim/models/keyedvectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions gensim/test/test_keyedvectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fd9041e

Please sign in to comment.