modelCacher1d
- sherpa.models.model.modelCacher1d(func: Callable) Callable [source] [edit on github]
A decorator to cache ArithmeticModel evaluations.
Apply to the
calc
method of a model to allow the model evaluation to be cached. The decision is based on theintegrate
setting, the evaluation grid, parameter values, and the keywords sent to the model.For historic reasons, this decorator was implemented for 1D models first. However, it is general enough that it works in higher dimensions, too. It can be used as either
@modelCacher1d
or@modelCacher
; the names are aliases for each other.Notes
The keywords are included in the hash calculation even if they are not relevant for the model (as there’s no easy way to find this out).
Examples
Allow
MyModel
model evaluations to be cached:def MyModel(ArithmeticModel): ... @modelCacher def calc(self, p, *args, **kwargs): ...