Skip to content

credibility.extensions

The evidence extensions: evidence of the contexts of use which a project adds.

The core of the credibility assesses what every model has: the data points of its adopted fits against the acceptance rules, the coverage of the claimed domain, the verification, the parameter uncertainty and the variability. A domain adds evidence of its own, e.g. the ratios between the arms of a study, the equivalency of the simulated and the reported inputs of the subjects, the chronology of the studies or the provenance of the study data. Such evidence is an EvidenceExtension, which a project registers (sbmlsim.project.CredibilitySettings.extensions) and the core calls at fixed points. Every method has a default which contributes nothing, so an extension overrides what it adds. The contract:

The declaration. A setting of an extension for one context of use, e.g. the acceptance of the ratio pairs, is an entry of ContextOfUse.extensions by the name of the extension; a setting with a method problems (ExtensionSetting) is checked with the declaration. A ratio quantity carries a Pairing, which the extension that knows it claims (claims). The project checks both when it loads the declaration (sbmlsim.project.Project.load_credibility, sbmlsim.credibility.Credibility.extension_problems): a setting by a name of no extension of the project and a pairing which no extension claims are problems, so a typo never falls back to a default silently.

The selection. selection_problems checks the decisive points of every context of use after the selection of the evidence (sbmlsim.credibility.selection.select), e.g. a study of a ratio with two reference arms.

The assessment. prepare reads what the extension needs from the project once per assessment, e.g. the chronology of the studies; assess_context gives its ContextContribution to a context of use:

  • acceptance: the results of the rules of the extension. They enter the verdict of the context and the factor output comparison together with the acceptance rules of the context, and they are rows of the acceptance of the record of the context: after the rows of the rules of the context, in the order of the extensions of the project, each with the name of its extension in the field extension (ACCEPTANCE_EXTENSION; a row of a rule of the context has none). acceptance evaluates the same rules on other predictions, those of a draw of the parameter uncertainty or of an alternative of the verification, in the same order.
  • quantities: the evaluable points of the quantities the extension derives, e.g. the pairs of a ratio quantity; a quantity with a point is covered.
  • factors: a FactorStatement per factor of V&V 40 the extension assesses, combined with the statement of the core by sbmlsim.credibility.factors.combine_factor: the statements before the core (before_core) in the order of the extensions, the statement of the core, the statements after it in the order of the extensions; a factor with a statement of an extension is assessed and has no step. The statement of the core is the one the core gives the factor (an assessed factor, a platform statement or the checks of the verification), none for a factor the core leaves not assessed.
  • section: the section of the extension in the record of the context.

assessment_section is its section of the record of the assessment, e.g. the provenance of the study data of every study.

The pooling. pool pools the sections of the contexts of several models into a table whose columns the extension decides; pool_lines words the rows for a command that prints them (by default every row as column=value).

The records. The record of a context of use and of an assessment has the sections of the extensions by their name in its field extensions (EXTENSIONS), which the extension of that name writes and reads; the core keeps a section as it is. A record of pkpdsim 0.19 has the evidence of its extensions as fields of its own, which read_sections reads as their sections (LEGACY_CONTEXT_SECTIONS, LEGACY_ASSESSMENT_SECTIONS) and read_acceptance its rule of the ratio pairs, ratio_acceptance, as a row of the acceptance of the extension ratios (LEGACY_ACCEPTANCE); a record of pkpdsim 0.17 or 0.18 has none.

The report. The rows of the acceptance of an extension are rows of the acceptance table of its context, after the rows of the context, with the name of the rule followed by the label of the extension. context_report_blocks gives the blocks of the extension in the card of a context, each placed after a block of the core (ContextBlock.after, one of CONTEXT_BLOCKS), the blocks after one block of the core in the order of the extensions; report_section a section of the report of its own with an entry in the navigation, after the core sections and before the provenance; report_tables the tables it writes next to the report.

