@@ -412,7 +412,7 @@ def _assemble_draws(self) -> None:
412412 self ._step_size [chain ] = float (step_size .strip ())
413413 if self ._metadata .cmdstan_config ['metric' ] != 'unit_e' :
414414 line = fd .readline ().strip () # metric type
415- line = fd .readline ().lstrip (' #\t ' )
415+ line = fd .readline ().lstrip (' #\t ' ). rstrip ()
416416 num_unconstrained_params = len (line .split (',' ))
417417 if chain == 0 : # can't allocate w/o num params
418418 if self .metric_type == 'diag_e' :
@@ -429,18 +429,21 @@ def _assemble_draws(self) -> None:
429429 ),
430430 dtype = float ,
431431 )
432- if self .metric_type == 'diag_e' :
433- xs = line .split (',' )
434- self ._metric [chain , :] = [float (x ) for x in xs ]
435- else :
436- xs = line .split (',' )
437- self ._metric [chain , 0 , :] = [float (x ) for x in xs ]
438- for i in range (1 , num_unconstrained_params ):
439- line = fd .readline ().lstrip (' #\t ' ).strip ()
432+ if line :
433+ if self .metric_type == 'diag_e' :
440434 xs = line .split (',' )
441- self ._metric [chain , i , :] = [
435+ self ._metric [chain , :] = [float (x ) for x in xs ]
436+ else :
437+ xs = line .strip ().split (',' )
438+ self ._metric [chain , 0 , :] = [
442439 float (x ) for x in xs
443440 ]
441+ for i in range (1 , num_unconstrained_params ):
442+ line = fd .readline ().lstrip (' #\t ' ).rstrip ()
443+ xs = line .split (',' )
444+ self ._metric [chain , i , :] = [
445+ float (x ) for x in xs
446+ ]
444447 else : # unit_e changed in 2.34 to have an extra line
445448 pos = fd .tell ()
446449 line = fd .readline ().strip ()
0 commit comments