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 logic for automatic display in ipython #8
Comments
@ellisonbg sounds good. Would the basic expected syntax be something like:
|
I think the registration code is explained in the same Custom Display Logic example notebook I used a bunch: Based on that example I think our registration code would look something like this:
|
Yep, here is the code I am using in a different library to define an automatic display function for numpy arrays: def enable():
"""Enable automatic visualization of NumPy arrays in the IPython Notebook."""
try:
from IPython.core.getipython import get_ipython
except ImportError:
raise ImportError('This feature requires IPython 1.0+')
ip = get_ipython()
f = ip.display_formatter.formatters['text/html']
f.for_type(np.ndarray, _array_to_html)
def disable():
"""Disable automatic visualization of NumPy arrays in the IPython Notebook."""
try:
from IPython.core.getipython import get_ipython
except ImportError:
raise ImportError('This feature requires IPython 1.0+')
ip = get_ipython()
f = ip.display_formatter.formatters['text/html']
f.type_printers.pop(np.ndarray, None) The naming of these types of functions tends to be something like |
Awesome, thanks @ellisonbg! |
Question - do you always send the entire data back to the browser? Do you Then there is a question of how you subsample the frame... On Sat, Oct 11, 2014 at 3:38 PM, Tim Shawver notifications@github.com
Brian E. Granger |
Also, this should be pretty easy to turn into a widget that allows data to On Sat, Oct 11, 2014 at 3:41 PM, Brian Granger ellisonbg@gmail.com wrote:
Brian E. Granger |
Currently I do always send all of the data back, and yes a huge DataFrame will freeze the UI (I think the limit is around 50K rows right now). I like the idea of allowing people to set an upper limit on the amount of data. Writing back to the DataFrame would be awesome. SlickGrid does support editing cells so it's probably not a ton of work. |
OK, maybe add a To get the write back, we will have to figure out how to tie it into the Cheers, Brian On Sat, Oct 11, 2014 at 4:03 PM, Tim Shawver notifications@github.com
Brian E. Granger |
Yep that sounds reasonable. Thanks again for the help. |
One thing that's tricky here is that we're currently using both |
Ahh, what we really need to do is have a display function registration for On Sun, Oct 12, 2014 at 4:35 AM, Scott Sanderson notifications@github.com
Brian E. Granger |
Opened up an issue in the main IPython repo here: ipython/ipython#6687. |
Here is the code that can do this: |
ping @aggFTW |
@ellisonbg do you have thoughts on what a reasonable API for enabling this would be? Presumably it'd be something like:
where the signature of autouse would be something like:
|
(The other option would be to enable this by default as an import-time side effect, but that feels too aggressive.) |
Finally got some time to do some dev work on qgrid and I included the automatic display capability in the new qgrid 1.0 beta. There are two new methods I don't think I'll have to add a See the installation instructions on the readme if you'd like to try out the new beta. |
Signed-off-by: Richard Lin <richard.lin.047@berkeley.edu>
Signed-off-by: Richard Lin <richard.lin.047@berkeley.edu>
Signed-off-by: Richard Lin <richard.lin.047@berkeley.edu>
Signed-off-by: Richard Lin <richard.lin.047@berkeley.edu>
Signed-off-by: Richard Lin <richard.lin.047@berkeley.edu>
Signed-off-by: Richard Lin <richard.lin.047@berkeley.edu>
Signed-off-by: Richard Lin <richard.lin.047@berkeley.edu>
Using the IPython display architecture you can register functions that are automatically called when a
DataFrame
is displayed. This will enable users to optionally enableqgrid
to displayDataFrame
by default, without an extra call. Running on a plane now, but please ping the ipython devs (or me later) on how this can be done. Awesome work!The text was updated successfully, but these errors were encountered: