base.py I see the following in the definition for
def __len__(self): chain = self.chains[-1] return len(self._straces[chain])
Could someone explain why this is the length of the trace? I thought that if I iterated over a MultiTrace using only an integer index, I would get back all of the points in all of the chains, but this length suggests that the length is defined as the length of a single, arbitrarily-chosen chain. But maybe I’m missing something here?
I guess this piece of the
MultiTrace docstring explains it:
For any methods that require a single trace (e.g., taking the length of the MultiTrace instance, which returns the number of draws), the trace with the highest chain number is always used.
…but this seems to almost directly contradict
1. Indexing with a variable or variable name (str) returns all values for that variable, combining values for all chains. >>> trace[varname]
and then I see this:
2. Indexing with an integer returns a dictionary with values for each variable at the given index (corresponding to a single sampling iteration).
…which is silent on the question of whether the indexing ranges over all of the chains or only a single one (and if so, which one).
If someone could clarify this for me, I will try to provide a pull request to clarify the documentation.
Also, what’s the way to get the total number of points, across all the chains? I think one could do
len(list(trace.points)) but that’s a very expensive query. Is there something more efficient?