materialsproject / api

New API client for the Materials Project
https://materialsproject.github.io/api/
Other
107 stars 39 forks source link

`MPRester.get_entries_in_chemsys` returns duplicate entries for repeated element queries #735

Closed mattmcdermott closed 1 year ago

mattmcdermott commented 1 year ago

If a user accidentally provides a repeated element when querying for entries in a chemical system, then the current behavior of the MPRester.get_entries_in_chemsys method returns duplicate entries. I ran into this in a real application when I was querying for a much larger system and had a duplicate element added.

with MPRester() as mpr:
    entries = mpr.get_entries_in_chemsys("Ti-Ti")

print(len(entries))
print(len(set(entries)))

returns:

20
10

I will open a PR to delete duplicate elements from the user's request, as I think this should be the default behavior.

munrojm commented 1 year ago

@mattmcdermott, I agree with you. Thank you for catching this and offering to fix it!

mattmcdermott commented 1 year ago

Closed with #736