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

convert + to ++ and - to -- in load4 #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bmaranville
Copy link
Member

No description provided.

# Flag to automatically convert "+" to "++" on load in load4
# (and "-" to "--")
AUTO_PROMOTE_HALPOL = True

Copy link
Member

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)
Copy link
Member

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

@glass-ships
Copy link
Member

Worth revisiting?

Implement half-polarized probe, that sums e.g. ++ and +- theory xs to compare to + summed data

possibly related?

@bmaranville
Copy link
Member Author

Agreed: this is a half-measure that can be abandoned in favor of the more rigorous solution being worked on.

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

Successfully merging this pull request may close these issues.

3 participants