Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mitzimorris committed Oct 7, 2021
1 parent 6e28bc9 commit d16271a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
15 changes: 7 additions & 8 deletions cmdstanpy/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1303,14 +1303,13 @@ def _run_cmdstan(
)
while proc.poll() is None:
if proc.stdout is not None:
lines = proc.stdout.readlines()
for line in lines:
fd_out.write(line)
line = line.strip()
if show_console and len(line) > 1:
print('chain {}: {}'.format(idx + 1, line))
if show_progress and progress_hook is not None:
progress_hook(line)
line = proc.stdout.readline()
fd_out.write(line)
line = line.strip()
if show_console and len(line) > 1:
print('chain {}: {}'.format(idx + 1, line))
if show_progress and progress_hook is not None:
progress_hook(line)
if show_progress and progress_hook is not None:
progress_hook("Done")

Expand Down
11 changes: 5 additions & 6 deletions cmdstanpy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,12 +961,11 @@ def do_command(
)
while proc.poll() is None:
if proc.stdout is not None:
lines = proc.stdout.readlines()
for line in lines:
if fd_out is not None:
fd_out.write(line)
if pbar is not None:
pbar(line.strip())
line = proc.stdout.readline()
if fd_out is not None:
fd_out.write(line)
if pbar is not None:
pbar(line.strip())

stdout, _ = proc.communicate()
if stdout:
Expand Down
8 changes: 1 addition & 7 deletions cmdstanpy_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,9 @@
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"import pandas as pd\n",
"\n",
"vars = fit.stan_variables()\n",
"for (k,v) in vars.items():\n",
" print(k, v.shape)\n",
"\n",
"thetas = fit.stan_variable(var='theta')\n",
"pd.DataFrame(data=thetas).plot.density()"
" print(k, v.shape)"
]
},
{
Expand Down

0 comments on commit d16271a

Please sign in to comment.