Skip to content

Conversation

sbradnam
Copy link

Was attempting to convert an MCNP file, which had the word 'implicit' in one of the tally comment cards. This broke the _get_importances function in MCNPInputs so fixed with a startswith operation on the string.

@makeclean
Copy link
Owner

Sorry its taken me so long to look into this - there are instances where 'imp' occurs at the end of a string instead, which this would break I think. Would it make more sense to replace the line to search for 'imp:' instead?


# check for importance keyword
if "imp" in self.file_lines[idx]:
if self.file_lines[idx].startswith('imp'):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about checking the start and end of the line

Suggested change
if self.file_lines[idx].startswith('imp'):
if self.file_lines[idx].startswith('imp') or self.file_lines[idx].endswith('imp') :

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having just had a similar issue i found we already had a pr to fix
endswith wont work,
changing the search to "imp:" makes the most sense

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if self.file_lines[idx].startswith('imp'):
if self.file_lines[idx].startswith('imp:'):

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.

4 participants