Gabriele Lanaro | 24 Oct 01:49 2014
Picon

IPython notebook custom widgets fastest way to send a numpy array to javascript

Hi!

I'm trying to use IPython traitlets system to send a NumPy array towards the JS side in an IPython notebook widget (it's a molecular viewer). The array I'm trying to send can be pretty big (like of shape (100000, 3)) as it's an array of 3d coordinates.

What I'm doing right now is:

setup a traitlet like:

class MolecularViewer:
    coordinates = Dict(sync=True)

Then I send the array as a base64 string and type info:

molecular_viewer.coordinates = {'type': dtype,
                                                     'shape', shape,
                                                     'data' : "b64stringrepresentation"}

and I decode back in JS to obtain a TypedArray. Unfortunately the decoding has become a bottleneck (it has to run at interactive speeds possibly).

Do you know a better way to pass large NumPy arrays to javascript (getting a TypedArray on the other side)?

Thank you,

Gabriele
_______________________________________________
IPython-User mailing list
IPython-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user
klo uo | 23 Oct 21:32 2014
Picon

Start script while starting qtconsole

Hi,

In terminal I can run:

    ipython -i <path-to-my-script>

and everything is as expected - script is executed, namespace populated, waiting my input.

For qtconsole same command errors. I can't find any other way to launch script on qtconsole start except with PYTHONSTARTUP variable. Ok, I've set it, but still not as expected:

After manipulating `sys.path` script ends with lines like this:

...
from anybox.recipe.proj.runtime.session import Session
session = Session(...)

After starting qtconsole I have `Session` object, but not `session` that instantiates it.

Does anyone know why, or is there some more sane way to load a script on qtconsole start without setting environment variables?

_______________________________________________
IPython-User mailing list
IPython-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user
gary.church1 | 19 Oct 04:15 2014
Picon
Picon

tk: (9)


http://garridomarketing.com.br/6a7d8j9hg0w1t2u3o4b5x.php

Myranda Dettmer
Mark Andrews | 16 Oct 21:59 2014
Picon

start ipython notebook with a particular (not default) firefox profile

(Note: this is an exact copy of a unanswered question I asked on stackoverflow about 1 month ago).

When I launch ipython notebook, I want it to launch firefox but using a particular firefox profile, which is not my default firefox profile.

In my ipython profile, I have

c.NotebookApp.browser = u'/usr/bin/firefox'

and that makes sure that ipython notebook chooses firefox. However, it chooses the default firefox profile, or else the most recently used firefox profile.

From my linux terminal, I can launch my preferred ipython specific firefox profile (named ipython) like this

firefox -P --no-remote ipython

However, doing

c.NotebookApp.browser = u'/usr/bin/firefox -P --no-remote ipython'

does not work at all (ipython doesn't open firefox at all, and skips to the another browswer'), nor does starting ipython notebook like so

ipython notebook --browser 'firefox -P --no-remote ipython'

which leads to and OSError exception.

Does anyone know of a way to launch firefox with the preferred profile?

thanks

Mark Andrews

_______________________________________________
IPython-User mailing list
IPython-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user
Brian Blais | 11 Oct 01:18 2014
Picon

proper animation in notebook?

Hello,

I have just found out how to do animations within an ipython notebook,
by looking at:
http://nbviewer.ipython.org/github/ipython/ipython/blob/2.x/examples/Notebook/Animations%20Using%20clear_output.ipynb

However, when I do it myself I get the animation, but I get a memory
leak - the memory of the python process just keeps growing.  Here's my
code:

%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt

import sys
import time
from IPython.display import display, clear_output

x=linspace(0,6,100)
for t in linspace(0,20,100):
    clear_output(wait=True)
    f=figure(figsize=(10,10))
    plot(sin(x)*sin(t),'-o')
    gca().set_ylim([-1,1])
    display(f)
    close()

somehow I think it isn't actually deleting the figures from one call
to another, so it is building up in the background, although I am not
sure.  Is there a proper way to do this kind of animation in the
notebook without the memory continually increasing?

thanks!

Brian Blais

-----------------

             bblais <at> gmail.com
             http://web.bryant.edu/~bblais
Julien Schueller | 8 Oct 09:36 2014

lookfor magic extension module

Hi list,

I just uploaded to pypi the lookfor extension module to search through docstrings:
https://github.com/jschueller/lookfor

--

-- 
J
Ivan Ogassawara | 26 Sep 15:21 2014
Picon

Executing some function on IPython is slower than a normal python function

Dear all,

I'm testing some functionalities of ipython and I'm think I'm doing something wrong.

I'm testing 3 different ways to execute some math operation.

  • 1st using  <at> parallel.parallel(view=dview, block=True) and function map
  • 2nd using single core function (python normal function)
  • 3rd using clients load balance function
the code is here:

https://stackoverflow.com/questions/26039254/executing-some-function-on-ipython-is-slower-than-a-normal-python-function

My result is:

True True 0.040741 secs (multicore) 0.004004 secs (singlecore) 1.286592 secs (multicore_load_balance)

Why are my multicore routines slower than my single core routine? What is wrong with this approach? What can I do to fix it?

Some environment information: python3.4.1, ipython 2.2.0, numpy 1.9.0, ipcluster starting 8 Engines with LocalEngineSetLauncher


My best regards,

Ivan Ogassawara



_______________________________________________
IPython-User mailing list
IPython-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user
nirinA raseliarison | 25 Sep 01:35 2014
Picon

issues with Notebook and qtconsole after updating IPython

Hi there,
After updating IPython, currently running git commit '3849e0a', I  
encounter similar problem as described here:

http://mail.scipy.org/pipermail/ipython-user/2014-August/013799.html

but the proposed solution, opening different browser, solved only  
partially my problems.
     ipython notebook
seems to work with chromium, opera and firefox but
it doesn't start at all with seamonkey, i get the following error:

<seamonkey error>
ipython notebook
[I 01:23:59.599 NotebookApp] Using existing profile dir:  
'/home/nirina/.ipython/profile_default'
[I 01:23:59.618 NotebookApp] Using MathJax from CDN:  
https://cdn.mathjax.org/mathjax/latest/MathJax.js
[I 01:23:59.657 NotebookApp] Serving notebooks from local directory:  
/home/nirina
[I 01:23:59.657 NotebookApp] 0 active kernels
[I 01:23:59.657 NotebookApp] The IPython Notebook is running at:  
http://localhost:8888/
[I 01:23:59.657 NotebookApp] Use Control-C to stop this server and shut  
down all kernels (twice to skip confirmation).

