~~stoggle_buttons~~ ====== jupyter ====== ===== nbextensions ===== pip install jupyter_contrib_nbextensions jupyter contrib nbextension install --user pip install jupyter_nbextensions_configurator jupyter nbextensions_configurator enable --user ===== trucos ===== [[https://medium.com/swlh/some-neat-jupyter-tricks-be0775c3f17]] * ''ESC+00'' Para reiniciar el kernel * ''ESC+Z'' Para **deshacer el borrado de una celda** from IPython.core.interactiveshell import InteractiveShell InteractiveShell.last_node_interactivity = "all" # "last_expr" por defecto # Imprimir Poner notebook al 100% de ancho from IPython.core.display import display, HTML display(HTML("")) ===== atajos de vim en juyter notebook ===== [[https://github.com/lambdalisue/jupyter-vim-binding]] ===== matplotlib interactivo ===== [[https://stackoverflow.com/questions/14261903/how-can-i-open-the-interactive-matplotlib-window-in-ipython-notebook]] %matplotlib inline # Plotear imágenes sobre el notebook, no interactivo %matplotlib notebook # Interactivo %matplotlib tk # Funciona por defecto %matplotlib qt # Instalar PyQt5 con pip ===== Entornos virtuales ===== [[https://anbasile.github.io/programming/2017/06/25/jupyter-venv/]] pip install tornado ipykernel ipython kernel install --user --name=kernelname # Para borrarlo jupyter kernelspec uninstall kernelname si se quiere crear un kernel asociado al entorno virtual. ''\sigma[TAB]'' autocompleta y crea variables de python con letras griegas ===== Kernels de C++ ===== [[https://blog.jupyter.org/interactive-workflows-for-c-with-jupyter-fe9b54227d92]] ====== ipython ====== ===== importar ipython ===== from IPython import start_ipython, embed # embed importa lo mínimo para poder salir de IPython sin consecuencias # start_ipython empieza una sesión de IPython y cambia el comportamiento de python por debajo (pulsar Ctrl+D para salir) ===== line_profiler and memory_profiler ===== [[https://github.com/rkern/line_profiler/issues/132]], [[https://github.com/rkern/line_profiler/issues/133]] ''%%pip install Cython git+https://github.com/rkern/line_profiler.git%%'' [[https://jakevdp.github.io/PythonDataScienceHandbook/01.07-timing-and-profiling.html]] %load_ext line_profiler %lprun -f func func(x, y, z) ''Ctrl+q, Ctrl+j'' ''Ctrl+J'' añade nueva línea en ipython Ctrl+Alt+Q, Ctrl+Shift+J -> Ctrl+O nueva línea debajo, Ctrl+O,Ctrl+N para añadir una nueva línea y moverse a ella ===== autoreload ===== [[https://ipython.readthedocs.io/en/stable/config/extensions/autoreload.html]] %load_ext autoreload %autoreload run 'loquesea.py'