cmdstanpy 1.2.4__tar.gz → 1.2.5__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.4/cmdstanpy.egg-info → cmdstanpy-1.2.5}/PKG-INFO +1 -1
  2. cmdstanpy-1.2.5/cmdstanpy/_version.py +3 -0
  3. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/model.py +3 -3
  4. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/stanfit/mcmc.py +13 -10
  5. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5/cmdstanpy.egg-info}/PKG-INFO +1 -1
  6. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/test/test_model.py +5 -2
  7. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/test/test_sample.py +31 -30
  8. cmdstanpy-1.2.4/cmdstanpy/_version.py +0 -3
  9. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/LICENSE.md +0 -0
  10. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/MANIFEST.in +0 -0
  11. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/README.md +0 -0
  12. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/__init__.py +0 -0
  13. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/cmdstan_args.py +0 -0
  14. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/compilation.py +0 -0
  15. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/install_cmdstan.py +0 -0
  16. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/install_cxx_toolchain.py +0 -0
  17. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/progress.py +0 -0
  18. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/py.typed +0 -0
  19. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/stanfit/__init__.py +0 -0
  20. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/stanfit/gq.py +0 -0
  21. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/stanfit/laplace.py +0 -0
  22. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/stanfit/metadata.py +0 -0
  23. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/stanfit/mle.py +0 -0
  24. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/stanfit/pathfinder.py +0 -0
  25. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/stanfit/runset.py +0 -0
  26. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/stanfit/vb.py +0 -0
  27. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/utils/__init__.py +0 -0
  28. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/utils/cmdstan.py +0 -0
  29. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/utils/command.py +0 -0
  30. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/utils/data_munging.py +0 -0
  31. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/utils/filesystem.py +0 -0
  32. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/utils/json.py +0 -0
  33. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/utils/logging.py +0 -0
  34. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy/utils/stancsv.py +0 -0
  35. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy.egg-info/SOURCES.txt +0 -0
  36. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy.egg-info/dependency_links.txt +0 -0
  37. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy.egg-info/entry_points.txt +0 -0
  38. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy.egg-info/requires.txt +0 -0
  39. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/cmdstanpy.egg-info/top_level.txt +0 -0
  40. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/pyproject.toml +0 -0
  41. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/setup.cfg +0 -0
  42. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/test/test_cmdstan_args.py +0 -0
  43. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/test/test_compiler_opts.py +0 -0
  44. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/test/test_compliance.py +0 -0
  45. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/test/test_cxx_installation.py +0 -0
  46. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/test/test_generate_quantities.py +0 -0
  47. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/test/test_install_cmdstan.py +0 -0
  48. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/test/test_laplace.py +0 -0
  49. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/test/test_log_prob.py +0 -0
  50. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/test/test_metadata.py +0 -0
  51. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/test/test_optimize.py +0 -0
  52. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/test/test_pathfinder.py +0 -0
  53. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/test/test_runset.py +0 -0
  54. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/test/test_utils.py +0 -0
  55. {cmdstanpy-1.2.4 → cmdstanpy-1.2.5}/test/test_variational.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cmdstanpy
3
- Version: 1.2.4
3
+ Version: 1.2.5
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.5'
@@ -205,9 +205,9 @@ class CmdStanModel:
205
205
  self._compiler_options.add_include_path(path)
206
206
 
207
207
  # try to detect models w/out parameters, needed for sampler
208
- if not cmdstan_version_before(
209
- 2, 27
210
- ): # unknown end of version range
208
+ if (not cmdstan_version_before(2, 27)) and cmdstan_version_before(
209
+ 2, 36
210
+ ):
211
211
  try:
212
212
  model_info = self.src_info()
213
213
  if 'parameters' in model_info:
@@ -412,7 +412,7 @@ class CmdStanMCMC:
412
412
  self._step_size[chain] = float(step_size.strip())
413
413
  if self._metadata.cmdstan_config['metric'] != 'unit_e':
414
414
  line = fd.readline().strip() # metric type
415
- line = fd.readline().lstrip(' #\t')
415
+ line = fd.readline().lstrip(' #\t').rstrip()
416
416
  num_unconstrained_params = len(line.split(','))
