-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add parents in HTML representation and always print class name #3700
Add parents in HTML representation and always print class name #3700
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
I like having both the user assigned name and the class name together but why are you not displaying name for the parent classes?
because the name is copied over to child classes, so I think it's redundant! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if you have a class with name "A", then you filter it and set the name to "B"? Is that allowed? Would the preprocessing chain have a different name in that case?
I have a slight leaning to keep the representation as it is even if it is a bit redundant to simplify the code and not care about edge cases. That said, I think this is good as it is:
LGTM
Feel free to merge.
Oh yes, JFYI you can paste html code to github so if you copy the output of a the notebook cell you can just paste it here with an HTML tag and we would be able to click on it! |
Maybe we can propagate the name and only display if different? |
Very fun! Yeah, looks good. I wonder if we should display the kwargs too? Maybe for another PR... There's some code for grabbing our the preprocessing kwargs in the #3438 ![]() |
If you feel that the complication is worth it to have a cleaner display I am OK with it. I am also OK with the things as they are here as what I mentioned is probably an edge case. |
@chrishalcrow let's extend to kwargs later. @h-mayorquin I added some logic to only display names if different from parent. Here's how it looks: RecordingPreprocessed (WhitenRecording): 4 channels - 25.0kHz - 1 segments - 250,000 samples - 10.00s - float32 dtype - 3.81 MiB Channel IDs
Annotations
Channel Propertiescontact_vector[(0, 0., 0., 'circle', 6., '', '0', 0, 'um', 1., 0., 0., 1.)\n (0, 0., 20., 'circle', 6., '', '1', 1, 'um', 1., 0., 0., 1.)\n (0, 20., 0., 'circle', 6., '', '2', 2, 'um', 1., 0., 0., 1.)\n (0, 20., 20., 'circle', 6., '', '3', 3, 'um', 1., 0., 0., 1.)]location[[ 0. 0.]\n [ 0. 20.]\n [20. 0.]\n [20. 20.]]group[0 0 0 0]gain_to_uV[1. 1. 1. 1.]offset_to_uV[0 0 0 0]Parent
CommonReferenceRecording: 4 channels - 25.0kHz - 1 segments - 250,000 samples - 10.00s - float32 dtype - 3.81 MiB Channel IDs
AnnotationsChannel Propertiescontact_vector[(0, 0., 0., 'circle', 6., '', '0', 0, 'um', 1., 0., 0., 1.)\n (0, 0., 20., 'circle', 6., '', '1', 1, 'um', 1., 0., 0., 1.)\n (0, 20., 0., 'circle', 6., '', '2', 2, 'um', 1., 0., 0., 1.)\n (0, 20., 20., 'circle', 6., '', '3', 3, 'um', 1., 0., 0., 1.)]location[[ 0. 0.]\n [ 0. 20.]\n [20. 0.]\n [20. 20.]]group[0 0 0 0]gain_to_uV[1. 1. 1. 1.]offset_to_uV[0 0 0 0]ParentHighpassFilterRecording: 4 channels - 25.0kHz - 1 segments - 250,000 samples - 10.00s - float32 dtype - 3.81 MiB Channel IDs
AnnotationsChannel Propertiescontact_vector[(0, 0., 0., 'circle', 6., '', '0', 0, 'um', 1., 0., 0., 1.)\n (0, 0., 20., 'circle', 6., '', '1', 1, 'um', 1., 0., 0., 1.)\n (0, 20., 0., 'circle', 6., '', '2', 2, 'um', 1., 0., 0., 1.)\n (0, 20., 20., 'circle', 6., '', '3', 3, 'um', 1., 0., 0., 1.)]location[[ 0. 0.]\n [ 0. 20.]\n [20. 0.]\n [20. 20.]]group[0 0 0 0]gain_to_uV[1. 1. 1. 1.]offset_to_uV[0 0 0 0]ParentGroundTruthRecording (InjectTemplatesRecording): 4 channels - 25.0kHz - 1 segments - 250,000 samples - 10.00s - float32 dtype - 3.81 MiB Channel IDs
AnnotationsChannel Propertiescontact_vector[(0, 0., 0., 'circle', 6., '', '0', 0, 'um', 1., 0., 0., 1.)\n (0, 0., 20., 'circle', 6., '', '1', 1, 'um', 1., 0., 0., 1.)\n (0, 20., 0., 'circle', 6., '', '2', 2, 'um', 1., 0., 0., 1.)\n (0, 20., 20., 'circle', 6., '', '3', 3, 'um', 1., 0., 0., 1.)]location[[ 0. 0.]\n [ 0. 20.]\n [20. 0.]\n [20. 20.]]group[0 0 0 0]gain_to_uV[1. 1. 1. 1.]offset_to_uV[0. 0. 0. 0.]SortingAnother name (UnitsSelectionSorting): 5 units - 1 segments - 25.0kHz Unit IDs
Annotations
Unit Propertiesgt_unit_locations[[11.9931 26.779676 45.756153 ]\n [ 4.539259 -4.575459 32.77219 ]\n [-6.4170756 29.897282 36.195335 ]\n [-7.765987 7.734192 14.736742 ]\n [-5.590045 12.970678 48.677856 ]]Parent
GroundTruthSorting (NumpySorting): 10 units - 1 segments - 25.0kHz Unit IDs
AnnotationsUnit Propertiesgt_unit_locations[[11.9931 26.779676 45.756153 ]\n [ 4.539259 -4.575459 32.77219 ]\n [-6.4170756 29.897282 36.195335 ]\n [-7.765987 7.734192 14.736742 ]\n [-5.590045 12.970678 48.677856 ]\n [26.28562 15.958191 13.609822 ]\n [25.525425 4.8619213 45.831062 ]\n [-8.12456 28.146242 16.332659 ]\n [21.863459 -7.436342 15.753815 ]\n [10.559567 14.730136 38.61602 ]] |
@@ -30,19 +30,26 @@ def __init__(self, sampling_frequency: float, unit_ids: List): | |||
self._cached_spike_trains = {} | |||
|
|||
def __repr__(self): | |||
return self._repr_header() | |||
|
|||
def _repr_header(self, parent_name=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I like this design. would be better to have an explicit display_name=True/False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and then have the logic in the _repr_html_()
? Ok for me
excelent. |
I'm always finding myself searching through the kwargs to check the preprocessing chain...
@chrishalcrow you're gonna like this :)
Added the
Parent
section in the HTML repr (and also appended the class name to theself.name
). Here's how it looks: