Skip to content

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?

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