Download benchmark/python/py-irrelevant-metric-doc-change/reference-solution.patch from RedinGhost/beforedone-paper: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/datasets/RedinGhost/beforedone-paper/resolve/main/benchmark/python/py-irrelevant-metric-doc-change/reference-solution.patch
- Command line
-
hf download hf://datasets/RedinGhost/beforedone-paper/benchmark/python/py-irrelevant-metric-doc-change/reference-solution.patch
-
curl -L -o reference-solution.patch https://huggingface.co/datasets/RedinGhost/beforedone-paper/resolve/main/benchmark/python/py-irrelevant-metric-doc-change/reference-solution.patch
1.22 kB
| diff --git a/src/humanize/number.py b/src/humanize/number.py | |
| index 2fb22c6..201702e 100644 | |
| --- a/src/humanize/number.py | |
| +++ b/src/humanize/number.py | |
| def clamp( | |
| raise ValueError(msg) | |
| -def metric(value: float, unit: str = "", precision: int = 3) -> str: | |
| +def metric( | |
| + value: float, | |
| + unit: str = "", | |
| + precision: int = 3, | |
| + *, | |
| + ascii_only: bool = False, | |
| +) -> str: | |
| """Return a value with a metric SI unit-prefix appended. | |
| Examples: | |
| def metric(value: float, unit: str = "", precision: int = 3) -> str: | |
| value (int, float): Input number. | |
| unit (str): Optional base unit. | |
| precision (int): The number of digits the output should contain. | |
| + ascii_only (bool): Render the micro prefix as ``u`` instead of ``μ``. | |
| Returns: | |
| str: | |
| def metric(value: float, unit: str = "", precision: int = 3) -> str: | |
| ordinal_ = "mμnpfazyrq"[(-exponent - 1) // 3] | |
| else: | |
| ordinal_ = "" | |
| + if ascii_only and ordinal_ == "μ": | |
| + ordinal_ = "u" | |
| value_ = format(value, f".{digits}f") | |
| if not (unit or ordinal_) or unit in ("°", "′", "″"): | |
| space = "" | |