errorbars 0.2.1__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {errorbars-0.2.1 → errorbars-0.2.2}/.gitignore +1 -0
- {errorbars-0.2.1 → errorbars-0.2.2}/CHANGELOG.md +21 -0
- {errorbars-0.2.1 → errorbars-0.2.2}/PKG-INFO +1 -1
- {errorbars-0.2.1 → errorbars-0.2.2}/pyproject.toml +1 -1
- {errorbars-0.2.1 → errorbars-0.2.2}/src/errorbars/__init__.py +1 -1
- {errorbars-0.2.1 → errorbars-0.2.2}/src/errorbars/adapters/lm_eval.py +2 -2
- {errorbars-0.2.1 → errorbars-0.2.2}/src/errorbars/cli.py +18 -0
- {errorbars-0.2.1 → errorbars-0.2.2}/src/errorbars/inputs.py +1 -1
- {errorbars-0.2.1 → errorbars-0.2.2}/src/errorbars/io.py +58 -11
- {errorbars-0.2.1 → errorbars-0.2.2}/LICENSE +0 -0
- {errorbars-0.2.1 → errorbars-0.2.2}/README.md +0 -0
- {errorbars-0.2.1 → errorbars-0.2.2}/docs/formulas.md +0 -0
- {errorbars-0.2.1 → errorbars-0.2.2}/src/errorbars/_tables.py +0 -0
- {errorbars-0.2.1 → errorbars-0.2.2}/src/errorbars/adapters/__init__.py +0 -0
- {errorbars-0.2.1 → errorbars-0.2.2}/src/errorbars/adapters/inspect_ai.py +0 -0
- {errorbars-0.2.1 → errorbars-0.2.2}/src/errorbars/compare.py +0 -0
- {errorbars-0.2.1 → errorbars-0.2.2}/src/errorbars/leaderboard.py +0 -0
- {errorbars-0.2.1 → errorbars-0.2.2}/src/errorbars/plot.py +0 -0
- {errorbars-0.2.1 → errorbars-0.2.2}/src/errorbars/power.py +0 -0
- {errorbars-0.2.1 → errorbars-0.2.2}/src/errorbars/py.typed +0 -0
- {errorbars-0.2.1 → errorbars-0.2.2}/src/errorbars/stats.py +0 -0
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.2.2] - 2026-10-02
|
|
6
|
+
|
|
7
|
+
Files and pipes as Windows and spreadsheets make them.
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- A CSV saved from a spreadsheet. Excel's "CSV UTF-8" starts with a byte-order
|
|
12
|
+
mark, which became part of the first column's name: "missing required column
|
|
13
|
+
'question_id' in row 1" for a file that has it. A spreadsheet in a locale
|
|
14
|
+
whose decimal mark is the comma writes semicolons between the fields and
|
|
15
|
+
`0,75` for a score, which failed the same way. The mark is skipped, the
|
|
16
|
+
delimiter (comma, semicolon or tab) is the one that splits the header into
|
|
17
|
+
the required columns, and decimal commas are read when the delimiter is not
|
|
18
|
+
the comma.
|
|
19
|
+
- That error now lists the columns the file does have.
|
|
20
|
+
- Output written to a pipe or a file is UTF-8. Before 3.15, Python on Windows
|
|
21
|
+
gives a redirected stdout the system's code page, so
|
|
22
|
+
`errorbars leaderboard scores.csv > table.txt` with a model name outside it
|
|
23
|
+
stopped with "'charmap' codec can't encode characters". (Reproduced on Linux
|
|
24
|
+
by giving the pipe cp1252 with `PYTHONIOENCODING`; the test does the same.)
|
|
25
|
+
|
|
5
26
|
## [0.2.1] - 2026-10-02
|
|
6
27
|
|
|
7
28
|
What the table commands print, checked the way their output is read: after `pip install
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: errorbars
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Error bars for LLM evals: standard errors, clustering, paired comparisons, leaderboards, and power analysis.
|
|
5
5
|
Project-URL: Homepage, https://antonsoo.github.io/errorbars/
|
|
6
6
|
Project-URL: Repository, https://github.com/antonsoo/errorbars
|
|
@@ -32,7 +32,7 @@ include = ["/src", "/docs/*.md", "/README.md", "/CHANGELOG.md", "/LICENSE*", "/p
|
|
|
32
32
|
|
|
33
33
|
[project]
|
|
34
34
|
name = "errorbars"
|
|
35
|
-
version = "0.2.
|
|
35
|
+
version = "0.2.2"
|
|
36
36
|
description = "Error bars for LLM evals: standard errors, clustering, paired comparisons, leaderboards, and power analysis."
|
|
37
37
|
dynamic = ["readme"]
|
|
38
38
|
license = "MIT"
|
|
@@ -91,7 +91,7 @@ def infer_model_name(path: str | Path) -> str | None:
|
|
|
91
91
|
candidates = others
|
|
92
92
|
for candidate in candidates:
|
|
93
93
|
try:
|
|
94
|
-
with open(candidate, encoding="utf-8") as f:
|
|
94
|
+
with open(candidate, encoding="utf-8-sig") as f:
|
|
95
95
|
results = json.load(f)
|
|
96
96
|
except (OSError, ValueError):
|
|
97
97
|
continue
|
|
@@ -137,7 +137,7 @@ def load_lm_eval_samples(
|
|
|
137
137
|
|
|
138
138
|
records: list[tuple[int, dict[str, object]]] = []
|
|
139
139
|
filters: dict[str, None] = {} # in order of first appearance
|
|
140
|
-
with open(path, encoding="utf-8") as f:
|
|
140
|
+
with open(path, encoding="utf-8-sig") as f:
|
|
141
141
|
for lineno, raw_line in enumerate(f, start=1):
|
|
142
142
|
line = raw_line.strip()
|
|
143
143
|
if not line:
|
|
@@ -476,9 +476,27 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
476
476
|
return parser
|
|
477
477
|
|
|
478
478
|
|
|
479
|
+
def _text_streams() -> None:
|
|
480
|
+
"""Make stdout and stderr able to carry any text.
|
|
481
|
+
|
|
482
|
+
A pipe or a file gets UTF-8: before 3.15, Python on Windows gives it the system's code
|
|
483
|
+
page, where a model name outside it raised ``UnicodeEncodeError``. A terminal keeps its own encoding
|
|
484
|
+
and shows a character it cannot encode as an escape.
|
|
485
|
+
"""
|
|
486
|
+
for stream in (sys.stdout, sys.stderr):
|
|
487
|
+
reconfigure = getattr(stream, "reconfigure", None)
|
|
488
|
+
if reconfigure is None: # replaced by something that isn't a text file
|
|
489
|
+
continue
|
|
490
|
+
if stream.isatty():
|
|
491
|
+
reconfigure(errors="backslashreplace")
|
|
492
|
+
else:
|
|
493
|
+
reconfigure(encoding="utf-8")
|
|
494
|
+
|
|
495
|
+
|
|
479
496
|
def main(argv: list[str] | None = None) -> None:
|
|
480
497
|
parser = build_parser()
|
|
481
498
|
args = parser.parse_args(argv)
|
|
499
|
+
_text_streams()
|
|
482
500
|
try:
|
|
483
501
|
args.func(args)
|
|
484
502
|
except UnicodeDecodeError as exc:
|
|
@@ -11,6 +11,7 @@ from __future__ import annotations
|
|
|
11
11
|
import csv
|
|
12
12
|
import json
|
|
13
13
|
import math
|
|
14
|
+
import re
|
|
14
15
|
from collections.abc import Iterable
|
|
15
16
|
from dataclasses import dataclass, field
|
|
16
17
|
from pathlib import Path
|
|
@@ -166,6 +167,14 @@ def _label(row: Any, column: str, n: int) -> str:
|
|
|
166
167
|
return str(value)
|
|
167
168
|
|
|
168
169
|
|
|
170
|
+
def _names(row: dict[str, Any]) -> str:
|
|
171
|
+
"""A row's field names for an error message: the first ten, each cut to a readable length."""
|
|
172
|
+
names = [str(name) for name in row]
|
|
173
|
+
shown = [name if len(name) <= 40 else name[:39] + "\u2026" for name in names[:10]]
|
|
174
|
+
more = f", and {len(names) - 10} more" if len(names) > 10 else ""
|
|
175
|
+
return (", ".join(shown) + more) or "no fields"
|
|
176
|
+
|
|
177
|
+
|
|
169
178
|
def _from_records(records: Iterable[dict[str, Any]], columns: ColumnMap) -> EvalData:
|
|
170
179
|
question_id: list[str] = []
|
|
171
180
|
model: list[str] = []
|
|
@@ -184,12 +193,11 @@ def _from_records(records: Iterable[dict[str, Any]], columns: ColumnMap) -> Eval
|
|
|
184
193
|
raise ValueError(
|
|
185
194
|
f"row {n}: more fields than the header has columns (an unquoted comma in a value?)"
|
|
186
195
|
)
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
raise ValueError(f"missing required column '{columns.score}' in row {n}")
|
|
196
|
+
for required in (columns.question_id, columns.model, columns.score):
|
|
197
|
+
if required not in row:
|
|
198
|
+
raise ValueError(
|
|
199
|
+
f"missing required column '{required}' in row {n} (it has: {_names(row)})"
|
|
200
|
+
)
|
|
193
201
|
question_id.append(_label(row, columns.question_id, n))
|
|
194
202
|
model.append(_label(row, columns.model, n))
|
|
195
203
|
score.append(_coerce_score(row[columns.score], n))
|
|
@@ -214,21 +222,60 @@ def _from_records(records: Iterable[dict[str, Any]], columns: ColumnMap) -> Eval
|
|
|
214
222
|
return EvalData(question_id, model, score, cluster_id, sample, columns)
|
|
215
223
|
|
|
216
224
|
|
|
225
|
+
def _delimiter(header: str, columns: ColumnMap) -> str:
|
|
226
|
+
"""The delimiter the header was written with.
|
|
227
|
+
|
|
228
|
+
A spreadsheet saves "CSV" with the list separator of its locale: a semicolon wherever the
|
|
229
|
+
decimal mark is a comma (most of Europe), sometimes a tab. The header settles it: the
|
|
230
|
+
delimiter is the one that splits it into the columns being looked for.
|
|
231
|
+
"""
|
|
232
|
+
wanted = {columns.question_id, columns.model, columns.score}
|
|
233
|
+
for delimiter in (",", ";", "\t"):
|
|
234
|
+
names = {name.strip() for name in next(csv.reader([header], delimiter=delimiter), [])}
|
|
235
|
+
if wanted <= names:
|
|
236
|
+
return delimiter
|
|
237
|
+
return ","
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
_DECIMAL_COMMA = re.compile(r"[+-]?\d+,\d+(?:[eE][+-]?\d+)?")
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def _decimal_commas(records: Iterable[dict[str, Any]], score: str) -> Iterable[dict[str, Any]]:
|
|
244
|
+
"""Scores written ``0,75`` in a file whose delimiter is not the comma."""
|
|
245
|
+
for row in records:
|
|
246
|
+
value = row.get(score)
|
|
247
|
+
if isinstance(value, str) and _DECIMAL_COMMA.fullmatch(value.strip()):
|
|
248
|
+
row[score] = value.strip().replace(",", ".")
|
|
249
|
+
yield row
|
|
250
|
+
|
|
251
|
+
|
|
217
252
|
def load_csv(path: str | Path, columns: ColumnMap | None = None) -> EvalData:
|
|
218
|
-
"""Load per-item scores from a CSV file.
|
|
253
|
+
"""Load per-item scores from a CSV file.
|
|
254
|
+
|
|
255
|
+
Read as a spreadsheet writes it too: with a byte-order mark ("CSV UTF-8" in Excel), with
|
|
256
|
+
semicolons or tabs between the fields, and with decimal commas when the delimiter is not
|
|
257
|
+
the comma.
|
|
258
|
+
"""
|
|
219
259
|
columns = columns or ColumnMap()
|
|
220
|
-
with open(path, newline="", encoding="utf-8") as f:
|
|
221
|
-
|
|
260
|
+
with open(path, newline="", encoding="utf-8-sig") as f:
|
|
261
|
+
header = f.readline()
|
|
262
|
+
f.seek(0)
|
|
263
|
+
delimiter = _delimiter(header, columns)
|
|
264
|
+
reader = csv.DictReader(f, delimiter=delimiter)
|
|
222
265
|
if reader.fieldnames is None:
|
|
223
266
|
raise ValueError(f"{path}: empty or headerless CSV")
|
|
224
|
-
|
|
267
|
+
reader.fieldnames = [name.strip() for name in reader.fieldnames]
|
|
268
|
+
records: Iterable[dict[str, Any]] = reader
|
|
269
|
+
if delimiter != ",":
|
|
270
|
+
records = _decimal_commas(reader, columns.score)
|
|
271
|
+
return _from_records(records, columns)
|
|
225
272
|
|
|
226
273
|
|
|
227
274
|
def load_jsonl(path: str | Path, columns: ColumnMap | None = None) -> EvalData:
|
|
228
275
|
"""Load per-item scores from a JSON Lines file (one record per line)."""
|
|
229
276
|
columns = columns or ColumnMap()
|
|
230
277
|
records: list[dict[str, Any]] = []
|
|
231
|
-
with open(path, encoding="utf-8") as f:
|
|
278
|
+
with open(path, encoding="utf-8-sig") as f:
|
|
232
279
|
for lineno, line in enumerate(f, start=1):
|
|
233
280
|
line = line.strip()
|
|
234
281
|
if not line:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|