-
Notifications
You must be signed in to change notification settings - Fork 144
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
adding ASE compatibility to Crystal class #534
Conversation
After a little playing around I'm not sure how useful the generic file reader is, I forgot that standard xyz files don't contain cell params. I think the majority of the other supported file types are MD related. So I think I'll remove the generic function and add in |
Updated to have |
1 similar comment
Updated to have |
Thanks @alex-rakowski , this is a great idea! Two questions: (1) dependency: right now you import
(2) tests: our test suite is still far from robust...but its got better coverage in IO than anywhere else, and I'd love to ideally not reduce that coverage. The pipeline for testing file read stuff should be pretty easy to add (a) new file(s) + test(s) to. If you drop some new test files in our usual sample file drive and modify the |
try: | ||
from ase.io import read | ||
except ImportError: | ||
pass |
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.
For an optional dependency that is not needed at the top level of the file, I think a better pattern is to move the import within the function that requires it. That way any import errors get raised at the appropriate moment.
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'm going to delete as its now a dependency
if find_spec("ase") is None: | ||
raise ImportWarning( | ||
"Could not import ASE, please install, restart and try again" | ||
) | ||
else: | ||
from ase.io import read |
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.
Is all this extra logic necessary? If ase
is missing it will raise a ModuleNotFoundError
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'm going to delete as its now a dependency
@sezelt Are you planning on creating a new PR for your CIF occupancy, adding into this one, or do you want to send me the code snippet and I can add it? |
closing as this will be wrapped in to #538 |
Added two functions:
from_ASE
creates Crystal fromase.Atom
objectfrom_generic_file
tries to create a Crystal usingase.io.read
tested using a CIF file, but should add a lot of file types. This might need a better name.