Skip to content
Snippets Groups Projects
Commit d8da3e33 authored by Luke Zappia's avatar Luke Zappia
Browse files

Reset path.from if nGroups changes in SplatParams

Fixes #36
parent 43217644
No related branches found
No related tags found
No related merge requests found
......@@ -107,6 +107,11 @@ setMethod("setParam", "SplatParams",function(object, name, value) {
if (name == "group.prob") {
object <- setParamUnchecked(object, "nGroups", length(value))
path.from <- getParam(object, "path.from")
if (length(path.from) > 1 & length(path.from) != length(value)) {
warning("nGroups has changed, resetting path.from")
object <- setParam(object, "path.from", 0)
}
}
object <- callNextMethod()
......
......@@ -30,4 +30,7 @@ test_that("path.from checks work", {
pp <- setParams(pp, group.prob = c(0.3, 0.3, 0.4))
pp <- setParamUnchecked(pp, "path.from", c(2, 1, 1))
expect_error(validObject(pp), "origin must be specified in path.from")
pp <- setParams(params, group.prob = c(0.5, 0.5), path.from = c(0, 1))
expect_warning(setParam(pp, "group.prob", 1),
"nGroups has changed, resetting path.from")
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment