@@ -43,8 +43,9 @@ fn _scalib_ext(_py: Python, m: &PyModule) -> PyResult<()> {
4343 vertex : usize ,
4444 nc : usize ,
4545 n : usize ,
46+ progress : bool ,
4647 ) -> PyResult < ( ) > {
47- belief_propagation:: run_bp ( py, functions, variables, it, vertex, nc, n)
48+ belief_propagation:: run_bp ( py, functions, variables, it, vertex, nc, n, progress )
4849 }
4950
5051 #[ pyfn( m, "partial_cp" ) ]
@@ -69,39 +70,45 @@ fn _scalib_ext(_py: Python, m: &PyModule) -> PyResult<()> {
6970
7071 #[ pyfn( m, "rank_accuracy" ) ]
7172 fn rank_accuracy (
73+ py : Python ,
7274 costs : Vec < Vec < f64 > > ,
7375 key : Vec < usize > ,
7476 acc : f64 ,
7577 merge : Option < usize > ,
7678 method : String ,
7779 max_nb_bin : usize ,
7880 ) -> PyResult < ( f64 , f64 , f64 ) > {
79- let res = str2method ( & method) . unwrap_or_else ( |s| panic ! ( "{}" , s) ) ;
80- let res = res. rank_accuracy ( & costs, & key, acc, merge, max_nb_bin) ;
81- match res {
82- Ok ( res) => Ok ( ( res. min , res. est , res. max ) ) ,
83- Err ( s) => {
84- panic ! ( "{}" , s) ;
81+ py. allow_threads ( || {
82+ let res = str2method ( & method) . unwrap_or_else ( |s| panic ! ( "{}" , s) ) ;
83+ let res = res. rank_accuracy ( & costs, & key, acc, merge, max_nb_bin) ;
84+ match res {
85+ Ok ( res) => Ok ( ( res. min , res. est , res. max ) ) ,
86+ Err ( s) => {
87+ panic ! ( "{}" , s) ;
88+ }
8589 }
86- }
90+ } )
8791 }
8892
8993 #[ pyfn( m, "rank_nbin" ) ]
9094 fn rank_nbin (
95+ py : Python ,
9196 costs : Vec < Vec < f64 > > ,
9297 key : Vec < usize > ,
9398 nb_bin : usize ,
9499 merge : Option < usize > ,
95100 method : String ,
96101 ) -> PyResult < ( f64 , f64 , f64 ) > {
97- let res = str2method ( & method) . unwrap_or_else ( |s| panic ! ( "{}" , s) ) ;
98- let res = res. rank_nbin ( & costs, & key, nb_bin, merge) ;
99- match res {
100- Ok ( res) => Ok ( ( res. min , res. est , res. max ) ) ,
101- Err ( s) => {
102- panic ! ( "{}" , s) ;
102+ py. allow_threads ( || {
103+ let res = str2method ( & method) . unwrap_or_else ( |s| panic ! ( "{}" , s) ) ;
104+ let res = res. rank_nbin ( & costs, & key, nb_bin, merge) ;
105+ match res {
106+ Ok ( res) => Ok ( ( res. min , res. est , res. max ) ) ,
107+ Err ( s) => {
108+ panic ! ( "{}" , s) ;
109+ }
103110 }
104- }
111+ } )
105112 }
106113
107114 Ok ( ( ) )
0 commit comments