-
Notifications
You must be signed in to change notification settings - Fork 24
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
convert + to ++ and - to -- in load4 #149
base: master
Are you sure you want to change the base?
Conversation
# Flag to automatically convert "+" to "++" on load in load4 | ||
# (and "-" to "--") | ||
AUTO_PROMOTE_HALPOL = True | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't bother with the flag. It'll error out if the flag is False, so it's not useful to reset it.
If you do want to keep it use "HALFPOL" rather than "HALPOL".
if AUTO_PROMOTE_HALPOL: | ||
for halfpol in ("+", "-"): | ||
if halfpol in data_by_xs: | ||
data_by_xs[halfpol*2] = data_by_xs.pop(halfpol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe want to warn if half-polarization is detected? Probably not.
We could check if halfpol*2 is already defined before promoting so we don't overwrite an existing ++ or –– cross-section, but I think that this is unlikely enough that we can blow it off.
The halfpol*2
is slightly magical. It may be cleaner to just write:
if '+' in data_by_xs:
data_by_xs['++'] = data_by_xs.pop('+')
if '-' in data_by_xs:
data_by_xs['--'] = data_by_xs.pop('-')
Or in anticipation of some other halfpol syntax:
_KEY_MAP = {'+': '++', '?+': '++', '+?': '++', '-': '--', '?-': '--', '-?': '--'}
for old, new in _KEY_MAP.items():
if value := data_by_xs.pop(old, None):
data_by_xs[new] = value
Worth revisiting?
possibly related? |
Agreed: this is a half-measure that can be abandoned in favor of the more rigorous solution being worked on. |
No description provided.