@@ -430,19 +430,19 @@ def compile(
430430 else :
431431 get_logger ().error ('model compilation failed' )
432432
433- def exe_info (self ) -> Optional [ Dict [str , str ] ]:
433+ def exe_info (self ) -> Dict [str , str ]:
434434 """
435435 Run model with option 'info'. Parse output statements, which all
436436 have form 'key = value' into a Dict.
437437 If exe file compiled with CmdStan < 2.27, calling model with
438438 option 'info' fail and method returns None.
439439 """
440+ result : Dict [str , Any ] = {}
440441 if self .exe_file is None :
441- return None
442+ return result
442443 try :
443444 info = StringIO ()
444445 do_command (cmd = [self .exe_file , 'info' ], fd_out = info )
445- result : Dict [str , Any ] = {}
446446 lines = info .getvalue ().split ('\n ' )
447447 for line in lines :
448448 kv_pair = [x .strip () for x in line .split ('=' )]
@@ -451,7 +451,7 @@ def exe_info(self) -> Optional[Dict[str, str]]:
451451 result [kv_pair [0 ]] = kv_pair [1 ]
452452 return result
453453 except RuntimeError :
454- return None
454+ return result
455455
456456 def optimize (
457457 self ,
@@ -947,10 +947,7 @@ def sample(
947947 ):
948948 assert isinstance (self .exe_file , str ) # make typechecker happy
949949 info_dict = self .exe_info ()
950- if (
951- info_dict is not None
952- and info_dict ['STAN_THREADS' ] == 'true'
953- ):
950+ if info_dict .get ('STAN_THREADS' ) == 'true' :
954951 one_process_per_chain = False
955952 num_threads = parallel_chains * num_threads
956953 parallel_procs = 1
0 commit comments