Skip to content

Commit

Permalink
randomness conftest typing (#569)
Browse files Browse the repository at this point in the history
randomness conftest typing
  • Loading branch information
hussain-jafari authored Jan 10, 2025
1 parent c1d9790 commit c85201b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
**3.2.14 - TBD/TBD/25**
**3.2.14 - 01/10/25**

- Type-hinting: Fix mypy errors in tests/framework/randomness/conftest.py
- Type-hinting: Fix mypy errors in tests/conftest.py

**3.2.13 - 12/27/24**
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ exclude = [
'tests/framework/lookup/test_lookup.py',
'tests/framework/population/test_manager.py',
'tests/framework/population/test_population_view.py',
'tests/framework/randomness/conftest.py',
'tests/framework/randomness/test_crn.py',
'tests/framework/randomness/test_index_map.py',
'tests/framework/randomness/test_manager.py',
Expand Down
18 changes: 11 additions & 7 deletions tests/framework/randomness/conftest.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
from __future__ import annotations

from typing import Any

import pandas as pd
import pytest

from vivarium.framework.randomness import RESIDUAL_CHOICE


@pytest.fixture(params=[10**4, 10**5])
def index(request):
def index(request: pytest.FixtureRequest) -> pd.Index[int] | None:
return pd.Index(range(request.param)) if request.param else None


@pytest.fixture(params=[["a", "small", "bird"]])
def choices(request):
return request.param
def choices(request: pytest.FixtureRequest) -> list[str]:
return request.param # type: ignore [no-any-return]


# TODO: Add 2-d weights to the tests.
@pytest.fixture(params=[None, [10, 10, 10], [0.5, 0.1, 0.4]])
def weights(request):
return request.param
def weights(request: pytest.FixtureRequest) -> None | list[int | float]:
return request.param # type: ignore [no-any-return]


@pytest.fixture(
Expand All @@ -27,5 +31,5 @@ def weights(request):
(0.1, RESIDUAL_CHOICE, RESIDUAL_CHOICE),
]
)
def weights_with_residuals(request):
return request.param
def weights_with_residuals(request: pytest.FixtureRequest) -> tuple[Any]:
return request.param # type: ignore [no-any-return]

0 comments on commit c85201b

Please sign in to comment.