我使用bower 1.0.0运行以下命令:
mkdir testdir;cd testdir
bower init #accept defaults
bower install jquery -s #the -s is supposed to cause update of bower.json
less bower.json
Run Code Online (Sandbox Code Playgroud)
在bower.json中,我希望看到列出的依赖项,但没有.到底是怎么回事?
注意:bower install jquery --save确实有效
注意:我所指的选项是通过记录 bower help install
**-S**, --save Save installed packages into the project's bower.json dependencies
Run Code Online (Sandbox Code Playgroud) 令我感到困惑的是,当我创建一个新的Error对象时,我可以看到它的消息或名称,但我无法通过标准方式看到它的键列表.这是为什么?
> err = new Error("an error")
[Error: an error]
> err.message
'an error'
> err.name
'Error'
> Object.keys(err)
[]
> JSON.stringify(err)
'{}'
Run Code Online (Sandbox Code Playgroud) 我正在尝试计算几个值的相关矩阵.这些值包括一些'nan'值.我正在使用numpy.corrcoef.对于输出相关矩阵的元素(i,j),我希望使用对于变量i和变量j都存在的所有值来计算相关性.
这就是我现在拥有的:
In[20]: df_counties = pd.read_sql("SELECT Median_Age, Rpercent_2008, overall_LS, population_density FROM countyVotingSM2", db_eng)
In[21]: np.corrcoef(df_counties, rowvar = False)
Out[21]:
array([[ 1. , nan, nan, -0.10998411],
[ nan, nan, nan, nan],
[ nan, nan, nan, nan],
[-0.10998411, nan, nan, 1. ]])
Run Code Online (Sandbox Code Playgroud)
太多的南瓜:(
我创建了一个任意的2x2矩阵:
In [87]: mymat = np.matrix([[2,4],[5,3]])
In [88]: mymat
Out[88]:
matrix([[2, 4],
[5, 3]])
Run Code Online (Sandbox Code Playgroud)
我尝试使用numpy.linalg.eig计算特征向量:
In [91]: np.linalg.eig(mymat)
Out[91]:
(array([-2., 7.]),
matrix([[-0.70710678, -0.62469505],
[ 0.70710678, -0.78086881]]))
In [92]: eigvec = np.linalg.eig(mymat)[1][0].T
In [93]: eigvec
Out[93]:
matrix([[-0.70710678],
[-0.62469505]])
Run Code Online (Sandbox Code Playgroud)
我将我的一个特征向量乘以我的矩阵,期望结果是一个向量,它是我的特征向量的标量倍数.
In [94]: mymat * eigvec
Out[94]:
matrix([[-3.91299375],
[-5.40961905]])
Run Code Online (Sandbox Code Playgroud)
但事实并非如此.任何人都可以向我解释这里出了什么问题吗?
我试图运行Vagrant机器,但因为我安装了Vagrant 1.0.1而遇到了错误.然后我卸载并安装了Vagrant 1.2.2.但是,当我运行vagrant时,我得到一个错误.
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
The box 'precise32' is still stored on disk in the Vagrant 1.0.x
format. This box must be upgraded in order to work properly with
this version of Vagrant.
Run Code Online (Sandbox Code Playgroud)
我尝试了vagrant init但也遇到了错误.
$ vagrant init precise32 http://files.vagrantup.com/precise32.box
`Vagrantfile` already exists in this directory. Remove it before
running `vagrant init`.
Run Code Online (Sandbox Code Playgroud)
如何将我的精确32盒升级为新版Vagrant?
我正在尝试使用量角器进行角度应用的E2E测试.我使用该命令./node_modules/protractor/bin/webdriver-manager启动我的selenium服务器.但是,默认的selenium服务器位置是localhost:4444/wd/hub,但localhost:4444已经在我的机器上使用,这很难改变.如何在4444以外的端口启动selenium服务器?
我试图降级我的conda版本。使用4.6.2版的conda时,我运行了conda install conda=4.5.12。然后,我去运行其他conda命令,但遇到以下错误:
CondaUpgradeError: This environment has previously been operated on by a conda version that's newer
than the conda currently being used. A newer version of conda is required.
target environment location: /home/selah/anaconda3
current conda version: 4.5.12
minimum conda version: 4.6
Run Code Online (Sandbox Code Playgroud)
我现在陷入困境,无法成功运行任何conda命令。如何才能使conda重新恢复正常工作?
我有一个模块.它有一个配置块,一个提供者和一个常量定义.配置块引用常量和提供者.我注意到我的常量可以在我的配置块之前或之后定义.但是,必须在配置块之前定义提供程序,否则我会收到错误.
Error: [$injector:modulerr] Failed to instantiate module loadOrder due to:
[$injector:unpr] Unknown provider: greetingsProvider
Run Code Online (Sandbox Code Playgroud)
以下是一些示例代码:
var myModule = angular.module('loadOrder', []);
//if I define this after the config block, I get an error
angular.module('loadOrder').provider('greetings',[ function(){
this.$get = [function(){
return { greet: function(){ return "Hola"; } };
}];
}]);
myModule.config(['$provide', 'greetingsProvider', 'planetName', function($provide, loadOrderProvider, planetName){
$provide.value('someVals',[3,6,8]);
console.log("Lets go to", planetName);
}]);
myModule.constant('planetName', 'Saturn');
Run Code Online (Sandbox Code Playgroud)
为什么是这样?为什么我的配置块后无法定义我的提供程序?
python版本是2.7.6,但是当我安装IPython时
sudo pip install ipython
Run Code Online (Sandbox Code Playgroud)
ipython指向python 3.4.0.由于python 3.x不兼容,这导致了我常用的模块中的许多语法错误.
我尝试编辑脚本/ usr/local/bin/ipython的第一行:
#!/usr/bin/python3.4
Run Code Online (Sandbox Code Playgroud)
变
#!/usr/bin/python
Run Code Online (Sandbox Code Playgroud)
但后来我收到一个错误:
ImportError: No module named IPython
Run Code Online (Sandbox Code Playgroud)
如何让Ipython和我的默认python版本(2.7.6)一起工作?
我想在我的Rails模型中初始化一个实例变量,它将保存一个数组,我想在我的模型中的其他方法中访问这个变量.我试过这个:
class Participant < ActiveRecord::Base
@possible_statuses = [
'exists',
'paired',
'quiz_finished',
'quiz_results_seen',
'money_sent'
]
def statuses
@possible_statuses
end
Run Code Online (Sandbox Code Playgroud)
但是当我使用rails console尝试以下操作时:
Participant.first.statuses
Run Code Online (Sandbox Code Playgroud)
我回来了nil :(
为什么会这样?有没有办法完成我想要完成的任务?
python ×4
angularjs ×2
numpy ×2
bower ×1
conda ×1
correlation ×1
eigenvector ×1
ipython ×1
javascript ×1
matrix ×1
model ×1
node.js ×1
pandas ×1
protractor ×1
ubuntu ×1
vagrant ×1