Skip to content

CLI: file argument, column options and wide input - #47

Merged
jerome-white merged 4 commits into
masterfrom
issue-40-cli-input
Oct 21, 2026
Merged

jerome-white merged 4 commits into
masterfrom
issue-40-cli-input

Conversation

@jerome-white

Copy link
Copy Markdown
Owner

Closes #40. Part of #38.

What this does

The CLI no longer needs the IR column names, and reads wide data and files:

  • A file argument: rthsd scores.csv; stdin when it is missing or -.
  • Choose the columns (tidy input): --block, --treatment, --value. A role you leave out takes the column called topic, system or score; if that still leaves a role open and the file has exactly three columns, the unused ones are taken in the order block, treatment, value. So dataset,model,accuracy works with no options at all, and the old files work unchanged.
  • Wide input: --format wide (default tidy). One row per block, one column per treatment, the header naming them; --block NAME names a column (an id) to leave out. --treatment and --value with --format wide are an error.
  • Missing scores follow the existing rules in both forms: an empty wide cell is a missing score.

In the library (unexported, like the others from #37): tidy_columns(names, block, treatment, value) decides the columns and wide_scores(names, columns) builds the matrix from a wide table. Both are unit-tested; the CLI stays glue.

Decisions

  • Explicit --format instead of detection. A wide file and a tidy file can both have three columns, so guessing would be wrong sometimes.
  • The roles rule above: it keeps every existing file working, needs no options in the common three-column case, and refuses to guess otherwise. With four or more columns that do not include the IR names, it stops and names the columns (cannot tell which columns hold the block, treatment; columns are ...; name them with --block, --treatment and --value).
  • In wide input every column but --block's is a treatment. A non-numeric one is an error that names it.
  • The treatment names are strings in wide input (the headers).

Verification

  • Library: 129 pass + 1 deliberately broken. New tests: tidy_columns (the IR names, any order, extra columns, explicit names, three columns with other names, partial requests, three errors) and wide_scores (order, missing to NaN, three errors).
  • CLI, by hand with --seed 1 and 500 trials on tiny.csv: the same output, byte for byte, from the original tidy file, a file with other column names (dataset,model,accuracy), a four-column file with explicit options, a file argument, - for stdin, a wide file with an id column and a wide file without one. The seven-input comparison from Move the CLI's input handling into the library #37 (NaN, absent row, empty cell, duplicate row, numeric names, large file; --missing error and drop) is unchanged apart from the known duplicate message.
  • Errors checked: ambiguous columns, a column that does not exist, a missing file, a bad --format, tidy-only options with --format wide, a wide empty cell with --missing error (stops) and drop (continues).
  • 80 columns checked.

Not done

  • The executable: looked into, filed as a follow-up with what I found.
  • The CLI still has no automated tests; the logic it needs is covered in the library.

🤖 Generated with Claude Code

jerome-white and others added 4 commits October 22, 2026 01:22
…e tables

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…olumns

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@jerome-white jerome-white self-assigned this Oct 21, 2026
@jerome-white
jerome-white merged commit 424b976 into master Oct 21, 2026
4 checks passed
@jerome-white
jerome-white deleted the issue-40-cli-input branch October 21, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI: choose the columns, read wide CSV, take a file argument

1 participant