cmdstanpy 1.2.2__tar.gz → 1.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. {cmdstanpy-1.2.2/cmdstanpy.egg-info → cmdstanpy-1.2.3}/PKG-INFO +1 -1
  2. cmdstanpy-1.2.3/cmdstanpy/_version.py +3 -0
  3. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/install_cmdstan.py +2 -0
  4. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/install_cxx_toolchain.py +4 -0
  5. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/stanfit/pathfinder.py +4 -2
  6. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/stanfit/runset.py +10 -10
  7. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/utils/stancsv.py +2 -1
  8. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3/cmdstanpy.egg-info}/PKG-INFO +1 -1
  9. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/test/test_optimize.py +5 -4
  10. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/test/test_sample.py +11 -8
  11. cmdstanpy-1.2.2/cmdstanpy/_version.py +0 -3
  12. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/LICENSE.md +0 -0
  13. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/MANIFEST.in +0 -0
  14. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/README.md +0 -0
  15. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/__init__.py +0 -0
  16. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/cmdstan_args.py +0 -0
  17. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/compilation.py +0 -0
  18. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/model.py +0 -0
  19. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/progress.py +0 -0
  20. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/py.typed +0 -0
  21. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/stanfit/__init__.py +0 -0
  22. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/stanfit/gq.py +0 -0
  23. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/stanfit/laplace.py +0 -0
  24. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/stanfit/mcmc.py +0 -0
  25. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/stanfit/metadata.py +0 -0
  26. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/stanfit/mle.py +0 -0
  27. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/stanfit/vb.py +0 -0
  28. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/utils/__init__.py +0 -0
  29. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/utils/cmdstan.py +0 -0
  30. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/utils/command.py +0 -0
  31. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/utils/data_munging.py +0 -0
  32. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/utils/filesystem.py +0 -0
  33. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/utils/json.py +0 -0
  34. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy/utils/logging.py +0 -0
  35. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy.egg-info/SOURCES.txt +0 -0
  36. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy.egg-info/dependency_links.txt +0 -0
  37. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy.egg-info/entry_points.txt +0 -0
  38. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy.egg-info/requires.txt +0 -0
  39. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/cmdstanpy.egg-info/top_level.txt +0 -0
  40. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/pyproject.toml +0 -0
  41. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/setup.cfg +0 -0
  42. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/test/test_cmdstan_args.py +0 -0
  43. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/test/test_compiler_opts.py +0 -0
  44. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/test/test_compliance.py +0 -0
  45. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/test/test_cxx_installation.py +0 -0
  46. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/test/test_generate_quantities.py +0 -0
  47. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/test/test_install_cmdstan.py +0 -0
  48. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/test/test_laplace.py +0 -0
  49. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/test/test_log_prob.py +0 -0
  50. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/test/test_metadata.py +0 -0
  51. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/test/test_model.py +0 -0
  52. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/test/test_pathfinder.py +0 -0
  53. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/test/test_runset.py +0 -0
  54. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/test/test_utils.py +0 -0
  55. {cmdstanpy-1.2.2 → cmdstanpy-1.2.3}/test/test_variational.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cmdstanpy
3
- Version: 1.2.2
3
+ Version: 1.2.3
4
4
  Summary: Python interface to CmdStan
5
5
  Author: Stan Dev Team
6
6
  License: BSD-3-Clause
@@ -0,0 +1,3 @@
1
+ """PyPi Version"""
2
+
3
+ __version__ = '1.2.3'
@@ -523,6 +523,8 @@ def retrieve_version(version: str, progress: bool = True) -> None:
523
523
  first = tar.next()
524
524
  if first is not None:
525
525
  top_dir = first.name
526
+ else:
527
+ top_dir = ''
526
528
  cmdstan_dir = f'cmdstan-{version}'
527
529
  if top_dir != cmdstan_dir:
528
530
  raise CmdStanInstallError(
@@ -235,8 +235,10 @@ def get_toolchain_name() -> str:
235
235
  return ''
236
236
 
237
237
 
238
+ # TODO(2.0): drop 3.5 support
238
239
  def get_url(version: str) -> str:
239
240
  """Return URL for toolchain."""
241
+ url = ''
240
242
  if platform.system() == 'Windows':
241
243
  if version == '4.0':
242
244
  # pylint: disable=line-too-long
@@ -277,6 +279,8 @@ def run_rtools_install(args: Dict[str, Any]) -> None:
277
279
 
278
280
  if 'verbose' in args:
279
281
  verbose = args['verbose']
282
+ else:
283
+ verbose = False
280
284
 
281
285
  install_dir = args['dir']
282
286
  if install_dir is None:
@@ -214,8 +214,10 @@ class CmdStanPathfinder:
214
214
  """
215
215
  return ( # type: ignore
216
216
  self._metadata.cmdstan_config.get("num_paths", 4) > 1
217
- and self._metadata.cmdstan_config.get('psis_resample', 1) == 1
218
- and self._metadata.cmdstan_config.get('calculate_lp', 1) == 1
217
+ and self._metadata.cmdstan_config.get('psis_resample', 1)
218
+ in (1, 'true')
219
+ and self._metadata.cmdstan_config.get('calculate_lp', 1)
220
+ in (1, 'true')
219
221
  )
220
222
 
221
223
  def save_csvfiles(self, dir: Optional[str] = None) -> None:
@@ -61,18 +61,26 @@ class RunSet:
61
61
  self._base_outfile = (
62
62
  f'{args.model_name}-{datetime.now().strftime(time_fmt)}'
63
63
  )
64
- # per-process console messages
64
+ # per-process outputs
65
65
  self._stdout_files = [''] * self._num_procs
66
+ self._profile_files = [''] * self._num_procs # optional
66
67
  if one_process_per_chain:
67
68
  for i in range(chains):
68
69
  self._stdout_files[i] = self.file_path("-stdout.txt", id=i)
70
+ if args.save_profile:
71
+ self._profile_files[i] = self.file_path(
72
+ ".csv", extra="-profile", id=chain_ids[i]
73
+ )
69
74
  else:
70
75
  self._stdout_files[0] = self.file_path("-stdout.txt")
76
+ if args.save_profile:
77
+ self._profile_files[0] = self.file_path(
78
+ ".csv", extra="-profile"
79
+ )
71
80
 
72
81
  # per-chain output files
73
82
  self._csv_files: List[str] = [''] * chains
74
83
  self._diagnostic_files = [''] * chains # optional
75
- self._profile_files = [''] * chains # optional
76
84
 
77
85
  if chains == 1:
78
86
  self._csv_files[0] = self.file_path(".csv")
@@ -80,10 +88,6 @@ class RunSet:
80
88
  self._diagnostic_files[0] = self.file_path(
81
89
  ".csv", extra="-diagnostic"
82
90
  )
83
- if args.save_profile:
84
- self._profile_files[0] = self.file_path(
85
- ".csv", extra="-profile"
86
- )
87
91
  else:
88
92
  for i in range(chains):
89
93
  self._csv_files[i] = self.file_path(".csv", id=chain_ids[i])
@@ -91,10 +95,6 @@ class RunSet:
91
95
  self._diagnostic_files[i] = self.file_path(
92
96
  ".csv", extra="-diagnostic", id=chain_ids[i]
93
97
  )
94
- if args.save_profile:
95
- self._profile_files[i] = self.file_path(
96
- ".csv", extra="-profile", id=chain_ids[i]
97
- )
98
98
 
99
99
  def __repr__(self) -> str:
100
100
  repr = 'RunSet: chains={}, chain_ids={}, num_processes={}'.format(
@@ -52,7 +52,7 @@ def check_sampler_csv(
52
52
  )
53
53
  )
54
54
  if save_warmup:
55
- if not ('save_warmup' in meta and meta['save_warmup'] == 1):
55
+ if not ('save_warmup' in meta and meta['save_warmup'] in (1, 'true')):
56
56
  raise ValueError(
57
57
  'bad Stan CSV file {}, '
58
58
  'config error, expected save_warmup = 1'.format(path)
@@ -116,6 +116,7 @@ def scan_optimize_csv(path: str, save_iters: bool = False) -> Dict[str, Any]:
116
116
  all_iters[i, :] = [float(x) for x in xs]
117
117
  if i == iters - 1:
118
118
  mle: np.ndarray = np.array(xs, dtype=float)
119
+ # pylint: disable=possibly-used-before-assignment
119
120
  dict['mle'] = mle
120
121
  if save_iters:
121
122
  dict['all_iters'] = all_iters
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cmdstanpy
3
- Version: 1.2.2
3
+ Version: 1.2.3
4
4
  Summary: Python interface to CmdStan
5
5
  Author: Stan Dev Team
6
6
  License: BSD-3-Clause
@@ -262,12 +262,13 @@ def test_variables_3d() -> None:
262
262
  )
263
263
  vars_iters = multidim_mle_iters.stan_variables(inc_iterations=True)
264
264
  assert len(vars_iters) == len(multidim_mle_iters.metadata.stan_vars)
265
+ assert 'frac_60' in vars_iters
266
+ n_iter = vars_iters['frac_60'].shape[0]
267
+ assert n_iter > 1
265
268
  assert 'y_rep' in vars_iters
266
- assert vars_iters['y_rep'].shape == (8, 5, 4, 3)
269
+ assert vars_iters['y_rep'].shape == (n_iter, 5, 4, 3)
267
270
  assert 'beta' in vars_iters
268
- assert vars_iters['beta'].shape == (8, 2)
269
- assert 'frac_60' in vars_iters
270
- assert vars_iters['frac_60'].shape == (8,)
271
+ assert vars_iters['beta'].shape == (n_iter, 2)
271
272
 
272
273
 
273
274
  def test_optimize_good() -> None:
@@ -1748,33 +1748,36 @@ def test_save_latent_dynamics() -> None:
1748
1748
 
1749
1749
  def test_save_profile() -> None:
1750
1750
  stan = os.path.join(DATAFILES_PATH, 'profile_likelihood.stan')
1751
- profile_model = CmdStanModel(stan_file=stan)
1751
+ profile_model = CmdStanModel(
1752
+ stan_file=stan, cpp_options={"STAN_THREADS": '1'}, force_compile=True
1753
+ )
1754
+
1752
1755
  profile_fit = profile_model.sample(
1753
1756
  chains=2,
1754
1757
  parallel_chains=2,
1758
+ force_one_process_per_chain=True,
1755
1759
  seed=12345,
1756
1760
  iter_warmup=100,
1757
1761
  iter_sampling=200,
1758
1762
  save_profile=True,
1759
1763
  )
1760
- for i in range(profile_fit.runset.chains):
1761
- profile_file = profile_fit.runset.profile_files[i]
1764
+ assert len(profile_fit.runset.profile_files) == 2
1765
+ for profile_file in profile_fit.runset.profile_files:
1762
1766
  assert os.path.exists(profile_file)
1763
1767
 
1764
1768
  profile_fit = profile_model.sample(
1765
1769
  chains=2,
1766
1770
  parallel_chains=2,
1771
+ force_one_process_per_chain=False,
1767
1772
  seed=12345,
1773
+ iter_warmup=100,
1768
1774
  iter_sampling=200,
1769
- save_latent_dynamics=True,
1770
1775
  save_profile=True,
1771
1776
  )
1772
1777
 
1773
- for i in range(profile_fit.runset.chains):
1774
- profile_file = profile_fit.runset.profile_files[i]
1778
+ assert len(profile_fit.runset.profile_files) == 1
1779
+ for profile_file in profile_fit.runset.profile_files:
1775
1780
  assert os.path.exists(profile_file)
1776
- diagnostics_file = profile_fit.runset.diagnostic_files[i]
1777
- assert os.path.exists(diagnostics_file)
1778
1781
 
1779
1782
 
1780
1783
  def test_xarray_draws() -> None:
@@ -1,3 +0,0 @@
1
- """PyPi Version"""
2
-
3
- __version__ = '1.2.2'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes