Download fixtures/sample_pkg/src/mathops.py from tailot/codex-python: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/datasets/tailot/codex-python/resolve/main/fixtures/sample_pkg/src/mathops.py
- Command line
-
hf download hf://datasets/tailot/codex-python/fixtures/sample_pkg/src/mathops.py
-
curl -L -o mathops.py https://huggingface.co/datasets/tailot/codex-python/resolve/main/fixtures/sample_pkg/src/mathops.py
1 kB
| """Arithmetic helpers for the sample Python fixture package.""" | |
| from __future__ import annotations | |
| class Accumulator: | |
| """Running sum helper used to verify class and method graph extraction.""" | |
| def __init__(self, initial: int = 0) -> None: | |
| self.total = initial | |
| def add(self, value: int) -> int: | |
| self.total += value | |
| return self.total | |
| class BoundedAccumulator(Accumulator): | |
| """Accumulator bounded by an upper limit.""" | |
| def __init__(self, limit: int, initial: int = 0) -> None: | |
| super().__init__(initial=initial) | |
| self.limit = limit | |
| def add(self, value: int) -> int: | |
| next_value = min(self.limit, self.total + value) | |
| self.total = next_value | |
| return self.total | |
| def add_numbers(left: int, right: int) -> int: | |
| """Return the sum of two integers.""" | |
| return left + right | |
| def double_sum(left: int, right: int) -> int: | |
| """Double the sum returned by add_numbers.""" | |
| return add_numbers(left, right) * 2 | |