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

在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 Artifactory插件或Maven Artifactory插件 。 两者都生成一个BuildInfo元数据 ,其中包含您需要的信息以及更多信息。 所有这些信息都附加到工件上,并使工件可追踪,而无需将此信息嵌入文件名或存档本身。 请花一些时间观看此截屏视频 。 它详细解释了您可以获得什么以及为什么它很重要。 Just use the Jenkins Artifactory Plugin or the Maven Artifactory Plugin. Both generate a ...
  • 屏幕截图中的最后一个选项Local Maven Repository,它是一个下拉列表,您将有其他条目: 本地执行人 本地工作区 默认(指向从您的设置中拾取的那个) 在您的情况下,选择Local to the workspace ,这不是您实际想要的行为。 将其更改为默认值 。 这也是Jenkins传递给maven的原因如下: -Dmaven.repo.local=C:\apps\Jenkins\jobs\SCAVENGER\workspace\.repository 根据上面选择的选项,存储库始终与相关 ...
  • 您需要将清单文件添加到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文件复制到jar / ...
  • 没有一个自动化的进程可以为你完成这项任务,因为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.
  • 检查一下。 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集成的方式是不正确的。 您必须使用artifactory或nexus ,它们都具有足够好用的免费版本。 您构建项目B并将它们部署到上面的存储库管理器,您的项目A从存储库管理器下载它。 针对您的具体问题,请检查 在项目配置中,将检查私有存储库选项 。 这将为每个jenkins执行器创建单独的存储库。 如果jenkins master中的执行者对A和B不同,则不会看到jar文件。 在您的设置中,您无法添加任何从属设备。 所有构建都应该在master上运行。 我希望你不是在不同的奴隶 ...
  • 如果真的需要部署到lib / ext,最简单的方法是为你的构建提供一个自定义的jdk(称之为Java6_With_MyProduct),在其中提供zipped / tar'gz'ed)jdk。 请您的管理员将其包含在Jenkins配置中。 这样,你的(只有你的版本)会得到你的扩展jdk。 或者,您可以使用-Djava.ext.dirs系统属性来覆盖扩展目录。 那样,你会的 将扩展程序作为预建步骤复制到工作区中 将原始扩展从$ JAVA_HOME / jre / lib / ext复制到同一目录中 将-Dja ...
  • 看起来它正在搜索特定于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 issue. ...
  • 您可以在Tomcat的配置中定义数据源,而不是将其放入应用程序配置中。 Tomcat具有类加载器的层次结构。 你可以在它的网站上阅读它,但长话短说有三个有趣的类加载器:JDK类加载器(Bootstrap),Tomcat类加载器(系统)和你的应用程序的类加载器(实际上有更多,但让它变得简单)。 将驱动程序的jar放入$ JAVA_HOME / jre / lib / ext /时,将其添加到JDK类加载器中。 将它添加到tomcat / lib时,将其添加到Tomcat类加载器。 当您在应用程序的gradle ...
  • 从长远来看,最好拥有自包含的war文件,每个文件都尽可能多地包含它们所需的依赖项,而不是依赖“提供的”依赖项或其他类路径依赖项。 在某些情况下(但不是很多)您需要将jar放在war文件之外,以便服务器可以在启动时访问它们,但这听起来不像其中一种情况。 把Tapestry罐子放在一个共享位置将是一个完全可以忽略的优化。 此外,如果您的某个应用需要不同版本的Tapestry,它可能会在稍后导致问题。 另一个潜在的问题是,如果您切换到不同于Tomcat的应用程序服务器(甚至是不同版本的Tomcat)。 不同的应用 ...

相关文章

更多

最新问答

更多
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • Java中的不可变类(Immutable class in Java)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • EXCEL VBA 基础教程下载
  • RoR - 邮件中的动态主体(部分)(RoR - Dynamic body (part) in mailer)
  • 无法在Google Script中返回2D数组?(Can not return 2D Array in Google Script?)
  • JAVA环境变量的设置和对path , classpth ,java_home设置作用和目的?
  • mysql 关于分组查询、时间条件查询
  • 如何使用PowerShell匹配运算符(How to use the PowerShell match operator)
  • Effective C ++,第三版:重载const函数(Effective C++, Third edition: Overloading const function)
  • 如何用DELPHI动态建立MYSQL的数据库和表? 请示出源代码。谢谢!
  • 带有简单redis应用程序的Node.js抛出“未处理的错误”(Node.js with simple redis application throwing 'unhandled error')
  • 使用前端框架带来哪些好处,相对于使用jquery
  • Ruby将字符串($ 100.99)转换为float或BigDecimal(Ruby convert string ($100.99) to float or BigDecimal)
  • 高考完可以去做些什么?注意什么?
  • 如何声明放在main之后的类模板?(How do I declare a class template that is placed after the main?)
  • 如何使用XSLT基于兄弟姐妹对元素进行分组(How to group elements based on their siblings using XSLT)
  • 在wordpress中的所有页面的标志(Logo in all pages in wordpress)
  • R:使用rollapply对列组进行求和的问题(R: Problems using rollapply to sum groups of columns)
  • Allauth不会保存其他字段(Allauth will not save additional fields)
  • python中使用sys模块中sys.exit()好像不能退出?
  • 将Int拆分为3个字节并返回C语言(Splitting an Int to 3 bytes and back in C)
  • 在SD / MMC中启用DDR会导致问题吗?(Enabling DDR in SD/MMC causes problems? CMD 11 gives a response but the voltage switch wont complete)
  • sed没有按预期工作,从字符串中间删除特殊字符(sed not working as expected, removing special character from middle of string)
  • 如何将字符串转换为Elixir中的函数(how to convert a string to a function in Elixir)