simInit silently fails to return a simList

16 views
Skip to first unread message

Steve Cumming

unread,
Apr 6, 2018, 6:50:59 PM4/6/18
to SpaDES Users
Hi: in the following code chunk, simInit silently fails when trying to build a model from at attached Module; using the development Version of a few weeks ago  I don't see anything wrong anyhere.

What would cause simInit to return nothing without throwing an error?

```{r module_usage}
library(SpaDES)
library(magrittr)

inputDir <- file.path(tempdir(), "inputs") %>% checkPath(create = TRUE)
outputDir <- file.path(tempdir(), "outputs")
times <- list(start = 0, end = 10)
parameters <- list()
modules <- list("yieldTables")
objects <- list()
paths <- list(
  cachePath = file.path(outputDir, "cache"),
  modulePath = file.path("scfmModules"),
  inputPath = inputDir,
  outputPath = outputDir
)

mySim <- simInit(times = times, params = parameters, modules = modules, paths = paths)

if (exists("mySim")){
  tmp <-spades(mySim)
}

```
yieldTables.R

Alex Chubaty

unread,
Apr 6, 2018, 11:40:51 PM4/6/18
to SpaDES Users
Using the current development version returns the error message:

"You have created an object with the same name as the module."

Just rename the object yieldTables that the module creates (or rename the module)

Eliot McIntire

unread,
Apr 7, 2018, 1:32:39 AM4/7/18
to SpaDES Users
One of several cases that is now dealt with in the code checking.  You can't create an object called sim$yieldTables because there is already sim$yieldTables which is the sub-environment of the module. That subenvironment has all the functions defined in your module (e.g., Init, doEvent.yieldTables, etc.).  YOu can see this with ls(mySim) or if you are in a browser inside your module, ls(sim).

Steve Cumming

unread,
Apr 7, 2018, 9:33:53 AM4/7/18
to SpaDES Users
oh, that problem again.
sorry.
I was a little thrown by the silent failure.

Thanks

Steve Cumming

unread,
Apr 7, 2018, 12:42:14 PM4/7/18
to SpaDES Users
That would work had I been able to get inside the module, Eliot, but simInit never returned an sim object to explore.

Reply all
Reply to author
Forward
0 new messages