Make tracedata reverse-compatible?

I understand that sample will return tracedata by default in a future version. What would you think of making the tracedata object support the bracket operator to select a variable from the trace? As in

trace = pm.sample(blah blah)
trace['varname']
2 Likes

I would recommend using something like:

idata = pm.sample(...)
trace = idata.posterior

trace will then be an xarray.Dataset containing only posterior samples with support for the bracket operator, as well as many others, see API reference — xarray 0.17.1.dev0+g835a53e6.d20210226 documentation for the full list.

We are thinking about ways to ease working with posterior samples with InferenceData as this is what is most usually done, and adding something like this has been discussed, but we have not decided on anything yet. Another similar request is Add helper function to easily stack `chain` and `draws` dimensions · Issue #1469 · arviz-devs/arviz · GitHub