Skip to content

Validation

pynumgeo.validation

Validation of a deck against what numgeo accepts.

Examples:

>>> from pynumgeo.deck import Deck
>>> d = Deck()
>>> _ = d.mesh.add_nodes([[0, 0], [1, 0]], labels=[1, 3]); _ = d.mesh.add_elements("u2-truss", [[1, 3]])
>>> [i.id for i in validate(d)]
['NG-MESH-001', 'NG-MESH-008']

BuildProfile(name='full', public=False, solvers=None) dataclass

Which numgeo build the deck is meant for.

full (default): the current developer source as built (public_version = .false.) — every model of the catalogue is allowed. public: a build with public_version = .true. (non-public models, contact models and line-search options are rejected). solvers: linear solvers compiled into the executable (None = unknown, not checked).

full() classmethod

The current developer build (default).

public_build() classmethod

A build with public_version = .true..

Rule(id, severity, title, func, source=None) dataclass

A registered validation rule.

Issue(id, severity, message, location=None, keyword=None, source=None) dataclass

One finding.

Attributes:

Name Type Description
id str

rule id, e.g. NG-STEP-003 (stable; documented in the validator).

severity Severity

error (numgeo fails or computes something else than intended), warning, info.

message str

what is wrong and what to do.

location str | None

file:line or an object path such as steps[0].items[2].

keyword str | None

the keyword concerned, if any.

source str | None

solver source location of the behaviour the rule mirrors (src/...:line).

as_dict()

Plain dict (for --json output).

rule(id, severity, title, *, source=None)

Register a rule (decorator). Ids must be unique.

has_errors(issues)

True if any issue has severity error.

validate(deck, *, profile=None, select=None)

Check deck and return the issues (errors first, then warnings and infos, each in rule order).

Parameters:

Name Type Description Default
deck Deck

the deck to check.

required
profile BuildProfile | None

numgeo build the deck is meant for (default: the current developer build).

None
select Iterable[str] | None

only these rule ids.

None

pynumgeo.validation.engine

Rule engine of the validator.

A rule is a function (ctx) -> Iterable[Finding] registered with :func:rule. Its metadata (id, severity, title, the solver source it mirrors) is part of the rule, so every reported :class:~pynumgeo.validation.issue.Issue can say why it is reported. Rule ids are stable (NG-<AREA>-<nnn>) and documented by :func:rules.

A finding is either a plain message or (message, location); the engine turns it into an Issue.

BuildProfile(name='full', public=False, solvers=None) dataclass

Which numgeo build the deck is meant for.

full (default): the current developer source as built (public_version = .false.) — every model of the catalogue is allowed. public: a build with public_version = .true. (non-public models, contact models and line-search options are rejected). solvers: linear solvers compiled into the executable (None = unknown, not checked).

full() classmethod

The current developer build (default).

public_build() classmethod

A build with public_version = .true..

Context(deck, catalogue, profile=BuildProfile()) dataclass

What a rule sees: the deck, the catalogue and the build profile.

Rule(id, severity, title, func, source=None) dataclass

A registered validation rule.

rule(id, severity, title, *, source=None)

Register a rule (decorator). Ids must be unique.

rules()

All registered rules, sorted by id.

run_rules(ctx, select=None)

Run all (or the selected) rules and return their issues in rule order.