Skip to content

Commit 8e9e68b

Browse files
committed
Merge branch 'develop' of https://github.com/stan-dev/cmdstanpy into develop
2 parents 0d978f5 + 23b6ad9 commit 8e9e68b

File tree

107 files changed

+11186
-6115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+11186
-6115
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ Describe the issue as clearly as possible.
1010
Provide any additional information here.
1111

1212
#### Current Version:
13-
13+
Please include the output of `cmdstanpy.show_versions()`, or
14+
at least the cmdstan and cmdstanpy versions used.

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ jobs:
9696
run: |
9797
install_cmdstan -h
9898
install_cxx_toolchain -h
99-
python -m cmdstanpy.install_cmdstan --version ${{ needs.get-cmdstan-version.outputs.version }}
99+
python -c "import cmdstanpy; cmdstanpy.install_cmdstan(version='${{ needs.get-cmdstan-version.outputs.version }}', cores=2)"
100100
101101
- name: Install CmdStan (Windows)
102102
if: matrix.os == 'windows-latest'
103103
run: |
104104
install_cmdstan -h
105105
install_cxx_toolchain -h
106-
python -m cmdstanpy.install_cmdstan --compiler --version ${{ needs.get-cmdstan-version.outputs.version }}
106+
python -m cmdstanpy.install_cmdstan --compiler --version ${{ needs.get-cmdstan-version.outputs.version }} --cores 2
107107
108108
- name: Run tests
109109
run: |

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
3333
- name: Install dependencies (python)
3434
run: |
35-
python -m pip install --upgrade pip wheel twine codecov sphinx nbsphinx ipython ipykernel pydata-sphinx-theme requests sphinx-copybutton matplotlib
35+
python -m pip install --upgrade pip wheel twine codecov "sphinx>4,<5" nbsphinx ipython ipykernel "pydata-sphinx-theme<0.9" requests sphinx-copybutton xarray matplotlib
3636
pip install -r requirements.txt
3737
pip install -e .
3838

cmdstanpy/__init__.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,6 @@
66
import shutil
77
import tempfile
88

9-
_STANSUMMARY_STATS = [
10-
'Mean',
11-
'MCSE',
12-
'StdDev',
13-
'5%',
14-
'50%',
15-
'95%',
16-
'N_Eff',
17-
'N_Eff/s',
18-
'R_hat',
19-
]
20-
219
_TMPDIR = tempfile.mkdtemp()
2210
_CMDSTAN_WARMUP = 1000
2311
_CMDSTAN_SAMPLING = 1000
@@ -38,20 +26,20 @@ def _cleanup_tmpdir() -> None:
3826

