next up previous index
Next: Unary Functions for Opus Up: Opus Variables Previous: Variable Dependencies Tree   Index


Expressions

In many cases variable definitions are simple expressions involving other variables. For these cases, Opus provides an expression language that allows them to be defined succinctly, rather than requiring the Opus user to write new variable definitions in Python. The material in this section is intended to complement that in Section 6.3.5 in Chapter 6, with the Chapter 6 material being more tutorial in nature.

The syntax of the expression language is that of Python, but the semantics are somewhat different -- for example, a name like gridcell.distance_to_cbd is a reference to the value of that variable; further, expressions are evaluated lazily.

An expression consists of an attribute name, or a function or operation applied to other expressions. This definition is recursive, so that a unary function or binary operator can be applied to expressions composed from other expressions.

The attribute name used in an expression can be:

(Currently the attribute name can also be an un-qualified attribute for an existing attribute of the dataset, but support for this may be dropped in future versions of Opus. So we recommend always qualifying the attribute name with the name of the dataset in an expression.)

The variable names can include arguments (Section 6.3.4). For example, is_near_highway_if_threshold_is_2 matches the variable definition for is_near_SSS_if_threshold_is_DDD.



Subsections
next up previous index
Next: Unary Functions for Opus Up: Opus Variables Previous: Variable Dependencies Tree   Index
info (at) urbansim.org