Skip to content

Commit

Permalink
solve mypy issues and add pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-zero committed Jul 27, 2023
1 parent 3706fae commit e9b9e9b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ repos:
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
hooks:
- id: mypy
additional_dependencies: ["pydantic>=2"]
2 changes: 1 addition & 1 deletion cp2k_input_tools/basissets/cp2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def cp2k_format_line_iter(self) -> Iterator[str]:
yield f"{self.element:2} {' '.join(n for n in self.identifiers)}"
yield f" {len(self.blocks):2}" # the number of sets this basis set contains

max_exp = -min(c.as_tuple().exponent for b in self.blocks for r in b.coefficients for c in r)
max_exp = -min(int(c.as_tuple().exponent) for b in self.blocks for r in b.coefficients for c in r)
max_len = max(len(f"{c:.{max_exp}f}") for b in self.blocks for r in b.coefficients for c in r[1:])
max_len_exp = max(9 + max_exp, *(len(str(r[0])) for b in self.blocks for r in b.coefficients))

Expand Down
4 changes: 2 additions & 2 deletions cp2k_input_tools/pseudopotentials/cp2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ def all_coeffs():
if self.nlcc:
yield f" NLCC {len(self.nlcc):{i_fmt}}"

r_nlcc_max_exp = -min(nlcc.r.as_tuple().exponent for nlcc in self.nlcc)
r_nlcc_max_exp = -min(int(nlcc.r.as_tuple().exponent) for nlcc in self.nlcc)
r_nlcc_max_len = max(6 + r_nlcc_max_exp, *(len(f"{nlcc.r:.{r_nlcc_max_exp}f}") for nlcc in self.nlcc))

c_nlcc_max_exp = -min(nlcc.c.as_tuple().exponent for nlcc in self.nlcc)
c_nlcc_max_exp = -min(int(nlcc.c.as_tuple().exponent) for nlcc in self.nlcc)
c_nlcc_max_len = max(6 + c_nlcc_max_exp, *(len(f"{nlcc.c:.{c_nlcc_max_exp}f}") for nlcc in self.nlcc))

for nlcc in self.nlcc:
Expand Down
4 changes: 2 additions & 2 deletions cp2k_input_tools/pseudopotentials/ecp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class ECP(BaseModel, extra="forbid"):
def crystal_format_line_iter(self) -> Iterator[str]:
yield f"{self.Znuc} " + " ".join(str(m) for m in self.M)

exp_max_exp = -min(r[0].as_tuple().exponent for r in self.coefficients)
exp_max_exp = -min(int(r[0].as_tuple().exponent) for r in self.coefficients)
exp_max_len = max(exp_max_exp, *(len(f"{r[0]:.{exp_max_exp}f}") for r in self.coefficients))
coeff_max_exp = -min(r[1].as_tuple().exponent for r in self.coefficients)
coeff_max_exp = -min(int(r[1].as_tuple().exponent) for r in self.coefficients)
coeff_max_len = max(exp_max_exp, *(len(f"{r[1]:.{coeff_max_exp}f}") for r in self.coefficients))

for row in self.coefficients:
Expand Down

0 comments on commit e9b9e9b

Please sign in to comment.