Skip to content

Commit

Permalink
Fix ruff N806 (#3394)
Browse files Browse the repository at this point in the history
* fix typo

* snake_case names

* release.yml add 📦 Dependencies and 🏷️ Type Hints
  • Loading branch information
janosh authored Oct 10, 2023
1 parent c1e1e0d commit 14a6c56
Show file tree
Hide file tree
Showing 9 changed files with 325 additions and 326 deletions.
4 changes: 4 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@ changelog:
labels: [security]
- title: 🏥 Package Health
labels: [pkg]
- title: 📦 Dependencies
labels: [dependencies, outdated]
- title: 🏷️ Type Hints
labels: [types]
- title: 🤷‍♂️ Other Changes
labels: ["*"]
12 changes: 6 additions & 6 deletions pymatgen/analysis/chempot_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,14 @@ def _get_2d_plot(self, elements: list[Element], label_stable: bool | None, eleme
pts_2d[:, idx] = np.where(np.isclose(col, self.default_min_limit), new_lim, col)

entry = self.entry_dict[formula]
ann_formula = formula
anno_formula = formula
if hasattr(entry, "original_entry"):
ann_formula = entry.original_entry.composition.reduced_formula
anno_formula = entry.original_entry.composition.reduced_formula

center = pts_2d.mean(axis=0)
normal = get_2d_orthonormal_vector(pts_2d)
ann_loc = center + 0.25 * normal # offset annotation location by arb. amount
annotation = self._get_annotation(ann_loc, ann_formula)
annotation = self._get_annotation(ann_loc, anno_formula)
annotations.append(annotation)

draw_domains[formula] = pts_2d
Expand Down Expand Up @@ -353,11 +353,11 @@ def _get_3d_plot(

simplexes, ann_loc = self._get_3d_domain_simplexes_and_ann_loc(pts_3d)

ann_formula = formula
anno_formula = formula
if hasattr(entry, "original_entry"):
ann_formula = entry.original_entry.composition.reduced_formula
anno_formula = entry.original_entry.composition.reduced_formula

annotation = self._get_annotation(ann_loc, ann_formula)
annotation = self._get_annotation(ann_loc, anno_formula)
annotations.append(annotation)

domain_simplexes[formula] = simplexes
Expand Down
16 changes: 8 additions & 8 deletions pymatgen/analysis/molecule_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def uniform_labels(self, mol1, mol2):
of the two molecules. The value of each element is the original
atom index in mol1 or mol2 of the current atom in uniform atom
order.
(None, None) if unform atom is not available.
(None, None) if uniform atom is not available.
"""

@abc.abstractmethod
Expand All @@ -81,10 +81,10 @@ def get_molecule_hash(self, mol):
"""

@classmethod
def from_dict(cls, d):
def from_dict(cls, dct):
"""
Args:
d (dict): Dict representation.
dct (dict): Dict representation.
Returns:
AbstractMolAtomMapper
Expand All @@ -95,12 +95,12 @@ def from_dict(cls, d):
f"pymatgen.analysis.{trans_modules}",
globals(),
locals(),
[d["@class"]],
[dct["@class"]],
level,
)
if hasattr(mod, d["@class"]):
class_proxy = getattr(mod, d["@class"])
return class_proxy.from_dict(d)
if hasattr(mod, dct["@class"]):
class_proxy = getattr(mod, dct["@class"])
return class_proxy.from_dict(dct)
raise ValueError("Invalid Comparator dict")


Expand All @@ -124,7 +124,7 @@ def uniform_labels(self, mol1, mol2):
of the two molecules. The value of each element is the original
atom index in mol1 or mol2 of the current atom in uniform atom
order.
(None, None) if unform atom is not available.
(None, None) if uniform atom is not available.
"""
ob_mol1 = BabelMolAdaptor(mol1).openbabel_mol
ob_mol2 = BabelMolAdaptor(mol2).openbabel_mol
Expand Down
7 changes: 1 addition & 6 deletions pymatgen/core/periodic_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,12 +631,7 @@ def is_noble_gas(self) -> bool:
@property
def is_transition_metal(self) -> bool:
"""True if element is a transition metal."""
ns = list(range(21, 31))
ns.extend(list(range(39, 49)))
ns.append(57)
ns.extend(list(range(72, 81)))
ns.append(89)
ns.extend(list(range(104, 113)))
ns = (*range(21, 31), *range(39, 49), 57, *range(72, 81), 89, *range(104, 113))
return self.Z in ns

@property
Expand Down
26 changes: 13 additions & 13 deletions pymatgen/electronic_structure/cohp.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,28 @@ def __init__(self, efermi, energies, cohp, are_coops=False, are_cobis=False, ico
def __repr__(self):
"""Returns a string that can be easily plotted (e.g. using gnuplot)."""
if self.are_coops:
cohpstring = "COOP"
cohp_str = "COOP"
elif self.are_cobis:
cohpstring = "COBI"
cohp_str = "COBI"
else:
cohpstring = "COHP"
header = ["Energy", cohpstring + "Up"]
cohp_str = "COHP"
header = ["Energy", cohp_str + "Up"]
data = [self.energies, self.cohp[Spin.up]]
if Spin.down in self.cohp:
header.append(cohpstring + "Down")
header.append(cohp_str + "Down")
data.append(self.cohp[Spin.down])
if self.icohp:
header.append("I" + cohpstring + "Up")
header.append("I" + cohp_str + "Up")
data.append(self.icohp[Spin.up])
if Spin.down in self.cohp:
header.append("I" + cohpstring + "Down")
header.append("I" + cohp_str + "Down")
data.append(self.icohp[Spin.down])
formatheader = "#" + " ".join("{:15s}" for __ in header)
formatdata = " ".join("{:.5f}" for __ in header)
stringarray = [formatheader.format(*header)]
for i, __ in enumerate(self.energies):
stringarray.append(formatdata.format(*(d[i] for d in data)))
return "\n".join(stringarray)
format_header = "#" + " ".join("{:15s}" for __ in header)
format_data = " ".join("{:.5f}" for __ in header)
str_arr = [format_header.format(*header)]
for idx in range(len(self.energies)):
str_arr.append(format_data.format(*(d[idx] for d in data)))
return "\n".join(str_arr)

def as_dict(self):
"""JSON-serializable dict representation of COHP."""
Expand Down
Loading

0 comments on commit 14a6c56

Please sign in to comment.