Open
Description
Feature Description
Sometimes, users may want to cherry-pick only a portion of the simulation outputs under a set of customized indices. Take, for example:
# Here is a simple 5x5 matrix
mat = np.arange(25).reshape((5, 5))
# Indices for the lower triangle portion of mat (15 indices, in this case)
ix, iy = np.tril_indices(5)
# A flattened vector of shape (15,) extracted from mat
picks = mat[ix, iy]
This can happen during data configuration. The Adapter
could be used to take care of some simple scenarios like this by allowing the users to specify the portions they would like to pick()
from the simulation output.
Example Usages
- (simple scenario)
sim = {'x': np.random.rand(25)}
picks = [1, 2, 3, 5, 8]
adapter = (
bf.adapters.Adapter()
# ...
.pick('x', indices=picks)
# ...
)
2 (this scenario follows the example provided at the beginning)
sim = {'a': np.random.rand(25).reshape((5, 5))
ix, iy = np.tril_indices(5)
adapter = (
bf.adapters.Adapter()
# ...
.pick('a', indices=[ix, iy])
# ...
)