Skip to content

[FEATURE] Adapter.pick() #509

Open
Open
@jerrymhuang

Description

@jerrymhuang

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

  1. (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])
    # ...
)

Metadata

Metadata

Assignees

Labels

featureNew feature or requestgood first issueGood for first-time contributorsuser interfaceChanges to the user interface and improvements in usability

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions