Skip to content

Commit a2df562

Browse files
Fix CI ruff lint and format issues
Co-authored-by: m9h <28337207+m9h@users.noreply.github.com>
1 parent d9fe300 commit a2df562

62 files changed

Lines changed: 2066 additions & 1184 deletions

Some content is hidden

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

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ jobs:
2323
- name: Install dependencies
2424
run: uv sync --group dev 2>/dev/null || uv pip install -e ".[dev]"
2525
- name: Ruff check
26-
run: uv run ruff check src/ tests/
26+
run: uv run ruff check alf/
2727
- name: Ruff format check
28-
run: uv run ruff format --check src/ tests/
28+
run: uv run ruff format --check alf/
2929
- name: No-mock check
3030
run: |
31-
if grep -rn "unittest\.mock\|MagicMock\|from mock import\|@patch" tests/ --include="*.py" | grep -v "^#"; then
31+
if grep -rn "unittest\.mock\|MagicMock\|from mock import\|@patch" alf/tests/ --include="*.py" | grep -v "^#"; then
3232
echo "::error::unittest.mock usage detected in tests"
3333
exit 1
3434
fi
3535
- name: Pytest
36-
run: uv run pytest tests/ -v --tb=short
36+
run: uv run pytest alf/tests/ -v --tb=short
2.6 KB
Binary file not shown.
-36 Bytes
Binary file not shown.
21 KB
Binary file not shown.
-33 Bytes
Binary file not shown.
44 Bytes
Binary file not shown.
-73 Bytes
Binary file not shown.
-17 Bytes
Binary file not shown.
-387 Bytes
Binary file not shown.

alf/agent.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
Inference. Journal of Mathematical Psychology.
2828
"""
2929

30-
from typing import Any, Optional
30+
from typing import Any
3131

3232
import numpy as np
3333

@@ -108,7 +108,10 @@ def step(
108108

109109
# 3. Action selection
110110
policy_idx, policy_probs = alf_policy.select_action(
111-
G, self.E, self.gamma, rng=self.rng,
111+
G,
112+
self.E,
113+
self.gamma,
114+
rng=self.rng,
112115
)
113116
self.policy_prob_history.append(policy_probs.copy())
114117

@@ -133,19 +136,20 @@ def learn(self, outcome_valence: float) -> None:
133136
"""
134137
if self.action_history:
135138
last_policy_idx = (
136-
self.policy_prob_history[-1].argmax()
137-
if self.policy_prob_history
138-
else 0
139+
self.policy_prob_history[-1].argmax() if self.policy_prob_history else 0
139140
)
140141
self.E = alf_policy.update_habits(
141-
self.E, last_policy_idx, outcome_valence,
142+
self.E,
143+
last_policy_idx,
144+
outcome_valence,
142145
learning_rate=self.learning_rate,
143146
)
144147

145148
def update_precision(self, prediction_error: float) -> None:
146149
"""Adapt policy precision based on prediction error."""
147150
self.gamma = alf_policy.update_precision(
148-
self.gamma, prediction_error,
151+
self.gamma,
152+
prediction_error,
149153
)
150154

151155
def reset(self) -> None:

0 commit comments

Comments
 (0)