417
417
  if chain == 0: # can't allocate w/o num params
418
418
  if self.metric_type == 'diag_e':
@@ -429,18 +429,21 @@ class CmdStanMCMC:
429
429
  ),
430
430
  dtype=float,
431
431
  )
432
- if self.metric_type == 'diag_e':
433
- xs = line.split(',')
434
- self._metric[chain, :] = [float(x) for x in xs]
435
- else:
436
- xs = line.split(',')
437
- self._metric[chain, 0, :] = [float(x) for x in xs]
438
- for i in range(1, num_unconstrained_params):
439
- line = fd.readline().lstrip(' #\t').strip()
432
+ if line:
433
+ if self.metric_type == 'diag_e':
440
434
  xs = line.split(',')
441
- self._metric[chain, i, :] = [
435
+ self._metric[chain, :] = [float(x) for x in xs]
436
+ else:
437
+ xs = line.strip().split(',')
438
+ self._metric[chain, 0, :] = [
442
439
  float(x) for x in xs
443
440
  ]
441
+ for i in range(1, num_unconstrained_params):
442
+ line = fd.readline().lstrip(' #\t').rstrip()
443
+ xs = line.split(',')
444
+ self._metric[chain, i, :] = [
445
+ float(x) for x in xs
446
+ ]
444
447
  else: # unit_e changed in 2.34 to have an extra line
445
448
  pos = fd.tell()
446
449
  line = fd.readline().strip()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cmdstanpy
3
- Version: 1.2.4
3
+ Version: 1.2.5
4
4
  Summary: Python interface to CmdStan
5
5
  Author: Stan Dev Team
6
6
  License: BSD-3-Clause
@@ -95,10 +95,13 @@ def test_exe_only() -> None:
95
95
  assert not model2._fixed_param
96
96
 
97
97
 
98
- def test_fixed_param() -> None:
98
+ def test_legacy_fixed_param() -> None:
99
99
  stan = os.path.join(DATAFILES_PATH, 'datagen_poisson_glm.stan')
100
100
  model = CmdStanModel(stan_file=stan)
101
- assert model._fixed_param
101
+ if cmdstan_version_before(2, 36):
102
+ assert model._fixed_param
103
+ else:
104
+ assert not model._fixed_param
102
105
 
103
106
 
104
107
  def test_model_pedantic(caplog: pytest.LogCaptureFixture) -> None:
@@ -642,13 +642,18 @@ def test_fixed_param_good() -> None:
642
642
  assert datagen_fit.step_size is None
643
643
 
644
644
 
645
- def test_fixed_param_unspecified() -> None:
645
+ def test_sample_no_params() -> None:
646
646
  stan = os.path.join(DATAFILES_PATH, 'datagen_poisson_glm.stan')
647
647
  datagen_model = CmdStanModel(stan_file=stan)
648
648
  datagen_fit = datagen_model.sample(iter_sampling=100, show_progress=False)
649
- assert datagen_fit.step_size is None
650
649
  summary = datagen_fit.summary()
651
- assert 'lp__' not in list(summary.index)
650
+
651
+ if cmdstan_version_before(2, 36):
652
+ assert 'lp__' not in list(summary.index)
653
+ assert datagen_fit.step_size is None
654
+ else:
655
+ assert 'lp__' in list(summary.index)
656
+ assert np.isnan(datagen_fit.step_size).all()
652
657
 
653
658
  exe_only = os.path.join(DATAFILES_PATH, 'exe_only')
654
659
  shutil.copyfile(datagen_model.exe_file, exe_only)
@@ -656,9 +661,14 @@ def test_fixed_param_unspecified() -> None:
656
661
  datagen2_model = CmdStanModel(exe_file=exe_only)
657
662
  datagen2_fit = datagen2_model.sample(iter_sampling=200, show_console=True)
658
663
  assert datagen2_fit.chains == 4
659
- assert datagen2_fit.step_size is None
660
664
  summary = datagen2_fit.summary()
661
- assert 'lp__' not in list(summary.index)
665
+
666
+ if cmdstan_version_before(2, 36):
667
+ assert datagen2_fit.step_size is None
668
+ assert 'lp__' not in list(summary.index)
669
+ else:
670
+ assert np.isnan(datagen2_fit.step_size).all()
671
+ assert 'lp__' in list(summary.index)
662
672
 
663
673
 
664
674
  def test_index_bounds_error() -> None:
@@ -823,7 +833,7 @@ def test_validate_good_run() -> None:
823
833
  assert 'Treedepth satisfactory for all transitions.' in diagnostics
824
834
  assert 'No divergent transitions found.' in diagnostics
825
835
  assert 'E-BFMI satisfactory' in diagnostics
826
- assert 'Effective sample size satisfactory.' in diagnostics
836
+ assert 'effective sample size satisfactory' in diagnostics.lower()
827
837
 
828
838
 
829
839
  def test_validate_big_run() -> None:
@@ -986,6 +996,12 @@ def test_from_csv_fixed_param() -> None:
986
996
  assert fixed_param_sample.draws_pd().shape == (100, 88)
987
997
 
988
998
 
999
+ def test_from_csv_no_param_hmc() -> None:
1000
+ csv_path = os.path.join(DATAFILES_PATH, 'no_param_hmc_sample.csv')
1001
+ no_parameters_sample = from_csv(path=csv_path)
1002
+ assert no_parameters_sample.draws_pd().shape == (100, 93)
1003
+
1004
+
989
1005
  def test_custom_metric() -> None:
990
1006
  stan = os.path.join(DATAFILES_PATH, 'bernoulli.stan')
991
1007
  jdata = os.path.join(DATAFILES_PATH, 'bernoulli.data.json')
@@ -1621,33 +1637,18 @@ def test_validate_sample_sig_figs(stanfile='bernoulli.stan'):
1621
1637
 
1622
1638
 
1623
1639
  def test_validate_summary_sig_figs() -> None:
1624
- # construct CmdStanMCMC from logistic model output, config
1625
- exe = os.path.join(DATAFILES_PATH, 'logistic' + EXTENSION)
1626
- rdata = os.path.join(DATAFILES_PATH, 'logistic.data.R')
1627
- sampler_args = SamplerArgs(iter_sampling=100)
1628
- cmdstan_args = CmdStanArgs(
1629
- model_name='logistic',
1630
- model_exe=exe,
1631
- chain_ids=[1, 2, 3, 4],
1632
- seed=12345,
1633
- data=rdata,
1634
- output_dir=DATAFILES_PATH,
1635
- sig_figs=17,
1636
- method_args=sampler_args,
1640
+ # construct CmdStanMCMC from logistic model output
1641
+ fit = from_csv(
1642
+ [
1643
+ os.path.join(DATAFILES_PATH, 'logistic_output_1.csv'),
1644
+ os.path.join(DATAFILES_PATH, 'logistic_output_2.csv'),
1645
+ os.path.join(DATAFILES_PATH, 'logistic_output_3.csv'),
1646
+ os.path.join(DATAFILES_PATH, 'logistic_output_4.csv'),
1647
+ ]
1637
1648
  )
1638
- runset = RunSet(args=cmdstan_args, chains=4)
1639
- runset._csv_files = [
1640
- os.path.join(DATAFILES_PATH, 'logistic_output_1.csv'),
1641
- os.path.join(DATAFILES_PATH, 'logistic_output_2.csv'),
1642
- os.path.join(DATAFILES_PATH, 'logistic_output_3.csv'),
1643
- os.path.join(DATAFILES_PATH, 'logistic_output_4.csv'),
1644
- ]
1645
- retcodes = runset._retcodes
1646
- for i in range(len(retcodes)):
1647
- runset._set_retcode(i, 0)
1648
- fit = CmdStanMCMC(runset)
1649
1649
 
1650
1650
  sum_default = fit.summary()
1651
+
1651
1652
  beta1_default = format(sum_default.iloc[1, 0], '.18g')
1652
1653
  assert beta1_default.startswith('1.3')
1653
1654
 
@@ -1,3 +0,0 @@
1
- """PyPi Version"""
2
-
3
- __version__ = '1.2.4'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes