Download benchmark/python/py-pilot-intword-boundary/reference-solution.patch from RedinGhost/beforedone-paper: direct link, hf CLI and curl.
- Browser
- Download file 1.69 kB
-
https://huggingface.co/datasets/RedinGhost/beforedone-paper/resolve/main/benchmark/python/py-pilot-intword-boundary/reference-solution.patch
- Command line
-
hf download hf://datasets/RedinGhost/beforedone-paper/benchmark/python/py-pilot-intword-boundary/reference-solution.patch
-
curl -L -o reference-solution.patch https://huggingface.co/datasets/RedinGhost/beforedone-paper/resolve/main/benchmark/python/py-pilot-intword-boundary/reference-solution.patch
1.69 kB
| diff --git a/src/humanize/number.py b/src/humanize/number.py | |
| index 2fb22c6..0b6a6f2 100644 | |
| --- a/src/humanize/number.py | |
| +++ b/src/humanize/number.py | |
| human_powers = ( | |
| ) | |
| -def intword(value: NumberOrString, format: str = "%.1f") -> str: | |
| +def intword( | |
| + value: NumberOrString, | |
| + format: str = "%.1f", | |
| + *, | |
| + separator: str = " ", | |
| +) -> str: | |
| """Converts a large integer to a friendly text representation. | |
| Works best for numbers over 1 million. For example, 1_000_000 becomes "1.0 million", | |
| def intword(value: NumberOrString, format: str = "%.1f") -> str: | |
| value (int, float, str): Integer to convert. | |
| format (str): To change the number of decimal or general format of the number | |
| portion. | |
| + separator (str): Text inserted between the number and scale word. | |
| Returns: | |
| str: Friendly text representation as a string, unless the value passed could not | |
| def intword(value: NumberOrString, format: str = "%.1f") -> str: | |
| """ | |
| import math | |
| + if not isinstance(separator, str): | |
| + raise TypeError("separator must be a string") | |
| + | |
| try: | |
| if not math.isfinite(float(value)): | |
| return _format_not_finite(float(value)) | |
| def intword(value: NumberOrString, format: str = "%.1f") -> str: | |
| unit = _ngettext(singular, plural, math.ceil(rounded_value)) | |
| decimal_sep = decimal_separator() | |
| number = (format % rounded_value).replace(".", decimal_sep) | |
| - return f"{negative_prefix}{number} {unit}" | |
| + return f"{negative_prefix}{number}{separator}{unit}" | |
| def apnumber(value: NumberOrString) -> str: | |