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

Minor changes in fresh PRs (pep8, misprints, etc) #1369

Merged
merged 14 commits into from
May 29, 2017

Conversation

menshikh-iv
Copy link
Contributor

@menshikh-iv menshikh-iv commented May 27, 2017

I have fixed all recent comments from you @piskvorky + some code style fixes. Now it's okay?

cc @tmylk

@chinmayapancholi13
Copy link
Contributor

@menshikh-iv Could you please also incorporate a minor PEP8 suggestion made by @piskvorky here. Since you are making all such fixes in this PR, I though it would be a good idea to bring this change to your notice as well. :)

Copy link
Owner

@piskvorky piskvorky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more minor suggestions.

return 1. - float(len(set1 & set2)) / float(len(set1 | set2))
"""
A distance metric between set representation.
Returns 1 minus the intersection divided by union.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP257: docstrings in imperative mode ("do X, return Y", not "does X, returns Y").

"""
A distance metric between set representation.
Returns 1 minus the intersection divided by union.
Returns a value in range <0, 1> where values closer to 0 mean less distance and thus higher similarity.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

less => smaller.

I see this is a potential gotcha for our users, because other metrics in gensim are similarity (not distance). How about we put this info directly into the method name -- jaccard_distance instead of jaccard_set?

@menshikh-iv
Copy link
Contributor Author

@chinmayapancholi13 thank you

@menshikh-iv
Copy link
Contributor Author

@piskvorky Need to walk with an automatic tool throughout the code (especially the old one) and fix code style issues (it will be a very big diff)

@menshikh-iv
Copy link
Contributor Author

But this is very important. New users come and write code according to the code they see (this code is not perfect).

@menshikh-iv menshikh-iv merged commit 944d621 into piskvorky:develop May 29, 2017
@piskvorky
Copy link
Owner

piskvorky commented May 30, 2017

Agreed! Fixing the existing code has been our priority for a long time now.

Except don't use an automatic tool please (except as rough guidance). Use common sense to make the code readable and easy to understand and maintain, and at the same time catch other non-PEP8 lapses too: direct formatting of strings inside logger.info, comprehensions (we're now 2.7+, no longer support 2.5 or 2.6, so the syntax is much simpler), hanging indents, docstring/comment typos etc.

@menshikh-iv menshikh-iv deleted the pep8_and_minor_changes branch May 30, 2017 03:53
@tmylk
Copy link
Contributor

tmylk commented May 30, 2017

Automatic linters are the solution for code style adopted in most projects, for example see this presentation from itertools maintainer.

@piskvorky
Copy link
Owner

piskvorky commented May 30, 2017

If it works well, sure.

There was one PR produced by an automatic linter recently, and that's definitely not what we want in gensim.

@menshikh-iv
Copy link
Contributor Author

I think It's a good idea to use linter for highlight the mistakes in codestyle, but fix it manually. Also, now flake8 break the build if some PEP8 problem founded in PR code and a user can fix them by reading the Travis log.

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.

None yet

4 participants