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 #1230. Fix word2vec reset_from bug in v1.0.1 and added unittest #1234

Merged
merged 34 commits into from
Mar 27, 2017

Conversation

Kreiswolke
Copy link
Contributor

Fixed reset_from attribute bug in gensim 1.0.1 version.

@Kreiswolke Kreiswolke changed the title 1230 1230 Fixed word2vec reset_from bug in v1.0.1 and added unittest Mar 22, 2017
@tmylk
Copy link
Contributor

tmylk commented Mar 22, 2017

Please fix the typo to make unit tests pass.

@tmylk tmylk changed the title 1230 Fixed word2vec reset_from bug in v1.0.1 and added unittest Fix #1230. Fix word2vec reset_from bug in v1.0.1 and added unittest Mar 22, 2017
@Kreiswolke
Copy link
Contributor Author

Typo fixed, tests passed.

"""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))
Copy link
Contributor

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.

try:
model.reset_from(model2)
except AttributeError:
self.fail('AttributeError in reset_from()')
Copy link
Contributor

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?

@@ -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"""
Copy link
Contributor

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.

try:
model.reset_from(model2)
except AttributeError:
self.fail('AttributeError in reset_from()')
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@tmylk tmylk merged commit d00b6c1 into piskvorky:develop Mar 27, 2017
@tmylk
Copy link
Contributor

tmylk commented Mar 27, 2017

Thanks for the fix!

@Kreiswolke
Copy link
Contributor Author

Happy I could help ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants