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
Deprecate CifParser.get_structures()
in favor of new parse_structures
in which primitive
defaults to False
#3419
Conversation
…() remain consistent in the future
… keyword only passed to CIF
I fear this will break a lot of code! Can one alert users about this change? |
Pls do not do this kind of thing. No breaking change unless absolutely necessary. |
We have lived with this for many years. Most people use Structure.from . Pls don't worry about this. |
Concur, we should leave it as is. I agree it’s a bad default but a breaking change is worse. For the specific example, MP has had issues in the other direction in the past too; for example accidentally calculating supercells because a primitive transformation was not applied, or calculating awkwardly-defined cells when a more reasonable basis might exist etc. Any default might give unwanted results in some cases. |
I will state this outright - any Pr that has a breaking change for end users must have at least two maintainer reviews. There is a balance to be struck here. There are a lot of things that can be done better in pymatgen but will also cause all hell to break loose in a lot of downstream code. We do not break user code unless it is extremely compelling. |
I see conflicting arguments here. Either most people use Good defaults are more important than no breaking changes imo. Breaking changes are a one time cost, a bad default will trip users up forever. If @esoteric-ephemera and myself can be bitten by this, it can happen to anyone.
@mkhorton If a user wants a primitive cell and forgets to reduce, that's their mistake. If a user loads a CIF file and expects it to remain as is but we silently reduce it, that's us laying a trap. We should not lay traps! |
The point is that it is unnecessary. CifParser predates Structure.from_file. There is a lot of legacy code that uses that. Even if you are willing to commit to fixing all intra MP code, you cannot fix code from other users. So you are imposing a huge cost on the community just for the sake of API cleanliness. Structure.from_file is more modern and used by newer users. In short, there is a lot of legacy stuff that can be fixed but will cause unnecessary headaches. It is pointless to do. Even if you want to do it, then you should do it instead in a NEW method name other than get_structures and then deprecate get_structures for a good long while. |
To chime in here, while most regular users of Pymatgen use Case and point: Me to ChatGPT: How do I read a CIF file with Pymatgen? Obviously the syntax is wrong, but you can see how one might go from this to the |
I personally also think that breaking changes should be introduced very carefully, especially to such a core part. |
…ew parse_structures() method
Alright, I deprecated Sounds like people would be ok with that? Happy to accommodate further suggestions. |
I would be in general careful with breaking changes and leave this really for several versions. I would btw point out more clearly that there is indeed a big difference in the default behaviour! |
Not sure I follow. Feel free to write a comment in the code what should be clearer. |
primitive=True
to False
in CifParser.get_structures()
CifParser.get_structures()
in favor of new parse_structures
in which primitive
defaults to True
CifParser.get_structures()
in favor of new parse_structures
in which primitive
defaults to True
CifParser.get_structures()
in favor of new parse_structures
in which primitive
defaults to False
return self.parse_structures(*args, **kwargs) E TypeError: CifParser.parse_structures() got multiple values for argument 'primitive'
Motivation
CifParser.get_structures('some.cif')[0]
andStructure.from_file('some.cif')
currently return different cells. Andprimitive=True
seems like a bad default. Cell reduction seems like something the user should request explicitly.Context
This came up in the MP ingestion of new ICSD structures added since 2019 with @esoteric-ephemera.
@shyuep @mkhorton Let me know if you disagree.