diff --git a/movement/validators/files.py b/movement/validators/files.py index 64929361..87d27775 100644 --- a/movement/validators/files.py +++ b/movement/validators/files.py @@ -247,7 +247,7 @@ def csv_file_contains_valid_header(self, attribute, value): @path.validator def csv_file_contains_valid_frame_numbers(self, attribute, value): - """Ensure that the VIA tracks csv file contains valid frame numbers. + """Ensure that the VIA tracks .csv file contains valid frame numbers. This involves: - Checking that frame numbers are included in `file_attributes` or @@ -309,13 +309,14 @@ def csv_file_contains_valid_frame_numbers(self, attribute, value): raise log_error( ValueError, "The number of unique frame numbers does not match the number " - "of unique image files. Please review the VIA tracks csv file " - "and ensure a unique frame number is defined for each file. ", + "of unique image files. Please review the VIA tracks .csv " + "file and ensure a unique frame number is defined for each " + "file. ", ) @path.validator def csv_file_contains_tracked_bboxes(self, attribute, value): - """Ensure that the VIA tracks csv contains tracked bounding boxes. + """Ensure that the VIA tracks .csv contains tracked bounding boxes. This involves: - Checking that the bounding boxes are defined as rectangles. @@ -365,7 +366,7 @@ def csv_file_contains_tracked_bboxes(self, attribute, value): f"{row.filename} (row {row.Index}): " "bounding box does not have a 'track' attribute defined " "under 'region_attributes'. " - "Please review the VIA tracks csv file.", + "Please review the VIA tracks .csv file.", ) # check track ID is castable as an integer @@ -376,14 +377,14 @@ def csv_file_contains_tracked_bboxes(self, attribute, value): ValueError, f"{row.filename} (row {row.Index}): " "the track ID for the bounding box cannot be cast " - "as an integer. Please review the VIA tracks csv file.", + "as an integer. Please review the VIA tracks .csv file.", ) from e @path.validator def csv_file_contains_unique_track_IDs_per_filename( self, attribute, value ): - """Ensure the VIA tracks csv contains unique track IDs per filename. + """Ensure the VIA tracks .csv contains unique track IDs per filename. It checks that bounding boxes IDs are defined once per image file. """ @@ -406,5 +407,5 @@ def csv_file_contains_unique_track_IDs_per_filename( f"{file}: " "multiple bounding boxes in this file " "have the same track ID. " - "Please review the VIA tracks csv file.", + "Please review the VIA tracks .csv file.", ) diff --git a/tests/conftest.py b/tests/conftest.py index 8029e4bb..27281b00 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -362,7 +362,7 @@ def via_tracks_csv_with_valid_header(tmp_path): def frame_number_in_file_attribute_not_integer( via_tracks_csv_with_valid_header, ): - """Return the file path for a VIA tracks csv file with invalid frame + """Return the file path for a VIA tracks .csv file with invalid frame number defined as file_attribute. """ file_path = via_tracks_csv_with_valid_header @@ -383,7 +383,7 @@ def frame_number_in_file_attribute_not_integer( def frame_number_in_filename_wrong_pattern( via_tracks_csv_with_valid_header, ): - """Return the file path for a VIA tracks csv file with invalid frame + """Return the file path for a VIA tracks .csv file with invalid frame number defined in the frame's filename. """ file_path = via_tracks_csv_with_valid_header @@ -404,7 +404,7 @@ def frame_number_in_filename_wrong_pattern( def more_frame_numbers_than_filenames( via_tracks_csv_with_valid_header, ): - """Return the file path for a VIA tracks csv file with more + """Return the file path for a VIA tracks .csv file with more frame numbers than filenames. """ file_path = via_tracks_csv_with_valid_header @@ -435,7 +435,7 @@ def more_frame_numbers_than_filenames( def less_frame_numbers_than_filenames( via_tracks_csv_with_valid_header, ): - """Return the file path for a VIA tracks csv file with with less + """Return the file path for a VIA tracks .csv file with with less frame numbers than filenames. """ file_path = via_tracks_csv_with_valid_header @@ -466,7 +466,7 @@ def less_frame_numbers_than_filenames( def region_shape_attribute_not_rect( via_tracks_csv_with_valid_header, ): - """Return the file path for a VIA tracks csv file with invalid shape in + """Return the file path for a VIA tracks .csv file with invalid shape in region_shape_attributes. """ file_path = via_tracks_csv_with_valid_header @@ -487,7 +487,7 @@ def region_shape_attribute_not_rect( def region_shape_attribute_missing_x( via_tracks_csv_with_valid_header, ): - """Return the file path for a VIA tracks csv file with invalid shape in + """Return the file path for a VIA tracks .csv file with missing `x` key in region_shape_attributes. """ file_path = via_tracks_csv_with_valid_header @@ -508,7 +508,7 @@ def region_shape_attribute_missing_x( def region_attribute_missing_track( via_tracks_csv_with_valid_header, ): - """Return the file path for a VIA tracks csv file with missing track + """Return the file path for a VIA tracks .csv file with missing track attribute in region_attributes. """ file_path = via_tracks_csv_with_valid_header @@ -529,7 +529,7 @@ def region_attribute_missing_track( def track_id_not_castable_as_int( via_tracks_csv_with_valid_header, ): - """Return the file path for a VIA tracks csv file with a track ID + """Return the file path for a VIA tracks .csv file with a track ID attribute not castable as an integer. """ file_path = via_tracks_csv_with_valid_header @@ -550,7 +550,7 @@ def track_id_not_castable_as_int( def track_ids_not_unique_per_frame( via_tracks_csv_with_valid_header, ): - """Return the file path for a VIA tracks csv file with a track ID + """Return the file path for a VIA tracks .csv file with a track ID that appears twice in the same frame. """ file_path = via_tracks_csv_with_valid_header diff --git a/tests/test_unit/test_validators/test_files_validators.py b/tests/test_unit/test_validators/test_files_validators.py index 2f39431b..403a67b3 100644 --- a/tests/test_unit/test_validators/test_files_validators.py +++ b/tests/test_unit/test_validators/test_files_validators.py @@ -99,14 +99,14 @@ def test_deeplabcut_csv_validator_with_invalid_input( ( "more_frame_numbers_than_filenames", "The number of unique frame numbers does not match the number " - "of unique image files. Please review the VIA tracks csv file and " - "ensure a unique frame number is defined for each file. ", + "of unique image files. Please review the VIA tracks .csv file " + "and ensure a unique frame number is defined for each file. ", ), ( "less_frame_numbers_than_filenames", "The number of unique frame numbers does not match the number " - "of unique image files. Please review the VIA tracks csv file and " - "ensure a unique frame number is defined for each file. ", + "of unique image files. Please review the VIA tracks .csv file " + "and ensure a unique frame number is defined for each file. ", ), ( "region_shape_attribute_not_rect", @@ -127,20 +127,20 @@ def test_deeplabcut_csv_validator_with_invalid_input( "04.09.2023-04-Right_RE_test_frame_01.png (row 0): " "bounding box does not have a 'track' attribute defined " "under 'region_attributes'. " - "Please review the VIA tracks csv file.", + "Please review the VIA tracks .csv file.", ), ( "track_id_not_castable_as_int", "04.09.2023-04-Right_RE_test_frame_01.png (row 0): " "the track ID for the bounding box cannot be cast " "as an integer. " - "Please review the VIA tracks csv file.", + "Please review the VIA tracks .csv file.", ), ( "track_ids_not_unique_per_frame", "04.09.2023-04-Right_RE_test_frame_01.png: " "multiple bounding boxes in this file have the same track ID. " - "Please review the VIA tracks csv file.", + "Please review the VIA tracks .csv file.", ), ], ) @@ -150,7 +150,7 @@ def test_via_tracks_csv_validator_with_invalid_input( """Test that invalid VIA tracks CSV files raise the appropriate errors. Errors to check: - - error if csv header is wrong + - error if .csv header is wrong - error if frame number is not defined in the file (frame number extracted either from the filename or from attributes) - error if extracted frame numbers are not 1-based integers