Skip to content

Commit

Permalink
Merge branch 'master' of github.com:materialsproject/pymatgen
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyue Ping Ong committed Nov 1, 2023
2 parents 69ae9b9 + d3ddce7 commit 9e7f55b
Show file tree
Hide file tree
Showing 108 changed files with 1,045 additions and 1,092 deletions.
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/jekyll-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Build with Jekyll
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,13 @@ jobs:

- name: Install dependencies
run: |
pip install --upgrade ruff black mypy
pip install --upgrade ruff mypy
- name: ruff
run: |
ruff --version
ruff .
- name: black
run: |
black --version
black --check --diff --color ${{ github.event.repository.name }}
ruff format --check .
- name: mypy
run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ venv/
ENV/
env.bak/
venv.bak/
**/secrets*
docs/tokens.py
12 changes: 4 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,21 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
rev: v0.1.3
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.6.1
hooks:
- id: mypy

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ If you use `pymatgen` in your research, please consider citing the following wor
In addition, some of `pymatgen`'s functionality is based on scientific advances/principles developed by the computational materials scientists in our team. Please refer to the [`pymatgen` docs] on how to cite them.

### Soliciting contributions to an updated pymatgen paper
### Soliciting contributions to 2nd `pymatgen` paper

If you are a long-standing `pymatgen` contributor and would like to be involved in working on an updated `pymatgen` publication,
please contact the maintainers [@shyuep, @mkhorton and @janosh](mailto:ongsp@ucsd.edu,m.k.horton@gmail.com,janosh@lbl.gov?subject=Contributing%20to%20updated%20pymatgen%20paper).
please fill out this [co-author registration form](https://docs.google.com/forms/d/e/1FAIpQLSecIhD2YjdPGldrRTM8Go3VxVg_vjKjZAOXtIKDG7qckHLYaQ/viewform) or contact [@shyuep, @mkhorton and @janosh](mailto:ongsp@ucsd.edu,m.k.horton@gmail.com,janosh@lbl.gov?subject=Contributing%20to%20updated%20pymatgen%20paper) with questions.

## License

Expand Down
7 changes: 3 additions & 4 deletions dev_scripts/chemenv/explicit_permutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ class Algo:
if len(cg.algorithms) != 1:
raise ValueError("Multiple algorithms !")
cg._algorithms = [ExplicitPermutationsAlgorithm(permutations=explicit_permutations)]
newgeom_dir = "new_geometry_files"
if not os.path.exists(newgeom_dir):
os.makedirs(newgeom_dir)
with open(f"{newgeom_dir}/{cg_symbol}.json", "w") as f:
new_geom_dir = "new_geometry_files"
os.makedirs(new_geom_dir, exist_ok=True)
with open(f"{new_geom_dir}/{cg_symbol}.json", "w") as f:
json.dump(cg.as_dict(), f)
3 changes: 1 addition & 2 deletions dev_scripts/chemenv/get_plane_permutations_optimized.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ def random_permutations_iterator(initial_permutation, n_permutations):
)
if test == "y":
new_geom_dir = "new_geometry_files"
if not os.path.exists(new_geom_dir):
os.makedirs(new_geom_dir)
os.makedirs(new_geom_dir, exist_ok=True)
with open(f"{new_geom_dir}/{cg_symbol}.json", "w") as file:
json.dump(cg.as_dict(), file)
6 changes: 3 additions & 3 deletions dev_scripts/potcar_scrambler.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ def to_file(self, filename: str):
with zopen(filename, "wt") as f:
f.write(self.scrambled_potcars_str)

@staticmethod
def from_file(input_filename: str, output_filename: str | None = None):
@classmethod
def from_file(cls, input_filename: str, output_filename: str | None = None):
psp = Potcar.from_file(input_filename)
psp_scrambled = PotcarScrambler(psp)
psp_scrambled = cls(psp)
if output_filename:
psp_scrambled.to_file(output_filename)
return psp_scrambled
Expand Down
2 changes: 1 addition & 1 deletion docs/fetch_pmg_contributors.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pymatgen/analysis/diffraction/tem.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ def x_ray_factors(
coeffs = np.array(ATOMIC_SCATTERING_PARAMS[atom.symbol])
for plane in bragg_angles:
scattering_factor_curr = atom.Z - 41.78214 * s2[plane] * np.sum(
coeffs[:, 0] * np.exp(-coeffs[:, 1] * s2[plane]), axis=None # type: ignore
coeffs[:, 0] * np.exp(-coeffs[:, 1] * s2[plane]),
axis=None, # type: ignore
)
scattering_factors_for_atom[plane] = scattering_factor_curr
x_ray_factors[atom.symbol] = scattering_factors_for_atom
Expand Down
3 changes: 2 additions & 1 deletion pymatgen/analysis/diffraction/xrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ def get_pattern(self, structure: Structure, scaled=True, two_theta_range=(0, 90)
# fs = el.Z - 41.78214 * s2 * sum(
# [d[0] * exp(-d[1] * s2) for d in coeff])
fs = zs - 41.78214 * s2 * np.sum(
coeffs[:, :, 0] * np.exp(-coeffs[:, :, 1] * s2), axis=1 # type: ignore
coeffs[:, :, 0] * np.exp(-coeffs[:, :, 1] * s2),
axis=1, # type: ignore
)

dw_correction = np.exp(-dwfactors * s2)
Expand Down
21 changes: 10 additions & 11 deletions pymatgen/analysis/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ def _initial_guess(self):
b0 = 2 * a * v0
b1 = 4 # b1 is usually a small number like 4

vmin, vmax = min(self.volumes), max(self.volumes)
vol_min, vol_max = min(self.volumes), max(self.volumes)

if not vmin < v0 and v0 < vmax:
raise EOSError("The minimum volume of a fitted parabola is not in the input volumes\n.")
if not vol_min < v0 and v0 < vol_max:
raise EOSError("The minimum volume of a fitted parabola is not in the input volumes.")

return e0, b0, b1, v0

Expand All @@ -77,8 +77,7 @@ def fit(self):
Do the fitting. Does least square fitting. If you want to use custom
fitting, must override this.
"""
# the objective function that will be minimized in the least square
# fitting
# the objective function that will be minimized in the least square fitting
self._params = self._initial_guess()
self.eos_params, ierr = leastsq(
lambda pars, x, y: y - self._func(x, pars),
Expand All @@ -87,7 +86,7 @@ def fit(self):
)
# e0, b0, b1, v0
self._params = self.eos_params
if ierr not in [1, 2, 3, 4]:
if ierr not in (1, 2, 3, 4):
raise EOSError("Optimal parameters not found")

@abstractmethod
Expand All @@ -97,8 +96,8 @@ def _func(self, volume, params):
that derive from this abstract class.
Args:
volume (float/numpy.array)
params (list/tuple): values for the parameters other than the
volume (float | list[float])
params (list | tuple): values for the parameters other than the
volume used by the eos.
"""

Expand All @@ -108,17 +107,17 @@ def func(self, volume):
to the ones obtained from fitting.
Args:
volume (list/numpy.array)
volume (float | list[float]): volumes in Ang^3
Returns:
numpy.array
"""
return self._func(np.array(volume), self.eos_params)

def __call__(self, volume):
def __call__(self, volume: float) -> float:
"""
Args:
volume (): Volume.
volume (float | list[float]): volume(s) in Ang^3
Returns:
Compute EOS with this volume.
Expand Down
Loading

0 comments on commit 9e7f55b

Please sign in to comment.