Ipython
Now Jupyter
Try online Jupyter or https://try.jupyter.org/ (based on tmpnb)Jupyter talk by Fernando Perez (Video+Slides Other video)
Scientific python lectures
kernels
Install python2 and python3 notebooks
[+]# apt-get remove python-pip python2-pip
Then
# aptitude install python-setuptools python3-setuptools python-dev python3-dev # easy_install-2.7 pip # easy_install3 pip
We must now install jupyter < 6 with support for python2 kernel
# pip3 install notebook
To install the python2 kernel
# pip2 install ipykernel
And each user must activate the kernel at user level:
$ python2 -m ipykernel install [--user]
Once
$ jupyter notebook
Install jupyterhub
[+]#!/usr/bin/env bash #=== INSTALLATION === # # pip3 install --upgrade notebook # JupyterHub can be installed with pip, and the proxy with npm: # # npm install -g configurable-http-proxy # # pip3 install jupyterhub #=== CERTIFICATE GENERATION: === # From: https://workaround.org/ispmail/jessie/create-certificate # # openssl req -newkey rsa:4096 -nodes -sha512 -x509 -days 3650 -nodes -out /etc/ssl/certs/mailserver.pem -keyout /etc/ssl/private/mailserver.pem # On "Common Name" use the hostname, e.g, www.yourserver.com #=== LAUNCH COMMAND as root: === jupyterhub --port 4443 --ssl-key /etc/ssl/private/mailserver.pem --ssl-cert /etc/ssl/certs/mailserver.pem
Install jupyter extensions:
[+]Install (old)
[+]To global install work in
/usr/local/share/jupyter/kernels
python2 -m IPython kernelspec install-self
python3 -m IPython kernelspec install-self
for the time being you will need to install IPython notebook with python 2 and issue a
$ ipython2 kernelspec install-self
This will make the IPython2 kernel available with IPython3 server running on python 3.
See kernels:
$ cat ~/.ipython/kernels/ir/kernel.json {"argv": ["R","-e","IRkernel::main()","--args","{connection_file}"], "display_name":"R" }
$ cat ~/.ipython/kernels/python2/kernel.json { "display_name": "Python 2", "language": "python", "codemirror_mode": { "version": 3, "name": "ipython" }, "argv": [ "/usr/bin/python", "-c", "from IPython.kernel.zmq.kernelapp import main; main()", "-f", "{connection_file}" ] }
o mejor el oficial de http://try.jupyter.org
jovyan@374b5bfac0c6:~$ cat /usr/local/share/jupyter/kernels/python2/kernel.json { "display_name": "Python 2", "language": "python", "argv": [ "/usr/bin/python2", "-m", "IPython.kernel", "-f", "{connection_file}" ] }
Parallel Ipython
[+]Ipython notebook with pylab support
[+]$ ipython notebook --InlineBackend.figure_format=svg
and in the first Ipython cell:
%pylab inline
Ipython notebook server
[+]Fast way
[+]ipython notebopok --ip=*
How to setup an ipython notebook server with the '%pylab inline' already active in Debian Wheezy. We assume that you have a full SciPy? installation as expalined in ubuntu.sh.
Instructions based in this tutorial
Configuring the notebook server
- First, get your password hashed with IPython utility (From the terminal console!).
In [1]: from IPython.lib import passwd In [2]: passwd() Enter password: Verify password:
- Next, create a new IPython configuration profile.Uncomment and edit the following lines in the IPython profile config file - ~/.ipython/profile_myserver/ipython_notebook_config.py
$ ipython profile create myserver $ vim ~/.ipython/profile_myserver/ipython_notebook_config.py
c = get_config() c.IPKernelApp.pylab = 'inline' c.NotebookApp.ip = '*' c.NotebookApp.open_browser = False c.NotebookApp.password = u'sha1:yourhashedpassword' c.NotebookApp.port = 9999
- In order to guarantee a secure conection a certificate must be created
$ openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem
- Running the server: now, you can run the server, to keep it running, you can manage the process with Supervisor.To check if inline chart works, just type that line in your new notebook at https://your.site:9999 (note the https protocol)
$ ipython notebook --profile=myserver --certfile=mycert.pem
In [1]: plot(arange(10)) Out[1]: [<matplotlib.lines.Line2D at 0x39c8e50>]
Ipython in-depth
[+]2012-FSF award
[+]Ipython notebook: how to insert a link to a local file into a markdown cell?
[+][PDF](files/workingdir/output.pdf)
Ipython notebook: make output cells like markdown
[+]from IPython.core.display import HTML def foo(): raw_html = "<h1>Yah, rendered HTML</h1>" return HTML(raw_html) foo()
Ipython notebook: display HTML code (as a cell output):
[+]from IPython.core.display import HTML def foo(): raw_html = "<h1>Yah, rendered HTML</h1>" return HTML(raw_html) foo()
from IPython.core.display import HTML raw_html = "<h1>Yah, rendered HTML</h1>" HTML(raw_html)
Yah, rendered HTML
Save notebook as LaTeX/PDF
[+]- File -> Download as reST (.rst)
in your terminal
$ pandoc -s file.rst -t latex -o file.tex
$ sudo apt-get install pandoc
Install in Debian 7 (Wheezy)
[+]Install npm from here:
# curl -sL https://deb.nodesource.com/setup | bash - # apt-get install -y nodejs # #or directly from: http://gfif.udea.edu.co/downloads/nodejs_0.10.36-1nodesource1~wheezy1_amd64.deb
# sudo apt-get install npm nodejs-legacy # npm install -g configurable-http-proxy # pip install ipython --upgrade # pip install ipython --upgrade # pip install pyzmq --upgrade # pip install tornado --upgrade # pip install jsonschema
Use Ipython Cell as optional editor
[+]#######IPYTHON CELL ####### [#]%%writefile run.py #!/usr/bin/env python CODE def run_from_ipython(): try: __IPYTHON__ return True except NameError: return False if not run_from_ipython() and len(sys.argv)>1: CODE
Non Advanced Search or Natural Search
Advanced Search or Boolean Search
Default search behavior
By default, all search terms are optional. It behaves like an OR logic. Objects that contain the more terms are rated higher in the results and will appear first in their type. For example, wiki forum will find:
- objects that include both terms
- objects that include the term wiki
- objects that include the term forum
Requiring terms
Add a plus sign ( + ) before a term to indicate that the term must appear in results. Example: +wiki forum will find objects containing at least wiki. Objects with both terms and many occurences of the terms will appear first.
Excluding terms
Add a minus sign ( - ) before a term to indicate that the term must not appear in the results. To reduce a term's value without completely excluding it, use a tilde. Example: -wiki forum will find objects that do not contain wiki but contain forum
Grouping terms
Use parenthesis ( ) to group terms into subexpressions. Example: +wiki +(forum blog) will find objects that contain wiki and forum or that contain wiki and blog in any order.
Finding phrases
Use double quotes ( " " ) around a phrase to find terms in the exact order, exactly as typed. Example: "Alex Bell" will not find Bell Alex or Alex G. Bell.
Using wildcards
Add an asterisk ( * ) after a term to find objects that include the root word. For example, run* will find:
- objects that include the term run
- objects that include the term runner
- objects that include the term running
Reducing a term's value
Add a tilde ( ~ ) before a term to reduce its value indicate to the ranking of the results. Objects that contain the term will appear lower than other objects (unlike the minus sign which will completely exclude a term). Example: +wiki ~forum will rate an object with only wiki higher that an object with wiki and forum.
Changing relevance value
Add a less than ( < ) or greater than ( > ) sign before a term to change the term's contribution to the overall relevance value assigned to a object. Example: +wiki +(>forum < blog) will find objects that contain wiki and forum or wiki and blog in any order. wiki forum will be rated higher.