我有一个非常简单的R脚本(实际上只是从“真实”脚本中提取的几行...)
suppressPackageStartupMessages(library("klaR"))
suppressPackageStartupMessages(library("caret"))
# The diabetes data has been modified with a header line
wdat <- read.csv('/git/uni/data/pima-indians-diabetes.csv', header=TRUE)
X <- wdat[,-c(9)]
Y <- wdat[,9]
set.seed(1)
xsquared = function(x) { x * x}
for (wi in 1:2) {
ttSplitx <- createDataPartition(y=Y, p=.8, list=FALSE)
Xx <- X
nxTrain <- Xx[ttSplitx, ]
nyTrain <- Y[ttSplitx]
labelTrue <- nyTrain>0
posCnt <- nxTrain[labelTrue, ]
negCnt <- nxTrain[!labelTrue,]
posMean <- sapply(posCnt, mean, na.rm=TRUE)
posSd <- sapply(posCnt, sd, na.rm=TRUE)
posOffsets <- t(t(nxTrain)-posMean)
posScaled <- t(t(posOffsets)/posSd)
posLogs <- -(1/2)*rowSums(apply(posScaled,c(1, 2),
function(x) { x * x} ), na.rm=TRUE)-sum(log(posSd)) # Line 25
# function(x) { xsquared(x) }), na.rm=TRUE)-sum(log(posSd)) # Line 26
}
print('done')
以上代码在大约三秒钟内启用调试运行。
但是当通过交换评论来使用line26
代替line25
时 - 它将运行但在调试模式下将无限期挂起。
posLogs <- -(1/2)*rowSums(apply(posScaled,c(1, 2),
#function(x) { x * x} ), na.rm=TRUE)-sum(log(posSd)) # Line 25
function(x) { xsquared(x) }), na.rm=TRUE)-sum(log(posSd)) # Line 26
这毫不含糊地表明pycharm
无法调试
xsquared = function(x) { x * x}
对于我尝试定义的任何函数都是如此。
那么..为什么用户函数不能通过pycharm
R
调试器调用?
插件开发人员提出了一个问题 - 他回答说该功能目前无法使用。