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

Debug OUTCAR and CHGCAR parsing #185

Merged
merged 7 commits into from
Mar 20, 2019
Merged

Debug OUTCAR and CHGCAR parsing #185

merged 7 commits into from
Mar 20, 2019

Conversation

sudarsan-surendralal
Copy link
Member

No description provided.

@coveralls
Copy link

coveralls commented Mar 20, 2019

Pull Request Test Coverage Report for Build 1300

  • 20 of 31 (64.52%) changed or added relevant lines in 4 files are covered.
  • 41 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.003%) to 66.245%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pyiron/vasp/outcar.py 2 4 50.0%
pyiron/vasp/volumetric_data.py 10 19 52.63%
Files with Coverage Reduction New Missed Lines %
pyiron/base/job/generic.py 41 58.12%
Totals Coverage Status
Change from base Build 1284: -0.003%
Covered Lines: 11424
Relevant Lines: 17245

💛 - Coveralls

sudarsan-surendralal and others added 3 commits March 20, 2019 17:15
when confronting empty files
when confronting empty files. Only parse if not empty. Else return None
@sudarsan-surendralal sudarsan-surendralal changed the title Debug OUTCAR for line mode Debug OUTCAR and CHGCAR parsing Mar 20, 2019
@jan-janssen
Copy link
Member

I guess the file size part is already fixed in #188

@sudarsan-surendralal
Copy link
Member Author

sudarsan-surendralal commented Mar 20, 2019

Then can we somehow merge these two requests

@@ -150,6 +151,8 @@ def _read_vol_data(self, filename, normalize=True):
list: A list of the volumetric data (length >1 for CHGCAR files with spin)

"""
if os.stat(filename).st_size == 0:
Copy link
Member

Choose a reason for hiding this comment

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

To have the same behaviour when parsing empty files we should also raise a warning here:
s.logger.warning("File:" + filename + "seems to be corrupted/empty")

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed here

@@ -69,6 +69,8 @@ class with very minor modifications. The new parser is faster
normalize (boolean): Flag to normalize by the volume of the cell

"""
if os.stat(filename).st_size == 0:
Copy link
Member

Choose a reason for hiding this comment

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

To have the same behaviour when parsing empty files we should also raise a warning here:
s.logger.warning("File:" + filename + "seems to be corrupted/empty")

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed here

line_ngx = lines[trigger_indices[0]-2]
try:
line_ngx = lines[trigger_indices[0]-2]
except IndexError:
Copy link
Member

Choose a reason for hiding this comment

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

I do not really like the try except style, because in my feeling this might surpress other errors, therefore I would prefer to check the file size and raise an error directly.

Copy link
Member Author

Choose a reason for hiding this comment

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

This fix is unrelated to the CHGCAR parsing fix. This is for calculations using the line mode kpoints (for band structures like Felix does) where theese lines are missing. I think this is an appropriate way to handle this. This pull request handles bugs in the OUTCAR parser as well.

Copy link
Member

Choose a reason for hiding this comment

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

Can not we simply check the length of the trigger_indices ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. But the only possible error that can be raised in this case is an IndexError. In 99% of the cases the if statement will be True. So using the EAFP philosophy a try and except statement would be better

Copy link
Member

Choose a reason for hiding this comment

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

That is right. Personally I still prefer to have the if statement, as it is just one line of code and I can not see how it helps to clean the code by adding more lines.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, implemented here

@sudarsan-surendralal sudarsan-surendralal merged commit b395959 into master Mar 20, 2019
@jan-janssen jan-janssen deleted the debug_outcar branch March 21, 2019 07:52
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