@@ -30,19 +30,26 @@ def __init__(self, sampling_frequency: float, unit_ids: List):
3030 self ._cached_spike_trains = {}
3131
3232 def __repr__ (self ):
33+ return self ._repr_header ()
34+
35+ def _repr_header (self , parent_name = None ):
3336 nseg = self .get_num_segments ()
3437 nunits = self .get_num_units ()
3538 sf_khz = self .get_sampling_frequency () / 1000.0
36- txt = f"{ self .name } : { nunits } units - { nseg } segments - { sf_khz :0.1f} kHz"
39+ if parent_name is None or parent_name != self .name :
40+ name = f"{ self .name } ({ self .__class__ .__name__ } )"
41+ else :
42+ name = self .__class__ .__name__
43+ txt = f"{ name } : { nunits } units - { nseg } segments - { sf_khz :0.1f} kHz"
3744 if "file_path" in self ._kwargs :
3845 txt += "\n file_path: {}" .format (self ._kwargs ["file_path" ])
3946 return txt
4047
41- def _repr_html_ (self ):
48+ def _repr_html_ (self , parent_name = None ):
4249 common_style = "margin-left: 10px;"
4350 border_style = "border:1px solid #ddd; padding:10px;"
4451
45- html_header = f"<div style='{ border_style } '><strong>{ self .__repr__ ( )} </strong></div>"
52+ html_header = f"<div style='{ border_style } '><strong>{ self ._repr_header ( parent_name )} </strong></div>"
4653
4754 html_unit_ids = f"<details style='{ common_style } '> <summary><strong>Unit IDs</strong></summary><ul>"
4855 html_unit_ids += f"{ self .unit_ids } </details>"
@@ -61,7 +68,13 @@ def _repr_html_(self):
6168 html_unit_properties += f"<details><summary><strong>{ key } </strong></summary>{ value_formatted } </details>"
6269 html_unit_properties += "</ul></details>"
6370
64- html_repr = html_header + html_unit_ids + html_annotations + html_unit_properties
71+ if self .get_parent ():
72+ html_parent = f"<details style='{ common_style } '> <summary><strong>Parent</strong></summary>"
73+ html_parent += self .get_parent ()._repr_html_ (parent_name = self .name )
74+ else :
75+ html_parent = ""
76+
77+ html_repr = html_header + html_unit_ids + html_annotations + html_unit_properties + html_parent
6578 return html_repr
6679
6780 @property
0 commit comments