Skip to content

Commit afd399c

Browse files
committed
Merge branch 'develop' into feature/log-prob
2 parents e9c4695 + 2068ca5 commit afd399c

Some content is hidden

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

76 files changed

+1365
-976
lines changed

.github/ISSUE_TEMPLATE.md

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

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

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Set update schedule for GitHub Actions
2+
3+
version: 2
4+
updates:
5+
6+
- package-ecosystem: "github-actions"
7+
directory: "/"
8+
schedule:
9+
# Check for updates to GitHub Actions every week
10+
interval: "weekly"

.github/workflows/main.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ jobs:
2525
id: check-cmdstan
2626
run: |
2727
if [[ "${{ github.event.inputs.cmdstan-version }}" != "" ]]; then
28-
echo "::set-output name=version::${{ github.event.inputs.cmdstan-version }}"
28+
echo "version=${{ github.event.inputs.cmdstan-version }}" >> $GITHUB_OUTPUT
2929
else
30-
echo "::set-output name=version::$(python -c 'import requests;print(requests.get("https://api.github.com/repos/stan-dev/cmdstan/releases/latest").json()["tag_name"][1:])')"
30+
echo "version=$(python -c 'import requests;print(requests.get("https://api.github.com/repos/stan-dev/cmdstan/releases/latest").json()["tag_name"][1:])')" >> $GITHUB_OUTPUT
3131
fi
3232
outputs:
3333
version: ${{ steps.check-cmdstan.outputs.version }}
@@ -39,16 +39,15 @@ jobs:
3939
strategy:
4040
matrix:
4141
os: [ubuntu-latest, macos-latest, windows-latest]
42-
python-version: [3.7, 3.8, 3.9, "3.10.6"]
43-
# more specific version of 3.10 due to https://github.com/python/mypy/issues/13627
42+
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]
4443
env:
4544
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
4645
steps:
4746
- name: Check out github
48-
uses: actions/checkout@v2
47+
uses: actions/checkout@v3
4948

5049
- name: Set up Python ${{ matrix.python-version }}
51-
uses: actions/setup-python@v2
50+
uses: actions/setup-python@v4
5251
with:
5352
python-version: ${{ matrix.python-version }}
5453

@@ -60,7 +59,7 @@ jobs:
6059
pip install codecov
6160
6261
- name: Run flake8, pylint, mypy
63-
if: matrix.python-version == '3.10'
62+
if: matrix.python-version == '3.11'
6463
run: |
6564
flake8 cmdstanpy test
6665
pylint -v cmdstanpy test
@@ -82,15 +81,11 @@ jobs:
8281
- name: Show libraries
8382
run: python -m pip freeze
8483

85-
- name: Get system info
86-
uses: kenchan0130/[email protected]
87-
id: system-info
88-
8984
- name: CmdStan installation cacheing
90-
uses: actions/cache@v2
85+
uses: actions/cache@v3
9186
with:
9287
path: ~/.cmdstan
93-
key: ${{ runner.os }}-${{ steps.system-info.outputs.release }}-cmdstan-${{ needs.get-cmdstan-version.outputs.version }}-${{ hashFiles('**/install_cmdstan.py') }}
88+
key: ${{ runner.os }}-cmdstan-${{ needs.get-cmdstan-version.outputs.version }}-${{ hashFiles('**/install_cmdstan.py') }}
9489

9590
- name: Install CmdStan (Linux, macOS)
9691
if: matrix.os != 'windows-latest'

.github/workflows/release.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
inputs:
66
new_version:
7-
description: 'New version, for example: 0.9.69'
7+
description: 'New version, for example: 0.9.69'
88
required: true
99

1010
jobs:
@@ -18,10 +18,10 @@ jobs:
1818
fail-fast: false
1919
steps:
2020
- name: Check out source code
21-
uses: actions/checkout@v2
22-
21+
uses: actions/checkout@v3
22+
2323
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v2
24+
uses: actions/setup-python@v3
2525
with:
2626
python-version: ${{ matrix.python-version }}
2727

@@ -36,7 +36,7 @@ jobs:
3636
pip install -r requirements.txt
3737
pip install -e .
3838
39-
- name: Install CmdStan
39+
- name: Install CmdStan
4040
run: |
4141
python -m cmdstanpy.install_cmdstan
4242
@@ -50,15 +50,15 @@ jobs:
5050
git checkout -b release/v${{ github.event.inputs.new_version }}
5151
5252
sed -i 's/^__version__ = .*$/__version__ = '\''${{ github.event.inputs.new_version }}'\''/g' cmdstanpy/_version.py
53-
53+
5454
cd docsrc
5555
make github
5656
cd ..
57-
57+
5858
git add .
5959
git commit -m "release/v${{ github.event.inputs.new_version }}: updating version numbers"
6060
git push -u origin release/v${{ github.event.inputs.new_version }}
61-
61+
6262
- name: Merge into develop
6363
run: |
6464
git checkout develop
@@ -78,13 +78,13 @@ jobs:
7878
git pull
7979
git reset --hard v${{ github.event.inputs.new_version }}
8080
git push -f origin master
81-
81+
8282
- name: Build wheel
8383
run: python setup.py sdist bdist_wheel
8484

