Skip to content

Restructure Gate_QisGate as discriminated union and add pauliexp#36

Draft
splch wants to merge 1 commit intomainfrom
pauliexp-gate-schema
Draft

Restructure Gate_QisGate as discriminated union and add pauliexp#36
splch wants to merge 1 commit intomainfrom
pauliexp-gate-schema

Conversation

@splch
Copy link
Copy Markdown
Collaborator

@splch splch commented May 2, 2026

Summary

  • Replace flat-bag Gate_QisGate with oneOf + discriminator(propertyName: gate) and 20 per-gate variant schemas.
  • Add Gate_Pauliexp(targets, terms, coefficients, time) so pauliexp payloads now type-check.
  • Type qubit indices as int32, minimum: 0 (was number/double).
  • Each variant pins gate to enum: [<name>] so the generated client gets Literal["x"] typing.

Test fixtures using singular target/control are 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.yaml applies cleanly
  • uvx openapi-python-client generate ... regenerates ionq_core/ cleanly
  • GatePauliexp(targets=[0,1,2,3,4,5], terms=["IIIIYX","IIIIXY"], coefficients=[0.88,-0.88], time=1.0) constructs and round-trips through to_dict/from_dict
  • Integration tests on pauliexp-gate-schema branch (gated; run weekly via integration.yml)

Important

Most code in ionq_core/ is auto-generated and overwritten on regeneration.
See CONTRIBUTING.md for which files are safe to edit.

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]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant