-
Notifications
You must be signed in to change notification settings - Fork 867
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
Add min "thickness" check in CifParser
to filter invalid structure which leads to infinite loop
#4133
Add min "thickness" check in CifParser
to filter invalid structure which leads to infinite loop
#4133
Conversation
@anyangml I hope this looks good to you, with this patch your example would terminate gracefully: /Users/yang/developer/pymatgen/src/pymatgen/io/cif.py:1318: UserWarning: No structure parsed for section 1 in CIF.
lattice.volume=2.2009330203855426e-06 ų below threshold, double check your structure.
warnings.warn(msg)
/Users/yang/developer/pymatgen/src/pymatgen/io/cif.py:1322: UserWarning: Issues encountered while parsing CIF: No structure parsed for section 1 in CIF.
lattice.volume=2.2009330203855426e-06 ų below threshold, double check your structure.
warnings.warn("Issues encountered while parsing CIF: " + "\n".join(self.warnings))
Traceback (most recent call last):
File "/Users/yang/developer/pymatgen/debug/recreate_cif.py", line 15, in <module>
read_file("./example.cif")
File "/Users/yang/developer/pymatgen/debug/recreate_cif.py", line 6, in read_file
structure = cif.parse_structures(primitive=True)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yang/developer/pymatgen/src/pymatgen/io/cif.py", line 1325, in parse_structures
raise ValueError("Invalid CIF file with no structures!")
ValueError: Invalid CIF file with no structures! |
@anyangml May I have your permission to include your cif file as a test file for |
256b88b
to
328939a
Compare
e7b811b
to
c6876cb
Compare
c6876cb
to
e86e485
Compare
yes! |
Cool thanks! |
CifParser
to filter invalid structure which leads to infinite loopCifParser
to filter invalid structure which leads to infinite loop
@@ -969,8 +969,22 @@ def _get_structure( | |||
primitive: bool, | |||
symmetrized: bool, | |||
check_occu: bool = False, | |||
min_thickness: float = 0.01, |
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.
I hope this default minimal "thickness" of 0.01 Å would be a good default value (it's already "lower than it should be", but I just want to prevent false positive), is there any case that we might expect valid structure below this threshold?
Summary
CifParser
to filter invalid structure which leads to infinite loop, to fix CifParser taking forever without throwing an error #4028