next up previous index
Next: Optional Method dependencies() Up: Implementation Previous: Creating a Variable Object   Index


Required Method compute()

Each variable class has a required method compute() which defines how to compute this variable.

It takes as an argument an object of class Resources, called arguments which is a container for all arguments and datasets that this variable might need for its computation. Since this method is called from the dataset method compute_variables(), it is important to pass all required objects into the resources argument of compute_variables(). If the variable needs attributes of another dataset, this dataset should be stored in resources under its dataset name.

The implementation of the compute() method can assume that all required variables are already computed and accessible by the dataset method get_attribute(), if they are listed in the dependencies() method (see Section 6.3.2).

The compute() method returns a numpy array of the size of number of elements in the ``owner'' dataset.


next up previous index
Next: Optional Method dependencies() Up: Implementation Previous: Creating a Variable Object   Index
info (at) urbansim.org