Skip to content

Commit

Permalink
Merge 7df3929 into 211bb8c
Browse files Browse the repository at this point in the history
  • Loading branch information
terrorfisch committed Jul 28, 2020
2 parents 211bb8c + 7df3929 commit d932157
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion qupulse/utils/types.py
Expand Up @@ -219,7 +219,7 @@ def from_float(cls, value: float, absolute_error: typing.Optional[float] = None)
elif absolute_error > 1:
raise ValueError('absolute_error needs to be <= 1')
else:
return cls(qupulse_numeric.approximate_double(value, absolute_error, fraction_type=cls._InternalType))
return cls(qupulse_numeric.approximate_double(value, absolute_error, fraction_type=cls._to_internal))

@classmethod
def from_fraction(cls, numerator: int, denominator: int) -> 'TimeType':
Expand Down
2 changes: 2 additions & 0 deletions tests/utils/time_type_tests.py
Expand Up @@ -97,6 +97,8 @@ def assert_fraction_time_from_float_with_precision_works(self, time_type):
fractions.Fraction(1))
self.assertEqual(time_type.from_float(2.50000000000008, absolute_error=1e-10),
time_type.from_fraction(5, 2))
self.assertEqual(time_type.from_float(9926.666666667, absolute_error=1e-9),
time_type.from_fraction(29780, 3))

def test_fraction_time_from_float_with_precision(self):
self.assert_fraction_time_from_float_with_precision_works(qutypes.TimeType)
Expand Down

0 comments on commit d932157

Please sign in to comment.