Skip to content

Commit

Permalink
Drop Tuple from schema
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Mar 25, 2024
1 parent 6357d8e commit 47d119c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 43 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ repos:
- id: end-of-file-fixer
exclude: |
(?x)^(
^specification/schema/|
\.snap$|
\.snap\.new$
specification/schema/.*|
.*.snap|
.*.snap.new
)$
- id: trailing-whitespace
exclude: |
Expand Down
7 changes: 2 additions & 5 deletions quantinuum-hugr-py/src/quantinuum_hugr/serialization/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,9 @@ def insert_child_dfg_signature(self, inputs: TypeRow, outputs: TypeRow) -> None:
if isinstance(pred, tys.UnitSum):
self.sum_rows = [[] for _ in range(cast(tys.UnitSum, pred).size)]
else:
assert isinstance(pred, tys.GeneralSum)
self.sum_rows = []
for variant in pred.rows:
assert isinstance(variant, tys.TupleType)
self.sum_rows.append(variant.inner)
self.sum_rows.append(variant)
self.other_outputs = outputs[1:]

class Config:
Expand Down Expand Up @@ -346,8 +344,7 @@ def insert_port_types(self, in_types: TypeRow, out_types: TypeRow) -> None:
assert isinstance(pred, tys.GeneralSum)
self.sum_rows = []
for ty in pred.rows:
assert isinstance(ty, tys.TupleType)
self.sum_rows.append(ty.inner)
self.sum_rows.append(ty)
self.other_inputs = list(in_types[1:])
self.outputs = list(out_types)

Expand Down
9 changes: 1 addition & 8 deletions quantinuum-hugr-py/src/quantinuum_hugr/serialization/tys.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,6 @@ class Array(MultiContainer):
len: int


class TupleType(BaseModel):
"""Product type, known-size tuple over elements of type row."""

t: Literal["Tuple"] = "Tuple"
inner: "TypeRow"


class UnitSum(BaseModel):
"""Simple predicate where all variants are empty tuples."""

Expand Down Expand Up @@ -286,7 +279,7 @@ class Type(RootModel):
"""A HUGR type."""

root: Annotated[
Qubit | Variable | USize | PolyFuncType | Array | TupleType | SumType | Opaque,
Qubit | Variable | USize | PolyFuncType | Array | SumType | Opaque,
WrapValidator(_json_custom_error_validator),
] = Field(discriminator="t")

Expand Down
28 changes: 1 addition & 27 deletions specification/schema/hugr_schema_v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -1276,28 +1276,6 @@
"title": "TupleParam",
"type": "object"
},
"TupleType": {
"description": "Product type, known-size tuple over elements of type row.",
"properties": {
"t": {
"const": "Tuple",
"default": "Tuple",
"title": "T"
},
"inner": {
"items": {
"$ref": "#/$defs/Type"
},
"title": "Inner",
"type": "array"
}
},
"required": [
"inner"
],
"title": "TupleType",
"type": "object"
},
"Type": {
"description": "A HUGR type.",
"discriminator": {
Expand All @@ -1308,7 +1286,6 @@
"Opaque": "#/$defs/Opaque",
"Q": "#/$defs/Qubit",
"Sum": "#/$defs/SumType",
"Tuple": "#/$defs/TupleType",
"V": "#/$defs/Variable"
},
"propertyName": "t"
Expand All @@ -1329,9 +1306,6 @@
{
"$ref": "#/$defs/Array"
},
{
"$ref": "#/$defs/TupleType"
},
{
"$ref": "#/$defs/SumType"
},
Expand Down Expand Up @@ -1669,4 +1643,4 @@
],
"title": "Hugr",
"type": "object"
}
}

0 comments on commit 47d119c

Please sign in to comment.