Skip to content

hertzforge.report.findings

findings

Findings register: deviations, anomalies and nonconformances in four parts (report feature findings).

With the feature on, the author enters each finding in a register: its number and kind (D-1, A-1, NC-1), the run, channel and band it concerns, and its four parts, fact, cause, effect, and approval or disposition (hertzforge.core.findings). The page draws the register in section 9 of the skeleton, each finding as its four labeled parts, and lists the findings by number under the Summary. A part left blank is drawn as owed, and the export's check lists it; it is never filled in and never left out.

The register is the author's section. The skeleton keeps the deviations section as the author's to write, and the register lives in that section's own block (the text block carrying section: 'deviations', under 'findings'), written only by what the author does: entering a finding, editing it, accepting a draft. Nothing is generated into it.

  • The fact may be offered as a draft, read off a measurement the project holds (draft_from_comparison: the channel, the band, the side and size of the excursion, the record). A draft is held beside the finding, and its words are not drawn; the author accepts it, edits it or discards it (accept, discard), and once accepted it is the author's fact. Until then the fact stays owed, on the page and in the check, marked as having a drafted fact waiting. Every source of a draft feeds it through one function, offer.
  • A run log brought into the project offers each deviation and anomaly it holds as a draft (offer_log): its kind, its fact as typed at the console and the log's number, proposed, citing the log, test and entry. The drafts are kept beside the register, never in it: the register and section 9 do not change, the section stays owed, and the editing page shows the drafts marked as drafted from the run log. Accepting one (accept_log) is what enters the finding, under the log's number when it is free, with its fact through offer; its cause, effect and approval or disposition stay owed. A fact the author has written is never offered over, and the log's approvals and dispositions are never offered. A log with no deviation or anomaly offers nothing, never "none".
  • Cause, effect and approval are only ever typed.
  • None is the skeleton's one-step None (none), and it says only what the author asks it to: with nothing entered it writes the section's own None wording, exactly as the skeleton does; with findings entered, it writes the "none" sentence of each kind that has none, such as "No anomalies.". An empty register is never read as "none": until the author says so, a kind with nothing entered is owed.

The feature needs Skeleton sections, whose sections it fills.

Classes:

Name Description
FactDraft

A fact offered for the author to accept, edit or discard.

Heads

The skeleton heads the register draws into (prepare) and what

Functions:

Name Description
register

The findings entered on report, each checked

find

The finding numbered number; ValueError naming the numbers

add

Enter a finding of kind and return its number.

edit

