小编min*_*ers的帖子

Numpy索引切片不会丢失维度信息

我正在使用numpy并希望索引一行而不会丢失维度信息.

import numpy as np
X = np.zeros((100,10))
X.shape        # >> (100, 10)
xslice = X[10,:]
xslice.shape   # >> (10,)  
Run Code Online (Sandbox Code Playgroud)

在这个例子中,xslice现在是1维,但我希望它是(1,10).在R中,我会使用X [10,:,drop = F].numpy中有类似的东西吗?我在文档中找不到它,也没有看到类似的问题.

谢谢!

python numpy

80
推荐指数
5
解决办法
3万
查看次数

compiling vim with python support

I'm trying to compile Vim 7.2 with Python 2.5.1 support, but I'm having some trouble.

  1. I run configure which seems like it is working as expected

    ./configure --with-features=huge --enable-pythoninterp --prefix=/home/username/vimpy
    
    Run Code Online (Sandbox Code Playgroud)

    I can see that changes to --with-features works as I expect (the final compiled version has new features), and it sets up Python correctly

    checking for python... (cached) //python/2.5/bin/python checking Python version... (cached) 2.5 checking Python is 1.4 or better... yep checking Python's install prefix... (cached) //python/2.5 checking Python's execution …

python vim

58
推荐指数
3
解决办法
6万
查看次数

标签 统计

python ×2

numpy ×1

vim ×1