The scorecard. An extension names its columns statically (scorecard_names) and scorecard_columns gives their values for a context, for every name of scorecard_names and no other; they follow the columns of the core (the order of the columns of pkpdsim changes, the scorecards are compared by the names of the columns). The rows of the acceptance of an extension are columns of their rule like the rules of the context, which the core compares as rules; the columns of scorecard_names it never compares (rule_columns): regressions of the extension alone judges them, e.g. a column of pairs which drops from 10 to 4 is no regression of a rule. The core gives regressions the rows as they are: a scorecard of the process has the values scorecard_columns gave, a scorecard read back from its TSV has texts (an empty text for a missing value), and a baseline of an older record lacks the columns; scorecard_number and scorecard_true read a value of either. pool pools the sections of the contexts of several models with the options of the pooling, which the caller passes through as it got them (e.g. {"field": "health"} of the qualification of the ratio pairs by a value of the metadata, an option of a command line), or empty for the defaults of the extension.

Pairing

Bases: Protocol

The derivation of a ratio quantity from the decisive points, see QuantityOfInterest.

A pairing is declared with the quantity and assessed by the extension which claims it (EvidenceExtension.claims), e.g. the arms of a study of the ratios of pkpdsim. The core reads its observable only: the evidence of a context of use is restricted to the observables of its quantities, a ratio quantity to the observable of its pairing.

observable property

observable

Get the observable of the points the ratio is derived from, e.g. [A].

ExtensionSetting

Bases: Protocol

A setting of an extension for a context of use which checks itself.

problems

problems()

Get the problems of the setting, empty if it is valid.

FactorStatement dataclass

FactorStatement(text, before_core=False)

The statement of an extension of a factor of V&V 40, see the module.

Attributes:

Name Type Description
text str

the statement.

before_core bool

place it before the statement of the core, e.g. the inputs before the variability in the equivalency of the inputs; after it otherwise, e.g. the temporal validation after the output comparison.

ContextContribution dataclass

ContextContribution(
    *,
    section=None,
    acceptance=(),
    quantities=dict(),
    factors=dict(),
)

What an extension contributes to the assessment of a context of use.

Attributes:

Name Type Description
section Mapping[str, Any] | None

the section of the extension in the record of the context, plain data which the extension reads back; None for none.

acceptance tuple[AcceptanceResult, ...]

the results of the rules of the extension, which enter the verdict and the output comparison of the context and are rows of the acceptance of its record, see the module.

quantities Mapping[str, int]

the evaluable points of every quantity of interest the extension derives, by its id, e.g. the pairs of a ratio quantity; a quantity with a point is covered.

factors Mapping[str, FactorStatement]

the statement of every factor of V&V 40 the extension assesses, by the id of the factor (sbmlsim.credibility.FACTORS), combined with the core by sbmlsim.credibility.combine_factor.

ContextBlock dataclass

ContextBlock(html, after='acceptance')

A block of an extension in the card of a context of use in the report.

Attributes:

Name Type Description
html str

the block, e.g. a heading h4 and a table.

after str

the block of the core it follows, one of CONTEXT_BLOCKS.

ReportSection dataclass

ReportSection(id, title, html)

A section of an extension in the report, with its entry in the navigation.

Attributes:

Name Type Description
id str

the anchor of the section, e.g. studies.

title str

its heading and the text of its entry, e.g. Study data.

html str

the content below the heading.

ScorecardChange dataclass

ScorecardChange(what, baseline, current)

A column of an extension of a context of use which got worse than its baseline.

Attributes:

Name Type Description
what str

the column, e.g. temporal_met.

baseline str

the value of the baseline, as text.

current str

the current value, as text.

EvidenceExtension

Evidence of the contexts of use which a project adds, see the module.

A subclass names itself (name, the key of its sections and settings) and overrides the methods of what it adds; every method contributes nothing by default.

Attributes:

Name Type Description
name str

the name of the extension, unique among the extensions of a project, e.g. ratios.

label str

what the rules of the extension evaluate, shown next to their rows in the acceptance table, e.g. ratio pairs; the name without.

scorecard_names tuple[str, ...]

the columns of the extension in the scorecard, which scorecard_columns gives and only regressions judges.

claims

claims(pairing)

Check whether the extension assesses a pairing of a ratio quantity.

Parameters:

Name Type Description Default
pairing Pairing

the pairing of a quantity of interest.

required

Returns:

Type Description
bool

Whether the extension assesses it; False by default.

selection_problems

selection_problems(cou, decisive, lookup)

Check the decisive points of a context of use after the selection.

Parameters:

Name Type Description Default
cou ContextOfUse

the context of use.

required
decisive DataFrame

the rows of the table of the fits of its decisive evidence.

required
lookup MappingLookup

the fit mapping of an experiment and a key.

required

Returns:

Type Description
list[str]

Every problem, without the name of the context, which the

list[str]

selection prefixes; empty for none.

prepare

prepare(project, credibility, fits)

Get what the extension reads from the project once per assessment.

Parameters:

Name Type Description Default
project Project

the project of the model.

required
credibility Credibility

its declaration.

required
fits FitTable

the fresh evaluation of its adopted fits.

required

Returns:

Type Description
object

What assess_context and assessment_section get as prepared,

object

None by default.

assess_context

assess_context(cou, decisive, fits, prepared)

Assess a context of use.

Parameters:

Name Type Description Default
cou ContextOfUse

the context of use.

required
decisive DataFrame

the rows of the table of the fits of its decisive evidence.

required
fits FitTable

the table of the fits.

required
prepared object

what prepare returned.

required

Returns:

Type Description
ContextContribution | None

The contribution, None for a context the extension does not

ContextContribution | None

concern.

acceptance

acceptance(cou, decisive, lookup)

Evaluate the rules of the extension on other predictions of the decisive points.

The predictions are the column IPRED of the points, e.g. those of a draw of the parameters; the results are in the order of the ones of assess_context.

Parameters:

Name Type Description Default
cou ContextOfUse

the context of use.

required
decisive DataFrame

its decisive points with the other predictions.

required
lookup MappingLookup

the fit mapping of an experiment and a key.

required

Returns:

Type Description
list[AcceptanceResult]

The results, empty for an extension without rules.

assessment_section

assessment_section(prepared)

Get the section of the extension in the record of the assessment.

Parameters:

Name Type Description Default
prepared object

what prepare returned.

required

Returns:

Type Description
Mapping[str, Any] | None

Plain data which the extension reads back, None for none.

context_report_blocks

context_report_blocks(context, section)

Get the blocks of the extension in the card of a context of use.

Parameters:

Name Type Description Default
context Mapping[str, Any]

the record of the context as plain data.

required
section Mapping[str, Any] | None

the section of the extension in it, None without.

required

Returns:

Type Description
Sequence[ContextBlock]

The blocks, each after a block of the core; empty for none.

report_section

report_section(record)

Get the section of the extension in the report.

Parameters:

Name Type Description Default
record Mapping[str, Any]

the record of the assessment as plain data, with the sections of the extension in extensions of the assessment and of its contexts.

required

Returns:

Type Description
ReportSection | None

The section with its entry in the navigation, None for none.

report_tables

report_tables(record)

Get the tables the report writes for the extension.

Parameters:

Name Type Description Default
record Mapping[str, Any]

the record of the assessment as plain data.

required

Returns:

Type Description
Mapping[str, DataFrame]

The tables by the name of their file without the suffix, e.g.

Mapping[str, DataFrame]

ratios; empty for none.

scorecard_columns

scorecard_columns(context)

Get the columns of the extension of a context of use in the scorecard.

Parameters:

Name Type Description Default
context Mapping[str, Any] | None

the section of the extension in the record of the context, None for a context without one, e.g. of an older record.

required

Returns:

Type Description
Mapping[str, object]

The values by column, one for every name of scorecard_names;

Mapping[str, object]

empty for an extension without columns.

regressions

regressions(baseline, current)

Compare the columns of the extension of a context with its baseline.

Parameters:

Name Type Description Default
baseline Mapping[str, object]

the row of the context in the baseline scorecard as it is, values of scorecard_columns or texts of a TSV, see the module; a baseline of an older record lacks the columns.

required
current Mapping[str, object]

the row of the context in the current scorecard.

required

Returns:

