@@ -582,27 +582,44 @@ fn circ_nested_dfgs() -> Circuit {
582582// A circuit with some simple circuit and an unsupported subgraph that does not interact with it.
583583#[ fixture]
584584fn circ_independent_subgraph ( ) -> Circuit {
585- let input_t = vec ! [
586- qb_t( ) ,
587- qb_t( ) ,
588- option_type( rotation_type( ) ) . into( ) ,
589- option_type( qb_t( ) ) . into( ) ,
590- ] ;
591- let output_t = vec ! [ qb_t( ) , qb_t( ) , rotation_type( ) , option_type( qb_t( ) ) . into( ) ] ;
585+ let input_t = vec ! [ qb_t( ) , qb_t( ) , option_type( bool_t( ) ) . into( ) ] ;
586+ let output_t = vec ! [ qb_t( ) , qb_t( ) , bool_t( ) ] ;
592587 let mut h =
593588 FunctionBuilder :: new ( "independent_subgraph" , Signature :: new ( input_t, output_t) ) . unwrap ( ) ;
594589
595- let [ q1, q2, maybe_rot , maybe_q ] = h. input_wires_arr ( ) ;
590+ let [ q1, q2, maybe_b ] = h. input_wires_arr ( ) ;
596591
597592 let [ q1, q2] = h
598593 . add_dataflow_op ( TketOp :: CX , [ q1, q2] )
599594 . unwrap ( )
600595 . outputs_arr ( ) ;
601- let [ rot ] = h
602- . build_unwrap_sum ( 1 , option_type ( rotation_type ( ) ) , maybe_rot )
596+ let [ maybe_b ] = h
597+ . build_unwrap_sum ( 1 , option_type ( bool_t ( ) ) , maybe_b )
603598 . unwrap ( ) ;
604599
605- let hugr = h. finish_hugr_with_outputs ( [ q1, q2, rot, maybe_q] ) . unwrap ( ) ;
600+ let hugr = h. finish_hugr_with_outputs ( [ q1, q2, maybe_b] ) . unwrap ( ) ;
601+ hugr. into ( )
602+ }
603+
604+ // A circuit with an unsupported wire from the input to the output.
605+ #[ fixture]
606+ fn circ_unsupported_io_wire ( ) -> Circuit {
607+ let input_t = vec ! [ qb_t( ) , qb_t( ) , option_type( qb_t( ) ) . into( ) ] ;
608+ let output_t = vec ! [ qb_t( ) , qb_t( ) , option_type( qb_t( ) ) . into( ) ] ;
609+ let mut h = FunctionBuilder :: new (
610+ "unsupported_input_to_output" ,
611+ Signature :: new ( input_t, output_t) ,
612+ )
613+ . unwrap ( ) ;
614+
615+ let [ q1, q2, maybe_q] = h. input_wires_arr ( ) ;
616+
617+ let [ q1, q2] = h
618+ . add_dataflow_op ( TketOp :: CX , [ q1, q2] )
619+ . unwrap ( )
620+ . outputs_arr ( ) ;
621+
622+ let hugr = h. finish_hugr_with_outputs ( [ q1, q2, maybe_q] ) . unwrap ( ) ;
606623 hugr. into ( )
607624}
608625
@@ -847,8 +864,9 @@ fn fail_on_modified_hugr(circ_tk1_ops: Circuit) {
847864//#[case::unsupported_subtree(circ_unsupported_subtree(), 3, CircuitRoundtripTestConfig::Default)]
848865#[ case:: global_defs( circ_global_defs( ) , 1 , CircuitRoundtripTestConfig :: Default ) ]
849866#[ case:: recursive( circ_recursive( ) , 1 , CircuitRoundtripTestConfig :: Default ) ]
850- // TODO: Encoding of independent subgraphs needs more debugging.
851- //#[case::independent_subgraph(circ_independent_subgraph(), 3, CircuitRoundtripTestConfig::Default)]
867+ #[ case:: independent_subgraph( circ_independent_subgraph( ) , 3 , CircuitRoundtripTestConfig :: Default ) ]
868+ // TODO: An unsupported wire from the input to the output causes an error.
869+ //#[case::unsupported_io_wire(circ_unsupported_io_wire(), 1, CircuitRoundtripTestConfig::Default)]
852870// TODO: fix edge case: non-local edge from an unsupported node inside a nested CircBox
853871// to/from the input of the head region being encoded...
854872//#[case::non_local(circ_non_local(), 1)]
0 commit comments