Skip to content

Commit

Permalink
More review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Mar 19, 2024
1 parent c96ff6e commit 1200731
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
17 changes: 9 additions & 8 deletions quantinuum-hugr-py/src/quantinuum_hugr/serialization/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ class DataflowBlock(BaseOp):
extension_delta: ExtensionSet = Field(default_factory=list)

def insert_port_types(self, in_types: TypeRow, out_types: TypeRow) -> None:
# The types will be all None because it's not dataflow, but we only care about
# the number of outputs. Note that we don't make use of the HUGR feature where
# the variant data is appended to successor input. Thus, `predicate_variants`
# will only contain empty rows.
num_cases = len(out_types)
self.sum_rows = [[] for _ in range(num_cases)]

Expand All @@ -192,7 +188,15 @@ def insert_child_dfg_signature(self, inputs: TypeRow, outputs: TypeRow) -> None:
class Config:
# Needed to avoid random '\n's in the pydantic description
json_schema_extra = {
"description": "A CFG basic block node. The signature is that of the internal Dataflow graph."
"required": [
"parent",
"op",
"inputs",
"other_outputs",
"sum_rows",
"extension_delta",
],
"description": "A CFG basic block node. The signature is that of the internal Dataflow graph.",
}


Expand Down Expand Up @@ -478,9 +482,6 @@ class TypeApply(LeafOpBase):
class TypeApplication(BaseModel):
"""Records details of an application of a PolyFuncType to some TypeArgs and the
result (a less-, but still potentially-, polymorphic type).
Note that Guppy only generates full type applications, where the result is a
monomorphic type. Partial type applications are not used by Guppy.
"""

input: PolyFuncType
Expand Down
10 changes: 1 addition & 9 deletions quantinuum-hugr-py/src/quantinuum_hugr/serialization/tys.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,13 @@ class UnitSum(BaseModel):


class GeneralSum(BaseModel):
"""General sum type that explicitly stores the types of the variants"""
"""General sum type that explicitly stores the types of the variants."""

t: Literal["Sum"] = "Sum"

s: Literal["General"] = "General"
rows: list["TypeRow"]

class Config:
# Needed to avoid random '\n's in the pydantic description
json_schema_extra = {
"description": (
"General sum type that explicitly stores the types of the variants."
)
}


class SumType(RootModel):
root: Union[UnitSum, GeneralSum] = Field(discriminator="s")
Expand Down
7 changes: 6 additions & 1 deletion specification/schema/hugr_schema_v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,12 @@
}
},
"required": [
"parent"
"parent",
"op",
"inputs",
"other_outputs",
"sum_rows",
"extension_delta"
],
"title": "DataflowBlock",
"type": "object"
Expand Down

0 comments on commit 1200731

Please sign in to comment.