next up previous index
Next: Visualizing Datasets Up: Datasets Previous: Attribute Names   Index


Computing Variables

A variable (or equivalently, a computed attribute) is specified either by an expression of by a fully-qualified name (see Section 24.3). Datasets automatically compute each variable when, and only when, needed. This mechanism uses the dependency information from each variable which gives an information about what variables this variable depends on. Additionally, it is checked if variable's dependent variables have changed (versioning mechanism). The computation is invoked by the dataset method compute_variables() which computes each of the given variables if either (a) this variable has not been computed before, or (b) the inputs to this variable (the values of variables upon which this variable depends) have changed since the last computation. Thus, invoking compute_variables() on a single variable may either result in no more computation, or have a ripple effect of computing many variables upon which this one variable depends. Lazily computing variables both helps minimize the computational load as well as eliminating the need to worry about when variables are computed: it will happen when, and only when, it is needed.

The method compute_variables() takes the following arguments:

The method returns an array of values that result from computing the last variable in the list of variable names.


next up previous index
Next: Visualizing Datasets Up: Datasets Previous: Attribute Names   Index
info (at) urbansim.org