Change the fields given of finding number (any of EDITABLE;

remove

Take finding number out of the register. Its number is not

none

The deviations section's one-step None, and the words it wrote.

offer

Offer draft as the fact of finding number, for the author to

accept

Make the draft offered on finding number its fact: as offered,

discard

Drop the draft offered on finding number; refused when none is

log_drafts

The findings a run log offers report and the author has not

offer_log

Offer the deviations and anomalies a run log extract holds as

accept_log

Accept the finding the run log offered as number, and return the

discard_log

Drop the finding the run log offered as number; nothing enters

fact_text

The fact a reading supports, in words: the channel, each stretch

fact_from_comparison

A fact draft read off a comparison the project holds: measured

draft_from_comparison

Read a fact draft off a comparison (fact_from_comparison) and

check

The skeleton's owed list with section 9 read off the register.

finding_html

One finding as the page draws it: its number and what it

register_html

The register as section 9 draws it: each kind in turn, its

summary_html

The Summary's line of findings by number: "Deviations: D-1, D-2.

offered_html

The findings a run log offers, as the editing page draws them under

prepare

Ready the page skeleton.arrange laid out for the register.

draw

Add the register to section 9's head and the line of findings to

Classes

FactDraft dataclass

FactDraft(text: str, source: str, run: str = '', channel: str = '', band: tuple[float, float] | None = None)

A fact offered for the author to accept, edit or discard.

text is the draft. source says where it came from, shown beside it in the editor. run, channel and band are what the draft concerns; on acceptance they fill the finding's own fields where the author has left them blank.

Heads dataclass

Heads(summary: dict[str, Any] | None, deviations: dict[str, Any] | None, summary_html: str, deviations_html: str, offered_html: str = '')

The skeleton heads the register draws into (prepare) and what it adds to each once they are drawn (draw).

Functions:

register

register(report: Any) -> list[dict[str, Any]]

The findings entered on report, each checked (core.findings.clean), by kind and then number. Empty when none are.

find

find(report: Any, number: str) -> dict[str, Any]

The finding numbered number; ValueError naming the numbers entered when there is none.

add

add(report: Any, kind: str, *, number: str | None = None, **fields: Any) -> str

Enter a finding of kind and return its number.

The number is the next of its kind (core.findings.next_number) unless number is given, which must be of that kind and not yet taken. fields are any of EDITABLE. Entering a finding of a kind the author had said there were none of takes that kind's none sentence out of the section's words: the finding is the later statement.

Raises:

Type Description
ValueError

When the report does not have the feature enabled, for an unknown kind, a number of another kind or already taken, an unknown field, or a field core.findings.clean refuses. Nothing is changed.

TypeError

When a text field is not a string.

edit

edit(report: Any, number: str, **fields: Any) -> None

Change the fields given of finding number (any of EDITABLE; a field given as None is left alone, and an empty band clears the band). Refused as add refuses, before anything changes; a finding's kind is its number's and is not edited (enter the finding again under the other kind, as a report does when an anomaly is found to be a nonconformance).

remove

remove(report: Any, number: str) -> None

Take finding number out of the register. Its number is not given again (core.findings.next_number).

none

none(report: Any) -> str

The deviations section's one-step None, and the words it wrote.

With nothing entered, it is the skeleton's None exactly: the section says "No deviations. No anomalies. No nonconformances.". With findings entered, it says "none" only of each kind that has nothing entered, keeping the rest of the section's words.

Raises ValueError when the feature is off, and when every kind has a finding entered, so there is no kind to say "none" of.

offer

offer(report: Any, number: str, draft: FactDraft) -> None

Offer draft as the fact of finding number, for the author to accept, edit or discard; it replaces any draft already offered.

This is the one way a fact draft reaches a finding, whatever made it: draft_from_comparison reads one off a measurement, and any later source (a run log's entry, say) builds a FactDraft and offers it here. A draft is not drawn on the page and fills nothing until it is accepted.

accept

accept(report: Any, number: str, text: str | None = None) -> None

Make the draft offered on finding number its fact: as offered, or as the author edited it (text). The draft's run, channel and band fill the finding's own where the author left them blank, and never replace what the author entered. Refused when no draft is waiting, or when the text accepted is blank.

discard

discard(report: Any, number: str) -> None

Drop the draft offered on finding number; refused when none is waiting.

log_drafts

log_drafts(report: Any) -> list[dict[str, Any]]

The findings a run log offers report and the author has not accepted or discarded, each {'number', 'kind', 'fact', 'source', 'run'}, in the order offered. The number is the log's, proposed; none of them is in the register.

offer_log

offer_log(report: Any, extract: Any) -> list[str]

Offer the deviations and anomalies a run log extract holds as drafts, and return a line on each.

Each is offered with the log's number, proposed, its kind and its fact as typed at the console, its source citing the log, test and entry (with the extract's badge when the log has newer entries). A draft is kept beside the register, never in it: the register and the deviations section do not change, the section stays owed, and the editing page shows the drafts marked FROM_LOG until the author accepts one (accept_log, which enters the finding) or discards it (discard_log). A new offer replaces the drafts waiting. Not offered, each with its line: a finding whose number the register holds with its fact written, and a finding with no fact logged. The cause, the effect and the approval or disposition are never offered, whatever the log holds.

A log holding no deviation or anomaly offers nothing; its line says so, and leaves setting the section to None (none) to the author.

Raises ValueError when the feature is off.

accept_log

accept_log(report: Any, number: str, text: str | None = None) -> str

Accept the finding the run log offered as number, and return the number it is entered under.

The finding is entered in the register then, and not before: under the log's number when the register has not given that number, and otherwise under the next number of its kind (add); a finding the register already holds under that number with its fact blank takes the fact instead. Its fact, as offered or as the author edited it (text), reaches it through the register's one entry point for drafts (offer) and is accepted (accept); its run fills the finding's where blank. Its cause, effect and approval or disposition stay owed. The draft is no longer offered afterwards.

Raises ValueError when the feature is off, no draft is offered as number, or the fact accepted is blank; nothing is changed.

discard_log

discard_log(report: Any, number: str) -> None

Drop the finding the run log offered as number; nothing enters the register. Refused when no draft is offered as number.

fact_text

fact_text(channel: str, reading: ExcursionReading, pair: str, record: str, band: Sequence[float] | None = None) -> str

The fact a reading supports, in words: the channel, each stretch above the limit and then each below (a side with more than LISTED said once, with its count, its reach and its worst stretch), the record, and what was not judged. Refused when the reading holds no stretch: a reading inside its limits is not a fact about a finding.

fact_from_comparison

fact_from_comparison(objects: Mapping[str, Any], measured: str, specification: str, channel: str, *, band: Sequence[float] | None = None, pair: str = 'abort', provenance: Mapping[str, Mapping[str, Any]] | None = None) -> FactDraft

A fact draft read off a comparison the project holds: measured (a spectrum, by name) against specification (by name), on channel, over band if given, against the pair of limits.

The reading is core.findings.excursions, on the same cells and at the same scale as the comparison figure. The record is named, and the time history it was computed from where provenance (the project's) says; that time history is offered as the run.

Raises:

Type Description
ValueError

A name that is not an object of the project or not of the right type, a channel the two do not share, anything excursions refuses, and a channel inside its limits wherever it was judged, since that is no fact about a finding.

draft_from_comparison

draft_from_comparison(report: Any, number: str, objects: Mapping[str, Any], measured: str, specification: str, channel: str | None = None, *, band: Sequence[float] | None = None, pair: str = 'abort', provenance: Mapping[str, Mapping[str, Any]] | None = None) -> FactDraft

Read a fact draft off a comparison (fact_from_comparison) and offer it on finding number. The channel and band default to the finding's own. Returns the draft. Refused, changing nothing, as those two refuse, and when no channel is given or entered.

check

check(report: Any, owed: Sequence[Owed]) -> tuple[Owed, ...]

The skeleton's owed list with section 9 read off the register.

With the feature off, owed as it is. With it on, the section is owed, as the skeleton says, while nothing is entered and nothing written; otherwise each of these is listed under it: a kind with nothing entered that the author has not said is none, a kind both entered and said to be none, and each finding's blank parts.

finding_html

finding_html(entry: Mapping[str, Any]) -> str

One finding as the page draws it: its number and what it concerns, then its four labeled parts, each blank one owed.

register_html

register_html(entries: Sequence[Mapping[str, Any]], said: set[str]) -> str

The register as section 9 draws it: each kind in turn, its findings in number order, or its none sentence where the author said so, or an owed line where neither.

summary_html

summary_html(entries: Sequence[Mapping[str, Any]], said: set[str]) -> str

The Summary's line of findings by number: "Deviations: D-1, D-2. Anomalies: A-1 (closed). Nonconformances: none." A kind the author has neither entered nor said is none is owed.

offered_html

offered_html(drafts: Sequence[Mapping[str, Any]]) -> str

The findings a run log offers, as the editing page draws them under section 9: marked FROM_LOG, each with its proposed number, its kind, where it came from and its fact. '' when none is offered.

prepare

prepare(blocks: Sequence[dict[str, Any]], report: Any, edit: bool = False) -> Heads

Ready the page skeleton.arrange laid out for the register.

Section 9's head keeps the skeleton's owed card while nothing is entered and nothing written. Otherwise the register fills the section: its head shows the heading and the author's other words, the none sentences being drawn in their kinds' places by draw. Call before the text is drawn as HTML, and draw after skeleton.finish. With edit, the findings a run log offers (log_drafts) are drawn under section 9 as well, marked as drafted; they are never on the reading page.

draw

draw(heads: Heads) -> None

Add the register to section 9's head and the line of findings to the Summary's, once skeleton.finish has drawn them.