Skip to content

Commit 60b47d4

Browse files
committed
Use trim_precision function in test_groupfloats
1 parent fa76ce3 commit 60b47d4

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

tests/test_iterative.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
split_len
3232
)
3333
from domdf_python_tools.testing import check_file_regression
34+
from domdf_python_tools.utils import trim_precision
3435

3536

3637
def test_chunks():
@@ -201,15 +202,9 @@ def test_groupfloats():
201202
expects: List[Tuple[float, ...]] = [(170.0, 170.05, 170.1, 170.15), (171.05, 171.1, 171.15, 171.2)]
202203
assert list(groupfloats([170.0, 170.05, 170.1, 170.15, 171.05, 171.1, 171.15, 171.2], step=0.05)) == expects
203204

204-
trim_precision = lambda f: float(f"{f:0.4f}")
205-
206205
expects = [(170.0, 170.05, 170.1, 170.15), (171.05, 171.1, 171.15, 171.2)]
207-
values = list(
208-
map(
209-
trim_precision,
210-
[170.0, 170.05, 170.10000000000002, 170.15, 171.05, 171.10000000000002, 171.15, 171.2]
211-
)
212-
)
206+
values = [170.0, 170.05, 170.10000000000002, 170.15, 171.05, 171.10000000000002, 171.15, 171.2]
207+
values = list(map(lambda v: trim_precision(v, 4), values))
213208

214209
assert list(groupfloats(values, step=0.05)) == expects
215210

0 commit comments

Comments
 (0)