These are chat archives for ipython/ipython

17th
Oct 2014
ssunkara1
@ssunkara1
Oct 17 2014 19:41
@jdfreder John, for the tags you are using https://github.com/maxwells/bootstrap-tags Any reason why you preferred it over https://github.com/timschlechter/bootstrap-tagsinput ? both seem very similar but the latter has more contributors..
Jonathan Frederic
@jdfreder
Oct 17 2014 20:03
@ssunkara1 my initial Google search for "bootstrap tags" mislead into thinking Bootstrap Tags was the more popular of the two, since it shows up first. I also looked at jquery tags, whos API isn't as nice (especially with suggestions support). So I just haven't given bootstrap-tagsinput a try. I had some troubles getting bootstrap-tags to behave with require.js (it took a lot of debugging to trace down a race condition to a body onready event), so I'm open to trying to implement it using bootstrap-tagsinput
I'll take a look into it right now.
Jonathan Frederic
@jdfreder
Oct 17 2014 20:09
@ssunkara1 why do you ask?
Damian Avila
@damianavila
Oct 17 2014 20:28
quick question...
how can easily get the cell content which is passed to the IPython.notebook.kernel.execute()...
I want to know how the cell text is "transformed" before being executed by this function...
Damian Avila
@damianavila
Oct 17 2014 20:33
for example... I know I can do IPython.notebook.kernel.execute("print('hi')), but I want to know how more complicated things like loops are "transformed to be successfully executed...
Remi Rampin
@remram44
Oct 17 2014 20:33
Argh, my fail-pushes show up in the gitter activity
Jason Grout
@jasongrout
Oct 17 2014 20:35
@ssunkara1 is gone, but he was looking at various tags libraries, and noticed the two, and asked us about your choice. We sent him here to ask you :)
Jonathan Frederic
@jdfreder
Oct 17 2014 20:43
Ah thanks @jasongrout
Andreas Klostermann
@akloster
Oct 17 2014 21:58
what is the recommended way to check if my function is running inside the notebook? I need to know if I can use widgets, and otherwise raise an exception
Andreas Klostermann
@akloster
Oct 17 2014 22:13
```PythonIPython.get_ipython().config['IPKernelApp']['parent_appname']=='ipython-notebook'
sorry...
IPython.get_ipython().config['IPKernelApp']['parent_appname']=='ipython-notebook'
Thomas Kluyver
@takluyver
Oct 17 2014 22:14
That won't work in master, we've removed parent_appname
in master you can try to create a widget
Andreas Klostermann
@akloster
Oct 17 2014 22:14
That's the way I came up with so far... does it clash with jupiter?
Thomas Kluyver
@takluyver
Oct 17 2014 22:15
it will raise RuntimeError if it's not possible
but I'm not sure what it does in 2.x
Andreas Klostermann
@akloster
Oct 17 2014 22:17
it raises an exception about comm_manager not being in get_ipython()
Thomas Kluyver
@takluyver
Oct 17 2014 22:19
OK, it sounds like that's the way to go then. Depending on what you need, you can either just try to create the widget and let the errors go up to the caller, or catch those errors and raise a different error, do a fallback thing, or whatever
Jason Grout
@jasongrout
Oct 17 2014 22:19
@jdfreder: we have a design question (err, well, maybe complaint...)
Andreas Klostermann
@akloster
Oct 17 2014 22:20
not really optimal. Creating a widget may raise all sorts of errors, in development, NameError is also common
or I should just check for the commserver directly
Jonathan Frederic
@jdfreder
Oct 17 2014 22:23
@jasongrout shoot
Jason Grout
@jasongrout
Oct 17 2014 22:24
actually, Romain will ask, since he's the one to discover it
Thomas Kluyver
@takluyver
Oct 17 2014 22:24
How would it raise NameError?
Maybe we should make a more specific exception class that you can catch if you're specifically interested in the case where there is no widget-capable frontend available.
Jonathan Frederic
@jdfreder
Oct 17 2014 22:26
Is he on gitter or is he going to email it to me/the list?
Andreas Klostermann
@akloster
Oct 17 2014 22:26
somehow it did... but I was testing it on an IPython 2.0 global install that I'm not really using for anything else...
Jason Grout
@jasongrout
Oct 17 2014 22:26
he's typing it now
@rmenegaux
Jonathan Frederic
@jdfreder
Oct 17 2014 22:26
ok
rmenegaux
@rmenegaux
Oct 17 2014 22:27
Hey @jdfreder I was looking at the selection widgets, and you pass the values as a dict. That seems problematic as there is no more order. Shouldn't it take just lists ?
Jason Grout
@jasongrout
Oct 17 2014 22:30
For example, Romain pointed out that if you assign it a list, it creates an ordered dict, but then later it only takes dicts
Jonathan Frederic
@jdfreder
Oct 17 2014 22:30
Ah yes
I was about to say, it does accept lists:
from IPython.html.widgets import *
Dropdown(values=['Val A', 'Val B'])
but you're right that over the line
it's serialized such that the order is lost
IIRC
Jason Grout
@jasongrout
Oct 17 2014 22:31
regardless, when it goes over JSON to javascript, yes
that's right.
so you have no control over the order the options are displayed.
Jonathan Frederic
@jdfreder
Oct 17 2014 22:32
I don't think that that was a design decision as much as it was an implementation failure
Jason Grout
@jasongrout
Oct 17 2014 22:33
IIRC, in Sage we originally had selectors implemented as dicts, but quickly realized that was terrible
rmenegaux
@rmenegaux
Oct 17 2014 22:33
yes it does accept lists in the initialization, but you can't change the `values' afterwards
```python
Jason Grout
@jasongrout
Oct 17 2014 22:34
(at least, in one iteration of interacts...)
rmenegaux
@rmenegaux
Oct 17 2014 22:34
dropdown.values = ['ying', 'yang']
will break
Jonathan Frederic
@jdfreder
Oct 17 2014 22:36
I think here it makes sense to store the keys and value as two separate list traits, linked by indicies, and manage synchronizing those traits in the base Python implementation.
Jason Grout
@jasongrout
Oct 17 2014 22:36
Or you can have a list of (key, value)
and then have magic traits to pull out the parts if you want
That way they can't get the separate lists out of sync
Jonathan Frederic
@jdfreder
Oct 17 2014 22:37
True
it would be nice if we had an ordered dict traitlet
Jason Grout
@jasongrout
Oct 17 2014 22:37
but then how would you insert something into the middle?
I don't think ordered dicts help much here
ordered dicts are for insertion order. We want displayed order
Jonathan Frederic
@jdfreder
Oct 17 2014 22:39
I wish tmpnb was up @rgbkrk , I think I've already integrated it into my workflow.
@jasongrout @rmenegaux scraping something together...
Jason Grout
@jasongrout
Oct 17 2014 22:42
gotta run, but thanks!
rmenegaux
@rmenegaux
Oct 17 2014 22:44
Thanks JD
Andreas Klostermann
@akloster
Oct 17 2014 22:44
sorry, I was forced offline. my special usecase is that I implemented a special mcmc sampling function for pymc3, called "nbsample", which uses a fancy progressbar, time elapsed and a stop button. The function should raise a NotImplementedError when no IPython notebook is present.
I think checking IPython.get_config().comm_manager should work nicely
Kyle Kelley
@rgbkrk
Oct 17 2014 23:38
Lol @jdfreder
help me with the sockets issue and it can stay up
happy to put your keys on the relevant boxes