Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions cmdstanpy/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ def code(self) -> str | None:
def optimize(
self,
data: Mapping[str, Any] | str | os.PathLike | None = None,
*,
jacobian: bool = False,
seed: int | None = None,
inits: Mapping[str, Any] | float | str | os.PathLike | None = None,
output_dir: OptionalPath = None,
Expand All @@ -291,8 +293,6 @@ def optimize(
refresh: int | None = None,
time_fmt: str = "%Y%m%d%H%M%S",
timeout: float | None = None,
jacobian: bool = False,
# would be nice to move this further up, but that's a breaking change
) -> CmdStanMLE:
"""
Run the specified CmdStan optimize algorithm to produce a
Expand All @@ -319,6 +319,11 @@ def optimize(
either as a dictionary with entries matching the data variables,
or as the path of a data file in JSON or Rdump format.

:param jacobian: Whether or not to use the Jacobian adjustment for
constrained variables in optimization. By default this is false,
meaning optimization yields the Maximum Likehood Estimate (MLE).
Setting it to true yields the Maximum A Posteriori Estimate (MAP).

:param seed: The seed for random number generator. Must be an integer
between 0 and 2^32 - 1. If unspecified,
:func:`numpy.random.default_rng` is used to generate a seed.
Expand Down Expand Up @@ -394,11 +399,6 @@ def optimize(

:param timeout: Duration at which optimization times out in seconds.

:param jacobian: Whether or not to use the Jacobian adjustment for
constrained variables in optimization. By default this is false,
meaning optimization yields the Maximum Likehood Estimate (MLE).
Setting it to true yields the Maximum A Posteriori Estimate (MAP).

:return: CmdStanMLE object
"""
optimize_args = OptimizeArgs(
Expand Down Expand Up @@ -468,6 +468,7 @@ def optimize(
def sample(
self,
data: Mapping[str, Any] | str | os.PathLike | None = None,
*,
chains: int | None = None,
parallel_chains: int | None = None,
threads_per_chain: int | None = None,
Expand All @@ -486,6 +487,13 @@ def sample(
thin: int | None = None,
max_treedepth: int | None = None,
metric: str | None = None,
inv_metric: (
str
| np.ndarray
| Mapping[str, Any]
| Sequence[str | np.ndarray | Mapping[str, Any]]
| None
) = None,
step_size: float | list[float] | None = None,
adapt_engaged: bool = True,
adapt_delta: float | None = None,
Expand All @@ -502,15 +510,7 @@ def sample(
refresh: int | None = None,
time_fmt: str = "%Y%m%d%H%M%S",
timeout: float | None = None,
*,
force_one_process_per_chain: bool | None = None,
inv_metric: (
str
| np.ndarray
| Mapping[str, Any]
| Sequence[str | np.ndarray | Mapping[str, Any]]
| None
) = None,
) -> CmdStanMCMC:
"""
Run or more chains of the NUTS-HMC sampler to produce a set of draws
Expand Down Expand Up @@ -980,6 +980,7 @@ def generate_quantities(
self,
data: Mapping[str, Any] | str | os.PathLike | None = None,
previous_fit: PrevFit | list[str] | None = None,
*,
seed: int | None = None,
gq_output_dir: OptionalPath = None,
sig_figs: int | None = None,
Expand Down Expand Up @@ -1172,6 +1173,7 @@ def generate_quantities(
def variational(
self,
data: Mapping[str, Any] | str | os.PathLike | None = None,
*,
seed: int | None = None,
inits: float | None = None,
output_dir: OptionalPath = None,
Expand Down
2 changes: 1 addition & 1 deletion cmdstanpy/utils/cmdstan.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,13 +581,13 @@ def windows_tbb_path() -> None:

def install_cmdstan(
version: str | None = None,
*,
dir: str | None = None,
overwrite: bool = False,
compiler: bool = False,
progress: bool = False,
verbose: bool = False,
cores: int = 1,
*,
interactive: bool = False,
) -> bool:
"""
Expand Down
Loading