Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qupulse/utils/types.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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