D6123: similar: add condition to avoid Zerodivisonerror in function _score() (issue6099)
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Fri Mar 15 09:44:41 EDT 2019
pulkit added a comment.
Can you try to add a test for this?
INLINE COMMENTS
> similar.py:66
> lengths = len(text) + len(orig)
> - return equal * 2.0 / lengths
> + if lengths != 0:
> + return equal * 2.0 / lengths
we can do `if lengths:` here.
> similar.py:68
> + return equal * 2.0 / lengths
> + else:
> + return 0
no need for this else. you can `return 0` without else.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D6123
To: akshjain.jain74, durin42, #hg-reviewers
Cc: av6, pulkit, mercurial-devel
More information about the Mercurial-devel
mailing list