3927
from ._version import __version__ # noqa
4028
from .install_cmdstan import rebuild_cmdstan
41-
from .model import CmdStanModel # noqa
42-
from .stanfit import ( # noqa
29+
from .model import CmdStanModel
30+
from .stanfit import (
4331
CmdStanGQ,
4432
CmdStanMCMC,
4533
CmdStanMLE,
4634
CmdStanVB,
4735
InferenceMetadata,
4836
from_csv,
4937
)
50-
from .utils import set_cmdstan_path # noqa
5138
from .utils import (
5239
cmdstan_path,
5340
cmdstan_version,
5441
install_cmdstan,
42+
set_cmdstan_path,
5543
set_make_env,
5644
show_versions,
5745
write_stan_json,

cmdstanpy/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""PyPi Version"""
22

3-
__version__ = '1.0.1'
3+
__version__ = '1.0.4'

cmdstanpy/cmdstan_args.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ def validate(self) -> None:
830830
'0 and 2**32-1, found {}.'.format(self.seed)
831831
)
832832
if isinstance(self.seed, int):
833-
if self.seed < 0 or self.seed > 2**32 - 1:
833+
if self.seed < 0 or self.seed > 2 ** 32 - 1:
834834
raise ValueError(
835835
'Argument "seed" must be an integer between '
836836
'0 and 2**32-1, found {}.'.format(self.seed)
@@ -849,7 +849,7 @@ def validate(self) -> None:
849849
)
850850
)
851851
for seed in self.seed:
852-
if seed < 0 or seed > 2**32 - 1:
852+
if seed < 0 or seed > 2 ** 32 - 1:
853853
raise ValueError(
854854
'Argument "seed" must be an integer value'
855855
' between 0 and 2**32-1,'

cmdstanpy/install_cmdstan.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
example model ``bernoulli.stan``.
88
99
Optional command line arguments:
10+
-i, --interactive: flag, when specified ignore other arguments and
11+
ask user for settings on STDIN
1012
-v, --version <release> : version, defaults to latest release version
1113
-d, --dir <path> : install directory, defaults to '$HOME/.cmdstan
1214
--overwrite: flag, when specified re-installs existing version
1315
--progress: flag, when specified show progress bar for CmdStan download
1416
--verbose: flag, when specified prints output from CmdStan build process
17+
--cores: int, number of cores to use when building, defaults to 1
1518
-c, --compiler : flag, add C++ compiler to path (Windows only)
1619
"""
1720
import argparse

cmdstanpy/install_cxx_toolchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from cmdstanpy.utils import pushd, validate_dir, wrap_url_progress_hook
2828

2929
EXTENSION = '.exe' if platform.system() == 'Windows' else ''
30-
IS_64BITS = sys.maxsize > 2**32
30+
IS_64BITS = sys.maxsize > 2 ** 32
3131

3232

3333
def usage() -> None:

cmdstanpy/stanfit/__init__.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
)
1313
from cmdstanpy.utils import check_sampler_csv, get_logger, scan_config
1414

15-
from .mcmc import CmdStanGQ, CmdStanMCMC
15+
from .gq import CmdStanGQ
16+
from .mcmc import CmdStanMCMC
1617
from .metadata import InferenceMetadata
1718
from .mle import CmdStanMLE
1819
from .runset import RunSet
@@ -29,7 +30,8 @@
2930

3031

3132
def from_csv(
32-
path: Union[str, List[str], None] = None, method: Optional[str] = None
33+
path: Union[str, List[str], os.PathLike, None] = None,
34+
method: Optional[str] = None,
3335
) -> Union[CmdStanMCMC, CmdStanMLE, CmdStanVB, None]:
3436
"""
3537
Instantiate a CmdStan object from a the Stan CSV files from a CmdStan run.
@@ -61,22 +63,22 @@ def from_csv(
6163
csvfiles = []
6264
if isinstance(path, list):
6365
csvfiles = path
64-
elif isinstance(path, str):
65-
if '*' in path:
66-
splits = os.path.split(path)
67-
if splits[0] is not None:
68-
if not (os.path.exists(splits[0]) and os.path.isdir(splits[0])):
69-
raise ValueError(
70-
'Invalid path specification, {} '
71-
' unknown directory: {}'.format(path, splits[0])
72-
)
73-
csvfiles = glob.glob(path)
74-
elif os.path.exists(path) and os.path.isdir(path):
66+
elif isinstance(path, str) and '*' in path:
67+
splits = os.path.split(path)
68+
if splits[0] is not None:
69+
if not (os.path.exists(splits[0]) and os.path.isdir(splits[0])):
70+
raise ValueError(
71+
'Invalid path specification, {} '
72+
' unknown directory: {}'.format(path, splits[0])
73+
)
74+
csvfiles = glob.glob(path)
75+
elif isinstance(path, (str, os.PathLike)):
76+
if os.path.exists(path) and os.path.isdir(path):
7577
for file in os.listdir(path):
76-
if file.endswith(".csv"):
78+
if os.path.splitext(file)[1] == ".csv":
7779
csvfiles.append(os.path.join(path, file))
7880
elif os.path.exists(path):
79-
csvfiles.append(path)
81+
csvfiles.append(str(path))
8082
else:
8183
raise ValueError('Invalid path specification: {}'.format(path))
8284
else:
@@ -85,7 +87,7 @@ def from_csv(
8587
if len(csvfiles) == 0:
8688
raise ValueError('No CSV files found in directory {}'.format(path))
8789
for file in csvfiles:
88-
if not (os.path.exists(file) and file.endswith('.csv')):
90+
if not (os.path.exists(file) and os.path.splitext(file)[1] == ".csv"):
8991
raise ValueError(
9092
'Bad CSV file path spec,'
9193
' includes non-csv file: {}'.format(file)

0 commit comments

Comments
 (0)