cosmiq.devices#
Devices: their limits, the bundled reference devices, discretisation and the check.
A device's limits and calibration. |
|
Every rounding |
|
The ids of the bundled devices, sorted. |
|
All violations of |
|
The register rules alone (R1-R4, RD, RF; R5 raises CapabilityError), for to_target before any drive is known. |
|
The schedule on |
|
A bundled device by id: a fresh copy, so changing its |
|
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:
_ModelA device’s limits and calibration. Load the bundled ones with
cosmiq.devices.get.- device: DeviceInfo#
- species: Species#
- geometry: Geometry#
- timing: Timing#
- analog: AnalogCapabilities#
- calibration: Calibration#
- property ref: str#
The device as violations and results record it: “id@capabilities_version”.
- class cosmiq.devices.DiscretizationReport(roundings: Iterable[Rounding] = ())#
Bases:
objectEvery rounding
discretizemade. Immutable; compares by its roundings.
- class cosmiq.devices.Rounding(kind: Literal['time', 'value', 'position'], where: str, before: float, after: float)#
Bases:
object
Functions
- 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 itsto_data(). Pass the pre-discretisation schedule asrounded_fromso violations caused by rounding are marked. Never raises for a rule; raises FormatError for malformed data or data labelled for another device (data.deviceis not None and isn’tspec‘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,labelsanddeviceare read (of a Schedule, itsto_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) asrounded_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, ascheckdoes.
- 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 targetsspec(itsdeviceandcapabilities_versionare the spec’s) only aftercosmiq.devices.checkfound nothing, so a device label always means a check passed (N-14). Otherwise it raises ConstraintError with every violation, those that only rounding caused markedcaused_by_rounding(with the fix to put the values on the grid first).exact=Trueraises ConstraintError on any non-zero rounding, before the check.specis 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
provenanceor 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.