CmdStanPy 1.0.0rc1

The release candidate for CmdStanPy v1.0 is now available on conda-forge:

Please give it a try.

Notable recent changes are the addition of progress bars for both the sampler and the CmdStan install scripts.

yellow bars indicate warmup:

blue bars indicate sampling:

This should work in both terminal windows and in Jupyter notebooks. For Jupyter notebooks, the tqdm package uses the ipywidgets package in order to update the browser display. Therefore you must have ipywidgets installed. If you have problems, see this tqdm GitHub issue.

All methods which can display progress bars have arguments show_progress and show_console.

For the sample method, show_progress=True and show_console=False. To suppress both, you must explicitly specify show_progress=False. For debugging purposes, show_console=True will turn off the progress bars and instead stream all CmdStan messages written to stdout and stderr to the console.


oops, I buried the lede - Deprecations Removed in Version 1.0.0

If you’ve got scripts, notebooks, or packages which use CmdStanPy, version 1.0 has removed the following deprecated properties, methods, method arguments, and package behaviors.

  • The default CmdStan install directory is $HOME/.cmdstan; CmdStanPy will no longer look for installations in directory $HOME/.cmdstanpy.

  • The argument logger deprecated for all CmdStanPy constructor methods.

Changes to classes CmdStanMCMC, CmdStanMLE, CmdStanVB, and CmdStanGQ.

  • method stan_variable, argument name changed to var.

Class CmdStanMCMC changes:

  • property sampler_vars_cols replaced by property metdata.method_vars_cols

  • property stan_vars_cols replaced by property metadata.stan_vars_cols

  • property stan_vars_cols replaced by property metadata.stan_vars_dims

  • property sample replaced by method draws()

  • property warmup replaced by method draws(inc_warmup=True), which returns draws for both warmup and sampling iterations.

  • method draws_pd argument params changed to vars

  • methods sampler_diagnostics and sampler_variables (same method, successive name) have been replaced by the more general name method_variables (see below). This method retrieves the sampler variables lp__, et al. The set of these variables varies by inference method.

Class CmdStanGQ changes:

  • properties generated_quantities and generated_quantities_pd replaced by methods draws() and draws_pd(), respectively.

  • properties sample_plus_quantities and sample_plus_quantities_pd replaced by methods draws(inc_sample=True) and draws_pd(inc_sample=True), respectively.

The goal of these changes is to make the API as uniform as possible for all inference result objects as follows:

  • The CmdStan configuration and Stan CSV file header comments and column headers information is assembled as a InferenceMetadata object with properties:

    • cmdstan_config - returns a dictionary over all CmdStan arguments. Dictionary names are the CmdStan names, not the CmdStanPy argument names, e.g., the CmdStanPy sampler config argument iter_warmup is CmdStan argument num_warmup.

    • method_vars_cols - maps the Stan CSV file column names which end in __ to their column index.

    • stan_vars_cols - maps the Stan program variable names to their corresponding column index or indices.

    • stan_vars_dims - maps the Stan program variable names to their corresponding dimensions.

  • All inference result objects have accessor methods method_variables, stan_variable, and stan_variables to retrieve method and Stan program variables. Stan program variables are returned as structured objects. If the inference method returns a sample, then stan_variable will return an array of structured objects. If the inference method returns a single estimate, then the stan_variable method returns a single structured object.

  • All methods which return a sample have method draws, draws_pd which returns data rows from the Stan CSV file as a numpy.ndarray and pandas.DataFrame, respectively.

  • All methods which return a sample have method draws_xr which which returns one or more named variables as an xarray Dataset.