Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
----------
posteriors: list
List of pandas DataFrame objects.
max_samples: int, opt
Maximum number of samples to take from each posterior,
default is length of shortest posterior chain.
Returns
-------
data: dict
Dictionary containing arrays of size (n_posteriors, max_samples)
There is a key for each shared key in posteriors.
"""
for posterior in posteriors:
max_samples = min(len(posterior), max_samples)
data = {key: [] for key in posteriors[0]}
logger.debug(f"Downsampling to {max_samples} samples per posterior.")
self.samples_per_posterior = max_samples
for posterior in posteriors:
temp = posterior.sample(self.samples_per_posterior)
for key in data:
data[key].append(temp[key])
for key in data:
data[key] = xp.array(data[key])
return data