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 )
4236def 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 )
5143def 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 )
11092def 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 )
174150def 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 )
198172def 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