wire
eigenkit.photonics.wire
The JSON encoding of photonic circuits.
This module is the photonic counterpart of core.wire. It turns a
PhotonicCircuitSpec into plain JSON data and back, so that a circuit can be sent
to a service or stored. It holds only data, and does not use Perceval.
The angles of the components use the same encoding as the parameters of the qubit
circuits, so a WeightRef or an InputRef means the same thing in both.
photonic_spec_from_json(data)
Build a photonic circuit from the data that photonic_spec_to_json produced.
The circuit goes through the same checks as one built by hand.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
The encoded circuit. |
required |
Returns:
| Type | Description |
|---|---|
PhotonicCircuitSpec
|
The decoded |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
KeyError
|
If a key is missing. |
ValueError
|
If a component is unknown, or the circuit is not valid. |
photonic_spec_to_json(spec)
Encode a photonic circuit as JSON data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
PhotonicCircuitSpec
|
The circuit to encode. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary with the keys |