Type Description
list[ScorecardChange]

Every column which got worse, e.g. the rules met on the studies

list[ScorecardChange]

collected after the fit and no longer met; empty for none.

pool

pool(contexts, options)

Pool the sections of the contexts of use of several models.

Parameters:

Name Type Description Default
contexts Mapping[str, Sequence[Mapping[str, Any] | None]]

the sections of the extension of every context of use, by model.

required
options Mapping[str, Any]

the options of the pooling as the caller got them, e.g. {"field": "health"}; empty for the defaults of the extension.

required

Returns:

Type Description
DataFrame | None

The pooled table, e.g. the ratio pairs by a value of the metadata;

DataFrame | None

None for an extension which pools nothing.

pool_lines

pool_lines(table, options)

Describe a pooled table as the lines a command prints.

The default prints every row as column=value pairs; an extension overrides it to word its own columns, e.g. the share of the ratio pairs within the limits of Guest.

Parameters:

Name Type Description Default
table DataFrame

the table pool returned.

required
options Mapping[str, Any]

the options pool got.

required

Returns:

Type Description
Sequence[str]

The lines, none for an empty table.

read_sections

read_sections(data, legacy)

Get the sections of the extensions of a record.

The sections are the field extensions of the record; a record without it, of pkpdsim 0.19 or earlier, has the evidence of the extensions as fields of its own, which are read as the sections: every extension of legacy with at least one of its fields in the record and not None gets the section of these fields with their values, e.g. {"temporal": {"temporal": ...}}; {"temporal": None} is no section. A record of pkpdsim 0.17 or 0.18 has none of them.

Parameters:

Name Type Description Default
data Mapping[str, Any]

the record of a context of use or of an assessment.

required
legacy Mapping[str, Sequence[str]]

the fields of every extension in a record of pkpdsim 0.19, LEGACY_CONTEXT_SECTIONS or LEGACY_ASSESSMENT_SECTIONS.

required

Returns:

Type Description
dict[str, Any]

The sections by the name of their extension, a copy.

read_acceptance

read_acceptance(data)

Get the rows of the acceptance of the record of a context of use.

The rows of the rules of the context and of the extensions as the record has them; a record of pkpdsim 0.19 has the rule of the ratio pairs as a field of its own (LEGACY_ACCEPTANCE), which is read as the last row, with the extension ratios.

Parameters:

Name Type Description Default
data Mapping[str, Any]

the record of a context of use.

required

Returns:

Type Description
list[dict[str, Any]]

The rows as plain data, copies.

scorecard_columns

scorecard_columns(extension, section)

Get the columns of an extension of a context, checked against its names.

Parameters:

Name Type Description Default
extension EvidenceExtension

the extension.

required
section Mapping[str, Any] | None

its section in the record of the context, None without.

required

Returns:

Type Description
dict[str, object]

The values by column, in the order of scorecard_names.

Raises:

Type Description
ValueError

if the columns are not the names of the extension.

rule_columns

rule_columns(columns, core, extensions)

Get the columns of a scorecard which the core compares as rules.

Every column which is neither a column of the core nor of an extension (EvidenceExtension.scorecard_names), whose regressions alone judges them, is the value of an acceptance rule.

Parameters:

Name Type Description Default
columns Iterable[str]

the columns of the scorecard, in their order.

required
core Collection[str]

the columns of the core, e.g. the model, the context and the verdict.

required
extensions Sequence[EvidenceExtension]

the extensions of the project.

required

Returns:

Type Description
list[str]

The columns of the rules, in their order.

scorecard_number

scorecard_number(value)

Get a value of a scorecard as a number, of the process or read from a TSV.

Parameters:

Name Type Description Default
value object

the value, e.g. 4, 4.0, "4" or "".

required

Returns:

Type Description
float

The number, NaN for None, an empty text or a text which is no

float

number.

scorecard_true

scorecard_true(value)

Check whether a value of a scorecard is true, of the process or read from a TSV.

Parameters:

Name Type Description Default
value object

the value, e.g. True or "True".

required

Returns:

Type Description
bool

Whether it is True or the text True.