errorbars 0.2.2__py3-none-any.whl → 0.2.4__py3-none-any.whl

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/__init__.py CHANGED
@@ -13,7 +13,7 @@ from errorbars.stats import (
13
13
  within_between_variance,
14
14
  )
15
15
 
16
- __version__ = "0.2.2"
16
+ __version__ = "0.2.4"
17
17
 
18
18
  __all__ = [
19
19
  "__version__",
errorbars/_tables.py CHANGED
@@ -12,10 +12,14 @@ terminal follows three rules, each of which the first version of this broke:
12
12
  columns wide and cuts each cell to fit, which left two models of one organisation with the
13
13
  same visible name. A pipe gets the table at its full width, and a terminal too narrow for
14
14
  it gets the long cells folded onto more lines.
15
+ - A name is printed as text. A control character in one (the ESC that starts a terminal escape
16
+ sequence) is written as a visible escape, ``\\x1b``, instead of being sent to the terminal,
17
+ where it could clear the screen, retitle the window or hide the rest of the line.
15
18
  """
16
19
 
17
20
  from __future__ import annotations
18
21
 
22
+ import re
19
23
  from dataclasses import dataclass, field
20
24
  from typing import Literal
21
25
 
@@ -27,12 +31,32 @@ try:
27
31
  except ImportError: # pragma: no cover - exercised by the test that hides rich
28
32
  HAS_RICH = False
29
33
 
30
- __all__ = ["HAS_RICH", "Output", "Table"]
34
+ __all__ = ["HAS_RICH", "Output", "Table", "visible"]
31
35
 
32
36
  Justify = Literal["left", "right"]
33
37
 
34
38
  _UNBOUNDED = 100_000
35
39
 
40
+ _CONTROL = re.compile(r"[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]")
41
+
42
+
43
+ def visible(text: str) -> str:
44
+ """``text`` with each control character (bar tab and line breaks) written as ``\\xNN``.
45
+
46
+ Model names, question ids and the values in an error come from the data, and a terminal
47
+ obeys the escape sequences in what it is given.
48
+ """
49
+ return _CONTROL.sub(lambda m: f"\\x{ord(m.group()):02x}", text)
50
+
51
+
52
+ def _visible_table(table: Table) -> Table:
53
+ return Table(
54
+ title=visible(table.title),
55
+ header_style=table.header_style,
56
+ columns=[(visible(header), justify) for header, justify in table.columns],
57
+ rows=[tuple(visible(cell) for cell in row) for row in table.rows],
58
+ )
59
+
36
60
 
37
61
  @dataclass
38
62
  class Table:
@@ -82,6 +106,7 @@ class Output:
82
106
  return Console(markup=False, emoji=False, highlight=False, width=width)
83
107
 
84
108
  def table(self, table: Table) -> None:
109
+ table = _visible_table(table)
85
110
  if not self._rich:
86
111
  if not self._first:
87
112
  print()
@@ -106,6 +131,7 @@ class Output:
106
131
  self._first = False
107
132
 
108
133
  def note(self, text: str, style: str | None = None) -> None:
134
+ text = visible(text)
109
135
  if self._rich:
110
136
  self._console().print(text, style=style)
111
137
  else:
errorbars/cli.py CHANGED
@@ -9,7 +9,7 @@ from pathlib import Path
9
9
  from typing import Any
10
10
 
11
11
  from errorbars import __version__
12
- from errorbars._tables import Output, Table
12
+ from errorbars._tables import Output, Table, visible
13
13
  from errorbars.compare import paired_compare
14
14
  from errorbars.inputs import load_inputs
15
15
  from errorbars.io import ColumnMap, EvalData, write_csv
@@ -41,7 +41,7 @@ def _load(args: argparse.Namespace, model: str | None = None) -> EvalData:
41
41
  except ImportError as exc:
42
42
  raise SystemExit(f"error: {exc}") from exc
43
43
  for note in loaded.notes:
44
- print(f"note: {note}", file=sys.stderr)
44
+ print(f"note: {visible(note)}", file=sys.stderr)
45
45
  return loaded.data
46
46
 
47
47
 
@@ -497,6 +497,16 @@ def main(argv: list[str] | None = None) -> None:
497
497
  parser = build_parser()
498
498
  args = parser.parse_args(argv)
499
499
  _text_streams()
500
+ try:
501
+ _run(args)
502
+ except SystemExit as exc:
503
+ # The messages quote models, files and values from the data.
504
+ if isinstance(exc.code, str):
505
+ raise SystemExit(visible(exc.code)) from exc.__cause__
506
+ raise
507
+
508
+
509
+ def _run(args: argparse.Namespace) -> None:
500
510
  try:
501
511
  args.func(args)
502
512
  except UnicodeDecodeError as exc:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: errorbars
3
- Version: 0.2.2
3
+ Version: 0.2.4
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
@@ -16,6 +16,8 @@ Classifier: Programming Language :: Python :: 3
16
16
  Classifier: Programming Language :: Python :: 3.10
17
17
  Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
19
21
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
22
  Classifier: Typing :: Typed
21
23
  Requires-Python: >=3.10
@@ -123,26 +125,23 @@ errorbars summarize examples/data/reading_comprehension.csv --model tuned-70b
123
125
  ```
124
126
 
125
127
  ```
126
- summarize: tuned-70b
127
- ┏━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓
128
- ┃ metric ┃ value ┃
129
- ┡━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩
130
- │ n │ 200 │
131
- │ mean │ 0.6900 │
132
- │ SE │ 0.0328 │
133
- │ 95% CI │ [0.6257, 0.7543] │
134
- │ method │ clt │
135
- └────────┴──────────────────┘
136
- clustering diagnostics
137
- ┏━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓
138
- ┃ metric ┃ value ┃
139
- ┡━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩
140
- │ n clusters │ 40 │
141
- │ ICC │ 0.0710 │
142
- │ design effect │ 1.284 │
143
- │ clustered SE │ 0.0372 │
144
- │ clustered CI │ [0.6148, 0.7652] │
145
- └───────────────┴──────────────────┘
128
+ summarize: tuned-70b
129
+ metric value
130
+ ------ ----------------
131
+ n 200
132
+ mean 0.6900
133
+ SE 0.0328
134
+ 95% CI [0.6257, 0.7543]
135
+ method clt
136
+
137
+ clustering diagnostics
138
+ metric value
139
+ ------------- ----------------
140
+ n clusters 40
141
+ ICC 0.0710
142
+ design effect 1.284
143
+ clustered SE 0.0372
144
+ clustered CI [0.6148, 0.7652]
146
145
  ```
147
146
 
148
147
  ```bash
@@ -200,14 +199,21 @@ errorbars compare out/sshleifer__tiny-gpt2 out/hf-internal-testing__tiny-random-
200
199
  ```
201
200
 
202
201
  ```
203
- │ n (shared questions) │ 20 │
204
- │ mean(sshleifer/tiny-gpt2) │ 0.6000 │
205
- │ mean(hf-internal-testing/tiny-random-gpt2) │ 0.8000 │
206
- │ mean diff (A - B) │ -0.2000 │
207
- │ paired SE │ 0.1376 │
208
- │ 95% CI │ [-0.4881, 0.0881] │
209
- │ p-value │ 0.1625 │
210
- │ McNemar discordant (A wrong/B right, A right/B wrong) │ 6 / 2 │
202
+ compare: sshleifer/tiny-gpt2 vs hf-internal-testing/tiny-random-gpt2
203
+ metric value
204
+ ----------------------------------------------------- -----------------
205
+ n (shared questions) 20
206
+ mean(sshleifer/tiny-gpt2) 0.6000
207
+ mean(hf-internal-testing/tiny-random-gpt2) 0.8000
208
+ mean diff (A - B) -0.2000
209
+ paired SE 0.1376
210
+ 95% CI [-0.4881, 0.0881]
211
+ p-value 0.1625
212
+ correlation(A, B) 0.1021
213
+ unpaired SE (for reference) 0.1451
214
+ variance reduction from pairing 10.0%
215
+ McNemar discordant (A wrong/B right, A right/B wrong) 6 / 2
216
+ McNemar exact p-value 0.2891
211
217
  ```
212
218
 
213
219
  That is a real run, committed under `tests/fixtures/lm_eval_output/` (two tiny models, 20 COPA
@@ -1,6 +1,6 @@
1
- errorbars/__init__.py,sha256=dj_qqbpED039RmkoOkwWf0GJ_Eg2b1cMWP3lyrXnucw,607
2
- errorbars/_tables.py,sha256=d6o6zYEPfKwJ37pDLKcik5erF1gTSLVS8PP8lFpfu-E,4550
3
- errorbars/cli.py,sha256=-eThQ6pRMjF-Dc8DL3w33agZrmAry2Ry1EbUiPXj_mo,21141
1
+ errorbars/__init__.py,sha256=_ji8lf1xBolhlEbjQtWZkDp6-It9-PJhFjjvqAuasSE,607
2
+ errorbars/_tables.py,sha256=hl-xfbj_uEnyjaOFrDMYpEv1_IAe2r9-0OJ_fGyaCFM,5626
3
+ errorbars/cli.py,sha256=8l6ZRRIjPgQpaDVOHiG54fOatLbP57LmXomhPYzmwQw,21451
4
4
  errorbars/compare.py,sha256=OZ8clRwaL6ek6KTBRN57_Q3utoIEMKULCKsY97dV-p4,6602
5
5
  errorbars/inputs.py,sha256=s-QEMgXCB8t0aElXUtS1DdCTVFRgxYMPqh8yXhj9HUI,6723
6
6
  errorbars/io.py,sha256=kCtKs87g9r6SkfLV1X8QKb0YSe3XusA7QnXC60vLTzE,12850
@@ -12,8 +12,8 @@ errorbars/stats.py,sha256=0PeQbrl6EQMnJpffUhD4iotONx7tjr_EMV1QFofWWlE,11970
12
12
  errorbars/adapters/__init__.py,sha256=XhWjHhf5OQrODBysnjKDAu_gjX_gY9qCVc6m0B5j1Z8,77
13
13
  errorbars/adapters/inspect_ai.py,sha256=IAgts_DH_piS7ihrVMqyQyIrHW3oPI5USJIkJSt5SD0,4276
14
14
  errorbars/adapters/lm_eval.py,sha256=PX51CzPzhWACK01_PHth4Xv6CeKd5sWWgPHoSTsLzpo,8656
15
- errorbars-0.2.2.dist-info/METADATA,sha256=lKseedyzK-mWUPGcBHPOkWMuQ_hbIy3r2ZIxHp9KQb8,18289
16
- errorbars-0.2.2.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
17
- errorbars-0.2.2.dist-info/entry_points.txt,sha256=4tLng6AuvkO_nJeSf4KDkgsGXsEqQcZGkIcjkdmG45E,49
18
- errorbars-0.2.2.dist-info/licenses/LICENSE,sha256=4mFEvoZz1pwXUSatjc2e14QxRk8LlxILeZ3HXsfttkc,1071
19
- errorbars-0.2.2.dist-info/RECORD,,
15
+ errorbars-0.2.4.dist-info/METADATA,sha256=AK8Xze8XMzh4bSYahDlaAWW47tWssEHYqu7x96Ow6kA,18134
16
+ errorbars-0.2.4.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
17
+ errorbars-0.2.4.dist-info/entry_points.txt,sha256=4tLng6AuvkO_nJeSf4KDkgsGXsEqQcZGkIcjkdmG45E,49
18
+ errorbars-0.2.4.dist-info/licenses/LICENSE,sha256=4mFEvoZz1pwXUSatjc2e14QxRk8LlxILeZ3HXsfttkc,1071
19
+ errorbars-0.2.4.dist-info/RECORD,,