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

Integration of the mp-api client to pyEQL #227

Merged
merged 7 commits into from
Feb 26, 2025

Conversation

SuixiongTay
Copy link
Contributor

Description

This pull request integrates the mp-api client to the pourbaix branch of pyEQL.

1. Ion Reference Data from MPRester

  • Downloaded the complete set of ion reference data using the get_ion_reference_data from mp-api.
  • Data stored in json file within mpr_reference_ion_database.json.

2. Integration

  • Copied the below methods from the mp-api repository into pourbaix_api.py:
    • get_ion_reference_data_for_chemsys
    • get_ion_entries
    • get_pourbaix_entries

3. Test Integration

  • Copied test_get_pourbaix_entries and test_get_ion_entries from test_mprester.py.
  • New test file is renamed to test_pourbaix_api.py.

4. test_pourbaix_api.py Edits

  • Changed assert len(bi_v_entry_data) == len(bi_data) + v_data to assert len(bi_v_entry_data) == len(bi_data) + len(v_data).
  • Changed ref_solid_entry = [e for e in ion_ref_entries if e.entry_id == "mp-4770"][0] to ref_solid_entry = [e for e in ion_ref_entries if e.entry_id == "mp-4770-GGA"][0].

Example Usage

mpr = MPRester(MP_API_KEY)
pourbaix_api = Pourbaix_api(mpr) #create instance before using

bi_v_entry_data = pourbaix_api.get_ion_reference_data_for_chemsys("Bi-V")
...

@SuixiongTay
Copy link
Contributor Author

SuixiongTay commented Feb 25, 2025

Tagging @rkingsbury.

Is this error related to how test_pourbaix_diagram.py handles the json file?

Copy link

codecov bot commented Feb 25, 2025

Codecov Report

Attention: Patch coverage is 18.27957% with 76 lines in your changes missing coverage. Please review.

Please upload report for BASE (pourbaix@397b820). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/pyEQL/pourbaix/pourbaix_api.py 18.27% 76 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             pourbaix     #227   +/-   ##
===========================================
  Coverage            ?   71.71%           
===========================================
  Files               ?       13           
  Lines               ?     2680           
  Branches            ?      478           
===========================================
  Hits                ?     1922           
  Misses              ?      676           
  Partials            ?       82           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@rkingsbury rkingsbury left a comment

Choose a reason for hiding this comment

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

Thank you @SuixiongTay ! Just a few small edits and this will be ready to merge. Notably, please make sure you install and run pre-commit to apply linting and formatting to all the new code.

pre-commit install
pre-commit run --all-files

@rkingsbury
Copy link
Member

The test look good. We have an issue where tests occasionally fail (as happened here for 1-2 cases) due to some kind of disk or caching problem on the test runners; it means I just have to rerun the tests manually and they usually pass. So you're all good there.

@SuixiongTay
Copy link
Contributor Author

Thanks for the detailed comments @rkingsbury ! The current revision includes:

  • Ran pre-commit on the new code.
  • Added mp-api to pyproject.toml.

@rkingsbury rkingsbury merged commit 960b689 into KingsburyLab:pourbaix Feb 26, 2025
13 checks passed
@rkingsbury
Copy link
Member

Thanks @SuixiongTay !

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