Skip to content

Commit

Permalink
fix: Serialisation of float values (#219)
Browse files Browse the repository at this point in the history
Fixes #218
  • Loading branch information
mark-koch authored May 17, 2024
1 parent 7ad3908 commit 937260a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion guppylang/prelude/_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ class ConstInt(BaseModel):
value: int


class ConstF64(BaseModel):
"""Hugr representation of float values."""

value: float


def bool_value(b: bool) -> ops.Value:
"""Returns the Hugr representation of a boolean value."""
unit = ops.Value(ops.TupleValue(vs=[]))
Expand Down Expand Up @@ -85,7 +91,7 @@ def float_value(f: float) -> ops.Value:
ops.ExtensionValue(
extensions=["arithmetic.float.types"],
typ=hugr_float_type,
value=ops.CustomConst(c="ConstF64", v=f),
value=ops.CustomConst(c="ConstF64", v=ConstF64(value=f)),
)
)

Expand Down

0 comments on commit 937260a

Please sign in to comment.