You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This diff "fixes" the Rust by making it output the same as hugr-py:
--- a/hugr-core/src/hugr/serialize.rs
+++ b/hugr-core/src/hugr/serialize.rs
@@ -183,7 +183,13 @@ impl TryFrom<&Hugr> for SerHugrLatest {
let op = hugr.get_optype(node);
let is_value_port = offset < op.value_port_count(dir);
let is_static_input = op.static_port(dir).map_or(false, |p| p.index() == offset);
- let offset = (is_value_port || is_static_input).then_some(offset as u16);
+ let offset = (is_value_port
+ || is_static_input
+ || matches!(
+ op.port_kind(crate::Port::new(dir, offset)),
+ Some(crate::types::EdgeKind::ControlFlow)
+ ))
+ .then_some(offset as u16);
(node_rekey[&node], offset)
};
although I wonder if we could avoid is_value_port and is_static_input (misnamed, should be is-static-port) altogether as these seem to duplicate logic in OpType::port_kind - maybe just something like matches!(op.port_kind(...), EdgeKind::Value(_) | EdgeKind::Static | EdgeKind::ControlFlow)
Rust produces edges something like:
...(where nodes 1-4 are DataflowBlocks - note the two
[1, null]
outports for successors 0 and 1 of the same block)Whereas hugr-py produces
...(eliding non-block edges)
In practice, both roundtrip, and Rust is able to load hugr-py output, but not vice versa.
The text was updated successfully, but these errors were encountered: