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

Change how WC values are passed to datacard maker #413

Open
bryates opened this issue May 17, 2024 · 0 comments
Open

Change how WC values are passed to datacard maker #413

bryates opened this issue May 17, 2024 · 0 comments
Assignees

Comments

@bryates
Copy link
Contributor

bryates commented May 17, 2024

# convert wc_vals string to a dictionary
wc_vals = ''.join(wc_vals)
wcs_dict = eval("dict({})".format(wc_vals))

These seems really fragile. If I'm not mistaken, it relies on the user specifying the arguments to --wc-vals as NAME=VAL, (note the trailing ,).

I suggest that either force the argument to --wc-vals be a single long string, ala NAME1=VAL1,NAME2=VAL2,... or change the action to 'extend' and indicate that each entry should be of the form NAME=VAL. To make the above code work with this latter case, you can do:

wc_vals = [x.split('=') for x in wc_vals]
wcs_dict = {k: float(x) for k,v in wc_vals}

I personally prefer the 2nd option as it only relies on the user needing to know to use the = as delimiter and this is made obvious if they look at the code, i.e. the x.split('=') line.

Originally posted by @Andrew42 in #406 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants