Restructure Gate_QisGate as discriminated union and add pauliexp#36
Draft
Restructure Gate_QisGate as discriminated union and add pauliexp#36
Conversation
Replace the flat-bag Gate_QisGate with a oneOf + discriminator(propertyName: gate)
tagged union, one variant per gate. The old shape declared
{gate, target, targets, control, controls, rotation} with additionalProperties:
false, which made every pauliexp payload (terms/coefficients/time) violate the
schema and let nonsensical combinations validate.
Adds 20 per-gate variant schemas including Gate_Pauliexp(targets, terms,
coefficients, time). Qubit indices are typed integer/int32/minimum: 0 instead
of number/double. Each variant pins gate to a single-value enum so the
generated client gets Literal["x"] typing.
Test fixtures using singular target/control are updated to the canonical
list form (targets: [t], controls: [c]).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Gate_QisGatewithoneOf+discriminator(propertyName: gate)and 20 per-gate variant schemas.Gate_Pauliexp(targets, terms, coefficients, time)so pauliexp payloads now type-check.int32, minimum: 0(wasnumber/double).gatetoenum: [<name>]so the generated client getsLiteral["x"]typing.Test fixtures using singular
target/controlare updated to the canonical list form.Test plan
uv run pytest --no-cov(237 passed, 28 integration deselected)uvx oas-patch overlay openapi.json openapi-overlay.yamlapplies cleanlyuvx openapi-python-client generate ...regeneratesionq_core/cleanlyGatePauliexp(targets=[0,1,2,3,4,5], terms=["IIIIYX","IIIIXY"], coefficients=[0.88,-0.88], time=1.0)constructs and round-trips throughto_dict/from_dictpauliexp-gate-schemabranch (gated; run weekly viaintegration.yml)Important
Most code in
ionq_core/is auto-generated and overwritten on regeneration.See CONTRIBUTING.md for which files are safe to edit.