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

Extracting the knobs of a sequence #34

Open
sterbini opened this issue Nov 10, 2020 · 0 comments
Open

Extracting the knobs of a sequence #34

sterbini opened this issue Nov 10, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@sterbini
Copy link
Contributor

Hi,

I would also add

def knobs_df(my_df):
    '''
    Extract the knob list of a pandas DF (it assumes that DF has a column called "knobs")
    and contanting lists
    
    Args:
        my_df: a pandas DF (it assumes that DF has a column called "knobs").
    Returns:
        A data frame of knobs.
    '''
    import itertools
    import numpy as np
    aux= list(my_df['knobs'].values)
    aux= list(np.unique(list(itertools.chain.from_iterable(aux))))
    my_dict={}
    for i in aux:
        my_dict[i]={}
        filter_df=knob_df(i, my_df)
        my_dict[i]['multeplicity']=len(filter_df)
        my_dict[i]['dependences']=list(filter_df.index)
    return pd.DataFrame(my_dict).transpose().sort_values('multeplicity', ascending=False)

to extract and sort "by-use" the knobs of a sequence or of the global space of MAD-X.
Cheers,

@giadarol giadarol added the enhancement New feature or request label Nov 22, 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

2 participants