After we performed model inference using MCMC sampling, we often want to check whether the model fitting is good or not by conditioned on some hold out data or future data. pm.set_data allows you to update the model input to some new data, more information here: https://docs.pymc.io/api/model.html?highlight=set_data#pymc3.model.set_data
after you set the new data, you need to update the the sample so that they conditioned on the new data as well, that’s what sample_posterior_predictive doing here.