[Bug]: bootstrap in network analysis cannot work well #3125
Labels
Module: jaspNetwork
Waiting for requester
If waiting for a long time it is reasonable to close an issue
JASP Version
0.19.3
Commit ID
No response
JASP Module
Network
What analysis are you seeing the problem on?
No response
What OS are you seeing the problem on?
Windows 11
Bug Description
该分析意外终止。
Error in .extractErrorMessage(e): length(error) = 1 is not TRUE
Stack trace
.networkAnalysisBootstrap(mainContainer, network, options)
.networkAnalysisComputeBootstrap(bootstrapContainer, network, options)
tryCatch({
jaspBase::.suppressGrDevice({
for (nm in names(allNetworks)) {
bootstrapResult[[nm]] <- bootnet::bootnet(data = allNetworks[[nm]], nBoots = options[['bootstrapSamples']], type = options[['bootstrapType']], nCores = nCores, statistics = c('edge', 'strength', 'closeness', 'betweenness'), labels = options[['variables']])
}
})
}, error = function(e) bootstrapContainer$setError(.extractErrorMessage(e)))
tryCatchList(expr, classes, parentenv, handlers)
tryCatchOne(expr, names, parentenv, handlers[[1]])
value[3]
bootstrapContainer$setError(.extractErrorMessage(e))
private$jaspObject$setError(x)
.extractErrorMessage(e)
stopifnot(length(error) = 1)
要获得有关此问题的帮助,请在以下位置报告上述消息:https://jasp-stats.org/bug-reports
Expected Behaviour
should work well
Steps to Reproduce
This error message indicates an issue in the R code related to the
networkAnalysisBootstrap
and related functions. The key error message islength(error) = 1 is not TRUE
which occurs within thestopifnot
statement in theextractErrorMessage
function (or a function that calls it).Here's a breakdown of what might be going wrong:
1.
extractErrorMessage
functionThe
extractErrorMessage
function likely expects theerror
object (which presumably represents an error that occurred earlier) to have a length of 1. But for some reason, when this check is made, the length oferror
is not 1, and thus thestopifnot
condition fails and throws the error you're seeing.2. Error handling in
tryCatch
The
tryCatch
block is set up to handle errors that occur when running thebootnet::bootnet
function. When an error happens during the execution of thatbootnet
call (for example, if there's an issue with the input dataallNetworks[[nm]]
, incorrect specification ofnBoots
,type
, etc., or a problem within thebootnet
function itself), theerror
handler is supposed to callbootstrapContainer$setError(.extractErrorMessage(e))
. However, since theextractErrorMessage
function has the length check issue, it fails to handle the error gracefully.3. Possible causes of incorrect
error
lengthextractErrorMessage
instead of a single error object, which would violate the expected length condition.extractErrorMessage
function. Maybe it's being initialized or populated in an unexpected way that results in it having a length other than 1.4. Suggested steps for debugging
bootnet
call: Look closely at the input data (allNetworks
), the values ofnBoots
,bootstrapType
,nCores
, and other parameters passed tobootnet::bootnet
. Make sure they are all correctly specified and that the data is in the expected format. There could be something wrong with these inputs that is causing an error that then gets mishandled later.error
object: Add some debugging statements to print theerror
object right before it's passed toextractErrorMessage
in thetryCatch
block. This can help you see what's actually in theerror
object and if it's indeed not in the expected format. For example, you could addprint(e)
just beforebootstrapContainer$setError(.extractErrorMessage(e))
in thetryCatch
block.extractErrorMessage
function: Examine theextractErrorMessage
function itself to see if there are any other parts of the code within it that could be modifying theerror
object's length or if there's an incorrect assumption about the structure of theerror
object that it's supposed to receive.Overall, the error message points to a problem in the error handling and assumptions about the error object's structure in the context of the network analysis code you're working with.
Log (if any)
No response
More Debug Information
No response
Final Checklist
The text was updated successfully, but these errors were encountered: