cosmiq.devices#

Devices: their limits, the bundled reference devices, discretisation and the check.

DeviceSpec

A device's limits and calibration.

DiscretizationReport

Every rounding discretize made.

Rounding

available

The ids of the bundled devices, sorted.

check

All violations of spec (and, with strict=True, of the strict envelope).

check_register

The register rules alone (R1-R4, RD, RF; R5 raises CapabilityError), for to_target before any drive is known.

discretize

The schedule on spec's grids, checked against it: the result targets spec (its device and capabilities_version are the spec's) only after cosmiq.devices.check found nothing, so a device label always means a check passed (N-14).

get

A bundled device by id: a fresh copy, so changing its provenance or calibration values can't change anyone else's.

strictest

The strict envelope: every bundled device's limits at once (the smallest maxima, the largest minima), as a fresh copy.

Classes

class cosmiq.devices.DeviceSpec(*, spec_format: Literal['cosmiq.device/1'] = 'cosmiq.device/1', device: DeviceInfo, species: Species, geometry: Geometry, timing: Timing, analog: AnalogCapabilities, calibration: Calibration, provenance: dict[str, str]=<factory>)#

Bases: _Model

A device’s limits and calibration. Load the bundled ones with cosmiq.devices.get.

spec_format: Literal['cosmiq.device/1']#
device: DeviceInfo#
species: Species#
geometry: Geometry#
timing: Timing#
analog: AnalogCapabilities#
calibration: Calibration#
provenance: dict[str, str]#
property ref: str#

The device as violations and results record it: “id@capabilities_version”.

class cosmiq.devices.DiscretizationReport(roundings: Iterable[Rounding] = ())#

Bases: object

Every rounding discretize made. Immutable; compares by its roundings.

property roundings: tuple[Rounding, ...]#
property max_shift: dict[str, float]#

The largest |after - before| per kind.

class cosmiq.devices.Rounding(kind: Literal['time', 'value', 'position'], where: str, before: float, after: float)#

Bases: object

kind: Literal['time', 'value', 'position']#
where: str#

“amplitude.t[2]”, “detuning.v[1]”, “atom 3.x”, …

before: float#
after: float#

Functions

cosmiq.devices.available() → list[str]#

The ids of the bundled devices, sorted.

cosmiq.devices.check(data: Schedule | ScheduleData, spec: DeviceSpec, *, strict: bool = False, rounded_from: Schedule | ScheduleData | None = None) → list[Violation]#

All violations of spec (and, with strict=True, of the strict envelope). A Schedule is checked as its to_data(). Pass the pre-discretisation schedule as rounded_from so violations caused by rounding are marked. Never raises for a rule; raises FormatError for malformed data or data labelled for another device (data.device is not None and isn’t spec‘s id: N-14), TypeError for an argument of the wrong type, and CapabilityError when the device can’t run the schedule at all (R5 trap layouts, or a local detuning on a device without one). A label with another capabilities version is fine: checking a document against the limits in force is what a re-check is for.

The strict envelope is checked for every range, slew, spacing and duration rule, but not for the grids (R4, R11, R12, the weight grid): a schedule is discretised for its target, and the grids of two devices needn’t nest.

cosmiq.devices.check_register(positions_and_labels: Schedule | ScheduleData, spec: DeviceSpec, *, strict: bool = False, rounded_from: Schedule | ScheduleData | None = None) → list[Violation]#

The register rules alone (R1-R4, RD, RF; R5 raises CapabilityError), for to_target before any drive is known. Only positions, labels and device are read (of a Schedule, its to_data()). With strict=True, the strict envelope’s register rules too (but not its position grid, R4). Pass the positions before rounding (devices._discretize.round_register) as rounded_from, so violations that only the rounding caused are marked. Raises TypeError for an argument of the wrong type, and FormatError for a register labelled for another device, as check does.

cosmiq.devices.discretize(schedule: Schedule, spec: DeviceSpec | str, *, exact: bool = False) → tuple[Schedule, DiscretizationReport]#

The schedule on spec‘s grids, checked against it: the result targets spec (its device and capabilities_version are the spec’s) only after cosmiq.devices.check found nothing, so a device label always means a check passed (N-14). Otherwise it raises ConstraintError with every violation, those that only rounding caused marked caused_by_rounding (with the fix to put the values on the grid first). exact=True raises ConstraintError on any non-zero rounding, before the check.

spec is a DeviceSpec or a bundled device’s id (“cosmiq-ref-1”); an id that isn’t bundled raises FormatError naming the ones that are, and anything else TypeError. Rounding that makes two atoms coincide raises ConstraintError (R3), since no register can hold them.

cosmiq.devices.get(device_id: str) → DeviceSpec#

A bundled device by id: a fresh copy, so changing its provenance or calibration values can’t change anyone else’s. Raises KeyError naming the available ids.

cosmiq.devices.strictest() → DeviceSpec#

The strict envelope: every bundled device’s limits at once (the smallest maxima, the largest minima), as a fresh copy. check(..., strict=True) checks against it, except for its grids.