diff --git a/cmdstanpy/model.py b/cmdstanpy/model.py index 7b910b9b..3b462941 100644 --- a/cmdstanpy/model.py +++ b/cmdstanpy/model.py @@ -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, @@ -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 @@ -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. @@ -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( @@ -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, @@ -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, @@ -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 @@ -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, @@ -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, diff --git a/cmdstanpy/utils/cmdstan.py b/cmdstanpy/utils/cmdstan.py index 60d84b74..02d34edf 100644 --- a/cmdstanpy/utils/cmdstan.py +++ b/cmdstanpy/utils/cmdstan.py @@ -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: """