Format the Python code and the Markdown code blocks with ruff format

No behavior change: paperspec check, with the byte-for-byte rebuild, gives the same
results before and after.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B8cL4zN4XpaQF5cBtASzfq
This commit is contained in:
alexmandClaude committed 2026-10-19 03:57:28 -04:00
1 parent 2cfa080393
commit 2ec1e013e5
36 files changed
+10800 -2555

No files matched your search

+67 -24
View File
@@ -102,7 +102,11 @@ def text(n):
for n in nodes:
if n["kind"] == "section":
heading = children[n["id"]][0]
print(n["id"], n.get("label", ""), " ".join(text(s) for s in children[heading["id"]]))
print(
n["id"],
n.get("label", ""),
" ".join(text(s) for s in children[heading["id"]]),
)
elif n["kind"] in ("figure", "table", "equation"):
print(n["id"], " ", n["kind"], n.get("label", ""))
```
@@ -163,29 +167,41 @@ import json, sqlite3
db = sqlite3.connect("lab.db")
# Sentences the converter left below F2. Receipts can raise them; see below.
for row in db.execute("SELECT id, fidelity FROM nodes WHERE doc_key = 'hale2026harmonic-damb' "
"AND kind = 'sentence' AND fidelity IN ('F0', 'F1') ORDER BY seq"):
for row in db.execute(
"SELECT id, fidelity FROM nodes WHERE doc_key = 'hale2026harmonic-damb' "
"AND kind = 'sentence' AND fidelity IN ('F0', 'F1') ORDER BY seq"
):
print(row)
# Every sentence that cites reference 2: the citation graph is sentence-level.
for row in db.execute("SELECT c.sentence FROM citations c JOIN refs r "
"ON r.doc_key = c.doc_key AND r.node = c.ref_node "
"WHERE c.doc_key = 'hale2026harmonic-damb' AND r.label = '2'"):
for row in db.execute(
"SELECT c.sentence FROM citations c JOIN refs r "
"ON r.doc_key = c.doc_key AND r.node = c.ref_node "
"WHERE c.doc_key = 'hale2026harmonic-damb' AND r.label = '2'"
):
print(row)
# Who signed what.
for row in db.execute("SELECT r.signer, r.scope, COUNT(*) FROM receipts r "
"JOIN receipt_nodes rn ON rn.receipt = r.id GROUP BY r.id ORDER BY r.made_at"):
for row in db.execute(
"SELECT r.signer, r.scope, COUNT(*) FROM receipts r "
"JOIN receipt_nodes rn ON rn.receipt = r.id GROUP BY r.id ORDER BY r.made_at"
):
print(row)
# Table 1's body, row by row.
rows = db.execute("SELECT r.id FROM nodes r JOIN nodes b ON b.doc_key = r.doc_key AND b.id = r.parent "
"WHERE r.doc_key = 'hale2026harmonic-damb' AND r.kind = 'row' AND b.kind = 'table-body' "
"ORDER BY r.seq").fetchall()
rows = db.execute(
"SELECT r.id FROM nodes r JOIN nodes b ON b.doc_key = r.doc_key AND b.id = r.parent "
"WHERE r.doc_key = 'hale2026harmonic-damb' AND r.kind = 'row' AND b.kind = 'table-body' "
"ORDER BY r.seq"
).fetchall()
for (row,) in rows:
cells = db.execute("SELECT content FROM nodes WHERE doc_key = 'hale2026harmonic-damb' AND parent = ? ORDER BY ord",
(row,)).fetchall()
print(" | ".join("".join(r.get("text", "") for r in json.loads(c)) for (c,) in cells))
cells = db.execute(
"SELECT content FROM nodes WHERE doc_key = 'hale2026harmonic-damb' AND parent = ? ORDER BY ord",
(row,),
).fetchall()
print(
" | ".join("".join(r.get("text", "") for r in json.loads(c)) for (c,) in cells)
)
```
```text
@@ -225,12 +241,19 @@ from paperspec import package, traces
draft = package.read_state("fixtures/packages/writer2027fixed-ynr7.v3")
paper = package.read_state("fixtures/packages/hale2026harmonic-damb")
same_as = json.load(open("fixtures/packages/hale2026harmonic-damb/document.json"))["work"]["same_as"]
annotations = [json.loads(line) for line in open("fixtures/records/traces/annotations.jsonl", encoding="utf-8")]
same_as = json.load(open("fixtures/packages/hale2026harmonic-damb/document.json"))[
"work"
]["same_as"]
annotations = [
json.loads(line)
for line in open("fixtures/records/traces/annotations.jsonl", encoding="utf-8")
]
for a in annotations:
if a["body"]["kind"] == "trace":
r = traces.resolve(a, draft, paper, same_as)
print(a["status"], r["result"], r["open"], traces.disputed(a["id"], annotations))
print(
a["status"], r["result"], r["open"], traces.disputed(a["id"], annotations)
)
```
```text
@@ -258,7 +281,13 @@ for name, module in (("chemistry", structures), ("biology", sequences)):
for line in open(f"fixtures/records/{name}/annotations.jsonl", encoding="utf-8"):
a = json.loads(line)
quote = a["target"]["selector"][1]["exact"]
print(a["status"], a["body"]["role"], a["body"]["identity"], repr(quote), module.problems(a))
print(
a["status"],
a["body"]["role"],
a["body"]["identity"],
repr(quote),
module.problems(a),
)
atoms, bonds = structures.scan("O([H])[H]")
print(atoms, sorted(bonds))
@@ -291,24 +320,38 @@ import json
from paperspec import data
descriptors = {}
for folder in ("fixtures/packages/hale2026harmonic-damb/datasets/ds-hale-bond-params",
"fixtures/records/datasets/ds-hale-ctct-scan"):
for folder in (
"fixtures/packages/hale2026harmonic-damb/datasets/ds-hale-bond-params",
"fixtures/records/datasets/ds-hale-ctct-scan",
):
with open(folder + "/datapackage.json", encoding="utf-8") as f:
d = json.load(f)
descriptors[d["id"]] = d
annotations = [json.loads(line) for line in open("fixtures/records/data/annotations.jsonl", encoding="utf-8")]
annotations = [
json.loads(line)
for line in open("fixtures/records/data/annotations.jsonl", encoding="utf-8")
]
for a in annotations:
b = a["body"]
quote = a["target"]["selector"][1]["exact"]
about = [s["label"] for s in b.get("subjects", [])]
print(a["status"], b["role"], b["data_type"], b.get("dataset"), repr(quote), about,
data.problems(a, descriptors.get(b.get("dataset"))))
print(
a["status"],
b["role"],
b["data_type"],
b.get("dataset"),
repr(quote),
about,
data.problems(a, descriptors.get(b.get("dataset"))),
)
ethane = "OTMSDBZUPAUEDD-UHFFFAOYSA-N"
for a in annotations:
b = a["body"]
if b["data_type"] == "force-field-parameters" and any(s["identity"] == ethane for s in b.get("subjects", [])):
if b["data_type"] == "force-field-parameters" and any(
s["identity"] == ethane for s in b.get("subjects", [])
):
print([(q["name"], q["unit"]) for q in b["quantities"]])
```