Skip to content

Commit

Permalink
mollify ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Jan 13, 2025
1 parent ba31a88 commit 729b6db
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/inspect_ai/_eval/task/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)
from inspect_ai.log._log import EvalSampleReductions
from inspect_ai.scorer import Metric, Score, Scorer
from inspect_ai.scorer._metric import SampleScore, ReducedScore
from inspect_ai.scorer._metric import ReducedScore, SampleScore
from inspect_ai.scorer._reducer import ScoreReducer, mean_score, reducer_log_name
from inspect_ai.scorer._scorer import (
SCORER_METRICS,
Expand Down
2 changes: 1 addition & 1 deletion src/inspect_ai/log/_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
from inspect_ai.util._store import Store
from inspect_ai.util._store_model import SMT

from ._transcript import Event
from ..scorer._metric import ReducedScore
from ._transcript import Event

logger = getLogger(__name__)

Expand Down
5 changes: 3 additions & 2 deletions src/inspect_ai/scorer/_metrics/std.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from .._metric import (
Metric,
Score,
ReducedScore,
ValueToFloat,
metric,
Expand Down Expand Up @@ -50,7 +49,9 @@ def metric(scores: list[ReducedScore]) -> float:

@metric
def stderr(to_float: ValueToFloat = value_to_float()) -> Metric:
"""Clustered standard error of the mean, where each ``ReducedScore``'s children form a cluster.
"""Clustered standard error of the mean.
Where each ``ReducedScore``'s children form a cluster.
If ``epochs=1`` such that each ``ReducedScore`` has only one child, clustered standard errors
reduce to heteroskedasticity-robust (White) standard errors.
Expand Down
8 changes: 7 additions & 1 deletion src/inspect_ai/scorer/_reducer/reducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

import numpy as np

from inspect_ai.scorer._metric import Score, Value, ValueToFloat, value_to_float, ReducedScore
from inspect_ai.scorer._metric import (
ReducedScore,
Score,
Value,
ValueToFloat,
value_to_float,
)

from .registry import REDUCER_NAME, score_reducer
from .types import ScoreReducer
Expand Down
2 changes: 1 addition & 1 deletion src/inspect_ai/scorer/_reducer/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Protocol, runtime_checkable

from .._metric import Score, ReducedScore
from .._metric import ReducedScore, Score


@runtime_checkable
Expand Down
2 changes: 1 addition & 1 deletion tests/scorer/test_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
scorer,
std,
)
from inspect_ai.scorer._metric import metric_create, ReducedScore
from inspect_ai.scorer._metric import ReducedScore, metric_create
from inspect_ai.scorer._target import Target
from inspect_ai.solver._task_state import TaskState

Expand Down
19 changes: 8 additions & 11 deletions tests/scorer/test_metric_stderr.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import pytest

from inspect_ai.scorer._metric import Score, ReducedScore
from inspect_ai.scorer._metric import ReducedScore, Score
from inspect_ai.scorer._metrics.std import stderr


"""
Comparisons to ``statsmodels`` are done using the following code:
```python
Expand All @@ -27,9 +26,7 @@ def cluster_se(data: pd.DataFrame) -> float:


def test_stderr_single_cluster():
"""
Backward compatibility: previous implementation of stderr returned 0 for a single reduced score.
"""
"""Backward compatibility: previous implementation of stderr returned 0 for a single reduced score."""
scores = [
ReducedScore(value=2.5, children=[
Score(value=1.0),
Expand All @@ -47,8 +44,8 @@ def test_stderr_single_cluster():


def test_stderr_singleton_clusters():
"""
Test clustered SE with three clusters of size 1 each.
"""Test clustered SE with three clusters of size 1 each.
This should reduce to the heteroskedasticity-robust standard error.
Statsmodels verification:
Expand Down Expand Up @@ -112,8 +109,8 @@ def test_stderr_identical_within_varied_between():


def test_stderr_1():
"""
Statsmodels verification:
"""Statsmodels verification.
```python
data = pd.DataFrame({
"y": [1, 1, 0, 0, 1, 0],
Expand All @@ -137,8 +134,8 @@ def test_stderr_1():


def test_stderr_2():
"""
Statsmodels verification:
"""Statsmodels verification.
```python
data = pd.DataFrame({
"y": [9.0, 4.0, 11.0, 6.0, 13.0, 8.0],
Expand Down

0 comments on commit 729b6db

Please sign in to comment.