8585
- name: Install bdist_wheel
8686
run: pip install dist/*.whl
87-
87+
8888
- name: Upload to pypi
8989
if: success()
9090
env:

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ repos:
1212
- id: isort
1313
# https://github.com/python/black#version-control-integration
1414
- repo: https://github.com/psf/black
15-
rev: 21.6b0
15+
rev: 22.10.0
1616
hooks:
1717
- id: black
1818
- repo: https://github.com/pycqa/flake8
1919
rev: 3.9.2
2020
hooks:
2121
- id: flake8
2222
- repo: https://github.com/pre-commit/mirrors-mypy
23-
rev: v0.910
23+
rev: v0.982
2424
hooks:
2525
- id: mypy
2626
# Copied from setup.cfg
2727
exclude: ^test/
28-
additional_dependencies: [ numpy >= 1.22, types-ujson ]
28+
additional_dependencies: [ numpy >= 1.22]
2929
# local uses the user-installed pylint, this allows dependency checking
3030
- repo: local
3131
hooks:

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# A comma-separated list of package or module names from where C extensions may
44
# be loaded. Extensions are loading into the active Python interpreter and may
55
# run arbitrary code.
6-
extension-pkg-whitelist=ujson
6+
extension-pkg-whitelist=
77

88
# Add files or directories to the blacklist. They should be base names, not
99
# paths.

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.7'
3+
__version__ = '1.0.8'

cmdstanpy/cmdstan_args.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def __init__(
396396
history_size: Optional[int] = None,
397397
) -> None:
398398

399-
self.algorithm = algorithm
399+
self.algorithm = algorithm or ""
400400
self.init_alpha = init_alpha
401401
self.iter = iter
402402
self.save_iterations = save_iterations
@@ -414,20 +414,17 @@ def validate(
414414
"""
415415
Check arguments correctness and consistency.
416416
"""
417-
if (
418-
self.algorithm is not None
419-
and self.algorithm not in self.OPTIMIZE_ALGOS
420-
):
417+
if self.algorithm and self.algorithm not in self.OPTIMIZE_ALGOS:
421418
raise ValueError(
422419
'Please specify optimizer algorithms as one of [{}]'.format(
423420
', '.join(self.OPTIMIZE_ALGOS)
424421
)
425422
)
426423

427424
if self.init_alpha is not None:
428-
if self.algorithm == 'Newton':
425+
if self.algorithm.lower() not in {'lbfgs', 'bfgs'}:
429426
raise ValueError(
430-
'init_alpha must not be set when algorithm is Newton'
427+
'init_alpha requires that algorithm be set to bfgs or lbfgs'
431428
)
432429
if isinstance(self.init_alpha, float):
433430
if self.init_alpha <= 0:
@@ -443,9 +440,9 @@ def validate(
443440
raise ValueError('iter must be type of int')
444441

445442
if self.tol_obj is not None:
446-
if self.algorithm == 'Newton':
443+
if self.algorithm.lower() not in {'lbfgs', 'bfgs'}:
447444
raise ValueError(
448-
'tol_obj must not be set when algorithm is Newton'
445+
'tol_obj requires that algorithm be set to bfgs or lbfgs'
449446
)
450447
if isinstance(self.tol_obj, float):
451448
if self.tol_obj <= 0:
@@ -454,9 +451,10 @@ def validate(
454451
raise ValueError('tol_obj must be type of float')
455452

456453
if self.tol_rel_obj is not None:
457-
if self.algorithm == 'Newton':
454+
if self.algorithm.lower() not in {'lbfgs', 'bfgs'}:
458455
raise ValueError(
459-
'tol_rel_obj must not be set when algorithm is Newton'
456+
'tol_rel_obj requires that algorithm be set to bfgs'
457+
' or lbfgs'
460458
)
461459
if isinstance(self.tol_rel_obj, float):
462460
if self.tol_rel_obj <= 0:
@@ -465,9 +463,9 @@ def validate(
465463
raise ValueError('tol_rel_obj must be type of float')
466464

467465
if self.tol_grad is not None:
468-
if self.algorithm == 'Newton':
466+
if self.algorithm.lower() not in {'lbfgs', 'bfgs'}:
469467
raise ValueError(
470-
'tol_grad must not be set when algorithm is Newton'
468+
'tol_grad requires that algorithm be set to bfgs or lbfgs'
471469
)
472470
if isinstance(self.tol_grad, float):
473471
if self.tol_grad <= 0:
@@ -476,9 +474,10 @@ def validate(
476474
raise ValueError('tol_grad must be type of float')
477475

478476
if self.tol_rel_grad is not None:
479-
if self.algorithm == 'Newton':
477+
if self.algorithm.lower() not in {'lbfgs', 'bfgs'}:
480478
raise ValueError(
481-
'tol_rel_grad must not be set when algorithm is Newton'
479+
'tol_rel_grad requires that algorithm be set to bfgs'
480+
' or lbfgs'
482481
)
483482
if isinstance(self.tol_rel_grad, float):
484483
if self.tol_rel_grad <= 0:
@@ -487,9 +486,9 @@ def validate(
487486
raise ValueError('tol_rel_grad must be type of float')
488487

489488
if self.tol_param is not None:
490-
if self.algorithm == 'Newton':
489+
if self.algorithm.lower() not in {'lbfgs', 'bfgs'}:
491490
raise ValueError(
492-
'tol_param must not be set when algorithm is Newton'
491+
'tol_param requires that algorithm be set to bfgs or lbfgs'
493492
)
494493
if isinstance(self.tol_param, float):
495494
if self.tol_param <= 0:
@@ -498,10 +497,9 @@ def validate(
498497
raise ValueError('tol_param must be type of float')
499498

500499
if self.history_size is not None:
501-
if self.algorithm == 'Newton' or self.algorithm == 'BFGS':
500+
if self.algorithm.lower() != 'lbfgs':
502501
raise ValueError(
503-
'history_size must not be set when algorithm is '
504-
'Newton or BFGS'
502+
'history_size requires that algorithm be set to lbfgs'
505503
)
506504
if isinstance(self.history_size, int):
507505
if self.history_size < 0:

0 commit comments

Comments
 (0)