Pattern Text Format

GraphQOMB writes pattern files using format version 2. Version 2 adds optional per-input positive Pauli eigenstate initialization:

.version 2
.input 0:0 1:1 2:2
.input_basis 1:Y 2:Z

Each .input_basis entry has the form node:X, node:Y, or node:Z and must reference a node declared by .input. X initialization is the default and is omitted when serializing, so the example initializes nodes 0, 1, and 2 as X+, Y+, and Z+ respectively.

Version 1 files remain readable. Inputs in a version 1 file, or in a version 2 file without a corresponding .input_basis entry, are initialized as X+. The .input_basis directive is rejected in version 1 files.

graphqomb.ptn_format module

Pattern text format (.ptn) module.

This module provides:

  • dump: Write a pattern to a .ptn file or string.

  • load: Read a pattern from a .ptn file or string.

  • dumps: Serialize a pattern to a .ptn format string.

  • loads: Deserialize a pattern from a .ptn format string.

graphqomb.ptn_format.dumps(pattern)[source]

Serialize a pattern to a .ptn format string.

Parameters:

pattern (Pattern) – The pattern to serialize.

Returns:

The .ptn format string.

Return type:

str

graphqomb.ptn_format.dump(pattern, file)[source]

Write a pattern to a .ptn file.

Parameters:
graphqomb.ptn_format.loads(s)[source]

Deserialize a .ptn format string to a pattern.

Parameters:

s (str) – The .ptn format string.

Returns:

The loaded pattern.

Return type:

Pattern

See also

_Parser.parse

Internal parser that may raise ValueError for invalid input.

graphqomb.ptn_format.load(file)[source]

Read a pattern from a .ptn file.

Parameters:

file (pathlib.Path | str) – The file path to read from.

Returns:

The loaded pattern. See loads for details.

Return type:

Pattern