Skip to content

Text backend does not support tallying a subset of variables (raises KeyError) #2560

Closed
@chumsley

Description

@chumsley

Attempting to use a trace that was loaded from the text backend yields a KeyError, if the trace contains only a subset of the model's variables (e.g., if it was created using the trace= argument to sample).

Failing example:

with pm.Model() as model:
    a = pm.Gamma('a', mu=10.0, sd=2.0)
    b = pm.Gamma('b', mu=10.0, sd=2.0)

    trace = pm.sample(trace=[model.a, model.a_log__])
    assert len(trace.varnames) == 2

    pm.backends.text.dump('trace.text', trace)

    loaded = pm.backends.text.load('trace.text')
    x = loaded[0] #!!! Will throw a KeyError looking for 'b_log__'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions