我已经创建了一个分支,用于在我test-branch推送的本地repo()中进行测试Github.
如果我转到我的Github帐户并选择此帐户,test-branch则会显示以下信息:
This branch is 1 commit ahead and 2 commits behind master
Run Code Online (Sandbox Code Playgroud)
我的问题是:
Github才能看到它)?我知道我可以看到分支之间的差异:
git diff master..test-branch
Run Code Online (Sandbox Code Playgroud)
或使用Meld(我更喜欢):
git difftool master..test-branch
Run Code Online (Sandbox Code Playgroud)
但我想知道是否有办法分别看到提前和落后的提交.IE:有没有办法表明1提前自己提交然后那2个提交自己呢?
我正在使用以下requirements.txt文件在Ubuntu 12.04中安装几个Python包:
numpy>=1.8.2,<2.0.0
matplotlib>=1.3.1,<2.0.0
scipy>=0.14.0,<1.0.0
astroML>=0.2,<1.0
scikit-learn>=0.14.1,<1.0.0
rpy2>=2.4.3,<3.0.0
Run Code Online (Sandbox Code Playgroud)
和这两个命令:
$ pip install --download=/tmp -r requirements.txt
$ pip install --user --no-index --find-links=/tmp -r requirements.txt
Run Code Online (Sandbox Code Playgroud)
(第一个下载包,第二个安装它们).
该过程经常因错误而停止:
Could not find a version that satisfies the requirement <package> (from matplotlib<2.0.0,>=1.3.1->-r requirements.txt (line 2)) (from versions: )
No matching distribution found for <package> (from matplotlib<2.0.0,>=1.3.1->-r requirements.txt (line 2))
Run Code Online (Sandbox Code Playgroud)
我手动修复:
pip install --user <package>
Run Code Online (Sandbox Code Playgroud)
然后pip install再次运行第二个命令.
但是,这仅适用于该特定的包.当我pip install再次运行第二个命令时,进程停止现在抱怨另一个必需的包,我需要再次重复该过程,即:手动安装新的所需包(使用上面的命令),然后运行第二个pip install命令.
到目前为止,我不得不手动安装six,pytz …
我有一个值列表,我需要根据布尔值列表中的值进行过滤:
list_a = [1, 2, 4, 6]
filter = [True, False, True, False]
Run Code Online (Sandbox Code Playgroud)
我使用以下行生成一个新的筛选列表:
filtered_list = [i for indx,i in enumerate(list_a) if filter[indx] == True]
Run Code Online (Sandbox Code Playgroud)
这导致:
print filtered_list
[1,4]
Run Code Online (Sandbox Code Playgroud)
线路工作,但看起来(对我来说)有点矫枉过正,我想知道是否有更简单的方法来达到同样的目的.
以下答案中给出的两个好建议的摘要:
1-不要filter像我一样命名列表,因为它是一个内置函数.
2-不要True像我一样比较事情,if filter[idx]==True..因为这是不必要的.只是使用if filter[idx]就足够了.
下面的代码会在子图之间产生间隙.如何消除子图之间的间隙并使图像成为紧密的网格?
import matplotlib.pyplot as plt
for i in range(16):
i = i + 1
ax1 = plt.subplot(4, 4, i)
plt.axis('on')
ax1.set_xticklabels([])
ax1.set_yticklabels([])
ax1.set_aspect('equal')
plt.subplots_adjust(wspace=None, hspace=None)
plt.show()
Run Code Online (Sandbox Code Playgroud) 我正在读取True - False文件中的值,我需要将其转换为布尔值.目前,True即使将值设置为,它也始终将其转换为False.
这MWE是我正在尝试做的事情:
with open('file.dat', mode="r") as f:
for line in f:
reader = line.split()
# Convert to boolean <-- Not working?
flag = bool(reader[0])
if flag:
print 'flag == True'
else:
print 'flag == False'
Run Code Online (Sandbox Code Playgroud)
该file.dat文件基本上由一个带有值的字符串组成True或False写在里面.这种安排看起来非常复杂,因为这是一个来自更大代码的最小例子,这就是我将参数读入其中的方式.
为什么flag总是转换成True?
numpy.random.shuffle(x)和之间有什么区别numpy.random.permutation(x)?
我已经阅读了doc页面,但是当我想随机改组数组元素时,我无法理解两者之间是否存在任何差异.
更确切地说,假设我有一个数组x=[1,4,2,8].
如果我想生成x的随机排列,那么shuffle(x)和之间的区别是permutation(x)什么?
我的代码
第一档:
data = {'school':'DAV', 'standard': '7', 'name': 'abc', 'city': 'delhi'}
my_function(*data)
Run Code Online (Sandbox Code Playgroud)
第二档:
my_function(*data):
schoolname = school
cityname = city
standard = standard
studentname = name
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,只传递了"data"字典的键my_function(),但我希望键值对能够通过.怎么纠正这个?
我想要my_function()像这样修改
my_function(school='DAV', standard='7', name='abc', city='delhi')
Run Code Online (Sandbox Code Playgroud)
这是我的要求,根据这个给出答案
编辑:字典键类更改为标准
我需要确定Python中两个n维向量之间的角度.例如,输入可以是两个列表,如下所示:[1,2,3,4]和[6,7,8,9].
我有一个只有一个分支(master)的存储库.我是我的回购的唯一贡献者.
我最近添加了一个tag,本地和推送到GitHub.在做了我最后一次必要的提交后,但现在我意识到我应该再做一次更改/提交.
所以我拥有的是:
commit 124
commit 125
commit 126 <-- tag v1.0
commit 127
Run Code Online (Sandbox Code Playgroud)
我想将v1.0标记移动到下一个提交,即:127,本地和GitHub.
我怎样才能做到这一点?
这可能是一个愚蠢的问题,但我无法找到一个函数来生成一定范围内给定长度的随机浮点数组.
我看过随机抽样,但没有功能似乎做我需要的.
random.uniform接近但它只返回一个元素,而不是一个特定的数字.
这就是我所追求的:
ran_floats = some_function(low=0.5, high=13.3, size=50)
Run Code Online (Sandbox Code Playgroud)
这将返回[0.5, 13.3]在该范围内均匀分布的随机非唯一浮点数组(即:允许重复)[0.5, 13.3].
有这样的功能吗?
python ×8
numpy ×3
git ×2
github ×2
angle ×1
arrays ×1
boolean ×1
commit ×1
dictionary ×1
function ×1
list ×1
matplotlib ×1
permutation ×1
pip ×1
python-2.7 ×1
random ×1
scipy ×1
shuffle ×1
string ×1
vector ×1
version ×1
versioning ×1