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 Feb 21, 2023
2 parents 3668645 + 4033e82 commit 13a860a
Show file tree
Hide file tree
Showing 213 changed files with 1,813 additions and 3,151 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.11'
cache: pip
cache-dependency-path: setup.py

- name: Install dependencies
run: |
pip install --upgrade pip
pip install -e '.[dev]'
- name: pylint
- name: ruff
run: |
pylint pymatgen
ruff --version
ruff check . --ignore 'D,SIM'
- name: black
run: |
black --version
black --check --diff --color pymatgen
- name: flake8
run: |
flake8 --version
flake8 --count --show-source --statistics pymatgen
# exit-zero treats all errors as warnings.
flake8 --count --exit-zero --max-complexity=20 --statistics pymatgen
- name: mypy
run: |
mypy --version
Expand Down
45 changes: 6 additions & 39 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@ exclude: ^(docs|.*test_files|cmd_line|tasks.py)

ci:
autoupdate_schedule: monthly
skip: [mypy, pylint, codespell, pydocstyle]
skip: [mypy, codespell]

repos:
- repo: https://github.com/PyCQA/autoflake
rev: v2.0.1
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.247
hooks:
- id: autoflake

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py38-plus]
- id: ruff
args: [--fix, --ignore, 'D,SIM']

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
Expand All @@ -24,38 +19,16 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
args: [--profile, black]

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

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
rev: v1.0.1
hooks:
- id: mypy

- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: python
types: [python]
args: [-sn, --rcfile=pylintrc]
additional_dependencies: [pylint]

- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
hooks:
Expand All @@ -64,12 +37,6 @@ repos:
exclude_types: [html]
args: [--ignore-words-list, 'titel,titels,reson,rute,pres,kno,coo']

- repo: https://github.com/PyCQA/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
exclude: tests

- repo: https://github.com/MarcoGorelli/cython-lint
rev: v0.12.4
hooks:
Expand Down
20 changes: 10 additions & 10 deletions ADMIN.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
# Introduction

This documentation provides a guide for pymatgen administrators. The
following assumes you are using miniconda or Anaconda.
This documentation provides a guide for `pymatgen` administrators. The
following assumes you are using `miniconda` or Anaconda.

## Releases

The general procedure to releasing pymatgen comprises the following
The general procedure to releasing `pymatgen` comprises the following
steps:

1. Make sure all CI checks are green. We don't want to release known bugs.
2. Update and edit change log.
3. Release PyPI versions + doc.
4. Release conda versions.
4. Release `conda` versions.
5. Release Dash documentation.

## Initial setup

Install some conda tools first:
Install some `conda` tools first:

```sh
conda install --yes conda-build anaconda-client
```

