Skip to content

Commit caafbb4

Browse files
Merge pull request #152 from NeurodataWithoutBorders/fix_file_counter
[Bug]: Fix display of similar files
2 parents 43aef39 + 78c7afd commit caafbb4

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

nwbinspector/inspector_tools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ def _add_subsection(
216216
increment = self._get_message_increment(level_counter=this_level_counter)
217217
message_header = self._get_message_header(message=message)
218218
num_same = len(same_messages)
219-
file_str = "files" if num_same > 1 else "file"
219+
file_or_files = "s" if num_same > 2 else ""
220+
additional_file_str = f" and {num_same-1} other file{file_or_files}" if num_same > 1 else ""
220221
self.formatted_messages.append(
221-
f"{increment}{message.file_path} and {num_same} other {file_str}: "
222-
f"{message_header.rstrip(' - ')}"
222+
f"{increment}{message.file_path}{additional_file_str}: " f"{message_header.rstrip(' - ')}"
223223
)
224224
self.formatted_messages.extend([f"{' ' * len(increment)} Message: {message.message}", ""])
225225
self.message_counter += 1

tests/test_inspector.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class TestInspector(TestCase):
7575
@classmethod
7676
def setUpClass(cls):
7777
cls.tempdir = Path(mkdtemp())
78+
# cls.tempdir = Path("E:/test_inspector/output2")
7879
cls.checks = [
7980
check_small_dataset_compression,
8081
check_regular_timestamps,

tests/true_nwbinspector_default_report.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ Found 5 issues over 2 files:
1515
0 CRITICAL
1616
===========
1717

18-
0.0 ./testing0.nwb and 1 other file: check_data_orientation - 'SpatialSeries' object at location '/processing/behavior/Position/my_spatial_series'
18+
0.0 ./testing0.nwb: check_data_orientation - 'SpatialSeries' object at location '/processing/behavior/Position/my_spatial_series'
1919
Message: Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer.
2020

21-
0.1 ./testing0.nwb and 1 other file: check_timestamps_match_first_dimension - 'TimeSeries' object at location '/acquisition/test_time_series_3'
21+
0.1 ./testing0.nwb: check_timestamps_match_first_dimension - 'TimeSeries' object at location '/acquisition/test_time_series_3'
2222
Message: The length of the first dimension of data does not match the length of timestamps.
2323

2424
1 BEST_PRACTICE_VIOLATION
2525
==========================
2626

27-
1.2 ./testing0.nwb and 2 other files: check_regular_timestamps - 'TimeSeries' object at location '/acquisition/test_time_series_2'
27+
1.2 ./testing0.nwb and 1 other file: check_regular_timestamps - 'TimeSeries' object at location '/acquisition/test_time_series_2'
2828
Message: TimeSeries appears to have a constant sampling rate. Consider specifying starting_time=1.2 and rate=2.0 instead of timestamps.
2929

3030
2 BEST_PRACTICE_SUGGESTION
3131
===========================
3232

33-
2.3 ./testing0.nwb and 1 other file: check_small_dataset_compression - 'TimeSeries' object at location '/acquisition/test_time_series_1'
33+
2.3 ./testing0.nwb: check_small_dataset_compression - 'TimeSeries' object at location '/acquisition/test_time_series_1'
3434
Message: data is not compressed. Consider enabling compression when writing a dataset.

0 commit comments

Comments
 (0)