Closed quirinmanz closed 3 years ago
Thank you for pointing that out!
The correct way to check would be:
if (inherits(data$export[[i]], "function"))
ref: https://github.com/mschubert/clustermq/blob/master/R/foreach.r#L59-L60
@quirinmanz I've got a follow-up question: What is your object that has more than one class including function
? Is function
the first or second class, and does stripping the environment (this will happen if function
is the first class but not otherwise) cause any issues for you?
Hi,
there are other objects with more than one class. They don't inherit from function
but from e.g. [1] "matrix" "array"
. Therefore I didn't have any issues in terms of errors, only warnings that could be avoided.
Best, Quirin
That makes sense, thanks!
Hi, first of all, thank you for the very helpful package! For me, the
register_dopar_cmq
function enables great compatibility with SLURM.Still, this warning keeps coming up:
In if (class(data$export[[i]]) == "function") environment(data$export[[i]]) = .GlobalEnv : the condition has length > 1 and only the first element will be used
It is not too bad but I would rather not use
supressWarnings()
all the time. My proposal is to replaceif (class(data$export[[i]]) == "function")
withif ("function" %in% class(data$export[[i]]))
.I know it is a minor issue but maybe you can find time to incorporate it.
Best, Quirin Manz