Python切片不会更改切片数组的值(Python slicing does not change the sliced array's value)
我正在尝试测试Python numpy的切片功能。 对于以下代码,我预计输出为[101,100,101,100,101,100]。
x = np.array([1,0,1,0,1,0]) y = x y = y + 100 x
但它返回[1,0,1,0,1,0]。 为什么? 我认为切片也会修改原始数组。
I am trying to test the slicing feature of Python numpy. For the following code, I would expect the output be [101,100,101,100,101,100].
x = np.array([1,0,1,0,1,0]) y = x y = y + 100 x
But it returns [1,0,1,0,1,0]. Why? I thought slicing modifies the original array as well.
原文:https://stackoverflow.com/questions/48323148
更新时间:2022-09-05 12:09
最满意答案
不知道这是否理想,但我从SonarQube api获得了一个请求的状态(你可以使用HttpRequest插件)。
def response = httpRequest 'https://SONAR_USER:SONAR_PASSWORD@SONAR_URL/api/qualitygates/project_status?projectKey=PROJECT_KEY' def slurper = new groovy.json.JsonSlurper() def result = slurper.parseText(response.content) if (result.projectStatus.status == "ERROR") { currentBuild.result = 'FAILURE' }
Don't know if this is ideal, but I'm getting the status from the SonarQube api with a request (which you can do with the HttpRequest plugin).
def response = httpRequest 'https://SONAR_USER:SONAR_PASSWORD@SONAR_URL/api/qualitygates/project_status?projectKey=PROJECT_KEY' def slurper = new groovy.json.JsonSlurper() def result = slurper.parseText(response.content) if (result.projectStatus.status == "ERROR") { currentBuild.result = 'FAILURE' }
相关问答
更多-
我想我明白了。 首先,您必须检索SonarQube扫描仪工具 def sonarqubeScannerHome = tool name: 'SonarQubeScanner', type: 'hudson.plugins.sonar.SonarRunnerInstallation' 然后你可以通过Shell调用声纳扫描器: sh "${sonarqubeScannerHome}/bin/sonar-scanner -e -Dsonar.host.url=..." I think I got it. Fi ...
-
你没有指示Jenkins检查你的存储库。 您可以在调用checkout scm之前添加checkout scm执行此操作。 喜欢这个: node { checkout scm sh "docker build -t 192.168.59.224:5000/ubuntu-test ." } 当您使用“来自SCM的管道”并指向Jenkins从中获取Jenkinsfile的位置时,变量scm由Jenkins设置。 You're not instructing Jenkins to check out y ...
-
不知道这是否理想,但我从SonarQube api获得了一个请求的状态(你可以使用HttpRequest插件)。 def response = httpRequest 'https://SONAR_USER:SONAR_PASSWORD@SONAR_URL/api/qualitygates/project_status?projectKey=PROJECT_KEY' def slurper = new groovy.json.JsonSlurper() def result = slurper.parseT ...
-
您的脚本成功运行并在预期后按预期工作 用node{ }和。围绕它 使用sh intead of shell 喜欢这个: node{ stage("check out project") { sh "pwd" echo "test 1" git credentialsId: '12341234-1234-1234-1234-123412341234', url: "git@github.com:sendgrid/sendgrid-java.git" ...
-
几个小时后我发现了问题。 这是一个简单的拼写错误,没有被管道解释器拿起,包括应该包括,见下文: stash includes: "**/*.log", name: "log_stage1" I found the problem after many hours. It was a simple typo that was not picked up by the pipeline interpreter, include should be includes, see below: stash incl ...
-
您可以检查线程转储和Jenkins日志文件。 有些东西被严重破坏,但仅从描述中就无法说出什么。 I finally found a solution. As I said in the question, I had to install (manually) the pipeline plugin and all its dependencies because I was under a proxy and I haven't at this time the credentials to pass t ...
-
你的函数get_user()什么都不返回。 内部wrap([$class: 'BuildUser']) {...}的return(s) wrap([$class: 'BuildUser']) {...}确实从wrap类返回,而不是从您的函数返回。 your function get_user() returns nothing. the return(s) inside wrap([$class: 'BuildUser']) {...} do return from wrap class and not f ...
-
如何在Jenkins管道脚本中使用“参数化远程触发插件”?(How to use “Parameterized Remote Trigger Plugin” in Jenkins Pipeline script?)[2023-04-17]
似乎是一个开放的bug: https : //issues.jenkins-ci.org/browse/JENKINS-38657 作为一种解决方法,您可以在本地创建另一个旧类型的作业,并使用旧学校非管道脚本方式的插件。 然后在您的管道脚本中,您只需触发此作业。 我知道这是一个丑陋的适配器但是你已经参数化了这个适配器并且几乎可以运行它并运行;) Seems to be an open bug: https://issues.jenkins-ci.org/browse/JENKINS-38657 As a w ... -
HTML Publisher插件似乎不懂通配符。 您可以在管道中执行的操作是使用Linux的复制命令,因为它可以使用通配符。 这[Docs_LoadTest]/jmeter/reports文件夹中所有目录的内容复制到本地工作空间中的jmeter_results文件夹: sh 'cp -r /var/lib/jenkins/workspace/Docs_LoadTest/target/jmeter/reports/*/. target/jmeter_results/' 请注意,您必须同时清除Docs_Loa ...
-
使用Pipeline Shared Groovy Library插件。 创建一个新的存储库,将您的groovy代码放在(root)/var/your_code.groovy下 使用@Library加载库或勾选Manage Jenkins - > Configure System - > Global Pipeline Libraries - > Implicitly加载以始终加载groovy代码 Use Pipeline Shared Groovy Library plugin. Create a new ...