Skip to content

Commit ea2597a

Browse files
committed
add more docs/comments
1 parent 786938f commit ea2597a

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

spikeinterface_gui/backend_panel.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,19 +294,22 @@ def make_half_layout(self, gs, layout_zone, left_or_right):
294294
1 2 3 4
295295
5 6 or 7 8
296296
297-
Then depending on which zones are non-zero, a different layout is generated.
297+
Then depending on which zones are non-zero, a different layout is generated using splits.
298298
299-
The second box (34,78) is equal to the first box (12,56) shifted by 2. We take advantage of this fact.
299+
The zone indices in the second box (34,78) are equal to the zone indices first box (12,56)
300+
shifted by 2. We take advantage of this fact.
300301
"""
301302

302303
shift = 0 if left_or_right == "left" else 2
303304

304305
layout_zone = fill_unnecessary_space(layout_zone, shift)
305306
present_zones = get_present_zones_in_half_of_layout(layout_zone, shift)
306307

308+
# `fill_unnecessary_space` ensures that zone{1+shift} always exists
307309
if present_zones == set([f'zone{1+shift}']):
308310
gs[0,0] = layout_zone.get(f'zone{1+shift}')
309311

312+
# Layouts with two non-zero zones
310313
if present_zones == set([f'zone{1+shift}', f'zone{2+shift}']):
311314
gs[slice(0, 1), slice(0+shift,1+shift)] = layout_zone.get(f'zone{1+shift}')
312315
gs[slice(0, 1), slice(1+shift,2+shift)] = layout_zone.get(f'zone{2+shift}')
@@ -330,7 +333,8 @@ def make_half_layout(self, gs, layout_zone, left_or_right):
330333
gs[slice(0, 1), slice(0+shift,2+shift)] = layout_zone.get(f'zone{1+shift}')
331334
gs[slice(1, 2), slice(0+shift,1+shift)] = layout_zone.get(f'zone{5+shift}')
332335
gs[slice(1, 2), slice(1+shift,2+shift)] = layout_zone.get(f'zone{6+shift}')
333-
336+
337+
# Layouts with four non-zero zones
334338
elif present_zones == set([f'zone{1+shift}', f'zone{2+shift}', f'zone{5+shift}', f'zone{6+shift}']):
335339
gs[slice(0, 1), slice(0+shift,1+shift)] = layout_zone.get(f'zone{1+shift}')
336340
gs[slice(0, 1), slice(1+shift,2+shift)] = layout_zone.get(f'zone{2+shift}')

spikeinterface_gui/backend_qt.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ def make_half_layout(self, widgets_zone, left_or_right):
226226
227227
Then depending on which zones are non-zero, a different layout is generated using splits.
228228
229-
The second box (34,78) is equal to the first box (12,56) shifted by 2. We take advantage of this fact.
229+
The zone indices in the second box (34,78) are equal to the zone indices first box (12,56)
230+
shifted by 2. We take advantage of this fact.
230231
"""
231232

232233
shift = 0 if left_or_right == "left" else 2
@@ -242,7 +243,9 @@ def make_half_layout(self, widgets_zone, left_or_right):
242243
dock = self.docks[view_name]
243244
self.addDockWidget(areas[left_or_right], dock)
244245

245-
# The main logic: apply splittings depending on which zones are present
246+
# The main logic: apply splittings between different zones and in
247+
# different orders, depending on which zones are present.
248+
246249
# Layouts with two non-zero zones
247250
if present_zones == set([f'zone{1+shift}', f'zone{2+shift}']):
248251
self.make_split(1,2,"horizontal", widgets_zone, shift)

spikeinterface_gui/utils_global.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ def fill_unnecessary_space(layout_zone, shift):
1616
. zone6 is equivalent to zone5 .
1717
1818
This function moves zones left-wards and upwards in a way that preserves
19-
the layouts and ensures the top-left zone is non-zero.
19+
the layouts and ensures that the top-left zone is non-zero.
2020
"""
2121

22-
# First, move the right hand column leftwards if the left-hand column is missing
22+
# Move the right hand column leftwards if the left-hand column is missing
2323
if len(layout_zone[f'zone{1+shift}']) == 0 and len(layout_zone[f'zone{5+shift}']) == 0:
2424
layout_zone[f'zone{1+shift}'] = layout_zone[f'zone{2+shift}']
2525
layout_zone[f'zone{5+shift}'] = layout_zone[f'zone{6+shift}']
2626
layout_zone[f'zone{2+shift}'] = []
2727
layout_zone[f'zone{6+shift}'] = []
2828

29-
# And move the bottom-left zone to the top-left, if the top-left is missing
29+
# Move the bottom-left zone to the top-left, if the top-left is missing
3030
# These steps reduce the number of layouts we have to consider
3131
if len(layout_zone[f'zone{1+shift}']) == 0:
3232
layout_zone[f'zone{1+shift}'] = layout_zone[f'zone{5+shift}']
@@ -37,9 +37,12 @@ def fill_unnecessary_space(layout_zone, shift):
3737

3838
def get_present_zones_in_half_of_layout(layout_zone, shift):
3939
"""
40-
Returns the zones which contain at least one view.
40+
Returns the zones which contain at least one view, for either:
41+
left-hand zones 1,2,5,6 (shift=0)
42+
right-hand zones 3,4,7,8 (shift=2)
4143
"""
42-
half_dict = {key: value for key, value in layout_zone.items() if key in [f'zone{1+shift}', f'zone{2+shift}', f'zone{5+shift}', f'zone{6+shift}']}
44+
zones_in_half = [f'zone{1+shift}', f'zone{2+shift}', f'zone{5+shift}', f'zone{6+shift}']
45+
half_dict = {key: value for key, value in layout_zone.items() if key in zones_in_half}
4346
is_present = [views is not None and len(views) > 0 for views in half_dict.values()]
4447
present_zones = set(np.array(list(half_dict.keys()))[np.array(is_present)])
4548
return present_zones

0 commit comments

Comments
 (0)