synthicity/urbansim — pull request #72 by jiffyclub (2014-07-29 00:19:36+00:00)
Title: Injectables and table sources

This adds two ideas to the simulation framework:

Injectables are basically naked values (numbers, strings, anything) that are injected into table/model/column functions just as tables are now. They are injected with no wrapping. If you make a function injectable by default the function is evaluated and its return value injected, but you can turn that off so the function itself is injected.

Examples:

```python
sim.add_injectable('answer', 42)

@sim.injectable('answer')
def answer():
return 42

@sim.injectable('div2', autocall=False)
def div2(x):
return x / 2
```

The other new thing is table sources. These are functions that return DataFrames, but the registered function is replaced by the returned DataFrame the first time the function is called (so the function is only ever called once).

Examples:

```python
@sim.table_source('source')
def source():
return store['buildings']
```