在numpy中生成缩小范围的1d数组(Generating 1d array of shrinking ranges in numpy)

我想在numpy中生成一个1D数组,如下所示:

In [181]: np.concatenate((np.arange(1, 4), np.arange(2, 4), np.arange(3, 4)))
Out[181]: array([1, 2, 3, 2, 3, 3])

在更大范围内,伪代码:

concatenate(1:n, 2:n, 3:n, ..., n:n)

是否有一种矢量化的方式在numpy和/或pandas中这样做?


I want to generate a 1D array in numpy like this:

In [181]: np.concatenate((np.arange(1, 4), np.arange(2, 4), np.arange(3, 4)))
Out[181]: array([1, 2, 3, 2, 3, 3])

On a larger scale, in pseudocode:

concatenate(1:n, 2:n, 3:n, ..., n:n)

Is there a vectorized way of doing this in numpy and/or pandas?


原文:https://stackoverflow.com/questions/23545014
2022-03-06 22:03

满意答案

如果真的需要部署到lib / ext,最简单的方法是为你的构建提供一个自定义的jdk(称之为Java6_With_MyProduct),在其中提供zipped / tar'gz'ed)jdk。

请您的管理员将其包含在Jenkins配置中。

这样,你的(只有你的版本)会得到你的扩展jdk。

或者,您可以使用-Djava.ext.dirs系统属性来覆盖扩展目录。 那样,你会的

  • 将扩展程序作为预建步骤复制到工作区中
  • 将原始扩展从$ JAVA_HOME / jre / lib / ext复制到同一目录中
  • 将-Djava.ext.dirs = $ WORKSPACE / myextensions设置为MAVEN_OPTS(仅当需要扩展才能实际构建项目时)
  • 将-Djava.ext.dirs = $ WORKSPACE / myextensions添加到argLine中以获取surefire和failfast插件

开放的问题是:你真的需要那些扩展来构建你的项目吗?


If it is really necessary to deploy than into lib/ext, the easiest way would be to provide a custom jdk for your build (call it Java6_With_MyProduct), in which you provide the zipped/tar'gz'ed) jdk.

Ask your administrators to include it into the Jenkins configuration.

That way, YOUR (and only your builds) would get your extended jdk.

Alternatively, you could use the -Djava.ext.dirs system property to override the extension directory. That way, your would

  • copy your extension into your workspace as a prebuild step
  • copy the original extensions from $JAVA_HOME/jre/lib/ext into the same directory
  • set -Djava.ext.dirs=$WORKSPACE/myextensions as MAVEN_OPTS (only if the extension is required to actually BUILD the project)
  • add -Djava.ext.dirs=$WORKSPACE/myextensions to the argLine for surefire and failfast plugins

The open question is: do your really need those extensions to BUILD your project?

相关问答

更多

如何在Jenkins / Maven / Git中标记构建(Publish Maven build to Artifactory from Jenkins)

只需使用Jenkins Artifactory插件或Maven Artifactory插件 。 两者都生成一个BuildInfo元数据 ,其中包含您需要的信息以及更多信息。 所有这些信息都附加到工件上,并使工件可追踪,而无需将此信息嵌入文件名或存档本身。 请花一些时间观看此截屏视频 。 它详细解释了您可以获得什么以及为什么它很重要。 Just use the Jenkins Artifactory Plugin or the Maven Artifactory Plugin. Both gener...

詹金斯和梅文(Jenkins and Maven)

屏幕截图中的最后一个选项Local Maven Repository,它是一个下拉列表,您将有其他条目: 本地执行人 本地工作区 默认(指向从您的设置中拾取的那个) 在您的情况下,选择Local to the workspace ,这不是您实际想要的行为。 将其更改为默认值 。 这也是Jenkins传递给maven的原因如下: -Dmaven.repo.local=C:\apps\Jenkins\jobs\SCAVENGER\workspace\.repository 根据上面选择的选项,存储库...

应该在lib / ext中放置一个jar文件而不是在Windows XP上使用CLASSPATH吗?(Should putting a jar file in lib/ext work instead of using a CLASSPATH on Windows XP?)

您需要将清单文件添加到A.jar文件中,如下所示。 清单文件的内容应该如下所示,其中Main-Class指向您的包名称和A中主类的类名。 将其保存在名为Manifest.mf的文件中 Manifest-Version: 1.0 Main-Class: com.your.package.name.A Class-Path: A.jar B.jar 您可以手动将此文件添加到jar中,方法是将.jar文件更改为.zip,然后打开它并修改现有清单文件的内容(如果有)或将Manifest.mf文件复制到j...

我如何使用maven将lib文件夹中的jar添加为单独的依赖项(How can i add the jars in my lib folder as individual dependencies using maven)

没有一个自动化的进程可以为你完成这项任务,因为jar可以包含在不同的依赖项中。 您必须手动将它们添加到您的pom文件。 There isn't an automatted process to do that task for you, because jars can be included in different dependencies. You have to add them manually to your pom file.

javac找不到已安装在jre / lib / ext中的jar文件(javac can't find jar files that have been installed in jre/lib/ext)

检查一下。 http://www.ntu.edu.sg/home/ehchua/programming/howto/Environment_Variables.html Check this . http://www.ntu.edu.sg/home/ehchua/programming/howto/Environment_Variables.html

使用jenkins构建的maven没有从本地.m2存储库中获取jar(maven build with jenkins not picking up jar from local .m2 repository)

你将jenkins与maven集成的方式是不正确的。 您必须使用artifactory或nexus ,它们都具有足够好用的免费版本。 您构建项目B并将它们部署到上面的存储库管理器,您的项目A从存储库管理器下载它。 针对您的具体问题,请检查 在项目配置中,将检查私有存储库选项 。 这将为每个jenkins执行器创建单独的存储库。 如果jenkins master中的执行者对A和B不同,则不会看到jar文件。 在您的设置中,您无法添加任何从属设备。 所有构建都应该在master上运行。 我希望你不是在...

如何在Jenkins / Maven构建中管理jre / lib / ext jar?(How do I manage jre/lib/ext jars in a Jenkins/Maven build?)

如果真的需要部署到lib / ext,最简单的方法是为你的构建提供一个自定义的jdk(称之为Java6_With_MyProduct),在其中提供zipped / tar'gz'ed)jdk。 请您的管理员将其包含在Jenkins配置中。 这样,你的(只有你的版本)会得到你的扩展jdk。 或者,您可以使用-Djava.ext.dirs系统属性来覆盖扩展目录。 那样,你会的 将扩展程序作为预建步骤复制到工作区中 将原始扩展从$ JAVA_HOME / jre / lib / ext复制到同一目录中 ...

Jenkins CI服务器中的Maven项目问题(Issue with Maven Project in Jenkins CI server)

看起来它正在搜索特定于oracle的库,而你正在使用open jdk。 切换到Oracle jdk可能会解决您的问题。 在Jenkins服务器中安装Oracle jdk,并将JAVA_HOME / PATH变量指向Oracle jdk。 Looks like it's searching for a oracle-specific library and you're using open jdk. Switching to Oracle jdk will probably fix your is...

将JAR从$ HOME / jre / lib / ext移动到Gradle时出现JDBC错误(JDBC Error when moving JAR from $HOME/jre/lib/ext to Gradle)

您可以在Tomcat的配置中定义数据源,而不是将其放入应用程序配置中。 Tomcat具有类加载器的层次结构。 你可以在它的网站上阅读它,但长话短说有三个有趣的类加载器:JDK类加载器(Bootstrap),Tomcat类加载器(系统)和你的应用程序的类加载器(实际上有更多,但让它变得简单)。 将驱动程序的jar放入$ JAVA_HOME / jre / lib / ext /时,将其添加到JDK类加载器中。 将它添加到tomcat / lib时,将其添加到Tomcat类加载器。 当您在应用程序的g...

将挂毯jar放入tomcat lib目录是不对的?(is it wrong to deploy tapestry jars into tomcat lib directory?)

从长远来看,最好拥有自包含的war文件,每个文件都尽可能多地包含它们所需的依赖项,而不是依赖“提供的”依赖项或其他类路径依赖项。 在某些情况下(但不是很多)您需要将jar放在war文件之外,以便服务器可以在启动时访问它们,但这听起来不像其中一种情况。 把Tapestry罐子放在一个共享位置将是一个完全可以忽略的优化。 此外,如果您的某个应用需要不同版本的Tapestry,它可能会在稍后导致问题。 另一个潜在的问题是,如果您切换到不同于Tomcat的应用程序服务器(甚至是不同版本的Tomcat)。 ...

相关文章

更多

3d引擎列表

免费引擎 Agar - 一个高级图形应用程序框架,用于2D和3D游戏。 Allegro lib ...

java3d的前景

奥运后一直在找工作,本来是做WEB方面的工作。 就像北京今天的天气一样,最近IT也是冷的要命。 工 ...

JOGL 处理3D图形

GLAutoDrawable&nbsp

About Unity3D 4.1.2 (to continue…)

Here are something that need to take care of when y ...

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

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

想开发3D引擎

想制作3D引擎,希望高手给推荐一本好书。 需要什么IDE? 需要什么语言?JAVA/C++/C#. ...

Python内建函数(D)

dir([object]) 说明:不带参数时,返回当前范围内的变量、方法和定义的类型列表;带 ...

3D音频理论研究(二)---3D全介绍(转)

作者:it168.com Reny 一、3D音效   随着软、硬件的不断发展,传统的双声道单层面立体声 ...

Autodesk Map 3D 2012 新功能介绍

如果你看过以前的文章欧特克Autodesk发布基础设施2012系列产品, 你会了解到Map 3D 20 ...

mysql删除外键(Cannot drop index 'FK7D676EBBD0A6D8FD': needed in a foreign key constraint)

如果使用SQLyogEnt删除外键,会提示Cannot drop index 'FK7D676 ...

最新问答

更多

获取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}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本