Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function to return fancy index list for pysb parameters #3

Open
blakeaw opened this issue Oct 20, 2020 · 0 comments
Open

function to return fancy index list for pysb parameters #3

blakeaw opened this issue Oct 20, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@blakeaw
Copy link
Collaborator

blakeaw commented Oct 20, 2020

It would be good to add a function to SwarmParam which can return the list of indices needed for fancy indexing the set of parameters. The current mask function which returns a boolean mask currently only works if parameters are added to a SwarmParam instance in the same relative order in which they are defined in model.parameters. Having a function to instead return the list of indices for fancy indexing would more easily accommodate adding parameters to SwarmParam out of order. This function accomplishes this task:

def fancy_index(swarm_param, parameters):
    idxs = list()
    for name in swarm_param.names():
        i = 0
        for parm in parameters:
            if parm.name == name:
                idxs.append(i)
                break
            i += 1
    return idxs

So, that can be adapted as a member function to SwarmParam.

@blakeaw blakeaw added the enhancement New feature or request label Oct 20, 2020
@blakeaw blakeaw changed the title function to return fancy index list function to return fancy index list for pysb parameters Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant