ipython

Using IPython notebooks under version control

梦想与她 提交于 2019-12-17 01:14:30
问题 What is a good strategy for keeping IPython notebooks under version control? The notebook format is quite amenable for version control: if one wants to version control the notebook and the outputs then this works quite well. The annoyance comes when one wants only to version control the input, excluding the cell outputs (aka. "build products") which can be large binary blobs, especially for movies and plots. In particular, I am trying to find a good workflow that: allows me to choose between

How to hide code from cells in ipython notebook visualized with nbviewer?

末鹿安然 提交于 2019-12-17 00:21:32
问题 I have an ipython/jupyter notebook that I visualize using NBviewer. How can I hide all the code from the notebook rendered by NBviewer, so that only the output of code (e.g. plots and tables) and the markdown cells are shown? 回答1: from IPython.display import HTML HTML('''<script> code_show=true; function code_toggle() { if (code_show){ $('div.input').hide(); } else { $('div.input').show(); } code_show = !code_show } $( document ).ready(code_toggle); </script> <form action="javascript:code

Linux使用配件

痞子三分冷 提交于 2019-12-14 23:32:04
今天补充几个linux使用过程中几个好用的配件和设置,注意本文操作全部在linux中进行。 iTerm 如果你使用的也是macOS系统,那么在使用终端terminal的时候应该会感觉便利度不够高,这里就推荐一个更加实用功能也更丰富的软件,就是iTerm。下载链接我放在这里了 iterm ,点进去download就好了,然后简简单单按照完成。 使用方法和terminal比较相似,扩展的功能有很多,大家可以根据自己需求来选择,网上也有很多推荐。 ipython 当我们想要临时使用一下python,比如查一个函数的用法,新建一个py文件会比较麻烦,那么ipython绝对是一个神器,而且它能像Jupiter notebook一样,一行命令一行输出。具体怎么安装呢?这里推荐使用pip安装,python模块的安装更新基本都可以用pip完成,如果你没有pip,可以先安装一个pip sudo easy_install pip 安装完pip,或是已经有pip,就可以安装如下命令直接安装ipython pip install ipython 或者 sudo pip install ipython 安装完成后,怎么使用呢?很简单,直接在linux命令行中输入ipython,就进入了ipython模式 ipython linux配色 一种方法是在preference中进行主题选择

Always start ipython with pylab being equal to inline, but toggle it off at some time

心不动则不痛 提交于 2019-12-14 04:18:50
问题 Is there any convention or configuration setting for how to start IPython shell? For example, when I start IPython, I almost always start it with pylab --inline . One approach is to create an alias, such as alias ipython="ipython --pylab inline" . However, I think it's impossible to start the shell with different options (other than inline option) once I decide to create and use the alias. So is it feasible to always start the shell with pylab=inline option, but still to toggle it off

Cannot show the graphs on ipython notebook

一曲冷凌霜 提交于 2019-12-14 03:58:42
问题 I'm playing around ipython notebook and have a question. I was trying to visualize the stock price and the trading volume in a graph. My code is: import datetime import pandas as pd import pandas.io.data from pandas import DataFrame import matplotlib.pyplot as plt from matplotlib import style # skipping some code to get stock prices ax1= plt.subplot(2,1,1) ax1.plot(df.Close,label="sp500") ax1.plot(ma,label='50MA') plt.legend() ax2=plt.subplot(2,1,2, sharex = ax1) ax2.plot(df['H-L'],label='H-L

Ipython notebook : Name error for Imported script function

China☆狼群 提交于 2019-12-14 03:27:03
问题 I have two scripts sources.py and nest.py . They are something like this sources.py import numpy as np from nest import * def make_source(): #rest of the code def detect(): Nest = nest() Nest.fit() if __name__=='main': detect() nest.py import numpy as np from sources import * class nest(object): def _init_(self): self.source = make_source() def fit(self): #rest of the code When I run the script like python sources.py It works fine. But in the Ipython notebook environment if I do the following

Save params between script runs in iPython console

你。 提交于 2019-12-14 03:06:45
问题 I want to find iPython console equivalent to the Spyder console command. When I use Spyder app all my variables are saved between script runs. By that I don't only mean I can inspect the values after script finished running but that those values will be preserved within next script run. Spyder console command (doesn't work in iPython console): runfile('some_file.py', wdir='/some/project/folder') There is a similar command in iPython console: %run -i "some_script.py" The problem is that this

Why sorted list detection does not work in this situation?

て烟熏妆下的殇ゞ 提交于 2019-12-14 02:50:22
问题 My goal is to have python code allowing to detect if a list is sorted or not. I would like to understand why the following code return True instead of my expected guess False l = [1, 2, 3, 4, 1, 6, 7, 8, 7] all(l[i] <= l[i+1] for i in xrange(len(l)-1)) # return "True" Notes: I'm using python 2.6.4 inside iPython 0.10 I use very huge list so I'd prefer to avoid solution of type l == l.sort() In the way to understand this I already read (and test) info from the main two following post: https:/

How to access shell variable in ipython

自闭症网瘾萝莉.ら 提交于 2019-12-14 02:25:18
问题 Using the ! magic I can access env type environment variables, but not ones defined in my terminal, or .bashrc . $:/<path>/balter/chip-seq-analysis/chipseq$ echo $hg38 /<path>/genomes/hg38/release-85/Homo_sapiens.GRCh38.dna.primary_assembly.fa balter@exalab3:/<path>/balter/chip-seq-analysis/chipseq$ ipython Python 2.7.12 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:42:40) Type "copyright", "credits" or "license" for more information. IPython 5.1.0 -- An enhanced Interactive Python. ?

python ipdb occasionally shows no code lines

白昼怎懂夜的黑 提交于 2019-12-14 01:43:21
问题 Interrupting execution of python code with import ipdb; ipdb.set_trace() sometimes (but not always) drops me into ipdb without showing surrounding lines of code, even if I issue the l command. Ie, I get something like > /path/to/file.py(58)main() ipdb> instead of > /path/to/file.py(58)main() -> print('hello 2') 55 print('hello') 56 import pdb; pdb.set_trace() 57 58 -> print('hello 2') 59 print('hello 3') ipdb> Does anyone know how to show lines of code? Edit: If I s tep into a new function