compute_variables()), it is checked, if
any of the version numbers of all dependent variables has changed since the
last computation. The computation is performed only, if there was any change
in the dependencies tree. The mechanism is described in Section 7.4.3
in more detail.
>>> households.get_version("income")
0
>>> res = interactions.compute_variables([
"urbansim.household_x_gridcell.cost_times_income"])
>>> interactions.get_version("cost_times_income")
0
>>> households.modify_attribute(name="income", data=[14000], index=[9])
>>> households.get_version("income")
1
>>> res = interactions.compute_variables([
"urbansim.household_x_gridcell.cost_times_income"])
urbansim.household_x_gridcell.cost_times_income.......................0.0 sec
>>> interactions.get_version("cost_times_income")
1
The first call of compute_variables() didn't perform the actual
computation, because nothing has changed since our previous computation on
page
.
After we modify one element of the ``income'' attribute
(note that ``income'' is a dependent variable of
``cost_times_income'' defined in the dependencies() method), the
variable is recomputed and the version number is increased.