ps.checks
ps.checks.Check
Section titled “ps.checks.Check”ps.checks.Check(*args, **kwargs)
A check of your own: its code, and the rows it finds on a model.
ps.checks.register(check) adds it; every m.check() (and so every compile and
deck.check()) runs it after PetroScript’s own checks, on the model as it is then.
PetroScript keeps its own rows from the model’s construction; a check of yours is never
kept, so one registered after a model was built finds the model at its next check. A row
states what was measured in value and unit and the bound it was held against in
held_against (PetroScript’s own rows cite their facts in facts instead); an error
row needs a registered code, so a project rule reports a warning or an info row.
Examples
Section titled “Examples”import petroscript as ps class BhpFloor: … code = “acme.bhp_floor” … def call(self, model): … return [ … ps.Issue(code=self.code, severity=“warning”, address=address, … message=“BHP limit below the company floor of 435 psia”, … value=control.bhp_limit, unit=“psia”, held_against=435.0) … for address in model.find(“schedule///control”) … if (control := model.get(address)).bhp_limit is not None … and control.bhp_limit < 435.0 … ]
ps.checks.register
Section titled “ps.checks.register”ps.checks.register(check: Check) -> None
Add check to the checks every m.check() runs after PetroScript’s own.
ps.checks.register(BhpFloor()) runs ps.checks.Check’s example check in every
m.check() after it.
A check may read the model’s facts and PetroScript’s own rows: while the registered checks
run, a model.describe() or model.check() one of them calls returns the facts and
PetroScript’s own rows and runs no registered check again, so a check never sees another
registered check’s rows (the order they run in is not promised).
Parameters
Section titled “Parameters”check : Check
An object with a code and a call check(model) that returns a list of
ps.Issue.
Raises
Section titled “Raises”LookupError A check with the same code was added already: the table is added to only.
Examples
Section titled “Examples”import petroscript as ps class BhpFloor: … code = “acme.bhp_floor” … def call(self, model): … return [ … ps.Issue(code=self.code, severity=“warning”, address=address, … message=“the BHP limit is below the floor of 55 barsa”, … value=model.get(address).bhp_limit, unit=“barsa”, … held_against=55.0) … for address in model.find(“schedule///control”) … if (model.get(address).bhp_limit or 0.0) < 55.0 … ] ps.checks.register(BhpFloor()) m = ps.load(“tests/results_fixtures/QUICKSTART/MERLE.DATA”) # limits of 50 barsa [row.address for row in m.check() if row.code == “acme.bhp_floor”] [‘schedule/2009-06-01/M-1/control’, ‘schedule/2011-03-01/M-2/control’]
PetroScript is licensed under the Apache License 2.0. © 2026 Blauweiss EDV LLC. PetroScript by Blauweiss AI.For AI agents: llms.txt