Skip to content

Commit 3528672

Browse files
committed
ruff fixes
1 parent e7c4d37 commit 3528672

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

rundetection/rules/imat_rules.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,26 @@
1717

1818

1919
def check_file(path: Path, run_number: str) -> bool:
20+
"""
21+
Check if a file matches the run number.
22+
23+
:param path: The path to the file.
24+
:param run_number: The run number to check for.
25+
:return: True if it is a file and the run number is in the name.
26+
"""
2027
return path.is_file() and run_number in path.name
2128

2229

2330
def check_dir(path: Path, run_number: str) -> Path | None:
31+
"""
32+
Check a directory for the IMAT image structure.
33+
34+
This looks for a file containing the run number and a directory named 'Tomo'.
35+
36+
:param path: The path to the experiment directory.
37+
:param run_number: The run number to check for.
38+
:return: The path to the Tomo directory if found, otherwise None.
39+
"""
2440
tomo = None
2541
file_found = False
2642
for child in path.iterdir():

test/rules/test_imat_rules.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
from rundetection.job_requests import JobRequest
1111
from rundetection.rules.imat_rules import IMATFindImagesRule
1212

13+
EXPECTED_ADDITIONAL_VALUES_LEN = 2
14+
RUN_NUMBER = 100
15+
1316

1417
@pytest.fixture
1518
def job_request():
@@ -50,9 +53,9 @@ def test_imat_find_images_success(job_request):
5053
rule.verify(job_request)
5154

5255
# Assertions
53-
assert len(job_request.additional_values) == 2
56+
assert len(job_request.additional_values) == EXPECTED_ADDITIONAL_VALUES_LEN
5457
assert job_request.additional_values["images_dir"] == str(tomo_dir)
55-
assert job_request.additional_values["runno"] == 100
58+
assert job_request.additional_values["runno"] == RUN_NUMBER
5659

5760

5861
def test_imat_find_images_tomo_first(job_request):

0 commit comments

Comments
 (0)