Skip to content
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

include custom widget #149

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

include custom widget #149

wants to merge 8 commits into from

Conversation

luiztauffer
Copy link
Collaborator

@luiztauffer luiztauffer commented Apr 7, 2021

This allows user-created widgets to be included in the neurodata_vis_spec, can be used like this:

import pynwb
from pynwb import NWBFile, NWBHDF5IO
from nwbwidgets import nwb2widget
from mywidgets import TunningCurvesWidget,

io = NWBHDF5IO('file.nwb', 'r')
nwbfile = io.read()

# include custom widgets
include_widgets = [{
    'widget': TunningCurvesWidget,
    'label': 'Tuning Curve',
    'pynwb_class': pynwb.misc.Units
}]

nwb2widget(node=nwbfile, include_widgets=include_widgets)

For now it only works for items which are OrderedDict. Maybe we would like to extend most items to be OrderedDict? This would in principle just nest each item in a single Tab, but allows for the possibility of easily adding customized widgets

nwbwidgets/view.py Outdated Show resolved Hide resolved
Co-authored-by: Ben Dichter <ben.dichter@gmail.com>
@codecov
Copy link

codecov bot commented Apr 7, 2021

Codecov Report

Merging #149 (43bb21e) into master (616ed9a) will decrease coverage by 0.24%.
The diff coverage is 37.50%.

@@            Coverage Diff             @@
##           master     #149      +/-   ##
==========================================
- Coverage   69.15%   68.91%   -0.25%     
==========================================
  Files          30       30              
  Lines        2169     2184      +15     
==========================================
+ Hits         1500     1505       +5     
- Misses        669      679      +10     
Flag Coverage Δ
unittests 68.91% <37.50%> (-0.25%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
nwbwidgets/view.py 66.66% <37.50%> (-27.78%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@bendichter
Copy link
Collaborator

@luiztauffer see edits to my comment. You may have to test it a bit. I'm not 100% sure it will work as I wrote it

@bendichter
Copy link
Collaborator

Now that I am thinking about it, maybe the values of neurodata_vis_spec should always be OrderedDicts, and we would only present it as lazy_tabs when the length is > 1. What do you think?

@luiztauffer
Copy link
Collaborator Author

@bendichter I agree, at least with most of the items. It makes adding custom widgets easy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants