Datasets:
Download code/evaluation-code/ent400-a06a1576/tools/release/numeric_choice.py from VEHwang/cocogni4d: direct link, hf CLI and curl.
- Browser
- Download file 830 Bytes
-
https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/ent400-a06a1576/tools/release/numeric_choice.py
- Command line
-
hf download hf://datasets/VEHwang/cocogni4d/code/evaluation-code/ent400-a06a1576/tools/release/numeric_choice.py
-
curl -L -o numeric_choice.py https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/ent400-a06a1576/tools/release/numeric_choice.py
830 Bytes
| """Display grid of numeric options: one decimal place, for the stored value and the text alike.""" | |
| from dataclasses import dataclass | |
| class Format: | |
| def value(self, value): | |
| """Round to the displayed decimal (same rounding as text), normalizing signed zero: stored value == shown value.""" | |
| if isinstance(value, list): | |
| return [self.value(x) for x in value] | |
| rounded = float(f"{value:.1f}") | |
| return 0. if rounded == 0 else rounded | |
| def text(self, value): | |
| """Plain decimal with one digit after the point (options are already quantized), also per vector component.""" | |
| if isinstance(value, list): | |
| return "[" + ", ".join(self.text(x) for x in value) + "]" | |
| text = f"{value:.1f}" | |
| return "0.0" if text == "-0.0" else text | |