@@ -712,8 +712,7 @@ fn get_2q_decomposers_from_target(
712
712
op. operation . matrix ( & op. params ) . unwrap ( ) . view ( ) ,
713
713
None ,
714
714
None ,
715
- )
716
- . unwrap ( )
715
+ ) ?
717
716
. a ;
718
717
let mut fidelity_value = match available_2q_props. get ( name) {
719
718
Some ( & ( _, error) ) => 1.0 - error. unwrap_or ( 0.0 ) ,
@@ -781,17 +780,15 @@ fn get_2q_decomposers_from_target(
781
780
& embodiments_dict,
782
781
pi2_decomposer,
783
782
) ) ?;
784
- let decomposer_gate = decomposer. getattr ( "gate" ) ?;
783
+ let decomposer_gate = decomposer. getattr ( intern ! ( py , "gate" ) ) ?;
785
784
786
- // .getattr("name")?
787
- // .extract::<String>()?;
788
785
789
786
decomposers. push ( DecomposerElement {
790
787
decomposer : DecomposerType :: XXDecomposer ( decomposer. into ( ) ) ,
791
- decomp_gate : decomposer_gate. getattr ( "name" ) ?. extract :: < String > ( ) ?,
788
+ decomp_gate : decomposer_gate. getattr ( intern ! ( py , "name" ) ) ?. extract :: < String > ( ) ?,
792
789
decomp_gate_params : Some (
793
790
decomposer_gate
794
- . getattr ( "params" ) ?
791
+ . getattr ( intern ! ( py , "params" ) ) ?
795
792
. extract :: < SmallVec < [ Param ; 3 ] > > ( ) ?,
796
793
) ,
797
794
} ) ;
@@ -816,7 +813,7 @@ fn preferred_direction(
816
813
let reverse_qubits: SmallVec < [ PhysicalQubit ; 2 ] > = qubits. iter ( ) . rev ( ) . copied ( ) . collect ( ) ;
817
814
818
815
let compute_cost =
819
- |lengths : bool , q_tuple : & SmallVec < [ PhysicalQubit ; 2 ] > , in_cost : f64 | -> PyResult < f64 > {
816
+ |lengths : bool , q_tuple : & [ PhysicalQubit ; 2 ] , in_cost : f64 | -> PyResult < f64 > {
820
817
let cost = match target. qargs_for_operation_name ( & decomposer. decomp_gate ) {
821
818
Ok ( _) => match target[ & decomposer. decomp_gate ] . get ( Some ( q_tuple) ) {
822
819
Some ( Some ( _props) ) => {
@@ -903,14 +900,15 @@ fn synth_su4(
903
900
let synth_dag = match & decomposer_2q. decomposer {
904
901
// the output will be a dag in the relative basis
905
902
DecomposerType :: XXDecomposer ( decomposer) => {
906
- let mut kwargs = HashMap :: < & str , bool > :: new ( ) ;
907
- kwargs. insert ( "approximate" , is_approximate) ;
908
- kwargs. insert ( "use_dag" , true ) ;
903
+ let kwargs: HashMap < & str , bool > = [
904
+ ( "approximate" , is_approximate) ,
905
+ ( "use_dag" , true )
906
+ ] . iter ( ) . collect ( ) ;
909
907
// can we avoid cloning the matrix to pass it to python?
910
908
decomposer
911
909
. call_method_bound (
912
910
py,
913
- "__call__" ,
911
+ intern ! ( py , "__call__" ) ,
914
912
( su4_mat. clone ( ) . into_pyarray_bound ( py) , ) ,
915
913
Some ( & kwargs. into_py_dict_bound ( py) ) ,
916
914
) ?
@@ -1025,16 +1023,12 @@ fn reversed_synth_su4(
1025
1023
let mut su4_mat_mm = su4_mat. clone ( ) ;
1026
1024
1027
1025
// Swap rows 1 and 2
1028
- let row_1 = su4_mat_mm. slice ( s ! [ 1 , ..] ) . to_owned ( ) ;
1029
- let row_2 = su4_mat_mm. slice ( s ! [ 2 , ..] ) . to_owned ( ) ;
1030
- su4_mat_mm. slice_mut ( s ! [ 1 , ..] ) . assign ( & row_2) ;
1031
- su4_mat_mm. slice_mut ( s ! [ 2 , ..] ) . assign ( & row_1) ;
1026
+ let ( mut row_1, mut row_2) = su4_mat_mm. multi_slice_mut ( ( s ! [ 1 , ..] , s ! [ 2 , ..] ) ) ;
1027
+ azip ! ( ( x in & mut row_1, y in & mut row2) ( * x, * y) = ( * y, * x) )
1032
1028
1033
1029
// Swap columns 1 and 2
1034
- let col_1 = su4_mat_mm. slice ( s ! [ .., 1 ] ) . to_owned ( ) ;
1035
- let col_2 = su4_mat_mm. slice ( s ! [ .., 2 ] ) . to_owned ( ) ;
1036
- su4_mat_mm. slice_mut ( s ! [ .., 1 ] ) . assign ( & col_2) ;
1037
- su4_mat_mm. slice_mut ( s ! [ .., 2 ] ) . assign ( & col_1) ;
1030
+ let ( mut col_1, mut col_2) = su4_mat_mm. multi_slice_mut ( ( s ! [ .., 1 ] , s ! [ .., 2 ] ) ) ;
1031
+ azip ! ( ( x in & mut col_1, y in & mut col_2) ( * x, * y) = ( * y, * x) )
1038
1032
1039
1033
let synth_dag = match & decomposer_2q. decomposer {
1040
1034
DecomposerType :: XXDecomposer ( decomposer) => {
0 commit comments