Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Jan 16, 2023
1 parent b3bbaf0 commit 8e93842
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pymatgen/analysis/dimensionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def find_clusters(struct, connected_matrix):

def visit(atom, atom_cluster):
visited[atom] = True
new_cluster = set(np.where(connected_matrix[atom] != 0)[0]) | {atom_cluster}
new_cluster = set(np.where(connected_matrix[atom] != 0)[0]) | atom_cluster
atom_cluster = new_cluster
for new_atom in atom_cluster:
if not visited[new_atom]:
Expand Down
16 changes: 8 additions & 8 deletions pymatgen/analysis/phase_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,16 +627,16 @@ def _get_facet_chempots(self, facet):
Returns:
{element: chempot} for all elements in the phase diagram.
"""
complist = [self.qhull_entries[i].composition for i in facet]
energylist = [self.qhull_entries[i].energy_per_atom for i in facet]
m = [[c.get_atomic_fraction(e) for e in self.elements] for c in complist]
chempots = np.linalg.solve(m, energylist)
comp_list = [self.qhull_entries[i].composition for i in facet]
energy_list = [self.qhull_entries[i].energy_per_atom for i in facet]
m = [[c.get_atomic_fraction(e) for e in self.elements] for c in comp_list]
chempots = np.linalg.solve(m, energy_list)

return dict(zip(self.elements, chempots))

def _get_simplex_intersections(self, c1, c2):
"""
Returns coordinates of the itersection of the tie line between two compositions
Returns coordinates of the intersection of the tie line between two compositions
and the simplexes of the PhaseDiagram.
Args:
Expand Down Expand Up @@ -895,15 +895,15 @@ def get_decomp_and_phase_separation_energy(
"additional unstable entries"
)

reduced_space = competing_entries - {self._get_stable_entries_in_space(entry_elems)} | {
self.el_refs.values()
reduced_space = competing_entries - {*self._get_stable_entries_in_space(entry_elems)} | {
*self.el_refs.values()
}

# NOTE calling PhaseDiagram is only reasonable if the composition has fewer than 5 elements
# TODO can we call PatchedPhaseDiagram here?
inner_hull = PhaseDiagram(reduced_space)

competing_entries = inner_hull.stable_entries | {self._get_stable_entries_in_space(entry_elems)}
competing_entries = inner_hull.stable_entries | {*self._get_stable_entries_in_space(entry_elems)}
competing_entries = {c for c in compare_entries if id(c) not in same_comp_mem_ids}

if len(competing_entries) > space_limit:
Expand Down
7 changes: 3 additions & 4 deletions pymatgen/core/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,7 @@ def from_weight_dict(cls, weight_dict) -> Composition:
Returns:
Composition
"""

weight_sum = sum([val / Element(el).atomic_mass for el, val in weight_dict.items()])
weight_sum = sum(val / Element(el).atomic_mass for el, val in weight_dict.items())
comp_dict = {el: val / Element(el).atomic_mass / weight_sum for el, val in weight_dict.items()}

return cls(comp_dict)
Expand Down Expand Up @@ -1278,13 +1277,13 @@ def __truediv__(self, other: object) -> ChemicalPotential:

def __sub__(self, other: object) -> ChemicalPotential:
if isinstance(other, ChemicalPotential):
els = {*self} | {other}
els = set(self) | {other}
return ChemicalPotential({e: self.get(e, 0) - other.get(e, 0) for e in els})
return NotImplemented

def __add__(self, other: object) -> ChemicalPotential:
if isinstance(other, ChemicalPotential):
els = {*self} | {other}
els = set(self) | {other}
return ChemicalPotential({e: self.get(e, 0) + other.get(e, 0) for e in els})
return NotImplemented

Expand Down
7 changes: 4 additions & 3 deletions pymatgen/ext/optimade.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def get_structures_with_filter(self, optimade_filter: str) -> dict[str, dict[str
Get structures satisfying a given OPTIMADE filter.
Args:
filter: An OPTIMADE-compliant filter
optimade_filter: An OPTIMADE-compliant filter
Returns: Dict of Structures keyed by that database's id system
"""
Expand All @@ -296,7 +296,8 @@ def get_snls_with_filter(
Get structures satisfying a given OPTIMADE filter.
Args:
filter: An OPTIMADE-compliant filter
optimade_filter: An OPTIMADE-compliant filter
additional_response_fields: Any additional fields desired from the OPTIMADE API,
Returns: Dict of Structures keyed by that database's id system
"""
Expand Down Expand Up @@ -534,7 +535,7 @@ def _handle_response_fields(self, additional_response_fields: str | list[str] |
additional_response_fields = {additional_response_fields}
if not additional_response_fields:
additional_response_fields = set()
return ",".join({additional_response_fields} | self.mandatory_response_fields)
return ",".join({*additional_response_fields} | self.mandatory_response_fields)

def refresh_aliases(self, providers_url="https://providers.optimade.org/providers.json"):
"""
Expand Down

0 comments on commit 8e93842

Please sign in to comment.