Merge pull request #5593 from skallet/mtdev-division-fix

Fix float division by zero
This commit is contained in:
Akshay Arora 2018-02-03 01:01:09 +05:30 committed by GitHub
commit 4c62d76c92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -220,7 +220,10 @@ else:
queue.append((action, touch))
def normalize(value, vmin, vmax):
return (value - vmin) / float(vmax - vmin)
try:
return (value - vmin) / float(vmax - vmin)
except ZeroDivisionError: # it's both in py2 and py3
return (value - vmin)
# open mtdev device
_fn = input_fn