From 3a171383d4d4e183211bc0de9f3367010901afb1 Mon Sep 17 00:00:00 2001 From: Marvin Ma Date: Mon, 16 Nov 2026 13:54:42 +0900 Subject: [PATCH] A workspace sets the points from which the run keeps pairs: set floor writes method.toml keep, and the run scores and stores every pair whose best case reaches it, 0 unless set The best-case bound and scored/ read the floor instead of a fixed 0, so a lower floor keeps pairs people can review that 0 drops. The oversized blocks' gate keeps its own floor. The floor enters the run's hash only when set, so a workspace that never sets it keeps its hash, and setting it owes a rerun. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012o8JNBKSY1aREPbMQDG8g2 --- docs/architecture.md | 3 ++- docs/commands.md | 26 ++++++++++++++++++++++++++ docs/performance.md | 2 +- docs/usage.md | 2 +- er/cli.py | 17 ++++++++++++++++- er/config.py | 10 +++++++--- er/run.py | 20 +++++++++++--------- tests/test_sizes.py | 32 ++++++++++++++++++++++++++++++++ 8 files changed, 96 insertions(+), 16 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index c1a5464..31be7ba 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -178,7 +178,8 @@ Scores every candidate, with the u step 3 measured on this file: for each field, - **Why:** bits add up, so every score can be explained field by field. - **Code:** `Run.score` → `match.score_fs`, `scaled_prior` (λ at this file's size) -- **Increment:** only the pairs touching the batch that can reach 0 are scored, as above, a slice at a time: `O(C_Δ·K·L²)`. +- **The floor:** a pair is scored and stored only if it can reach the workspace's floor: 0 points, or `method.toml` `keep` (`set floor`). A lower floor keeps pairs people can review that 0 drops, such as a moved customer with a new ID, for more pairs scored and stored. The oversized blocks' gate keeps its own floor (step 5). +- **Increment:** only the pairs touching the batch that can reach the floor are scored, as above, a slice at a time: `O(C_Δ·K·L²)`. ### 7 · Cluster: from pairs to entities · `O(C + E·d + N)` diff --git a/docs/commands.md b/docs/commands.md index 6d6f2d5..e57d626 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -49,6 +49,7 @@ Written by `scripts/document_commands.py` from the declarations in `er/cli.py`; | [`try method`](#nayose-try-method) | Try a change of the method beside the method as it is | | [`try sample`](#nayose-try-sample) | Find how large a sample the model needs to learn from | | [`set fit`](#nayose-set-fit) | Set the sample the model learns from, and how EM learns | +| [`set floor`](#nayose-set-floor) | Set the points from which the run keeps pairs | | [`choose em`](#nayose-choose-em) | Choose the fields EM learns from, by the given name | | [`try everything`](#nayose-try-everything) | Try everything on a file, and write a report to send that holds no record's value | | [`adopt method`](#nayose-adopt-method) | Adopt a method tried, and find matches with it | @@ -1217,6 +1218,31 @@ Keeps them in the workspace (method.toml fit): the records the next run's fit sa nayose set fit --workspace workspaces/customers --records 64000 --em keys ``` +## nayose set floor + +Set the points from which the run keeps pairs. + +``` +nayose set floor --workspace WORKSPACE --points POINTS [--pipeline PIPELINE] [--format text|json] +``` + +Keeps it in the workspace (method.toml keep): a pair whose best case can't reach it is never compared in full or stored, so people can't review it. 0 unless set; lower keeps more pairs and costs more. The next run uses it. O(1). + +| Parameter | | +|---|---| +| `--workspace WORKSPACE` | the workspace: the folder that keeps one matching job (required) | +| `--points POINTS` | the points to keep pairs from, for example -10 (required) | +| `--pipeline PIPELINE` | the pipeline file (default: config/final.toml) | + +| Result | | +|---|---| +| `method` | the workspace's method.toml | +| `next` | the commands that usually follow | + +```bash +nayose set floor --workspace workspaces/customers --points -10 +``` + ## nayose choose em Choose the fields EM learns from, by the given name. diff --git a/docs/performance.md b/docs/performance.md index 27c5ac4..0570774 100644 --- a/docs/performance.md +++ b/docs/performance.md @@ -42,7 +42,7 @@ reads the file before these steps, about 15 s a million records from CSV, 7 s fr | 9 | report: qa.md, report.txt and the review sheet, built before the write and landing with it | `Run.report` | O(review pairs) + O(N) | N | 0.78 s | | | **total** | | | | **53.0 s** | -**Pairs that can't reach 0 points.** Nothing reads a candidate's score below 0: `scored/` keeps 0 points and up, and the line, the trust steps and review all start there. So a pair is scored only when its bound reaches 0: the prior, each comparison whose tests are equality, Hamming or one edit at its own level, and each other at the best level the pair may land in (`bound_tests`): DuckDB settles each level's test where it can in C++, a name or a company name in katakana by Jaro–Winkler on its one-byte copy, and only a test it can't settle (text outside katakana and ASCII, an edit distance past one) counts as passing. 0 where its fields are missing. Each test is computed once: the outcomes index a table of the bounds they allow, since DuckDB computes an expression as often as it is written. A pair a rule found is scored whatever its bound. A full run's candidates step already leaves the rest out as its keys list them (below); an increment's are counted (`unscored`, one row "below 0" in report.txt's SCORES and the score chart) and never compared by name, company or address: on a file whose address and phone are mostly empty, that is nearly every candidate. Every score written is the same to the last bit. The gate on oversized blocks and the probe do the same at their own floors, the review floor and the line. K_c is the comparisons settled first, C₀ the candidates whose bound reaches 0. +**Pairs that can't reach 0 points.** Nothing reads a candidate's score below the floor: `scored/` keeps 0 points and up (or `method.toml` `keep`), and the line, the trust steps and review all start there. So a pair is scored only when its bound reaches the floor: the prior, each comparison whose tests are equality, Hamming or one edit at its own level, and each other at the best level the pair may land in (`bound_tests`): DuckDB settles each level's test where it can in C++, a name or a company name in katakana by Jaro–Winkler on its one-byte copy, and only a test it can't settle (text outside katakana and ASCII, an edit distance past one) counts as passing. 0 where its fields are missing. Each test is computed once: the outcomes index a table of the bounds they allow, since DuckDB computes an expression as often as it is written. A pair a rule found is scored whatever its bound. A full run's candidates step already leaves the rest out as its keys list them (below); an increment's are counted (`unscored`, one row "below 0" in report.txt's SCORES and the score chart) and never compared by name, company or address: on a file whose address and phone are mostly empty, that is nearly every candidate. Every score written is the same to the last bit. The gate on oversized blocks and the probe do the same at their own floors, the review floor and the line. K_c is the comparisons settled first, C₀ the candidates whose bound reaches 0. At a million records, scoring the candidates (16.05 s) and the fit (9.40 s) take nearly half the time. The fit costs nearly the same at any size: it learns on n records, and its u sample of the file is S pairs for each of name, company diff --git a/docs/usage.md b/docs/usage.md index cc02d5a..e89a21f 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -244,7 +244,7 @@ None of these runs anything: they read the workspace's files. | `review.parquet` | pair for people | `why` (`decide` or `audit`); an empty `decision`; both records' compared fields; per comparison, the level reached and its bits; `accepted`, whether the run joined the pair; `household`, whether it may be two people of one household ([section 6](#6--review-and-decide)) | decide the next range below the trust line and audit above it, or, with no line, decide the pairs just below the threshold and those above it with no name compared, and audit those just above ([section 6](#6--review-and-decide)) | | `kind_review.parquet` | record for people | `why` (`decide` or `measure`), `reason` in words, `engine_says`, `name_says`, `flag` and `birth_date` if the file has them, the name; `engine` and `engine_p` (the engine's kind and its probability of a company), `name_p`, `drawn`; an empty `kind` | answer 1 person, 2 company or 0 can't tell ([section 6](#6--review-and-decide)) | | `decisions/` | decided pair | both IDs and `decision`; `why` (`decide`, `audit`, or `split` from `split entity`) when there is one; `round`, the round it was decided in; one part per file people gave back | what people decided; a full run applies it again | -| `method.toml` | | the workspace's changes to the tuned method: `trust` (the trust line), `merge` (the conditions under which pairs merge without people), `line`, `drop_rules`, `drop_keys`, `add_keys` | every command on the workspace runs the method it says ([section 6](#the-trust-line)) | +| `method.toml` | | the workspace's changes to the tuned method: `trust` (the trust line), `merge` (the conditions under which pairs merge without people), `line`, `drop_rules`, `drop_keys`, `add_keys`, `fit`, `keep` (the points from which pairs are stored, 0 unless `set floor` sets it) | every command on the workspace runs the method it says ([section 6](#the-trust-line)) | | `rounds.json` | round | per method the workspace ran: its `config` hash, `method`, when, the links it made and the false links the model expects | see each round's results side by side | | `trials/` | trial | each trial's result (`.json`, the last 5); the clusters of the method it was tried against (`base.parquet`, `base.json`) | `adopt method --trial n` | | `index/` | key of a record | every key of every record and every searched value, sorted (`.duckdb`); the records as compared (`.records.duckdb`); what changed since (`-.duckdb`); the person/company classifier's fitted part (`.kind.pkl`); `manifest.json`, which names them and what they rest on | `match record`, `search records`, the *Look up* page | diff --git a/er/cli.py b/er/cli.py index 50f69e9..7e0e4e6 100644 --- a/er/cli.py +++ b/er/cli.py @@ -683,6 +683,15 @@ def set_fit(a: dict, emit: "Emit") -> dict: return write_fit(a, fit_records(a), em) +def set_floor(a: dict, emit: "Emit") -> dict: # method.toml's keep, checked, then written + ws, points = Path(a["workspace"]), number(a["points"], "points", fix="a number of points, for example -10 or 0") + with folder.run_lock(ws): # read, checked and written as one + method = {**folder.method(ws), "keep": points} + setup(a, method) # refused before anything is written + folder.write_method(ws, method) + return {"method": method, "next": [dict(command=nayose("rerun", "records", "--workspace", ws), why="find matches with it")]} + + def choose_em(a: dict, emit: "Emit") -> dict: s, p, _ = setup(a) records = fit_records(a) if a.get("records") else p.fit_rows @@ -1631,6 +1640,12 @@ def open_ui(a: dict, emit: "Emit") -> dict: Param("em", "rules: as the method has it; keys: one session per equality key; choose: as choose em, at each fit; or fields, comma-separated: one session per field", required=True, metavar="rules|keys|choose|FIELDS"), PIPELINE), {"method": "the workspace's method.toml", "next": "the commands that usually follow"}, "nayose set fit --workspace workspaces/customers --records 64000 --em keys", set_fit), + Command("set", "floor", "Set the points from which the run keeps pairs", + "Keeps it in the workspace (method.toml keep): a pair whose best case can't reach it is never compared in full or " + "stored, so people can't review it. 0 unless set; lower keeps more pairs and costs more. The next run uses it. O(1).", + (WORKSPACE, Param("points", "the points to keep pairs from, for example -10", required=True, metavar="POINTS"), PIPELINE), + {"method": "the workspace's method.toml", "next": "the commands that usually follow"}, + "nayose set floor --workspace workspaces/customers --points -10", set_floor), Command("choose", "em", "Choose the fields EM learns from, by the given name", "Fits the model on the run's fit sample (--records of them, default the method's), against the u the run measured, " "in one EM session per field a comparison's first level tests for equality (an identifying field left out). " @@ -1878,7 +1893,7 @@ def open_ui(a: dict, emit: "Emit") -> dict: "apply answers", "describe merging", "set merging", "list entities", "describe entity", "split entity")), ("Look up", ("build index", "match record", "search records")), ("Look inside", ("describe workspace", "describe matching", "describe key", "list patterns", "explain pair", "compare records")), - ("Method", ("describe method", "try method", "try sample", "set fit", "choose em", "adopt method", "reset method", "describe review", "lower trust", "raise trust", "draw pairs", "list pairs")), + ("Method", ("describe method", "try method", "try sample", "set fit", "set floor", "choose em", "adopt method", "reset method", "describe review", "lower trust", "raise trust", "draw pairs", "list pairs")), ) diff --git a/er/config.py b/er/config.py index 9848feb..88d3aeb 100644 --- a/er/config.py +++ b/er/config.py @@ -435,6 +435,7 @@ class ThresholdRule: max_fp_rate_hi: float margin_steps: int search_floor: float = 0.0 # bits: the oversized-block gate and the gap aim here (er.match.search_floor); the idle-key check, the review floor + keep_from: float = field(default=0.0, repr=False) # bits: a pair the best case says can't reach it is never stored (method.toml keep); in the run's hash only when set (run_config) @dataclass(frozen=True, kw_only=True) @@ -726,7 +727,7 @@ def rekeyed(b: Blocker, old: str, new: str) -> Blocker: # the generator, readin fs=replace(p.fs, model=model, blockers=p.fs.blockers + tuple(c for b in p.fs.blockers for c in copies.get(b.name, ())))) -METHOD_KEYS = ("line", "drop_rules", "drop_keys", "trust", "add_keys", "merge", "fit") +METHOD_KEYS = ("line", "drop_rules", "drop_keys", "trust", "add_keys", "merge", "fit", "keep") GIVEN, PERSON = "given_name", "person_name" # agreement on the given name tells one person's records from a household's; the full name, where it is sparse (er.match.chosen) @@ -754,7 +755,7 @@ def adjust(p: "Pipeline", method: Mapping[str, object]) -> "Pipeline": `fit`, the sample the model learns from: `records` (fit_rows) and `em`, "rules" (em_rules), "keys" (one session per equality key, each level's m their median), as try sample shows them, "choose" (one session per compared field, kept by the given name: em_candidates), or a list of fields (`field` or `field:normalizer`), one session blocked on - each, in place of em_rules. + each, in place of em_rules; `keep`, the points from which the run stores pairs (keep_from, default 0). Nothing changed: the same pipeline, so the same config hash. O(rules + generators).""" if not method: return p @@ -764,6 +765,9 @@ def adjust(p: "Pipeline", method: Mapping[str, object]) -> "Pipeline": line = method.get("line", p.fs.min_match_weight) if isinstance(line, bool) or not isinstance(line, int | float) or not all(isinstance(method.get(k, []), list) for k in METHOD_KEYS[1:3]): raise InputError("method.toml: line is a weight in bits, drop_rules and drop_keys lists of names", fix) + keep = method.get("keep", p.threshold.keep_from) + if isinstance(keep, bool) or not isinstance(keep, int | float) or not math.isfinite(keep): + raise InputError("method.toml: keep is the points from which pairs are stored, for example -10", fix) trust = method.get("trust") if trust is not None and trust != "none" and (isinstance(trust, bool) or not isinstance(trust, int | float) or float(trust) not in p.trust.steps): raise InputError(f'method.toml: trust is "none" or one of the steps {list(p.trust.steps)}', fix) @@ -795,7 +799,7 @@ def adjust(p: "Pipeline", method: Mapping[str, object]) -> "Pipeline": model = replace(model, em_rules=sessions) return replace(p, rules=replace(p.rules, stages=stages), fs=replace(p.fs, blockers=blockers, min_match_weight=float(line), model=model), trust=p.trust if trust is None else replace(p.trust, line=math.inf if trust == "none" else float(trust)), - fit_rows=fit.get("records", p.fit_rows)) + fit_rows=fit.get("records", p.fit_rows), threshold=replace(p.threshold, keep_from=float(keep))) def load_pipeline(path: Path, std: Standardization, chains: Mapping[str, tuple[Normalizer, ...]], diff --git a/er/run.py b/er/run.py index f8f7017..0f6d512 100644 --- a/er/run.py +++ b/er/run.py @@ -153,7 +153,7 @@ class Run: echo: Callable[[dict], None] | None = None # called with each step as it finishes: progress for people (nayose) told: Callable[..., None] | None = None # called as a long step goes (done, total, unit, facts): how far it is, for people kind_labels: Path | None = None # people's person/company labels (a filled-in kind_review.parquet); an increment keeps the run's - reaching_only: bool = True # candidates stores only the pairs that can reach 0 (_reaching); design time measures every pair the keys list + reaching_only: bool = True # candidates stores only the pairs that can reach keep_from (_reaching); design time measures every pair the keys list def __post_init__(self) -> None: self.con, self.db = connect(self.settings.compute) @@ -600,14 +600,15 @@ def candidates(self, batch: str | None = None) -> pd.DataFrame: gate_seconds=round(self.gate_seconds, 2), gate_pairs=self.gate_pairs, generators=listed(report)) # the gate: its samples scored return report - def _reaching(self, pairs: str) -> str: # a generator's pairs that score() scores: those that can reach 0, and the rules', never stored otherwise + def _reaching(self, pairs: str) -> str: # a generator's pairs that score() scores: those that can reach keep_from, and the rules', never stored otherwise bound, have = bound_tests(self.pipeline.fs.model), self.columns() cols = [c for c in sorted(bound_reads(self.scoring, bound)) if c in have] self.con.execute(f"CREATE TABLE IF NOT EXISTS er_bound_records AS SELECT {', '.join(q(c) for c in [self.uid, *cols])} FROM records") # what the bound reads, narrow hashed = [c for c in sorted(rough_reads(self.scoring, bound)) if c in have] self.con.execute(f"CREATE TABLE IF NOT EXISTS er_bound_hashes AS SELECT {q(self.uid)}, " # what the rough test reads: a hash of each, NULL where missing f"{', '.join(f'CASE WHEN {q(c)} IS NOT NULL THEN hash({q(c)}) END AS {q(c)}' for c in hashed) or 'NULL AS __none'} FROM records") - return reaching_sql(self.scoring, "er_bound_records", pairs, self.uid, set(cols), self.n, 0.0, bound, "rule_kept", hashed="er_bound_hashes") + return reaching_sql(self.scoring, "er_bound_records", pairs, self.uid, set(cols), self.n, self.pipeline.threshold.keep_from, bound, "rule_kept", + hashed="er_bound_hashes") def _joined(self) -> Callable[..., None] | None: """told for candidates' joins, each generator weighed as the budget counted it (the records it reads, the pairs @@ -667,8 +668,8 @@ def _gated(self, records: list[dict]) -> None: # the oversized blocks' decision self.notes.append(f"{len(gated):,} oversized blocks in all: {kept:,} kept, {len(gated) - kept:,} skipped (qa.md lists them)") def score(self) -> None: - """Every candidate that can reach 0 points scored by Splink, with the model and u that fit() settled (the rest: a - bound settles it below 0, which nothing reads: unscored); and the patterns the scored pairs fall in (_patterns).""" + """Every candidate that can reach keep_from points (method.toml keep, 0 unless set) scored by Splink, with the model + and u that fit() settled (the rest: a bound settles it below, which nothing reads: unscored); and the patterns the scored pairs fall in (_patterns).""" t, fs = time.perf_counter(), self.pipeline.fs k, model_line = len(fs.model.comparisons), bits(fs.min_match_weight) total, done, likely = self._count("cands"), 0, 0 # likely: the pairs the model scores as matches, whatever trust lets merge @@ -679,7 +680,7 @@ def each(scored: str, sliced: int) -> None: # how far scoring is, after each sl done, likely = done + sliced, likely + hit if self.told: self.told(done, total, "pairs", likely=likely) - self._scored("cands", "scores", each=each, floor=0.0, exempt="rule_kept") # scored/ keeps 0 points and up, and every rule pair + self._scored("cands", "scores", each=each, floor=self.pipeline.threshold.keep_from, exempt="rule_kept") # scored/ keeps keep_from points and up, and every rule pair reached: dict[str, dict[str, int]] = {} # per comparison, the pairs at each level (gamma, as score_fs gives it): one scan for c, g, n in self.con.execute("SELECT c, g, count(*) FROM (UNPIVOT scores ON COLUMNS('^gamma_') INTO NAME c VALUE g) GROUP BY ALL").fetchall(): reached.setdefault(c.removeprefix("gamma_"), {})[str(g)] = n @@ -713,13 +714,13 @@ def scored(self) -> str: JOIN rule_clusters a ON a.{u} = s.{l} JOIN rule_clusters b ON b.{u} = s.{r}""" def _links(self) -> str: - """Every pair scored at 0 points or more and every rule pair, as scored/ keeps them for people (er.results): its + """Every pair scored at keep_from points or more and every rule pair, as scored/ keeps them for people (er.results): its points, how it was found (sources: the keys; rule: the rule), named, keep, and one gamma per comparison.""" fs, l, r = self.pipeline.fs, q(self.l), q(self.r) gammas = [c for c, *_ in self.con.execute("DESCRIBE scores").fetchall() if c.startswith("gamma_")] rule = f"(SELECT {l}, {r}, min(rule) AS rule FROM rule_kept GROUP BY ALL)" model = f"""SELECT s.{l}, s.{r}, s.match_weight, s.match_probability, s.sources, k.rule, s.named, s.keep, {', '.join(f's.{q(g)}' for g in gammas)} - FROM ({self.scored()}) s LEFT JOIN {rule} k USING ({l}, {r}) WHERE s.match_weight >= 0 OR k.rule IS NOT NULL""" + FROM ({self.scored()}) s LEFT JOIN {rule} k USING ({l}, {r}) WHERE s.match_weight >= {self.pipeline.threshold.keep_from} OR k.rule IS NOT NULL""" if not self.con.execute("SELECT count(*) FROM duckdb_tables() WHERE table_name = 'rule_scores'").fetchall()[0][0]: return model return f"""{model} UNION ALL BY NAME SELECT x.{l}, x.{r}, x.match_weight, x.match_probability, NULL::VARCHAR AS sources, k.rule, @@ -1185,7 +1186,8 @@ def run_config(p: Pipeline, s: Settings) -> str: sample and EM (method.toml's fit: the sessions' rules too) are left out: an increment and a lookup score with the stored model.""" fit = {f.name: f.default for f in fields(FSModel) if f.name in ("em_from_keys", "em_median")} # em_choose: never in a model's repr p = replace(p, fit_rows=FINGERPRINTED_ROWS, fs=replace(p.fs, model=replace(p.fs.model, em_rules=(), **fit))) - return config_hash((p, s.columns, s.standardize, s.flag_company, s.input, PLACEHOLDERS)) + keep = p.threshold.keep_from # out of the dataclass's repr, so a workspace that never set it keeps its hash + return config_hash((p, s.columns, s.standardize, s.flag_company, s.input, PLACEHOLDERS) + ((("keep", keep),) if keep else ())) def listed(report: pd.DataFrame) -> list[dict]: # each generator's pairs and seconds, kept in steps.json (describe matching) diff --git a/tests/test_sizes.py b/tests/test_sizes.py index b6fef71..cf34eb7 100644 --- a/tests/test_sizes.py +++ b/tests/test_sizes.py @@ -129,3 +129,35 @@ def test_a_run_with_em_choose_keeps_each_session_s_verdict_in_its_model_and_the_ from er.report import qa, report_text report = report_text(run, qa(run, [f for f in s.columns if f not in ("id", "entity")]), s.root / "tests" / "method.toml") assert "EM SESSIONS" in report and all(x["session"] in report for x in choice) + + +def test_a_floor_below_0_keeps_the_pairs_down_to_it_and_every_pair_the_default_kept(ran, tmp_path, capsys): + import shutil + import duckdb + from er import cli + s, p, ws = ran + low = tmp_path / "low" + shutil.copytree(ws, low) + read = lambda w: duckdb.sql(f"SELECT * EXCLUDE (match_probability) FROM read_parquet('{w}/scored/*.parquet')").df() + before = read(ws) + pipeline = ["--pipeline", str(s.root / "tests" / "method.toml")] # as the run was made + assert cli.main(["set", "floor", "--points", "-10", "--workspace", str(low), *pipeline, "--format", "json"]) == 0 + assert cli.rerun_owed({"workspace": str(low), "pipeline": pipeline[1]}) # stored pairs change: the run owes a rerun + assert cli.main(["rerun", "records", "--workspace", str(low), *pipeline, "--format", "json"]) == 0 + capsys.readouterr() + after = read(low) + model = lambda d: d[d["rule"].isna()] + assert (model(after)["match_weight"] < 0).any() and (model(after)["match_weight"] >= -10).all() + key = lambda d: d[d["match_weight"] >= 0].sort_values(list(d.columns[:2])).reset_index(drop=True) + pd.testing.assert_frame_equal(key(after)[key(before).columns], key(before), check_dtype=False) # at 0 and up: the same pairs and points + + +def test_keep_in_method_toml_is_a_number_and_changes_the_run_s_hash_only_when_set(ran): + from er.config import adjust + from er.run import run_config + s, p, ws = ran + assert run_config(adjust(p, {"keep": 0}), s) == run_config(p, s) != run_config(adjust(p, {"keep": -10}), s) + assert adjust(p, {"keep": -10}).threshold.keep_from == -10 + for bad in ("low", True, float("inf")): + with pytest.raises(InputError, match="keep"): + adjust(p, {"keep": bad})