Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ jobs:
strategy:
matrix:
include:
- {runs-on: ubuntu-24.04, python-version: "3.10"}
- {runs-on: ubuntu-24.04, python-version: "3.11"}
- {runs-on: ubuntu-24.04, python-version: "3.12"}
- {runs-on: macos-13, python-version: "3.10"}
- {runs-on: macos-13, python-version: "3.11"}
- {runs-on: macos-13, python-version: "3.12"}
- {runs-on: ubuntu-24.04, python-version: "3.13"}
- {runs-on: ubuntu-24.04, python-version: "3.14"}
- {runs-on: macos-15-intel, python-version: "3.12"}
steps:
- name: Check out repository
uses: actions/checkout@v4
Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ classifiers = [
]

[tool.poetry.dependencies]
python = "^3.10"
python = "^3.12"
aiohttp = "^3.6"
httpstan = "~4.13"
pysimdjson = ">=5.0.2,<7"
pysimdjson = ">=5.0.2"
numpy = ">=1.19"
clikit = "^0.6"
setuptools = "*"

[tool.poetry.dev-dependencies]
pytest = "^6.2"
pytest-asyncio = "^0.18.3"
pytest = "^9.0.2"
pytest-asyncio = "^1.3"
pandas = ">=1.0,<3"
black = "22.6.0"
black = "26.3.0"
isort = "^5.9"
mypy = "0.982"
mypy = "1.19"
types-setuptools = "^57.4"
# documentation
# NOTE: when changing these, update docs-requirements.txt
Expand Down
1 change: 1 addition & 0 deletions stan/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Common routines"""

import socket
import typing

Expand Down
1 change: 1 addition & 0 deletions stan/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def __init__(
)

draw_row = tuple(msg["values"].values()) # a "row" of values from a single draw from Stan C++
draw_row = cast(Tuple[float, ...], draw_row)
self._draws[:, draw_index, chain_index] = draw_row
draw_index += 1
finally:
Expand Down
8 changes: 3 additions & 5 deletions stan/plugins.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import abc
from typing import Generator

import pkg_resources
import importlib.metadata

import stan.fit


def get_plugins() -> Generator[pkg_resources.EntryPoint, None, None]:
def get_plugins() -> importlib.metadata.EntryPoints:
"""Iterate over available plugins."""
return pkg_resources.iter_entry_points(group="stan.plugins")
return importlib.metadata.entry_points(group="stan.plugins")


class PluginBase(abc.ABC):
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""pytest configuration for all tests."""

import pytest


Expand Down
1 change: 1 addition & 0 deletions tests/test_build_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for build related exceptions."""

import pytest

import stan
Expand Down
1 change: 1 addition & 0 deletions tests/test_build_program.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test building a Stan program."""

import pytest

import stan
Expand Down
1 change: 1 addition & 0 deletions tests/test_constrain_pars.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test constrain parameters."""

import random

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions tests/test_corr_matrix.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CPU-intensive test, useful for testing progress bars."""

import stan

program_code = """
Expand Down
1 change: 1 addition & 0 deletions tests/test_eight_schools_large.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Introduced in response to a macOS bug that only
triggered when a larger number of parameters were used.
"""

import pytest

import stan
Expand Down
1 change: 1 addition & 0 deletions tests/test_fit_basic_array.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test model with array parameter."""

import numpy as np
import pytest

Expand Down
1 change: 1 addition & 0 deletions tests/test_fit_basic_matrix.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test model with a matrix parameter."""

import pytest

import stan
Expand Down
1 change: 1 addition & 0 deletions tests/test_fit_basic_scalar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test model with a scalar parameter."""

import numpy as np
import pytest

Expand Down
1 change: 1 addition & 0 deletions tests/test_fit_basic_vector.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test model with a vector parameter."""

import numpy as np
import pytest

Expand Down
1 change: 1 addition & 0 deletions tests/test_fit_cache.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests related to cached fits."""

import os
import pathlib
import random
Expand Down
1 change: 1 addition & 0 deletions tests/test_fit_shape.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test model parameter shapes."""

import pytest

import stan
Expand Down
1 change: 1 addition & 0 deletions tests/test_grad_log_prob.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test model with array parameter."""

import random

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions tests/test_log_prob.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test model with array parameter."""

import numpy as np
import pytest

Expand Down
1 change: 1 addition & 0 deletions tests/test_model_build_data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test handling of `data` dictionary."""

import copy

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions tests/test_nan_inf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test serialization of nan and inf values."""

import math

import stan
Expand Down
13 changes: 7 additions & 6 deletions tests/test_plugins.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pkg_resources
import importlib.metadata

import pytest

import stan
Expand All @@ -20,7 +21,7 @@ def load():
return DummyPlugin


def mock_iter_entry_points(group):
def mock_entry_points(group):
return iter([MockEntryPoint])


Expand All @@ -31,7 +32,7 @@ def normal_posterior():

def test_get_plugins(monkeypatch):

monkeypatch.setattr(pkg_resources, "iter_entry_points", mock_iter_entry_points)
monkeypatch.setattr(importlib.metadata, "entry_points", mock_entry_points)

entry_points = stan.plugins.get_plugins()
Plugin = next(entry_points).load()
Expand All @@ -40,7 +41,7 @@ def test_get_plugins(monkeypatch):

def test_dummy_plugin(monkeypatch, capsys, normal_posterior):

monkeypatch.setattr(pkg_resources, "iter_entry_points", mock_iter_entry_points)
monkeypatch.setattr(importlib.metadata, "entry_points", mock_entry_points)

fit = normal_posterior.sample(stepsize=0.001)
assert fit is not None and "y" in fit
Expand All @@ -65,10 +66,10 @@ def load():
def test_two_plugins(monkeypatch, capsys, normal_posterior):
"""Make sure that both plugins are used."""

def mock_iter_entry_points(group):
def mock_entry_points(group):
return iter([MockEntryPoint, OtherMockEntryPoint])

monkeypatch.setattr(pkg_resources, "iter_entry_points", mock_iter_entry_points)
monkeypatch.setattr(importlib.metadata, "entry_points", mock_entry_points)

fit = normal_posterior.sample(stepsize=0.001)
assert fit is not None and "y" in fit
Expand Down
1 change: 1 addition & 0 deletions tests/test_sample_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for sampling related exceptions."""

import pytest

import stan
Expand Down
1 change: 1 addition & 0 deletions tests/test_stanc_warnings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test that stanc warnings are visible."""

import contextlib
import io

Expand Down
1 change: 1 addition & 0 deletions tests/test_transformed_data_rng.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Verify that the RNG in the transformed data block uses the overall seed."""

import numpy as np

import stan
Expand Down
1 change: 1 addition & 0 deletions tests/test_unconstrain_pars.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test constrain parameters."""

import random

import numpy as np
Expand Down
Loading