-
Notifications
You must be signed in to change notification settings - Fork 15
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
Properly parse energy states and occupations #832
Conversation
Due to a faulty regex previously we threw away the signs of both energy states and occupations parsed from sphinx logs.
Pull Request Test Coverage Report for Build 3402601774
💛 - Coveralls |
pyiron_atomistics/sphinx/base.py
Outdated
@@ -2124,7 +2124,7 @@ def n_steps(self): | |||
def _parse_band(self, term): | |||
fa = re.findall(term, self.log_main, re.MULTILINE) | |||
arr = ( | |||
np.array(re.sub("[^0-9\. ]", "", "".join(fa)).split()) | |||
np.array(re.sub("[^-0-9\. ]", "", "".join(fa)).split()) |
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.
Now this only works on negative quantities?!
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.
wouldn't this allow, but not require a -
sign? (Not tested!)
np.array(re.sub("[^-0-9\. ]", "", "".join(fa)).split()) | |
np.array(re.sub("[^-?0-9\. ]", "", "".join(fa)).split()) |
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.
No, this regex matches everything []
that is not ^
a -
, 0-9
, \.
(plain dot, \
is for escaping) or
and replaces it by the empty string. This leaves just numbers and spaces, which are then "parsed". Because the regex previously also matched the -
the parsed number were effectively only the absolute value.
Actually the whole regex business is too complicated, because in the sphinx log the lines are of the form some text: number number number
. So removing that prefix would be enough.
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.
Well in that case, it souds like an easier and more stable solution to replace everything until a colon (being greedy it will be the last colon) by the empty string and parsing the numbers. Right now, a single -
in the string would again flip the sign of the first number...
The weird double application of regex matching was only to remove a (constant) prefix. This is more elegantly done with capture groups.
Due to a faulty regex previously we threw away the signs of both energy states and occupations parsed from sphinx logs.