-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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 #1230. Fix word2vec reset_from bug in v1.0.1 and added unittest #1234
Conversation
Please fix the typo to make unit tests pass. |
Typo fixed, tests passed. |
gensim/test/test_word2vec.py
Outdated
"""Test if exception is raised when reset_from is used""" | ||
model = word2vec.Word2Vec(sentences, min_count=1) | ||
model2 = word2vec.Word2Vec(new_sentences, min_count=1) | ||
self.assertRaises(AttributeError, model.reset_from(model2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does it raise an error? A positive outcome is expected. Please change this test to a positive test.
gensim/test/test_word2vec.py
Outdated
try: | ||
model.reset_from(model2) | ||
except AttributeError: | ||
self.fail('AttributeError in reset_from()') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the purpose of this line? what would be different if it was removed?
gensim/test/test_word2vec.py
Outdated
@@ -678,6 +678,16 @@ def test_sentences_should_not_be_a_generator(self): | |||
def testLoadOnClassError(self): | |||
"""Test if exception is raised when loading word2vec model on instance""" | |||
self.assertRaises(AttributeError, load_on_instance) | |||
|
|||
def test_reset_from(self): | |||
"""Test if exception is raised when reset_from is used""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there some reason that exception should be raised when reset_from is used? correct behavious is no exception. please add checks that the model is actually reset.
gensim/test/test_word2vec.py
Outdated
try: | ||
model.reset_from(model2) | ||
except AttributeError: | ||
self.fail('AttributeError in reset_from()') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because an uncaught error will result in a test failure, this catch-then-fail seems superfluous - it's enough to try the reset_from()
, and do some afterwards checking that it's had the intended effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, it is not needed and I just updated the test.
Thanks for the fix! |
Happy I could help ;) |
Fixed reset_from attribute bug in gensim 1.0.1 version.