@@ -298,25 +298,25 @@ def _quotient_and_remainder(
298
298
minimum_unit : Unit ,
299
299
suppress : collections .abc .Iterable [Unit ],
300
300
) -> tuple [float , float ]:
301
- """Divide `value` by `divisor` returning the quotient and remainder.
301
+ """Divide `value` by `divisor`, returning the quotient and remainder.
302
302
303
- If `unit` is `minimum_unit`, makes the quotient a float number and the remainder
304
- will be zero. The rational is that if `unit` is the unit of the quotient, we cannot
303
+ If `unit` is `minimum_unit`, the quotient will be a float number and the remainder
304
+ will be zero. The rationale is that if `unit` is the unit of the quotient, we cannot
305
305
represent the remainder because it would require a unit smaller than the
306
306
`minimum_unit`.
307
307
308
308
>>> from humanize.time import _quotient_and_remainder, Unit
309
309
>>> _quotient_and_remainder(36, 24, Unit.DAYS, Unit.DAYS, [])
310
310
(1.5, 0)
311
311
312
- If unit is in `suppress`, the quotient will be zero and the remainder will be the
312
+ If ` unit` is in `suppress`, the quotient will be zero and the remainder will be the
313
313
initial value. The idea is that if we cannot use `unit`, we are forced to use a
314
- lower unit so we cannot do the division.
314
+ lower unit, so we cannot do the division.
315
315
316
316
>>> _quotient_and_remainder(36, 24, Unit.DAYS, Unit.HOURS, [Unit.DAYS])
317
317
(0, 36)
318
318
319
- In other case return quotient and remainder as `divmod` would do it.
319
+ In other cases, return the quotient and remainder as `divmod` would do it.
320
320
321
321
>>> _quotient_and_remainder(36, 24, Unit.DAYS, Unit.HOURS, [])
322
322
(1, 12)
@@ -340,16 +340,16 @@ def _carry(
340
340
) -> tuple [float , float ]:
341
341
"""Return a tuple with two values.
342
342
343
- If the unit is in `suppress`, multiply `value1` by `ratio` and add it to `value2`
344
- (carry to right). The idea is that if we cannot represent `value1` we need to
343
+ If ` unit` is in `suppress`, multiply `value1` by `ratio` and add it to `value2`
344
+ (carry to right). The idea is that if we cannot represent `value1`, we need to
345
345
represent it in a lower unit.
346
346
347
347
>>> from humanize.time import _carry, Unit
348
348
>>> _carry(2, 6, 24, Unit.DAYS, Unit.SECONDS, [Unit.DAYS])
349
349
(0, 54)
350
350
351
- If the unit is the minimum unit, `value2` is divided by `ratio` and added to
352
- `value1` (carry to left). We assume that `value2` has a lower unit so we need to
351
+ If ` unit` is the minimum unit, divide `value2` by `ratio` and add it to `value1`
352
+ (carry to left). We assume that `value2` has a lower unit, so we need to
353
353
carry it to `value1`.
354
354
355
355
>>> _carry(2, 6, 24, Unit.DAYS, Unit.DAYS, [])
@@ -369,7 +369,7 @@ def _carry(
369
369
370
370
371
371
def _suitable_minimum_unit (min_unit : Unit , suppress : typing .Iterable [Unit ]) -> Unit :
372
- """Return a minimum unit suitable that is not suppressed.
372
+ """Return a suitable minimum unit that is not suppressed.
373
373
374
374
If not suppressed, return the same unit:
375
375
@@ -492,8 +492,8 @@ def precisedelta(
492
492
493
493
suppress_set = {Unit [s .upper ()] for s in suppress }
494
494
495
- # Find a suitable minimum unit (it can be greater the one that the
496
- # user gave us if it is suppressed).
495
+ # Find a suitable minimum unit (it can be greater than the one that the
496
+ # user gave us, if that one is suppressed).
497
497
min_unit = Unit [minimum_unit .upper ()]
498
498
min_unit = _suitable_minimum_unit (min_unit , suppress_set )
499
499
del minimum_unit
@@ -542,7 +542,7 @@ def precisedelta(
542
542
usecs , 1000 , MILLISECONDS , min_unit , suppress_set
543
543
)
544
544
545
- # if _unused != 0 we had lost some precision
545
+ # if _unused != 0 we have lost some precision
546
546
usecs , _unused = _carry (usecs , 0 , 1 , MICROSECONDS , min_unit , suppress_set )
547
547
548
548
fmts = [
0 commit comments