aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--mdpoly/util.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/mdpoly/util.py b/mdpoly/util.py
index ed7c234..937e7d4 100644
--- a/mdpoly/util.py
+++ b/mdpoly/util.py
@@ -1,7 +1,6 @@
from .constants import NUMERICS_EPS
from itertools import tee, filterfalse
-from math import abs
def partition(pred, iterable):
"""Partition entries into false entries and true entries.
@@ -14,8 +13,20 @@ def partition(pred, iterable):
def isclose(x: float, y: float, eps: float =NUMERICS_EPS) -> bool:
+ r""" Check if two numbers are close.
+
+ Close means :math:`|x - y| < \varepsilon` where :math:`\varepsilon` is the
+ given ``eps`` or the default value at
+ :py:data:`mdpoly.constants.NUMERICS_EPS`.
+ """
+ # TODO: probably faster with math.isclose
return abs(x - y) < eps
def iszero(x: float, eps: float =NUMERICS_EPS) -> bool:
+ r""" Check a number is zero.
+
+ Being zero means :math:`|x| < \varepsilon` where :math:`\varepsilon` is the given
+ ``eps`` or the default value at :py:data:`mdpoly.constants.NUMERICS_EPS`.
+ """
return isclose(x, 0.)