Skip to content

Commit

Permalink
Merge pull request #202 from sv99/201
Browse files Browse the repository at this point in the history
Fix #201

NameError name 'Fraction' is not defined
  • Loading branch information
waveform80 committed Mar 2, 2015
2 parents 98df914 + b5d3f28 commit 16a9f70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion picamera/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def to_rational(value):
"int, float, Decimal, or Fraction instead"))
except (TypeError, ValueError):
# try and convert anything else (e.g. Decimal) to a Fraction
value = Fraction(value)
value = fractions.Fraction(value)
n, d = value.numerator, value.denominator
# Ensure denominator is reasonable
if d == 0:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,3 +434,8 @@ def test_resolution(camera, previewing):
finally:
camera.resolution = save_resolution

def test_to_rational():
n, d = camera.to_rational(1)
assert d == 1
n, d = camera.to_rational(Decimal(1))
assert d == 1

0 comments on commit 16a9f70

Please sign in to comment.