PredictiveEcology / SpaDES

R package for developing and running Spatial Discrete Event Simulation models
https://spades.predictiveecology.org
Other
55 stars 21 forks source link

spiffy simInit #353

Closed SteveCumming closed 6 years ago

SteveCumming commented 6 years ago

in my Silvertown.R, mapDim is provided only as en element in the object list, not as a parameter.

spiffyInit asks for a default value but I see no way of providing one in a expectsInput() call.

Running .inputObjects for Silvertown

Module Code Checking

Silvertown: module code: mapDim is declared in inputObjects, but no default(s) is provided in .inputObjects

Module Code Checking

dev()

eliotmcintire commented 6 years ago

There is no space in the metadata to provide a custom way to do "whatever it is you need to do for every input object". Instead, there is a section in your module, a function called: .inputObjects. In that, you can give default values, and even sophisticated default ways of downloading, unzipping, cropping, whatever.

For this latter, See development version of SpaDES.core ... prepInputs function.

Where a good strategy is:

if (is.null(sim$yourObject)) {
  sim$yourObject <- somethingDefault
}

### or use prepInputs, but that is somewhat advanced at the moment
if (is.null(sim$yourObject)) {
  sim$yourObject <- Cache(prepInputs, archive = ..., etc.)
}

If you don't want to set any defaults, you can ignore the Module Code Checking about that.

SteveCumming commented 6 years ago

I see. I missed that it was so specific as to ask for a default in inputObjects as opposed to one of the data.frame rows createable by function inputObjects().

All is now clear.