Skip to content

Commit a389f4b

Browse files
tpurcell90janosh
andauthored
Adding FHI-aims inputs developers (#3592)
* Adding FHI-aims inputs developers * fix ruff SIM300 Yoda conditions * fix ruff RUF025 Unnecessary dict comprehension for iterable; use dict.fromkeys instead * drop __all__ from io/aims/sets/core.py to discourage starred imports --------- Co-authored-by: Janosh Riebesell <[email protected]>
1 parent b40ce6e commit a389f4b

File tree

16 files changed

+52
-51
lines changed

16 files changed

+52
-51
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ci:
88

99
repos:
1010
- repo: https://github.com/astral-sh/ruff-pre-commit
11-
rev: v0.1.14
11+
rev: v0.1.15
1212
hooks:
1313
- id: ruff
1414
args: [--fix, --unsafe-fixes]
@@ -47,7 +47,7 @@ repos:
4747
- id: blacken-docs
4848

4949
- repo: https://github.com/igorshubovych/markdownlint-cli
50-
rev: v0.38.0
50+
rev: v0.39.0
5151
hooks:
5252
- id: markdownlint
5353
# MD013: line too long

docs/assets/metadata.yml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pymatgen/analysis/bond_valence.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def _calc_site_probabilities(self, site, nn):
181181
try:
182182
prob = {k: v / sum(prob.values()) for k, v in prob.items()}
183183
except ZeroDivisionError:
184-
prob = {key: 0 for key in prob}
184+
prob = dict.fromkeys(prob, 0)
185185
return prob
186186

187187
def _calc_site_probabilities_unordered(self, site, nn):
@@ -202,7 +202,7 @@ def _calc_site_probabilities_unordered(self, site, nn):
202202
try:
203203
prob[el] = {k: v / sum(prob[el].values()) for k, v in prob[el].items()}
204204
except ZeroDivisionError:
205-
prob[el] = {key: 0 for key in prob[el]}
205+
prob[el] = dict.fromkeys(prob[el], 0)
206206
return prob
207207

208208
def get_valences(self, structure: Structure):

pymatgen/analysis/elasticity/elastic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def get_structure_property_dict(
450450
)
451451
sp_dict: dict[str, float | Structure | None]
452452
if ignore_errors and (self.k_vrh < 0 or self.g_vrh < 0):
453-
sp_dict = {prop: None for prop in s_props}
453+
sp_dict = dict.fromkeys(s_props)
454454
else:
455455
sp_dict = {prop: getattr(self, prop)(structure) for prop in s_props}
456456
sp_dict["structure"] = structure

pymatgen/analysis/phase_diagram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ def get_chempot_range_map(
11751175
if referenced:
11761176
el_energies = {el: self.el_refs[el].energy_per_atom for el in elements}
11771177
else:
1178-
el_energies = {el: 0 for el in elements}
1178+
el_energies = dict.fromkeys(elements, 0)
11791179

11801180
chempot_ranges = collections.defaultdict(list)
11811181
vertices = [list(range(len(self.elements)))]

pymatgen/io/abinit/netcdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def structure_from_ncdata(ncdata, site_properties=None, cls=Structure):
344344

345345

346346
class _H:
347-
__slots__ = ("name", "doc", "etsf_name")
347+
__slots__ = ("doc", "etsf_name", "name")
348348

349349
def __init__(self, name, doc, etsf_name=None):
350350
self.name, self.doc, self.etsf_name = name, doc, etsf_name

pymatgen/io/aims/sets/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def get_input_files(self) -> tuple[str, str]:
7676
}
7777
updated_params = dict(**self._parameters)
7878
for prop in self._properties:
79-
aims_name = property_flags.get(prop, None)
79+
aims_name = property_flags.get(prop)
8080
if aims_name is not None:
8181
updated_params[aims_name] = True
8282

pymatgen/io/aims/sets/core.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
if TYPE_CHECKING:
1111
from pymatgen.core import Molecule
1212

13-
__all__ = ["StaticSetGenerator", "RelaxSetGenerator", "SocketIOSetGenerator"]
14-
1513

1614
@dataclass
1715
class StaticSetGenerator(AimsInputGenerator):

pymatgen/io/cp2k/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def get_unique_site_indices(struct: Structure | Molecule):
167167
for i, itm in enumerate(items):
168168
_sites[itm].append(i)
169169
sites = {}
170-
nums = {s: 1 for s in struct.symbol_set}
170+
nums = dict.fromkeys(struct.symbol_set, 1)
171171
for s in _sites:
172172
sites[f"{s[0]}_{nums[s[0]]}"] = _sites[s]
173173
nums[s[0]] += 1

pymatgen/io/nwchem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def from_molecule(
276276

277277
elements = set(mol.composition.get_el_amt_dict())
278278
if isinstance(basis_set, str):
279-
basis_set = {el: basis_set for el in elements}
279+
basis_set = dict.fromkeys(elements, basis_set)
280280

281281
return NwTask(
282282
charge,

0 commit comments

Comments
 (0)