SitePattern¶
from cascaqit import SitePattern
Specify dimensionless weights for addressed controls. site_ids and weights must be nonempty tuples of equal length, with unique nonempty site names. Numeric weights lie in [0, 1]; booleans are not numeric weights. Once all values are numeric, at least one weight must be positive.
Weights may contain Parameter or Expression values. Within AHS, parameters must be owned by that program and dimensionless. Program export requires weights for every filled target site and maps them into register order; the alphabetical order chosen by from_mapping() does not define state bit order.
from cascaqit import SitePattern
pattern = SitePattern.from_mapping({"q1": 0.25, "q0": 1.0})
assert pattern.site_ids == ("q0", "q1")
assert pattern.to_ir().weights == (1.0, 0.25)
See Local detuning for usage.
Copy a site-to-weight mapping in sorted site-name order and return a new SitePattern. Keys must be strings; constructor validation still checks empty input, identity and weight constraints.
Evaluate weights from a name-to-value mapping and return an independent SitePattern. Parameter evaluation and numeric limits are checked again, including rejection of an all-zero result.
Return True when every weight is a normalized float. This does not check whether sites exist in a particular register.
Return sorted unique parameter dependency names as a tuple.
validate_parameter_references ¶
validate_parameter_references(
declarations: Mapping[str, Parameter],
) -> None
Check parameter ownership and dimensionless units, and ensure expression dependencies exist. Return None on success or raise ProgramValidationError for mismatches. This does not bind values.
Return numeric SitePatternIR. Unbound weights raise ProgramValidationError; array order remains this pattern’s site_ids order.