我是第一次尝试使用 Doxygen。在运行 Doxygen 时,我收到大量以下形式的警告:
<code>.cxx:<行号>:警告:记录的函数“<function>::<function>”未声明或定义。
我不知道如何解决这个问题。我正在使用一个大型 C++ 包,并且在运行 Doxygen 时会出现数百次此类警告。
以下是更具体的信息:
警告示例:
Accept.cxx:14: warning: documented function `Accept::Accept' was not declared or defined.
Run Code Online (Sandbox Code Playgroud)
相应的示例代码部分:
#include "Analysis/Accept.h"
#include "Analysis/Cutflow.h"
#include "GlaNtp/GlaUtil/Steer/Steer.h"
#include <iostream>
Accept::Accept(unsigned int cutmask, unsigned int invertword, StringIntMap* CutTypeMap, Cutflow* analysis_cutflow): m_cutmask(cutmask), m_invertword(invertword),
m_cutword(0),m_cutword_set(false), m_CutTypeMap(CutTypeMap),
m_analysis_cutflow(analysis_cutflow){
// this is constructor
InitBitOrder();
}
Accept::~Accept(){}
void Accept::setCutWord(const unsigned int &cutword){
m_cutword_set = true;
m_cutword = cutword;
}
bool Accept::didBitPass(){
//std::cout << "Rick Evnt Pass: " << rickTestCutWord() << std::endl;
return testCutWord();
} …Run Code Online (Sandbox Code Playgroud) 我试图解析一个相当简单的网页,以获取shell脚本中的信息.我现在正在使用的网页是在这里生成的.例如,我想将互联网服务提供商的信息提取到shell变量中.为此目的,使用其中一个程序xmllint,XMLStarlet或xpath可能是有意义的.我对shell脚本非常熟悉,但我不熟悉XPath语法和用于实现XPath语法的实用程序,所以我很欣赏一些指向正确方向的指针.
这是shell脚本的开头:
HTMLISPInformation="$(curl --user-agent "Mozilla/5.0" http://aruljohn.com/details.php)"
# ISP="$(<XPath magic goes here.>)"
Run Code Online (Sandbox Code Playgroud)
为方便起见,这是一个在线动态测试XPath语法的实用程序:
我试图解析VNC服务器启动事件的输出,并在命令替换中使用sed解析时遇到问题.具体来说,远程VNC服务器的启动方式如下:
address1="user1@lxplus.cern.ch"
VNCServerResponse="$(ssh "${address1}" 'vncserver' 2>&1)"
Run Code Online (Sandbox Code Playgroud)
然后解析在此启动事件中生成的标准错误输出,以便提取服务器和显示信息.此时变量的内容VNCServerResponse如下所示:
New 'lxplus0186.cern.ch:1 (user1)' desktop is lxplus0186.cern.ch:1
Starting applications specified in /afs/cern.ch/user/u/user1/.vnc/xstartup
Log file is /afs/cern.ch/user/u/user1/.vnc/lxplus0186.cern.ch:1.log
Run Code Online (Sandbox Code Playgroud)
可以通过以下方式解析此输出,以便提取服务器并显示信息:
echo "${VNCServerResponse}" | sed '/New.*desktop.*is/!d' \
| awk -F" desktop is " '{print $2}'
Run Code Online (Sandbox Code Playgroud)
结果如下:
lxplus0186.cern.ch:1
Run Code Online (Sandbox Code Playgroud)
我想要做的是在命令替换中使用此解析,如下所示:
VNCServerAndDisplayNumber="$(echo "${VNCServerResponse}" \
| sed '/New.*desktop.*is/!d' | awk -F" desktop is " '{print $2}')"
Run Code Online (Sandbox Code Playgroud)
在尝试这样做时,我收到以下错误:
bash: !d': event not found
Run Code Online (Sandbox Code Playgroud)
我不知道如何解决这个问题.在命令替换中使用sed的方式似乎是一个问题.我很感激指导.
我有一个数字列表,[1, 2, 3, 4, 5, 6, 7]我希望有一个函数来返回这个数字列表的四分位数范围.四分位数范围是上下四分位数之间的差异.我试图使用NumPy函数和Wolfram Alpha计算四分位数范围.我发现所有的答案,从我的手册,到NumPy,Wolfram Alpha,都是不同的.我不知道为什么会这样.
我在Python中的尝试如下:
>>> a = numpy.array([1, 2, 3, 4, 5, 6, 7])
>>> numpy.percentile(a, 25)
2.5
>>> numpy.percentile(a, 75)
5.5
>>> numpy.percentile(a, 75) - numpy.percentile(a, 25) # IQR
3.0
Run Code Online (Sandbox Code Playgroud)
我在Wolfram Alpha的尝试如下:
因此,我发现NumPy和Wolfram Alpha返回的值是我认为的第一个四分位数,第三个四分位数和四分位数范围不一致.为什么是这样?我应该用Python做什么来正确计算四分位数范围?
据我所知,四分位数范围[1, 2, 3, 4, 5, 6, 7]应如下:
median(5, 6, 7) - median(1, 2, 3) = 4.
Run Code Online (Sandbox Code Playgroud) 我想看看Python程序如何通过使用该模块发出命令来自杀sys.我怎么能用以下形式的命令让它自杀呢?:
os.system(killCommand)
Run Code Online (Sandbox Code Playgroud)
编辑:强调清晰
所以,为了清楚起见,我希望有一个在shell中运行的字符串可以杀死Python程序.
我可以使用如下过程从现有图像文件生成像素值列表:
from PIL import Image
image = Image.open("test.png")
pixels = list(image.getdata())
width, height = image.size
pixels = [pixels[i * width:(i + 1) * width] for i in xrange(height)]
Run Code Online (Sandbox Code Playgroud)
如何将此像素值列表转换回图像文件?
我试图使用Python子进程执行以下等效操作:
>cat /var/log/dmesg | festival --tts &
[1] 30875
>kill -9 -30875
Run Code Online (Sandbox Code Playgroud)
请注意,我正在杀死进程组(由负号前面指示进程ID号),以便终止所有子进程Festival启动.
在Python中,我目前有以下代码,其中两个进程是通过管道创建和链接的.
process_cat = subprocess.Popen([
"cat",
"/var/log/dmesg"
], stdout = subprocess.PIPE)
process_Festival = subprocess.Popen([
"festival",
"--tts"
], stdin = process_cat.stdout, stdout = subprocess.PIPE)
Run Code Online (Sandbox Code Playgroud)
我应该如何以与上面显示的Bash方式相同的方式杀死这些进程及其子进程?以下方法是不够的,因为它不会杀死子进程:
os.kill(process_cat.pid, signal.SIGKILL)
os.kill(process_Festival.pid, signal.SIGKILL)
Run Code Online (Sandbox Code Playgroud)
有没有更优雅的方法来做到这一点,也许只使用一个过程?
我用以下方式创建了一个NumPy数组:
data = numpy.zeros((1, 15, 3), dtype = numpy.uint8)
Run Code Online (Sandbox Code Playgroud)
然后,我用RGB像素值填充了此数组,生成了一些彩色图像,可以使用以下过程将其保存:
image = Image.fromarray(data)
image.save("image.png")
Run Code Online (Sandbox Code Playgroud)
我如何缩放NumPy数组的大小(不进行插值),以创建600 x 300像素的图像?
我有一个源代码的Bash脚本.当这个脚本来源时,它在Bash脚本中运行一个函数.如果匹配某个条件,此函数应终止脚本.如何在不终止脚本所在的shell的情况下完成此操作?
要明确:我希望终止操作由源shell脚本中的函数完成,而不是在源shell脚本的主体中完成.我可以看到的问题是,return在exit 1终止调用shell时,只需从函数返回到脚本的main .
以下最小示例说明了此问题:
main(){
echo "starting test of environment..."
ensure_environment
echo "environment safe -- starting other procedures..."
}
ensure_environment(){
if [ 1 == 1 ]; then
echo "environment problemm -- terminating..."
# exit 1 # <-- terminates calling shell
return # <-- returns only from function, not from sourced script
fi
}
main
Run Code Online (Sandbox Code Playgroud) 我想创建一个描述周期性事件的ICS文件,该事件发生在2016年全年的每个UTC时间13:00至14:00。ICS文件应可由Google日历导入。我发现很难在网上找到和了解有关如何构造此类文件的详细信息。我目前所拥有的是一种创建包含单个事件列表的文件的方法,但是我想在文件中定义一个事件规则。我现在有类似以下内容:
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//SERN//INDICO//EN
BEGIN:VEVENT
SUMMARY:Software Meeting
DTSTART;VALUE=DATE-TIME:20160818T150000Z
DTEND;VALUE=DATE-TIME:20160818T160000Z
DTSTAMP;VALUE=DATE-TIME:20160912T165700Z
UID:indico-event-563636@sern.ch
DESCRIPTION:https://indico.sern.ch/event/999999/
LOCATION:42-3-002 (SERN)
URL:https://indico.sern.ch/event/999999/
END:VEVENT
BEGIN:VEVENT
SUMMARY:Software Meeting
DTSTART;VALUE=DATE-TIME:20160825T150000Z
DTEND;VALUE=DATE-TIME:20160825T160000Z
DTSTAMP;VALUE=DATE-TIME:20160912T165700Z
UID:indico-event-565483@sern.ch
DESCRIPTION:https://indico.sern.ch/event/999999/
LOCATION:42-3-002 (SERN)
URL:https://indico.sern.ch/event/999999/
END:VEVENT
END:VCALENDAR
Run Code Online (Sandbox Code Playgroud)
编辑:按照zcontent提供的解决方案,我编写了以下ICS文件,该文件似乎可以成功运行:
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//SERN//INDICO//EN
BEGIN:VEVENT
SUMMARY:Software Meeting
TZID:Europe/Zurich
DTSTART:20150202T170000
DTEND:20150202T180000
DTSTAMP:20150202T170000
RRULE:FREQ=WEEKLY;UNTIL=20380119T000000
UID:indico-event-565483@sern.ch
DESCRIPTION:https://indico.sern.ch/event/999999/
LOCATION:42-3-002 (SERN)
URL:https://indico.sern.ch/event/999999/
END:VEVENT
END:VCALENDAR
Run Code Online (Sandbox Code Playgroud) python ×5
bash ×2
image ×2
kill ×2
parsing ×2
shell ×2
c++ ×1
calendar ×1
date ×1
doxygen ×1
exit ×1
festival ×1
file ×1
html ×1
icalendar ×1
list ×1
median ×1
numpy ×1
percentile ×1
return ×1
scale ×1
sed ×1
shape ×1
statistics ×1
subprocess ×1
terminate ×1
time ×1
warnings ×1
wolframalpha ×1
xml ×1
xpath ×1