Skip to content

Commit 65f7a57

Browse files
committed
Merge upstream/develop
2 parents a3329e7 + f577794 commit 65f7a57

29 files changed

+288
-234
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ jobs:
6868
run: python -m pip freeze
6969

7070
- name: Run flake8, pylint, mypy
71-
if: matrix.python-version == '3.11'
71+
if: matrix.python-version == '3.14'
7272
run: |
7373
flake8 cmdstanpy test
7474
pylint -v cmdstanpy test
75-
mypy cmdstanpy
75+
mypy cmdstanpy test
7676
7777
- name: CmdStan installation cacheing
7878
id: cache-cmdstan

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ repos:
2323
rev: v1.5.0
2424
hooks:
2525
- id: mypy
26-
exclude: ^test/
2726
additional_dependencies: [ numpy >= 1.22]
2827
# local uses the user-installed pylint, this allows dependency checking
2928
- repo: local

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ We welcome contributions! Contributions should follow the general outlines of t
1919

2020
* The GitHub repo organization follows the gitflow model described by Vincent Driessen in the blog post ["A successful Git branching model."](https://nvie.com/posts/a-successful-git-branching-model/). The main developer branch is `develop`; it should always be runnable.
2121

22-
* Unit tests must be runnable under both the [unittest](https://docs.python.org/3/library/unittest.html#module-unittest) and [PyTest](https://docs.pytest.org/en/stable/) frameworks.
22+
* Unit tests must be runnable under the [PyTest](https://docs.pytest.org/en/stable/) framework, and must pass against the latest release of [CmdStan](https://github.com/stan-dev/cmdstan).
2323

2424
* Both [PyLint](https://www.pylint.org) and [Flake8](https://flake8.pycqa.org/en/latest/) are used to check code style and formatting according to rules in https://github.com/stan-dev/cmdstanpy/blob/develop/.pylintrc and https://github.com/stan-dev/cmdstanpy/blob/a6e09190af555aa6d05993d630ebf39a3d4bb867/.travis.yml#L30. Code is formatted with [isort](https://pycqa.github.io/isort/) and [black](https://black.readthedocs.io/en/stable/).
2525

cmdstanpy/cmdstan_args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ def __init__(
643643
| PathfinderArgs
644644
),
645645
data: Mapping[str, Any] | str | None = None,
646-
seed: int | list[int] | None = None,
646+
seed: int | np.integer | list[int] | list[np.integer] | None = None,
647647
inits: int | float | str | list[str] | None = None,
648648
output_dir: OptionalPath = None,
649649
sig_figs: int | None = None,

cmdstanpy/install_cmdstan.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
import urllib.error
3030
import urllib.request
3131
from collections import OrderedDict
32+
from functools import cached_property
3233
from pathlib import Path
3334
from time import sleep
34-
from typing import TYPE_CHECKING, Any, Callable
35+
from typing import Any, Callable
3536

3637
from tqdm.auto import tqdm
3738

@@ -47,18 +48,6 @@
4748

4849
from . import progress as progbar
4950

50-
if sys.version_info >= (3, 8) or TYPE_CHECKING:
51-
# mypy only knows about the new built-in cached_property
52-
from functools import cached_property
53-
else:
54-
# on older Python versions, this is the recommended
55-
# way to get the same effect
56-
from functools import lru_cache
57-
58-
def cached_property(fun):
59-
return property(lru_cache(maxsize=None)(fun))
60-
61-
6251
try:
6352
# on MacOS and Linux, importing this
6453
# improves the UX of the input() function

cmdstanpy/model.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from concurrent.futures import ThreadPoolExecutor
1414
from io import StringIO
1515
from multiprocessing import cpu_count
16-
from typing import Any, Callable, Mapping, TypeVar
16+
from typing import Any, Callable, Mapping, Sequence, TypeVar
1717

1818
import numpy as np
1919
import pandas as pd
@@ -461,8 +461,7 @@ def sample(
461461
Mapping[str, Any]
462462
| float
463463
| str
464-
| list[str]
465-
| list[Mapping[str, Any]]
464+
| Sequence[str | Mapping[str, Any]]
466465
| None
467466
) = None,
468467
iter_warmup: int | None = None,
@@ -493,7 +492,7 @@ def sample(
493492
str
494493
| np.ndarray
495494
| Mapping[str, Any]
496-
| list[str | np.ndarray | Mapping[str, Any]]
495+
| Sequence[str | np.ndarray | Mapping[str, Any]]
497496
| None
498497
) = None,
499498
) -> CmdStanMCMC:
@@ -1360,7 +1359,13 @@ def pathfinder(
13601359
calculate_lp: bool = True,
13611360
# arguments standard to all methods
13621361
seed: int | None = None,
1363-
inits: dict[str, float] | float | str | os.PathLike | None = None,
1362+
inits: (
1363+
Mapping[str, Any]
1364+
| float
1365+
| str
1366+
| Sequence[str | Mapping[str, Any]]
1367+
| None
1368+
) = None,
13641369
output_dir: OptionalPath = None,
13651370
sig_figs: int | None = None,
13661371
save_profile: bool = False,

cmdstanpy/stanfit/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def from_csv(
252252
mode: CmdStanMLE = from_csv(
253253
config_dict['mode'], # type: ignore
254254
method='optimize',
255-
) # type: ignore
255+
)
256256
return CmdStanLaplace(runset, mode=mode)
257257
elif config_dict['method'] == 'pathfinder':
258258
pathfinder_args = PathfinderArgs(

cmdstanpy/stanfit/mcmc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def _validate_csv_files(self) -> dict[str, Any]:
348348
save_warmup=self._save_warmup,
349349
thin=self._thin,
350350
)
351-
self._chain_time.append(dzero['time']) # type: ignore
351+
self._chain_time.append(dzero['time'])
352352
if not self._is_fixed_param:
353353
self._divergences[i] = dzero['ct_divergences']
354354
self._max_treedepths[i] = dzero['ct_max_treedepth']
@@ -360,7 +360,7 @@ def _validate_csv_files(self) -> dict[str, Any]:
360360
save_warmup=self._save_warmup,
361361
thin=self._thin,
362362
)
363-
self._chain_time.append(drest['time']) # type: ignore
363+
self._chain_time.append(drest['time'])
364364
for key in dzero:
365365
# check args that matter for parsing, plus name, version
366366
if (

cmdstanpy/stanfit/pathfinder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def is_resampled(self) -> bool:
206206
Returns True if the draws were resampled from several Pathfinder
207207
approximations, False otherwise.
208208
"""
209-
return ( # type: ignore
209+
return (
210210
self._metadata.cmdstan_config.get("num_paths", 4) > 1
211211
and self._metadata.cmdstan_config.get('psis_resample', 1)
212212
in (1, 'true')

cmdstanpy/utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def show_versions(output: bool = True) -> str:
8080
deps_info.append((module, None))
8181
else:
8282
try:
83-
ver = mod.__version__ # type: ignore
83+
ver = mod.__version__
8484
deps_info.append((module, ver))
8585
# pylint: disable=broad-except
8686
except Exception:

0 commit comments

Comments
 (0)