Skip to content

Commit 1ed363a

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent a4c8efe commit 1ed363a

File tree

2 files changed

+19
-61
lines changed

2 files changed

+19
-61
lines changed

nwbinspector/checks/ophys.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,24 @@ def check_roi_response_series_dims(roi_response_series: RoiResponseSeries):
3434
)
3535

3636

37-
@register_check(
38-
importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=RoiResponseSeries
39-
)
37+
@register_check(importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=RoiResponseSeries)
4038
def check_roi_response_series_link_to_plane_segmentation(
4139
roi_response_series: RoiResponseSeries,
4240
):
4341
"""Check that each ROI response series links to a plane segmentation."""
4442
if not isinstance(roi_response_series.rois.table, PlaneSegmentation):
45-
return InspectorMessage(
46-
message="rois field does not point to a PlaneSegmentation table."
47-
)
43+
return InspectorMessage(message="rois field does not point to a PlaneSegmentation table.")
4844

4945

50-
@register_check(
51-
importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=OpticalChannel
52-
)
46+
@register_check(importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=OpticalChannel)
5347
def check_emission_lambda_in_nm(optical_channel: OpticalChannel):
5448
"""Check that emission lambda is in feasible range for unit nanometers."""
5549
if optical_channel.emission_lambda < MIN_LAMBDA:
56-
return InspectorMessage(
57-
f"emission lambda of {optical_channel.emission_lambda} should be in units of nm."
58-
)
50+
return InspectorMessage(f"emission lambda of {optical_channel.emission_lambda} should be in units of nm.")
5951

6052

61-
@register_check(
62-
importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=ImagingPlane
63-
)
53+
@register_check(importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=ImagingPlane)
6454
def check_excitation_lambda_in_nm(imaging_plane: ImagingPlane):
6555
"""Check that emission lambda is in feasible range for unit nanometers."""
6656
if imaging_plane.excitation_lambda < MIN_LAMBDA:
67-
return InspectorMessage(
68-
f"excitation lambda of {imaging_plane.excitation_lambda} should be in units of nm."
69-
)
57+
return InspectorMessage(f"excitation lambda of {imaging_plane.excitation_lambda} should be in units of nm.")

nwbinspector/checks/tables.py

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@
1717

1818

