From 6604dca2131c25a3f06020ee3c2437e1d87d4399 Mon Sep 17 00:00:00 2001 From: Michael Penkov Date: Thu, 15 Dec 2022 21:37:35 +0900 Subject: [PATCH 1/2] add missing model file --- .../test/test_data/model-from-gensim-3.8.0.w2v | Bin 0 -> 18926 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 gensim/test/test_data/model-from-gensim-3.8.0.w2v diff --git a/gensim/test/test_data/model-from-gensim-3.8.0.w2v b/gensim/test/test_data/model-from-gensim-3.8.0.w2v new file mode 100644 index 0000000000000000000000000000000000000000..40f7e22e32741c0e2f220dca87c6b3948dfab2aa GIT binary patch literal 18926 zcmeHvX;YM4w;rH^B7zDEDuM$lh=8aFy;Tq=6r2DRP_b>AmPW>#ZYDvQCjps9nFj$8 znUQWlPS(mi=Op<9`E;sMm8yKmw^Sw9ZhfBjByUyn0}fgR-S@qRwbyX1wfA0&QX6fG zF4K^j;h&L}tV=ie=V#?4U&zyG?c?N!XZWC4`IITv?-d*Gcqc0>s|-zn`b}!4CS9GE zrPU-U+aAX6!egx_Jv~XIO*1Iled4#{L3)-ZS=sT&=()z!bc4NYq|VAzYtuCb13sh| z+AFs4HfWunr`Y|`_BSPIxqa5&#vX0vJ;GA`}a`5+< z$;QHLbak~X?ad{{t**94ITWKD_KwGjEZ|wo!%)v_<)ra z)loZ@3$Eo=`YA$rg=@%sj>l70+@H4G5ad3Rcl_k(=P9Vs29z?(;OQ#s$$l znfV7ba9OZ#6!nogoU5oxTsX*`WOn2!ni15n^ReJMZlgYt8AIh{b`C`&^NX|GE4VqB zzM&UQ6$@?%qcvLP`VcNt(Lx|~lldBd&n5Hi6j~IQUpQc{ubM0P*~w<^AQKJq>|tR| z3;1uQX5OGqGDV)|Ph{TBbGOJGKrQKb^NA-t#aaGIJ!HDXd&Vk70vLnv*3kjZ;UWT8<)wf1I-`F?27>h z1(&ngPf!Q9bGz{3ekvpLK3XhNd0q+^yhc?#NUMq7TqDjH?g<{SqG2+7@$xBwbq`S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d03a2463026a425 Mon Sep 17 00:00:00 2001 From: Michael Penkov Date: Thu, 15 Dec 2022 21:38:45 +0900 Subject: [PATCH 2/2] update test --- gensim/models/word2vec.py | 3 --- gensim/test/test_word2vec.py | 7 +++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gensim/models/word2vec.py b/gensim/models/word2vec.py index b172f57c8a..d4a4ba992e 100755 --- a/gensim/models/word2vec.py +++ b/gensim/models/word2vec.py @@ -1986,9 +1986,6 @@ def _load_specials(self, *args, **kwargs): for a in ('hashfxn', 'layer1_size', 'seed', 'syn1neg', 'syn1'): if hasattr(self.trainables, a): setattr(self, a, getattr(self.trainables, a)) - if hasattr(self, 'syn1'): - self.syn1 = self.syn1 - del self.syn1 del self.trainables if not hasattr(self, 'shrink_windows'): self.shrink_windows = True diff --git a/gensim/test/test_word2vec.py b/gensim/test/test_word2vec.py index d1749e4bfa..a07cf08b10 100644 --- a/gensim/test/test_word2vec.py +++ b/gensim/test/test_word2vec.py @@ -275,6 +275,13 @@ def test_persistence(self): self.assertTrue(np.allclose(wv.vectors, loaded_wv.vectors)) self.assertEqual(len(wv), len(loaded_wv)) + def test_persistence_backwards_compatible(self): + """Can we still load a model created with an older gensim version?""" + path = datapath('model-from-gensim-3.8.0.w2v') + model = word2vec.Word2Vec.load(path) + x = model.score(['test']) + assert x is not None + def test_persistence_from_file(self): """Test storing/loading the entire model trained with corpus_file argument.""" with temporary_file(get_tmpfile('gensim_word2vec.tst')) as corpus_file: