-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: extract_hugr
not removing root node ports
#1239
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -381,6 +381,7 @@ mod test { | |
use crate::builder::test::simple_dfg_hugr; | ||
use crate::builder::{Container, Dataflow, DataflowSubContainer, HugrBuilder, ModuleBuilder}; | ||
use crate::extension::PRELUDE_REGISTRY; | ||
use crate::hugr::views::DescendantsGraph; | ||
use crate::ops::handle::{CfgID, DataflowParentID, DfgID, FuncID}; | ||
use crate::ops::{dataflow::IOTrait, Input, OpTag, Output}; | ||
use crate::ops::{OpTrait, OpType}; | ||
|
@@ -493,10 +494,11 @@ mod test { | |
fn extract_hugr() -> Result<(), Box<dyn std::error::Error>> { | ||
let (hugr, def, _inner) = make_module_hgr()?; | ||
|
||
let region: SiblingGraph = SiblingGraph::try_new(&hugr, def)?; | ||
let region: DescendantsGraph = DescendantsGraph::try_new(&hugr, def)?; | ||
let extracted = region.extract_hugr(); | ||
extracted.validate(&PRELUDE_REGISTRY)?; | ||
|
||
let region: SiblingGraph = SiblingGraph::try_new(&hugr, def)?; | ||
let region: DescendantsGraph = DescendantsGraph::try_new(&hugr, def)?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you changing to a DescendentsGraph? I think his test is supposed to be testing functionality of SiblingGraph. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test hugr contains an inner DFG, so extracting just the SiblingGraph produced an invalid DFG node without children -.- There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a good solution is to change it to extract the dfg, and assert that the root of the new hugr has no ports There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess I should have moved this test to |
||
|
||
assert_eq!(region.node_count(), extracted.node_count()); | ||
assert_eq!(region.root_type(), extracted.root_type()); | ||
aborgna-q marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we add a test?
make_module_hgr
seems to provide a suitable case, the inner DFG (which has ports) should be extracted.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what the descendant graph test is doing. Only
SiblingGraph
andDescendantGraph
run this code on extraction.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test you changed: