classmethod Var.from_dict(base, values, name=None, default=0, info=None)

Construct a Var object by mapping base to values.

base : sequence

Sequence to be mapped to the new Var.

values : dict

Mapping from values in base to values in the new Var.

name : str

Name for the new Var.

default : scalar

Default value to supply for entries in base that are not in values.


>>> base = Factor('aabbcde')
>>> Var.from_dict(base, {'a': 5, 'e': 8}, default=0)
Var([5, 5, 0, 0, 0, 0, 8])