Unable to predict using set_value with an errors-in-variables model

Hi William,
Yeah, that’s exactly what I was talking about, and I can replicate your issue – i.e pm.set_data doesn’t update the shape of x_lat:

with pm.Model() as model:
    a = pm.Normal('intercept', 0., 1.)
    b = pm.Normal('slope', 0., 1.)
    
    x_len = pm.Data('x_len', x.shape[0])
    x_in = pm.Data('x_in', x)
    x_lat = pm.Normal('x_lat', 0., 5., shape=x_len.get_value().astype(int))
    x_obs = pm.Normal('x_obs', mu=x_lat, sd=1., observed=x_in)

    y_lat = a + b * x_lat
    y_in = pm.Data('y_in', y)
    y_obs = pm.Normal('y_obs', mu=y_lat, sd=1., observed=y_in)

    trace = pm.sample(2000, tune=2000)

This samples correctly and gives:

model['x_len'].get_value(), model['x_in'].get_value().shape, model['x_lat'].tag.test_value.shape
(array(100.), (100,), (100,))

But updating the data with a new shape doesn’t trickle down to x_lat:

x_new = np.linspace(0, 2, 200)
with model:
    pm.set_data({'x_len': 200, 'x_in': x_new})
    ppc = pm.fast_sample_posterior_predictive(trace, var_names=["x_lat", "x_obs"])

model['x_len'].get_value(), model['x_in'].get_value().shape, ppc["x_lat"].shape
(array(200.), (200,), (8000, 100))

You can see the shape of x_lat not updating above.
@junpenglao @lucianopaz I think you know more than me about this: is it even possible to update the shape of an RV for posterior pred sampling? Should this issue be reported on our GitHub?