|
13 | 13 | from concurrent.futures import ThreadPoolExecutor |
14 | 14 | from io import StringIO |
15 | 15 | from multiprocessing import cpu_count |
16 | | -from typing import Any, Callable, Iterable, Mapping, Optional, TypeVar, Union |
| 16 | +from typing import Any, Callable, Mapping, Optional, TypeVar, Union |
17 | 17 |
|
18 | 18 | import numpy as np |
19 | 19 | import pandas as pd |
@@ -242,53 +242,6 @@ def src_info(self) -> dict[str, Any]: |
242 | 242 | return {} |
243 | 243 | return compilation.src_info(str(self.stan_file), self._stanc_options) |
244 | 244 |
|
245 | | - # TODO(2.0) remove |
246 | | - def format( |
247 | | - self, |
248 | | - overwrite_file: bool = False, |
249 | | - canonicalize: Union[bool, str, Iterable[str]] = False, |
250 | | - max_line_length: int = 78, |
251 | | - *, |
252 | | - backup: bool = True, |
253 | | - ) -> None: |
254 | | - """ |
255 | | - Deprecated: Use :func:`cmdstanpy.format_stan_file()` instead. |
256 | | -
|
257 | | - Run stanc's auto-formatter on the model code. Either saves directly |
258 | | - back to the file or prints for inspection |
259 | | -
|
260 | | -
|
261 | | - :param overwrite_file: If True, save the updated code to disk, rather |
262 | | - than printing it. By default False |
263 | | - :param canonicalize: Whether or not the compiler should 'canonicalize' |
264 | | - the Stan model, removing things like deprecated syntax. Default is |
265 | | - False. If True, all canonicalizations are run. If it is a list of |
266 | | - strings, those options are passed to stanc (new in Stan 2.29) |
267 | | - :param max_line_length: Set the wrapping point for the formatter. The |
268 | | - default value is 78, which wraps most lines by the 80th character. |
269 | | - :param backup: If True, create a stanfile.bak backup before |
270 | | - writing to the file. Only disable this if you're sure you have other |
271 | | - copies of the file or are using a version control system like Git. |
272 | | - """ |
273 | | - |
274 | | - get_logger().warning( |
275 | | - "CmdStanModel.format() is deprecated and will be " |
276 | | - "removed in the next major version.\n" |
277 | | - "Use cmdstanpy.format_stan_file() instead." |
278 | | - ) |
279 | | - |
280 | | - if self.stan_file is None: |
281 | | - raise ValueError("No Stan file found for this module") |
282 | | - |
283 | | - compilation.format_stan_file( |
284 | | - self.stan_file, |
285 | | - overwrite_file=overwrite_file, |
286 | | - max_line_length=max_line_length, |
287 | | - canonicalize=canonicalize, |
288 | | - backup=backup, |
289 | | - stanc_options=self._stanc_options, |
290 | | - ) |
291 | | - |
292 | 245 | def code(self) -> Optional[str]: |
293 | 246 | """Return Stan program as a string.""" |
294 | 247 | if not self._stan_file: |
@@ -517,9 +470,7 @@ def sample( |
517 | 470 | save_warmup: bool = False, |
518 | 471 | thin: Optional[int] = None, |
519 | 472 | max_treedepth: Optional[int] = None, |
520 | | - metric: Union[ |
521 | | - str, dict[str, Any], list[str], list[dict[str, Any]], None |
522 | | - ] = None, |
| 473 | + metric: Optional[str] = None, |
523 | 474 | step_size: Union[float, list[float], None] = None, |
524 | 475 | adapt_engaged: bool = True, |
525 | 476 | adapt_delta: Optional[float] = None, |
@@ -845,27 +796,6 @@ def sample( |
845 | 796 | 'Chain_id must be a non-negative integer value,' |
846 | 797 | ' found {}.'.format(chain_id) |
847 | 798 | ) |
848 | | - if metric is not None and metric not in ( |
849 | | - 'diag', |
850 | | - 'dense', |
851 | | - 'unit_e', |
852 | | - 'diag_e', |
853 | | - 'dense_e', |
854 | | - ): |
855 | | - get_logger().warning( |
856 | | - "Providing anything other than metric type for" |
857 | | - " 'metric' is deprecated and will be removed" |
858 | | - " in the next major release." |
859 | | - " Please provide such information via" |
860 | | - " 'inv_metric' argument." |
861 | | - ) |
862 | | - if inv_metric is not None: |
863 | | - raise ValueError( |
864 | | - "Cannot provide both (deprecated) non-metric-type 'metric'" |
865 | | - " argument and 'inv_metric' argument." |
866 | | - ) |
867 | | - inv_metric = metric # type: ignore # for backwards compatibility |
868 | | - metric = None |
869 | 799 |
|
870 | 800 | if metric is None and inv_metric is not None: |
871 | 801 | metric = try_deduce_metric_type(inv_metric) |
@@ -908,7 +838,7 @@ def sample( |
908 | 838 | save_warmup=save_warmup, |
909 | 839 | thin=thin, |
910 | 840 | max_treedepth=max_treedepth, |
911 | | - metric_type=metric, # type: ignore |
| 841 | + metric_type=metric, |
912 | 842 | metric_file=cmdstan_metrics, |
913 | 843 | step_size=step_size, |
914 | 844 | adapt_engaged=adapt_engaged, |
@@ -1037,8 +967,6 @@ def generate_quantities( |
1037 | 967 | refresh: Optional[int] = None, |
1038 | 968 | time_fmt: str = "%Y%m%d%H%M%S", |
1039 | 969 | timeout: Optional[float] = None, |
1040 | | - *, |
1041 | | - mcmc_sample: Union[CmdStanMCMC, list[str], None] = None, |
1042 | 970 | ) -> CmdStanGQ[Fit]: |
1043 | 971 | """ |
1044 | 972 | Run CmdStan's generate_quantities method which runs the generated |
@@ -1104,19 +1032,6 @@ def generate_quantities( |
1104 | 1032 |
|
1105 | 1033 | :return: CmdStanGQ object |
1106 | 1034 | """ |
1107 | | - # TODO(2.0): remove |
1108 | | - if mcmc_sample is not None: |
1109 | | - if previous_fit: |
1110 | | - raise ValueError( |
1111 | | - "Cannot supply both 'previous_fit' and " |
1112 | | - "deprecated argument 'mcmc_sample'" |
1113 | | - ) |
1114 | | - get_logger().warning( |
1115 | | - "Argument name `mcmc_sample` is deprecated, please " |
1116 | | - "rename to `previous_fit`." |
1117 | | - ) |
1118 | | - |
1119 | | - previous_fit = mcmc_sample # type: ignore |
1120 | 1035 |
|
1121 | 1036 | if isinstance(previous_fit, (CmdStanMCMC, CmdStanMLE, CmdStanVB)): |
1122 | 1037 | fit_object = previous_fit |
@@ -1243,8 +1158,6 @@ def variational( |
1243 | 1158 | refresh: Optional[int] = None, |
1244 | 1159 | time_fmt: str = "%Y%m%d%H%M%S", |
1245 | 1160 | timeout: Optional[float] = None, |
1246 | | - *, |
1247 | | - output_samples: Optional[int] = None, |
1248 | 1161 | ) -> CmdStanVB: |
1249 | 1162 | """ |
1250 | 1163 | Run CmdStan's variational inference algorithm to approximate |
@@ -1342,19 +1255,6 @@ def variational( |
1342 | 1255 |
|
1343 | 1256 | :return: CmdStanVB object |
1344 | 1257 | """ |
1345 | | - # TODO(2.0): remove |
1346 | | - if output_samples is not None: |
1347 | | - if draws is not None: |
1348 | | - raise ValueError( |
1349 | | - "Cannot supply both 'draws' and deprecated argument " |
1350 | | - "'output_samples'" |
1351 | | - ) |
1352 | | - get_logger().warning( |
1353 | | - "Argument name `output_samples` is deprecated, please " |
1354 | | - "rename to `draws`." |
1355 | | - ) |
1356 | | - |
1357 | | - draws = output_samples |
1358 | 1258 |
|
1359 | 1259 | variational_args = VariationalArgs( |
1360 | 1260 | algorithm=algorithm, |
|
0 commit comments