我的numpy数组总是以零结尾?(My numpy array always ends in zero?)

我想我错过了某个地方。 我使用两个for循环(x和y)和一个基于x,y位置的函数填充了一个numpy数组。 唯一的问题是,无论数组的大小如何,数组的值总是以零结尾。

thetamap = numpy.zeros(36, dtype=float)
thetamap.shape = (6, 6)
for y in range(0,5):
    for x in range(0,5):
        thetamap[x][y] =  x+y
print thetamap

I think I missed something somewhere. I filled a numpy array using two for loops (x and y) and a function based on the x,y position. The only problem is that the value of the array always ends in zero irregardless of the size of the array.

thetamap = numpy.zeros(36, dtype=float)
thetamap.shape = (6, 6)
for y in range(0,5):
    for x in range(0,5):
        thetamap[x][y] =  x+y
print thetamap

原文:https://stackoverflow.com/questions/15329557
2023-10-13 16:10

满意答案

使用:

wincmd k

我得到了我需要的东西


Using:

wincmd k

I got what I needed

相关问答

更多

Vim:有没有一个命令来切换窗口(Vim: is there a command to switch windows)

使用: wincmd k 我得到了我需要的东西 Using: wincmd k I got what I needed

如何在vim中翻转窗口?(How to flip windows in vim? [duplicate])

如果你让他们垂直地分开Cw J来移动一个到底部 如果你把它们分开水平地移动一个向右移动 要在分割窗口的“列”或“行”中旋转, Cw Cr 以下命令可用于更改窗口布局。 例如,当有两个垂直分割窗口时,CTRL-W K将在水平拆分窗口中更改。 相反,CTRL-W H也是这样。 If you have them split vertically C-wJ to move one to the bottom If you have them split horizontally C-wL to move ...

在Vim中如何切换命令和插入模式?(How do I switch between command and insert mode in Vim?)

看起来你的Vim是以简单的模式启动的。 看:help easy 当使用-y参数或evim调用Vim时,会发生这种情况,或者您可能在.vimrc配置中存在:set insertmode 。 找到源并禁用它; 暂时还可以通过Ctrl + O完成 :set noim Enter 。 Looks like your Vim is launched in easy mode. See :help easy. This happens when Vim is invoked with the -y argum...

vim,使用vanilla Vim快速切换文件(无插件)(vim, switching between files rapidly using vanilla Vim (no plugins))

ST2的Ctrl + P最接近的等价物(“最接近”而不是“精确”)是一个称为“插件”的插件。 还有其他类似的插件,如Command-T或FuzzyFinder 。 我使用CtrlP,我喜欢它,但我衷心地支持你的决定去“无插件”。 这不是最简单的方法,但从长远来看将会有所回报。 打开文件 打开文件的最基本的方法是:e /path/to/filename 。 幸运的是,你得到标签完成和通配符:经典*和一个特殊的** ,代表“任何子目录”。 结合所有这些,你可以做: :e **/*foo<Tab> 从...

如何使用命令或本地vimrc文件在多个vim配置之间切换?(How to switch between multiple vim configurations with a command or local vimrc files?)

综上所述 有几种方法可以做到这一点,其中大多数都是建议的,但是我以为我会用两个额外的方法来总结: 每个目录vimrc - 有一个缺点,Vim必须在正确的目录启动:如果你的项目在~/project1 ,你有~/project1/.vim.custom和做~/project1/.vim.custom cd ~ ; vim project1/file.c cd ~ ; vim project1/file.c ,将不会找到自定义设置。 模型 - 非常有效,但有缺点,需要将它们添加到所有文件(并记住将它们添...

你喜欢在Vim中缓冲区之间切换?(How do you prefer to switch between buffers in Vim?)

我已经使用Wincent Colaiuta的Command-T vim插件几个月了。 Wincent写了C中需要很快的部分,我必须说这是! 而且,我认为它的文件模式匹配逻辑甚至比Textmate的Command-T更好。 查看屏幕录像 。 VIM的Command-T插件提供了一种非常快速,直观的机制,以最少的击键打开文件。 它被命名为“Command-T”,因为它受到TextMate中绑定到Command-T的“Go to File”窗口的启发。 通过键入出现在其路径中的字符来选择文件,并通过一种...

无法在窗口之间切换(Unable to switch among the windows)

如果你只在getWindowHandles()中看到2个窗口,那么弹出窗口可能是一个iframe。 在这种情况下,使用driver.switchTo()。frame()将焦点切换到该帧,而不是寻找一个全新的窗口。 这是关于切换方法的文档: http : //selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#switchTo() If you're only seeing 2 window in ...

从Vim中的用户定义命令切换到** insert **模式(Switch to **insert** mode from a user-defined command in Vim)

来自:help :normal > :norm[al][!] {commands} *:norm* *:normal* (...) {commands} should be a complete command. If {commands} does not finish a command, the last one will be aborted as if <Esc> or ...

每当我切换到它时,VIM刷新缓冲区(VIM refreshing buffer whenever I switch to it)

首先,使用set eventignore=all测试此行为。 如果问题得到解决,请尝试切换到scp缓冲区使用(确保你没有设置eventignore) debug buffer scp-buffer-name或debug wincmd p (取决于你何时看到问题),它将打开调试模式,你会能够看到它正在执行的所有自动命令(使用s[tep]或n[ext]移动到下一个命令,请参阅:h >next和:h >step以获取更多详细信息)。 First, test this behavior with set ...

如何在SSH终端之间切换窗口?(How to switch between windows in SSH Terminal?)

你有两个Vim实例,第二个将第一个放在后台。 您需要使用shell的作业控制命令: <C-z> to suspend the current job fg to switch to the latest background job fg2 to switch to the second latest background job jobs to list all current jobs 在您的情况下,单个<Cz>将暂停第二个Vim并显示第一个。 另一个<Cz>将暂停第一个Vim并...

相关文章

更多

报错说找不到abbrev这个方法,但Array有这个方法的吧?

以下是ruby-doc.org http://www.ruby-doc.org/core/class ...

scala数组操作

定长数组 最简单的数组创建如下,记住方括号在Scala中用做泛型,相当于<>在Java中作用。 定义1 ...

Java 数组

Java 数组 数组对于每一门编辑应语言来说都是重要的数据结构之一,当然不同语言对数组的实现及处 ...

动态拼接JSON数组的问题

比如说var level = [[&quot;ID&quot;,&quot;NAME&quot;]]; ...

找数组的波谷

算法的分析来自与‘待字闺中’微信公众平台 利用python语言实现(刚学习python,练习一下)。 ...

Guava处理java byte类型工具类-Bytes类

static int indexOf(byte[] array

怎么得到String数组?

今天遇见一个问题.不知道怎么解决. 如: 自己建立了一个文件read.txt 里面存放这样的 键值 ...

Guava 处理java short实用工具类-Shorts类

static short min(short... array)返回出现在数组的最小值

Guava Chars类-char类型的实用工具类

static char min(char... array)返回出现在数组最小值

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本