Python API reference
The public API of the gecode_iris package. pdoc 16.0.0 generates it during each site build from the package's type stubs and docstrings. The Python guide shows the API in use, and the spec builder's reference covers gecode_iris.build.
Read text instance files with Iris reader specs.
Parse a reader spec with Spec.parse or Spec.load, then read an
input with spec.read. Language errors raise Error. Build a reader
spec in Python with typed handles in gecode_iris.build.
The package also installs the iris command, the same command line as the
Rust iris binary.
CallSite
A place in the host program: where a builder statement was called.
str(site) is file:line.
CallSite.filename
The file of the calling code, as its code object names it.
CallSite.line
The line of the call, counting from 1.
CallSite.function
The name of the calling function, such as <module>.
Data
The data from one read or catalog.
data[name] returns an entry's value and name in data tests for an
entry. Values are copied into Python objects on each access: an int,
float or str at depth 0, and nested lists at greater depths.
A handle from gecode_iris.build can stand for the name, and then
data[handle] has the handle's type: None when an optional entry is
absent. A handle whose entry has another value type or depth, because a
later statement redefined its name or the handle belongs to another reader
spec, raises TypeError.
Data.ints
The integer row of an entry at a path.
Data.array
An array of an entry, or of its row at a path.
The result is a numpy.ndarray when numpy is importable and the
array is rectangular, and nested lists otherwise.
Data.to_dict
All entries as a dict from name to value, in entry order.
Data.to_json
The canonical JSON document, ending in a newline.
Data.to_dzn
The MiniZinc data text defined in the Specification's appendix B.
Data.entries
The entries in the order their names were defined.
Entry
The name, value type and depth of one entry in Data.
Entry.name
The entry name.
Entry.value_type
The type of the entry's scalars.
Entry.depth
The number of array levels: 0 for a scalar, 1 for a row, and so on.
Error
A language error from parsing a reader spec or reading an input.
str(error) is the full diagnostic. The location is the input
location when there is one, and otherwise the reader spec location;
line, column and origin are each None when unknown.
path is the record path of a failed check over records.
Host failures, such as a missing file, raise built-in exceptions instead and have no error code.
Error.code
The stable error code, such as E-CHECK-FAILED.
Error.message
The message, without location or excerpt.
Error.line
The line of the location, counting from 1.
Error.column
The byte column of the location, counting from 1.
Error.path
The record path of a failed check over records.
Error.origin
The input or reader spec origin of the location, such as its path.
Error.call_site
Where the statement the error belongs to was called, for a spec built
with gecode_iris.build; None for a spec parsed from text.
Error.to_json
Return the canonical JSON error document.
Spec
A parsed and checked reader spec.
One Spec can read any number of inputs, and threads can share it.
Spec.parse
Parse and check a reader spec given as str or bytes.
Spec.load
Read and parse a reader spec file; the path is the error origin.
Spec.read
Read one instance from input bytes or from a path.
Spec.catalog
List the instances in the input, with the same arguments as read.
Value
An entry value: int, float or str at depth 0, and a list of
values one level shallower at each greater depth.
The iris command
The iris console script, which runs the Rust iris command line.
Run iris on this process's arguments and exit with its status.