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

Properly parse energy states and occupations #832

Merged
merged 3 commits into from
Nov 7, 2022
Merged

Properly parse energy states and occupations #832

merged 3 commits into from
Nov 7, 2022

Conversation

pmrv
Copy link
Contributor

@pmrv pmrv commented Oct 22, 2022

Due to a faulty regex previously we threw away the signs of both energy states and occupations parsed from sphinx logs.

Due to a faulty regex previously we threw away the signs of both energy
states and occupations parsed from sphinx logs.
@pmrv pmrv added the bug Something isn't working label Oct 22, 2022
@coveralls
Copy link

coveralls commented Oct 22, 2022

Pull Request Test Coverage Report for Build 3402601774

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.007%) to 68.645%

Files with Coverage Reduction New Missed Lines %
pyiron_atomistics/lammps/structure.py 1 82.03%
Totals Coverage Status
Change from base Build 3401874913: -0.007%
Covered Lines: 12085
Relevant Lines: 17605

💛 - Coveralls

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

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?!

Copy link
Member

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!)

Suggested change
np.array(re.sub("[^-0-9\. ]", "", "".join(fa)).split())
np.array(re.sub("[^-?0-9\. ]", "", "".join(fa)).split())

Copy link
Contributor Author

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.

Copy link
Member

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...

@pmrv pmrv added the integration Start the notebook integration tests for this PR label Oct 24, 2022
The weird double application of regex matching was only to remove a
(constant) prefix.  This is more elegantly done with capture groups.
@pmrv pmrv added the format_black reformat the code using the black standard label Nov 6, 2022
@pmrv pmrv merged commit cf713bb into master Nov 7, 2022
@delete-merged-branch delete-merged-branch bot deleted the sphinx_sign branch November 7, 2022 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working format_black reformat the code using the black standard integration Start the notebook integration tests for this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants