Skip to content

feat: add function that returns cif filenames based on chemical formula #336

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

Closed
wants to merge 5 commits into from

Conversation

yucongalicechen
Copy link
Contributor

Task 2 in #331
@sbillinge ready for review

Copy link

codecov bot commented May 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (a51b553) to head (4c1521f).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #336   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            9         9           
  Lines          516       525    +9     
=========================================
+ Hits           516       525    +9     
Files with missing lines Coverage Δ
tests/test_tools.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

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

is there a reason you are using beautiful soup and not making an API call to COD?

@yucongalicechen
Copy link
Contributor Author

is there a reason you are using beautiful soup and not making an API call to COD?

Whoops not really, that was a mistake. I've corrected the function now :)

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

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

that looks better. What is the payload from the API call? I am a bit confused that there are cif files involved. Doesn't it send json or sthg like that?

@yucongalicechen
Copy link
Contributor Author

that looks better. What is the payload from the API call? I am a bit confused that there are cif files involved. Doesn't it send json or sthg like that?

Yes, the API returns a json file. I implemented something similar to what I saw here https://github.com/materialsproject/pymatgen/blob/master/src/pymatgen/ext/cod.py. I was thinking it might be cleaner if we extract the cif filenames, so that when we compute the density we can pass the cif filenames as arguments. If we keep the functions for computing density private, it would be easier to work with the json files directly?

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

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

this looks good. Two quick questions:

  1. why are we dealing with cif files? Is there a way to get the data without files involved?
  2. Let's think about whether we want to use the pymatgen wrapper directly. Downside is we then have pymatgen as a dependency. Another Downside is that we can then only do things that pymatgetn can do. Upside is that they maintain that code. Let's just think about it for a bit.

But issue (1) is more problematic for me if we can avoid it.

@yucongalicechen
Copy link
Contributor Author

this looks good. Two quick questions:

  1. why are we dealing with cif files? Is there a way to get the data without files involved?
  2. Let's think about whether we want to use the pymatgen wrapper directly. Downside is we then have pymatgen as a dependency. Another Downside is that we can then only do things that pymatgetn can do. Upside is that they maintain that code. Let's just think about it for a bit.

But issue (1) is more problematic for me if we can avoid it.

We don't need the cif files, from the purpose of computing density we can stop at data = response.json() and use the json file directly. At this point I don't think we need pymatgen because it removed quite a lot of densities for common chemical compositions.

@sbillinge
Copy link
Contributor

We don't need the cif files, from the purpose of computing density we can stop at data = response.json() and use the json file directly. At this point I don't think we need pymatgen because it removed quite a lot of densities for common chemical compositions.

Shall we close this then, since we don't need this function?

@yucongalicechen
Copy link
Contributor Author

We don't need the cif files, from the purpose of computing density we can stop at data = response.json() and use the json file directly. At this point I don't think we need pymatgen because it removed quite a lot of densities for common chemical compositions.

Shall we close this then, since we don't need this function?

Yep, closing this, made a new PR on computing density based on a json file in #338

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.

2 participants