Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def plot(self, **kwargs):
"""Update the view with the current cluster selection."""
if not self.cluster_ids:
return
bunchs = self.get_clusters_data()
if not bunchs:
return
# All channel ids appearing in all selected clusters.
channel_ids = sorted(set(_flatten([d.channel_ids for d in bunchs])))
self.channel_ids = channel_ids
if bunchs[0].data is not None:
self.wave_duration = bunchs[0].data.shape[1] / float(self.sample_rate)
else: # pragma: no cover
self.wave_duration = 1.
# Channel labels.
channel_labels = {}
for d in bunchs:
chl = d.get('channel_labels', ['%d' % ch for ch in d.channel_ids])
channel_labels.update({
channel_id: chl[i] for i, channel_id in enumerate(d.channel_ids)})
# Update the Boxed box positions as a function of the selected channels.
if channel_ids:
self.canvas.boxed.update_boxes(_get_box_pos(bunchs, channel_ids))
def _concatenate_parents_attributes(cls, name):
"""Return the concatenation of class attributes of a given name among all parents of a
class."""
return _flatten([getattr(_, name, ()) for _ in inspect.getmro(cls)])