X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=math_utils.py;h=37fcec5f6c557cdf1a66d39b671fd8d9438ba29c;hb=804988efe7c8b131fc0c4b30088de2b5c5bd0b74;hp=3953ae585d249123c17e82f4a829ad68cf442c0b;hpb=31c81f6539969a5eba864d3305f9fb7bf716a367;p=python_utils.git diff --git a/math_utils.py b/math_utils.py index 3953ae5..37fcec5 100644 --- a/math_utils.py +++ b/math_utils.py @@ -1,5 +1,7 @@ #!/usr/bin/env python3 +"""Mathematical helpers.""" + import functools import math from heapq import heappop, heappush @@ -76,8 +78,8 @@ def truncate_float(n: float, decimals: int = 2): 3.141 """ - assert decimals > 0 and decimals < 10 - multiplier = 10 ** decimals + assert 0 < decimals < 10 + multiplier = 10**decimals return int(n * multiplier) / multiplier