1919
@register_check(importance=Importance.CRITICAL, neurodata_type=DynamicTableRegion)
20-
def check_dynamic_table_region_data_validity(
21-
dynamic_table_region: DynamicTableRegion, nelems=200
22-
):
20+
def check_dynamic_table_region_data_validity(dynamic_table_region: DynamicTableRegion, nelems=200):
2321
"""Check if a DynamicTableRegion is valid."""
24-
if np.any(
25-
np.asarray(dynamic_table_region.data[:nelems]) > len(dynamic_table_region.table)
26-
):
22+
if np.any(np.asarray(dynamic_table_region.data[:nelems]) > len(dynamic_table_region.table)):
2723
return InspectorMessage(
2824
message=(
2925
f"Some elements of {dynamic_table_region.name} are out of range because they are greater than the "
@@ -36,18 +32,14 @@ def check_dynamic_table_region_data_validity(
3632
)
3733

3834

39-
@register_check(
40-
importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=DynamicTable
41-
)
35+
@register_check(importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=DynamicTable)
4236
def check_empty_table(table: DynamicTable):
4337
"""Check if a DynamicTable is empty."""
4438
if len(table.id) == 0:
4539
return InspectorMessage(message="This table has no data added to it.")
4640

4741

48-
@register_check(
49-
importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=TimeIntervals
50-
)
42+
@register_check(importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=TimeIntervals)
5143
def check_time_interval_time_columns(time_intervals: TimeIntervals, nelems: int = 200):
5244
"""
5345
Check that time columns are in ascending order.
@@ -74,12 +66,8 @@ def check_time_interval_time_columns(time_intervals: TimeIntervals, nelems: int
7466
)
7567

7668

77-
@register_check(
78-
importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=TimeIntervals
79-
)
80-
def check_time_intervals_stop_after_start(
81-
time_intervals: TimeIntervals, nelems: int = 200
82-
):
69+
@register_check(importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=TimeIntervals)
70+
def check_time_intervals_stop_after_start(time_intervals: TimeIntervals, nelems: int = 200):
8371
"""
8472
Check that all stop times on a TimeInterval object occur after their corresponding start times.
8573
@@ -91,11 +79,7 @@ def check_time_intervals_stop_after_start(
9179
very long so you don't need to load the entire array into memory. Use None to
9280
load the entire arrays.
9381
"""
94-
if np.any(
95-
np.asarray(time_intervals["stop_time"][:nelems])
96-
- np.asarray(time_intervals["start_time"][:nelems])
97-
< 0
98-
):
82+
if np.any(np.asarray(time_intervals["stop_time"][:nelems]) - np.asarray(time_intervals["start_time"][:nelems]) < 0):
9983
return InspectorMessage(
10084
message=(
10185
"stop_times should be greater than start_times. Make sure the stop times are with respect to the "
@@ -104,9 +88,7 @@ def check_time_intervals_stop_after_start(
10488
)
10589

10690

107-
@register_check(
108-
importance=Importance.BEST_PRACTICE_SUGGESTION, neurodata_type=DynamicTable
109-
)
91+
@register_check(importance=Importance.BEST_PRACTICE_SUGGESTION, neurodata_type=DynamicTable)
11092
def check_column_binary_capability(table: DynamicTable, nelems: int = 200):
11193
"""
11294
Check each column of a table to see if the data could be set as a boolean dtype.
@@ -130,13 +112,9 @@ def check_column_binary_capability(table: DynamicTable, nelems: int = 200):
130112
if unique_values.size != 2:
131113
continue
132114
parsed_unique_values = np.array(unique_values)
133-
if isinstance(
134-
parsed_unique_values[0], Real
135-
): # upcast to float for comparison
115+
if isinstance(parsed_unique_values[0], Real): # upcast to float for comparison
136116
parsed_unique_values = parsed_unique_values.astype(float)
137-
elif (
138-
str(parsed_unique_values.dtype)[:2] == "<U"
139-
): # parse strings as all lower-case
117+
elif str(parsed_unique_values.dtype)[:2] == "<U": # parse strings as all lower-case
140118
for j in range(2):
141119
parsed_unique_values[j] = parsed_unique_values[j].lower()
142120
pairs_to_check = [
@@ -168,9 +146,7 @@ def check_column_binary_capability(table: DynamicTable, nelems: int = 200):
168146
)
169147

170148

171-
@register_check(
172-
importance=Importance.BEST_PRACTICE_SUGGESTION, neurodata_type=DynamicTable
173-
)
149+
@register_check(importance=Importance.BEST_PRACTICE_SUGGESTION, neurodata_type=DynamicTable)
174150
def check_single_row(
175151
table: DynamicTable,
176152
exclude_types: Optional[list] = (Units,),
@@ -192,17 +168,11 @@ def check_single_row(
192168
)
193169

194170

195-
@register_check(
196-
importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=DynamicTable
197-
)
171+
@register_check(importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=DynamicTable)
198172
def check_table_values_for_dict(table: DynamicTable, nelems: int = 200):
199173
"""Check if any values in a row or column of a table contain a string casting of a Python dictionary."""
200174
for column in table.columns:
201-
if (
202-
not hasattr(column, "data")
203-
or isinstance(column, VectorIndex)
204-
or not isinstance(column.data[0], str)
205-
):
175+
if not hasattr(column, "data") or isinstance(column, VectorIndex) or not isinstance(column.data[0], str):
206176
continue
207177
for string in column.data[:nelems]:
208178
if is_dict_in_string(string=string):

0 commit comments

Comments
 (0)