Skip to content

Commit e49ac53

Browse files
authored
Convert time units to the next integer. (#158)
1 parent 0270cc2 commit e49ac53

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

docs/source/changes.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ all releases are available on `PyPI <https://pypi.org/project/pytask>`_ and
77
`Anaconda.org <https://anaconda.org/conda-forge/pytask>`_.
88

99

10-
0.1.3 - 2021-xx-xx
10+
0.1.4 - 2021-xx-xx
11+
------------------
12+
13+
14+
0.1.3 - 2021-11-30
1115
------------------
1216

1317
- :gh:`157` adds packaging to the dependencies of the package.
18+
- :gh:`158` converts time units to the nearest integer.
1419

1520

1621
0.1.2 - 2021-11-27

src/_pytask/logging.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ def _humanize_time(amount: int, unit: str, short_label: bool = False):
130130
--------
131131
>>> _humanize_time(173, "hours")
132132
[(7, 'days'), (5, 'hours')]
133+
>>> _humanize_time(173.345, "seconds")
134+
[(2, 'minutes'), (53, 'seconds')]
133135
>>> _humanize_time(173, "hours", short_label=True)
134136
[(7, 'd'), (5, 'h')]
135137
>>> _humanize_time(0, "seconds", short_label=True)
@@ -153,7 +155,7 @@ def _humanize_time(amount: int, unit: str, short_label: bool = False):
153155
result = []
154156
remaining_seconds = seconds
155157
for entry in _TIME_UNITS:
156-
whole_units = remaining_seconds // entry["in_seconds"]
158+
whole_units = int(remaining_seconds / entry["in_seconds"])
157159
if whole_units >= 1:
158160
if short_label:
159161
label = entry["short"]
@@ -166,7 +168,7 @@ def _humanize_time(amount: int, unit: str, short_label: bool = False):
166168
result.append((whole_units, label))
167169
remaining_seconds -= whole_units * entry["in_seconds"]
168170
else:
169-
result.append((remaining_seconds, label))
171+
result.append((int(remaining_seconds), label))
170172

171173
if not result:
172174
result.append(

0 commit comments

Comments
 (0)