Skip to content

Commit d8af22b

Browse files
committed
fixing tests
1 parent 3772e1a commit d8af22b

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/pyptv/ptv.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def _as_text(value: str | bytes) -> str:
8383
return value.decode() if isinstance(value, bytes) else value
8484

8585

86-
def _prepare_output_path(filename: str) -> Path:
86+
def _prepare_output_path(filename: str | Path) -> Path:
8787
"""Return a writable output path, creating parent directories when needed."""
8888
output_path = Path(filename)
8989
parent = output_path.parent
@@ -134,7 +134,7 @@ def _ensure_directory_writable(directory: Path, label: str) -> Path:
134134
return directory
135135

136136

137-
def _ensure_target_output_writable(short_file_bases: List[str]) -> None:
137+
def _ensure_target_output_writable(short_file_bases: List[str | Path]) -> None:
138138
"""Check target output directories before the first target file write."""
139139
checked_dirs = set()
140140

@@ -946,7 +946,7 @@ def py_calibration(selection, exp):
946946
return calib_particles(exp)
947947

948948

949-
def write_targets(targets: TargetArray, short_file_base: str, frame: int) -> bool:
949+
def write_targets(targets: TargetArray, short_file_base: str | Path, frame: int) -> bool:
950950
"""Write targets to a file."""
951951
output_path = _prepare_output_path(_target_filename(short_file_base, frame))
952952
num_targets = len(targets)
@@ -1010,7 +1010,7 @@ def _sum_grey_value(target):
10101010
_raise_output_write_error(output_path, exc)
10111011
return success
10121012

1013-
def read_targets(short_file_base: str, frame: int) -> TargetArray:
1013+
def read_targets(short_file_base: str | Path, frame: int) -> TargetArray:
10141014
"""Read targets from a file."""
10151015
filename = _target_filename(short_file_base, frame)
10161016
print(f" Reading targets from: filename: {filename}")
@@ -1043,8 +1043,9 @@ def read_targets(short_file_base: str, frame: int) -> TargetArray:
10431043
return targs
10441044

10451045

1046-
def _target_filename(short_file_base: str, frame: int) -> str:
1046+
def _target_filename(short_file_base: str | Path, frame: int) -> str:
10471047
"""Resolve a target filename from either a plain base or a legacy %d pattern."""
1048+
short_file_base = str(short_file_base)
10481049
if "%d" in short_file_base:
10491050
return re.sub(r"%0?\d*d", str(frame), short_file_base) + "_targets"
10501051
return f"{short_file_base}.{frame:04d}_targets"

tests/pyptv/test_calibration_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import tempfile
99
from pathlib import Path
1010

11-
# Import the functions from the original file
12-
from tests.pyptv.test_calibration import (
11+
# Import the functions from the sibling test module
12+
from test_calibration import (
1313
read_dt_lsq,
1414
read_calblock,
1515
pair_cal_points,

0 commit comments

Comments
 (0)