Pymatgen uses [invoke](http://www.pyinvoke.org/) to automate releases.
Pymatgen uses [invoke](http://pyinvoke.org) to automate releases.
You will also need sphinx and doc2dash. Install these using:

```sh
pip install --upgrade invoke sphinx doc2dash
```

Create environment for py38 using conda:
Create environment for py38 using `conda`:

```sh
conda create --yes -n py38 python=3.8
```

For each env, install some packages using conda followed by dev install
for pymatgen:
For each env, install some packages using `conda` followed by dev install
for `pymatgen`:

```sh
conda install --yes numpy scipy sympy matplotlib cython
Expand Down Expand Up @@ -105,7 +105,7 @@ generated by Appveyor.

Fork and clone the
[materials.sh](https://github.com/materialsvirtuallab/materials.sh).
This repo contains the conda skeletons to build the conda versions for
This repo contains the `conda` skeletons to build the `conda` versions for
various matsci codes on the Anaconda [matsci
channel](https://anaconda.org/matsci).

Expand Down
4 changes: 2 additions & 2 deletions dev_scripts/chemenv/get_plane_permutations_optimized.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def random_permutations_iterator(initial_permutation, n_permutations):
exit()
# 2. Optimization of the permutations
print(f"Getting explicit optimized permutations for geometry {cg.name!r} (symbol : {cg_symbol!r})\n")
perms_used_algos = [dict() for algo in cg.algorithms]
perms_used_algos = [{} for algo in cg.algorithms]

# Loop on algorithms
for ialgo, algo in enumerate(cg.algorithms):
Expand Down Expand Up @@ -357,7 +357,7 @@ def random_permutations_iterator(initial_permutation, n_permutations):
points_perfect = lgf.perfect_geometry.points_wcs_ctwcc()

# Loop on the facets
separation_permutations = list()
separation_permutations = []
for iplane, plane_point_indices in enumerate(all_planes_point_indices):
prt2(
string=f"In plane {iplane:d} ({'-'.join(str(pp) for pp in plane_point_indices)})",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,11 @@ def get_weights(self, weights_options):
alldeltacsmmins = []
all_cn_pairs = []
for ii in range(1, 14):
self_weight_max_csms_per_cn[str(ii)] = list()
self_weight_max_csms_per_cn[str(ii)] = []
for jj in range(ii + 1, 14):
cn_pair = f"{ii:d}_{jj:d}"
self_weight_max_csms[cn_pair] = list()
delta_csm_mins[cn_pair] = list()
self_weight_max_csms[cn_pair] = []
delta_csm_mins[cn_pair] = []
all_cn_pairs.append(cn_pair)
for ce_pair_dict in ce_pairs:
ce1 = ce_pair_dict["initial_environment_symbol"]
Expand Down
5 changes: 1 addition & 4 deletions dev_scripts/chemenv/test_algos_all_geoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@
symbol_name_mapping = allcg.get_symbol_name_mapping(coordination=coordination)

if perms_def == "standard":
if coordination > 6:
test = "500"
else:
test = "all"
test = "500" if coordination > 6 else "all"
elif perms_def == "ndefined":
test = nperms # type: ignore[assignment]
else:
Expand Down
16 changes: 5 additions & 11 deletions dev_scripts/update_pt_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import re
from itertools import product

import ruamel.yaml as yaml
from monty.serialization import dumpfn, loadfn
from ruamel import yaml

from pymatgen.core import Element
from pymatgen.core.periodic_table import get_el_sp
Expand Down Expand Up @@ -176,16 +176,13 @@ def parse_shannon_radii():
el = sheet[f"A{i}"].value
if sheet[f"B{i}"].value:
charge = int(sheet[f"B{i}"].value)
radii[el][charge] = dict()
radii[el][charge] = {}
if sheet[f"C{i}"].value:
cn = sheet[f"C{i}"].value
if cn not in radii[el][charge]:
radii[el][charge][cn] = dict()
radii[el][charge][cn] = {}

if sheet[f"D{i}"].value is not None:
spin = sheet[f"D{i}"].value
else:
spin = ""
spin = sheet[f"D{i}"].value if sheet[f"D{i}"].value is not None else ""

radii[el][charge][cn][spin] = {
"crystal_radius": float(sheet[f"E{i}"].value),
Expand Down Expand Up @@ -300,10 +297,7 @@ def add_ionization_energies():
if row:
Z = int(row[0])
val = re.sub(r"\s", "", row[8].strip("()[]"))
if val == "":
val = None
else:
val = float(val)
val = None if val == "" else float(val)
data[Z].append(val)
print(data)
print(data[51])
Expand Down
4 changes: 3 additions & 1 deletion docs_rst/conf-docset.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.
from __future__ import annotations

import os
import sys

from pymatgen.core import __author__, __version__

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand All @@ -21,7 +24,6 @@
sys.path.insert(0, os.path.dirname("../pymatgen"))
sys.path.insert(0, os.path.dirname("../.."))

from pymatgen.core import __author__, __version__

# -- General configuration -----------------------------------------------------

Expand Down
11 changes: 7 additions & 4 deletions docs_rst/conf-normal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.
from __future__ import annotations

import os
import sys

from pymatgen.core import __author__, __file__, __version__

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand All @@ -21,8 +24,6 @@
sys.path.insert(0, os.path.dirname("../pymatgen"))
sys.path.insert(0, os.path.dirname("../.."))

from pymatgen.core import __author__, __file__, __version__

# -- General configuration -----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
Expand Down Expand Up @@ -318,9 +319,11 @@
# Allow duplicate toc entries.
# epub_tocdup = True

# Resolve function for the linkcode extension.
# Thanks to https://github.com/Lasagne/Lasagne/blob/master/docs/conf.py

def linkcode_resolve(domain, info):
# Resolve function for the linkcode extension.
# Thanks to https://github.com/Lasagne/Lasagne/blob/master/docs/conf.py

def find_source():
# try to find the file and line number, based on code from numpy:
# https://github.com/numpy/numpy/blob/master/doc/source/conf.py#L286
Expand Down
7 changes: 4 additions & 3 deletions docs_rst/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.
from __future__ import annotations

import os
import sys

from pymatgen.core import __author__, __file__, __version__

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand All @@ -21,7 +24,6 @@
sys.path.insert(0, os.path.dirname("../pymatgen"))
sys.path.insert(0, os.path.dirname("../.."))

from pymatgen.core import __author__, __file__, __version__

# -- General configuration -----------------------------------------------------

Expand Down Expand Up @@ -346,5 +348,4 @@ def find_source():
# no need to be relative to core here as module includes full path.
filename = info["module"].replace(".", "/") + ".py"

tag = "v" + __version__
return f"https://github.com/materialsproject/pymatgen/blob/{tag}/{filename}"
return f"https://github.com/materialsproject/pymatgen/blob/v{__version__}/{filename}"
Loading

0 comments on commit 13a860a

Please sign in to comment.