ENV:
我git commit说,它说:
warning: LF will be replaced by CRLF.
Run Code Online (Sandbox Code Playgroud)
这个警告尾巴落后了吗?
我在Windows中编辑文件,行尾是CRLF,就像这张图:

并且git将其更改LF为承诺回购.
所以我认为正确的警告是:
warning: CRLF will be replaced by LF.
Run Code Online (Sandbox Code Playgroud) 我刚刚运行git init了一个已经存在的git repo.
结果是重新初始化现有的Git存储库
我该怎么撤消这个?
谢谢!
Ipython 0.13.1可以从python库打印一个对象的源,
比如,os.path.abspath ??
但我不能打印我在ipython中通过%ed magic定义的任何对象的源代码,我
做错了什么?
比如,我通过%ed magic定义一个类名:
%ed
Run Code Online (Sandbox Code Playgroud)
然后
class Name(object):
"""docstring for Name"""
name = 'hong'
def __init__(self, arg):
super(Name, self).__init__()
self.arg = arg
def pri():
print 'class Name'
Run Code Online (Sandbox Code Playgroud)
回到ipython时,我看不到类Name的源代码:
In [59]: Name??
Type: type
String Form:<class '__main__.Name'>
Docstring: docstring for Name
Constructor information:
Definition:Name(self, arg)
Run Code Online (Sandbox Code Playgroud)
这是IPython的错误吗?
环境:
代码:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib.animation import PillowWriter
fig = plt.figure()
def f(x, y):
return np.sin(x) + np.cos(y)
x = np.linspace(0, 2 * np.pi, 120)
y = np.linspace(0, 2 * np.pi, 100).reshape(-1, 1)
# ims is a list of lists, each row is a list of artists to draw in the
# current frame; here we are just animating one artist, the image, in
# each frame
ims …Run Code Online (Sandbox Code Playgroud) ENV:
我尝试配置:
ipython -i -c "import sys; sys.path.append('path_name')"
Run Code Online (Sandbox Code Playgroud)
但它似乎没有用.
那么什么是正确的解决方案?
或者如何在ipython启动时将当前目录添加到sys.path?
谢谢.
numpy.dot docstring说:
对于2-D阵列,它相当于矩阵乘法,对于1-D阵列相当于矢量的内积(没有复共轭).对于N维,它是a的最后一个轴和b的倒数第二个轴的和积
但它没有说明numpy.dot如何计算具有二维数组的一维数组.那么Numpy如何处理具有二维数组(矩阵)的一维数组(向量)?
我做了一些测试:
In [27]: a
Out[27]:
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
In [28]: b
Out[28]: array([0, 1, 2])
In [29]: np.dot(a,b)
Out[29]: array([ 5, 14, 23])
In [30]: np.dot(a, b.reshape(-1,1))
Out[30]:
array([[ 5],
[14],
[23]])
In [31]: np.dot(a, b.reshape(-1,1)).ravel() # same as np.dot(a,b)
Out[31]: array([ 5, 14, 23])
In [32]: np.dot(b,a)
Out[32]: array([15, 18, 21])
In [33]: np.dot(b.reshape(1,-1), a)
Out[33]: array([[15, 18, 21]])
In [34]: np.dot(b.reshape(1,-1), a).ravel() # same as np.dot(b,a)
Out[34]: array([15, …Run Code Online (Sandbox Code Playgroud) babel-preset-es2015已安装,并且可以使用es6功能,如下所示let a = 2;.
但无法使用es6模块功能import fs from 'fs'如下:
$ babel-node --presets es2015
> let a = 2;
'use strict'
> a
2
> import fs from 'fs';
SyntaxError: repl: Modules aren't supported in the REPL
import fs from 'fs';
at File.buildCodeFrameError (/usr/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/index.js:407:15)
at NodePath.buildCodeFrameError (/usr/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/index.js:149:26)
at PluginPass.ModuleDeclaration (/usr/lib/node_modules/babel-cli/lib/_babel-node.js:78:20)
at newFn (/usr/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/visitors.js:262:19)
at NodePath._call (/usr/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/context.js:63:18)
at NodePath.call (/usr/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/context.js:47:17)
at NodePath.visit (/usr/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/context.js:93:12)
at TraversalContext.visitQueue (/usr/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/context.js:152:16)
at TraversalContext.visitMultiple (/usr/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/context.js:110:17)
at TraversalContext.visit (/usr/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/context.js:182:19)
Run Code Online (Sandbox Code Playgroud)
那有什么不对?
谢谢!
有一个bmp图像,如下图所示的第一张图片,其信息列表为下面的第二张图片.但是当在IPython-notebook上使用matplotlib的plt.imshow()函数显示时,它的颜色错误,正如第三张图片所示.所以我能知道原因吗?
谢谢!



原始文件已在dropbox上共享https://dl.dropboxusercontent.com/u/26518813/test2.bmp
在IPython-notebook上显示图像的代码是:
%pylab inline --no-import-all
from PIL import Image
plt.imshow(Image.open("./test/test2.bmp"))
Run Code Online (Sandbox Code Playgroud) 比如,我已经删除了github.com中的patch-1分支,并运行git fetch origin更新本地repo来跟踪远程,但命令git branch -a仍显示我本地repo跟踪remotes/origin/patch-1.
$ git branch -a
* master
origin
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/patch-1
Run Code Online (Sandbox Code Playgroud)
那么,如何更新我的本地回购?
谢谢!