Skip to content

Commit

Permalink
Fix error message referring to default regexp only, and adapt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sfmig committed Dec 5, 2024
1 parent 8fbc251 commit 489cba1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
10 changes: 4 additions & 6 deletions movement/validators/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,16 +358,14 @@ def _extract_frame_numbers_using_regexp(self, df):
# try extracting the frame number from the filename using the
# compiled regexp
try:
list_frame_numbers.append(int(regex_match.group(1))) # type: ignore
list_frame_numbers.append(int(regex_match.group(1)))
except AttributeError as e:
raise log_error(
AttributeError,
f"{f} (row {f_i}): The frame regexp did not "
f"{f} (row {f_i}): The provided frame regexp "
f"({self.frame_regexp}) did not "
"return any matches and a frame number could not "
"be extracted from the filename. If included in "
"the filename, the frame number is expected as a "
"zero-padded integer before the file extension "
"(e.g. 00234.png).",
"be extracted from the filename.",
) from e
except ValueError as e:
raise log_error(
Expand Down
8 changes: 3 additions & 5 deletions tests/test_unit/test_load_bboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,9 @@ def test_from_via_tracks_file(
r"_(0\d*)_$",
AttributeError,
"/crab_1/00000.jpg (row 0): "
"The frame regexp did not return any matches and a "
"frame number could not be extracted from the filename. "
"If included in the filename, the frame number is expected "
"as a zero-padded integer before the file extension "
"(e.g. 00234.png).",
"The provided frame regexp (_(0\d*)_$) did not return any "
"matches and a frame number could not be extracted from "
"the filename.",
),
(
r"(0\d*\.\w+)$",
Expand Down
7 changes: 3 additions & 4 deletions tests/test_unit/test_validators/test_files_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,10 @@ def test_deeplabcut_csv_validator_with_invalid_input(
"frame_number_in_filename_wrong_pattern",
AttributeError,
"04.09.2023-04-Right_RE_test_frame_1.png (row 0): "
"The frame regexp did not return any matches and a "
"The provided frame regexp ((0\d*)\.\w+$) did not return "
"any matches and a "
"frame number could not be extracted from the "
"filename. If included in the filename, the frame "
"number is expected as a zero-padded integer before "
"the file extension (e.g. 00234.png).",
"filename.",
),
(
"more_frame_numbers_than_filenames",
Expand Down

0 comments on commit 489cba1

Please sign in to comment.