(process:1297): GLib-CRITICAL **: g_slice_set_config: assertion  
`sys_page_size == 0' failed
[W 01:24:08.486 NotebookApp] Notebook /Untitled0.ipynb is not trusted
[I 01:24:08.850 NotebookApp] Kernel started:  
25d6d157-06a6-4a7c-b1c4-8032b29663ad
[E 01:25:34.884 tornado.application] Uncaught exception GET  
/static/components/codemirror/lib/codemirror.js?v=8dec958ead2e288182a77a5b3d87fe3c  
(127.0.0.1)
     HTTPServerRequest(protocol='http', host='localhost:8888',  
method='GET',  
uri='/static/components/codemirror/lib/codemirror.js?v=8dec958ead2e288182a77a5b3d87fe3c',  
version='HTTP/1.1', remote_ip='127.0.0.1', headers={'Accept-Language':  
'en-US,en;q=0.5', 'Referer':  
'http://localhost:8888/notebooks/Untitled0.ipynb', 'Host':  
'localhost:8888', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:29.0)  
Gecko/20100101 Firefox/29.0 SeaMonkey/2.26.1', 'Accept-Encoding': 'gzip,  
deflate', 'Connection': 'keep-alive', 'Accept': '*/*'})
     Traceback (most recent call last):
       File 

"/usr/local/lib/python3.4/site-packages/tornado-4.1.dev1-py3.4-linux-x86_64.egg/tornado/web.py",

line 1338, in _execute
         result = yield result
       File 

"/usr/local/lib/python3.4/site-packages/tornado-4.1.dev1-py3.4-linux-x86_64.egg/tornado/gen.py",

line 642, in run
         value = future.result()
       File 

"/usr/local/lib/python3.4/site-packages/tornado-4.1.dev1-py3.4-linux-x86_64.egg/tornado/concurrent.py",

line 110, in result
         raise_exc_info(self._exc_info)
       File "<string>", line 3, in raise_exc_info
       File 

"/usr/local/lib/python3.4/site-packages/tornado-4.1.dev1-py3.4-linux-x86_64.egg/tornado/gen.py",

line 645, in run
         yielded = self.gen.throw(*sys.exc_info())
       File 

"/usr/local/lib/python3.4/site-packages/tornado-4.1.dev1-py3.4-linux-x86_64.egg/tornado/web.py",

line 2176, in get
         yield self.flush()
       File 

"/usr/local/lib/python3.4/site-packages/tornado-4.1.dev1-py3.4-linux-x86_64.egg/tornado/gen.py",

line 642, in run
         value = future.result()
       File 

"/usr/local/lib/python3.4/site-packages/tornado-4.1.dev1-py3.4-linux-x86_64.egg/tornado/concurrent.py",

line 112, in result
         raise self._exception
     tornado.iostream.StreamClosedError
[E 01:25:34.916 tornado.general] Cannot send error response after headers  
written
</seamonkey error>

Another issue is with qtconsole,

     ipython qtconsole

seems to work, but:

     ipython qtconsole --profile julia

gives:

<qtconsole error>
/usr/local/lib/python3.4/site-packages/IPython/kernel/manager.py:96:  
UserWarning: Setting kernel_cmd is deprecated, use kernel_spec to start  
different kernels.
   warnings.warn("Setting kernel_cmd is deprecated, use kernel_spec to "
Starting kernel event loops.
ERROR:tornado.application:Exception in callback  
functools.partial(<function wrap.<locals>.null_wrapper at 0x7f7b24078d08>)
Traceback (most recent call last):
   File 

"/usr/local/lib/python3.4/site-packages/tornado-4.1.dev1-py3.4-linux-x86_64.egg/tornado/ioloop.py",

line 565, in _run_callback
     ret = callback()
   File 

"/usr/local/lib/python3.4/site-packages/tornado-4.1.dev1-py3.4-linux-x86_64.egg/tornado/stack_context.py",

line 275, in null_wrapper
     return fn(*args, **kwargs)
   File  
"/usr/local/lib/python3.4/site-packages/IPython/kernel/channels.py", line  
170, in thread_send
     self.session.send(self.stream, msg)
   File  
"/usr/local/lib/python3.4/site-packages/IPython/kernel/zmq/session.py",  
line 646, in send
     msg = adapt(msg, self.adapt_version)
   File "/usr/local/lib/python3.4/site-packages/IPython/kernel/adapter.py",  
line 329, in adapt
     return adapter(msg)
   File "/usr/local/lib/python3.4/site-packages/IPython/kernel/adapter.py",  
line 68, in __call__
     return handler(msg)
   File "/usr/local/lib/python3.4/site-packages/IPython/kernel/adapter.py",  
line 152, in object_info_request
     line, _ = code_to_line(code, cursor_pos)
   File "/usr/local/lib/python3.4/site-packages/IPython/kernel/adapter.py",  
line 24, in code_to_line
     return line, cursor_pos
UnboundLocalError: local variable 'line' referenced before assignment
ERROR:tornado.general:Uncaught exception, closing connection.
Traceback (most recent call last):
   File  
"/usr/local/lib/python3.4/site-packages/zmq/eventloop/zmqstream.py", line  
407, in _run_callback
     callback(*args, **kwargs)
   File 

"/usr/local/lib/python3.4/site-packages/tornado-4.1.dev1-py3.4-linux-x86_64.egg/tornado/stack_context.py",

line 275, in null_wrapper
     return fn(*args, **kwargs)
   File  
"/usr/local/lib/python3.4/site-packages/IPython/kernel/channels.py", line  
179, in _handle_recv
     msg = self.session.unserialize(smsg)
   File  
"/usr/local/lib/python3.4/site-packages/IPython/kernel/zmq/session.py",  
line 847, in unserialize
     return adapt(message)
   File "/usr/local/lib/python3.4/site-packages/IPython/kernel/adapter.py",  
line 329, in adapt
     return adapter(msg)
   File "/usr/local/lib/python3.4/site-packages/IPython/kernel/adapter.py",  
line 68, in __call__
     return handler(msg)
   File "/usr/local/lib/python3.4/site-packages/IPython/kernel/adapter.py",  
line 262, in inspect_reply
     new_content['name'] = content['name']
KeyError: 'name'
ERROR:tornado.general:Uncaught exception, closing connection.
Traceback (most recent call last):
   File  
"/usr/local/lib/python3.4/site-packages/zmq/eventloop/zmqstream.py", line  
433, in _handle_events
     self._handle_recv()
   File  
"/usr/local/lib/python3.4/site-packages/zmq/eventloop/zmqstream.py", line  
465, in _handle_recv
     self._run_callback(callback, msg)
   File  
"/usr/local/lib/python3.4/site-packages/zmq/eventloop/zmqstream.py", line  
407, in _run_callback
     callback(*args, **kwargs)
   File 

"/usr/local/lib/python3.4/site-packages/tornado-4.1.dev1-py3.4-linux-x86_64.egg/tornado/stack_context.py",

line 275, in null_wrapper
     return fn(*args, **kwargs)
   File  
"/usr/local/lib/python3.4/site-packages/IPython/kernel/channels.py", line  
179, in _handle_recv
     msg = self.session.unserialize(smsg)
   File  
"/usr/local/lib/python3.4/site-packages/IPython/kernel/zmq/session.py",  
line 847, in unserialize
     return adapt(message)
   File "/usr/local/lib/python3.4/site-packages/IPython/kernel/adapter.py",  
line 329, in adapt
     return adapter(msg)
   File "/usr/local/lib/python3.4/site-packages/IPython/kernel/adapter.py",  
line 68, in __call__
     return handler(msg)
   File "/usr/local/lib/python3.4/site-packages/IPython/kernel/adapter.py",  
line 262, in inspect_reply
     new_content['name'] = content['name']
KeyError: 'name'
ERROR:tornado.application:Exception in callback None
Traceback (most recent call last):
   File 

"/usr/local/lib/python3.4/site-packages/tornado-4.1.dev1-py3.4-linux-x86_64.egg/tornado/ioloop.py",

line 837, in start
     handler_func(fd_obj, events)
   File 

"/usr/local/lib/python3.4/site-packages/tornado-4.1.dev1-py3.4-linux-x86_64.egg/tornado/stack_context.py",

line 275, in null_wrapper
     return fn(*args, **kwargs)
   File  
"/usr/local/lib/python3.4/site-packages/zmq/eventloop/zmqstream.py", line  
433, in _handle_events
     self._handle_recv()
   File  
"/usr/local/lib/python3.4/site-packages/zmq/eventloop/zmqstream.py", line  
465, in _handle_recv
     self._run_callback(callback, msg)
   File  
"/usr/local/lib/python3.4/site-packages/zmq/eventloop/zmqstream.py", line  
407, in _run_callback
     callback(*args, **kwargs)
   File 

"/usr/local/lib/python3.4/site-packages/tornado-4.1.dev1-py3.4-linux-x86_64.egg/tornado/stack_context.py",

line 275, in null_wrapper
     return fn(*args, **kwargs)
   File  
"/usr/local/lib/python3.4/site-packages/IPython/kernel/channels.py", line  
179, in _handle_recv
     msg = self.session.unserialize(smsg)
   File  
"/usr/local/lib/python3.4/site-packages/IPython/kernel/zmq/session.py",  
line 847, in unserialize
     return adapt(message)
   File "/usr/local/lib/python3.4/site-packages/IPython/kernel/adapter.py",  
line 329, in adapt
     return adapter(msg)
   File "/usr/local/lib/python3.4/site-packages/IPython/kernel/adapter.py",  
line 68, in __call__
     return handler(msg)
   File "/usr/local/lib/python3.4/site-packages/IPython/kernel/adapter.py",  
line 262, in inspect_reply
     new_content['name'] = content['name']
KeyError: 'name'
</qtconsole error>

i will appreciate any hint,
thanks in advance.
--

-- 
nirinA
Andy Davidson | 21 Sep 21:54 2014

newbie iPython notebook, how to update matplotlib.pyplot figure/graph?

Hi 
 
I am new to iPthon notebook and matplotlib. I am trying to figure out how to create a loop that does the following

While( not done)
Read new data from network
Update data set
Redraw graph

Bellow is my test code. I figure out how to generated a new graph/fig every time I iterate how ever I can not figure out to pass the figure/plot into my graph function. Clear it and redraw

Any comments or suggestions would be greatly appreciated.

Thanks

Andy



%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import time

dynamicPosData     = [1, 1, 1, 1, 1] #[0, 0, 0, 0, 0] #[2, 12, 3, 7, 9]
dynamicNegData     = [1, 1, 1, 1, 1] #[0, 0, 0, 0, 0] #[1, 10, 2, 4, 8]
dynamicNeutralData = [1, 1, 1, 1, 1] #[0, 0, 0, 0, 0] #[3, 4, 5, 6, 7]
dynamicN = 5

def graph (fig, ax, posDataArg, negDataArg, neutralDataArg, NArg) :
    ind = np.arange(NArg)  # the x locations for the groups
    width = 0.25        # the width of the bars
    fig, ax = plt.subplots() # this will generated a new plot each time, not update existing plot
    ax.clear() # 
    rects1 = ax.bar(ind, negDataArg, width, color='r')
    rects2 = ax.bar(ind+width, neutralDataArg, width, color='y')
    rects3 = ax.bar(ind+width*2, posDataArg, width, color='g')
    ax.set_title('Are People Happy?')
    #ax.set_xticks(ind+width)
    ax.set_xlabel('1 to 5 sec ago')
    ax.legend( (rects1[0], rects2[0], rects3[0]), ('neg', 'unknown', 'pos') )
    fig.canvas.draw() # I thought this would cause the existing graph to update, how ever it does not work?
    
dynamicFig = plt.figure()
dynamicAx = dynamicFig.add_subplot(111)
i = 0
count = 3
while (i < count) :
    graph(dynamicFig, dynamicAx, dynamicPosData, dynamicNegData, dynamicNeutralData, dynamicN)
    plt.show()
    dataIndex = i % dynamicN
    dynamicPosData[dataIndex] = dynamicPosData[dataIndex] + i + 1
    dynamicNeutralData[dataIndex] = dynamicNeutralData[dataIndex] + i + 1
    dynamicNegData[dataIndex] = dynamicNegData[dataIndex] + i + 1
    i += 1
    time.sleep(5) # seconds
    
_______________________________________________
IPython-User mailing list
IPython-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user
Vladan Divljak | 14 Sep 05:41 2014
Picon

Feature request: Redirect history in side panel

Hi guys,

I was just thinking why %history action bloats my qt console terminal, instead printing the output  in side panel?

So, yeah.
Just think to call %history twice in a session and welcome to the jungle.


Cheers

_______________________________________________
IPython-User mailing list
IPython-User <at> scipy.org
http://mail.scipy.org/mailman/listinfo/ipython-user
desp | 12 Sep 04:05 2014

Notebook: How to search for function/method with non-prefix string

Say I'm in iPython notebook, and have done: import pandas [as pd]

Now I want to find a function that deals with CSV. Is there a way to do
something like:

*csv* /[auto-complete-like key]/

or 

*pd.csv* /[auto-complete-like key]/

and see all the function or method names that contain "csv" anywhere in
their name?

Thanks!

--
View this message in context: http://python.6.x6.nabble.com/Notebook-How-to-search-for-function-method-with-non-prefix-string-tp5071387.html
Sent from the IPython - User mailing list archive at Nabble.com.

Gmane