Skip to content

Commit

Permalink
Merge remote-tracking branch 'trunk/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gmatteo committed Sep 4, 2024
2 parents f358b53 + 1404220 commit 361b463
Show file tree
Hide file tree
Showing 362 changed files with 18,686 additions and 14,832 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,23 @@ jobs:
matrix:
# maximize CI coverage of different platforms and python versions while minimizing the
# total number of jobs. We run all pytest splits with the oldest supported python
# version (currently 3.9) on windows (seems most likely to surface errors) and with
# version (currently 3.10) on windows (seems most likely to surface errors) and with
# newest version (currently 3.12) on ubuntu (to get complete coverage on unix).
config:
- os: windows-latest
python: "3.9"
python: "3.10"
resolution: highest
extras: ci,optional
- os: windows-latest
python: "3.10"
resolution: highest
extras: ci,optional,numpy1 # Test NP1 on Windows (quite buggy ATM)
- os: ubuntu-latest
python: ">3.9"
python: ">3.10"
resolution: lowest-direct
extras: ci,optional
- os: macos-latest
python: "3.10"
python: "3.11"
resolution: lowest-direct
extras: ci # test with only required dependencies installed

Expand Down
2 changes: 1 addition & 1 deletion ADMIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The general procedure for releasing `pymatgen` comprises the following steps:

## Initial setup

Pymatgen uses [invoke](http://pyinvoke.org) to automate releases.
Pymatgen uses [invoke](https://pyinvoke.org) to automate releases.
You will also need `sphinx` and `doc2dash`.

```sh
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ message: |
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 pymatgen's docs at http://pymatgen.org on how to cite them.
Please refer to pymatgen's docs at https://pymatgen.org on how to cite them.
authors:
- family-names: Ong
given-names: Shyue Ping
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Given that `pymatgen` is intended to be a long-term code base, we adopt very str
pre-commit run --all-files # ensure your entire codebase passes linters
```
1. **Python 3**. We only support Python 3.9+.
1. **Python 3**. We only support Python 3.10+.
1. **Documentation** is required for all modules, classes and methods. In particular, the method doc strings should make clear the arguments expected and the return values. For complex algorithms (e.g., an Ewald summation), a summary of the algorithm should be provided and preferably with a link to a publication outlining the method in detail.
For the above, if in doubt, please refer to the core classes in `pymatgen` for examples of what is expected.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ height="70">
[![codecov](https://codecov.io/gh/materialsproject/pymatgen/branch/master/graph/badge.svg?token=XC47Un1LV2)](https://codecov.io/gh/materialsproject/pymatgen)
[![PyPI Downloads](https://img.shields.io/pypi/dm/pymatgen?logo=pypi&logoColor=white&color=blue&label=PyPI)](https://pypi.org/project/pymatgen)
[![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/pymatgen?logo=condaforge&color=blue&label=Conda)](https://anaconda.org/conda-forge/pymatgen)
[![Requires Python 3.9+](https://img.shields.io/badge/Python-3.9+-blue.svg?logo=python&logoColor=white)](https://python.org/downloads)
[![Requires Python 3.10+](https://img.shields.io/badge/Python-3.10+-blue.svg?logo=python&logoColor=white)](https://python.org/downloads)
[![Paper](https://img.shields.io/badge/J.ComMatSci-2012.10.028-blue?logo=elsevier&logoColor=white)](https://doi.org/10.1016/j.commatsci.2012.10.028)

</h4>
Expand Down Expand Up @@ -63,7 +63,7 @@ If you'd like to use the latest unreleased changes on the main branch, you can i
pip install -U git+https://github.com/materialsproject/pymatgen
```

The minimum Python version is 3.9. Some extra functionality (e.g., generation of POTCARs) does require additional setup (see the [`pymatgen` docs]).
The minimum Python version is 3.10. Some extra functionality (e.g., generation of POTCARs) does require additional setup (see the [`pymatgen` docs]).

## Change Log

Expand Down
6 changes: 2 additions & 4 deletions dev_scripts/chemenv/explicit_permutations_plane_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,14 @@
raise ValueError("Should all be separation plane")

perms_on_file = f"Permutations on file in this algorithm ({len(sep_plane_algo._permutations)}) "
print(perms_on_file)
print(sep_plane_algo._permutations)
print(f"{perms_on_file}\n{sep_plane_algo._permutations}")
permutations = sep_plane_algo.safe_separation_permutations(
ordered_plane=sep_plane_algo.ordered_plane, ordered_point_groups=sep_plane_algo.ordered_point_groups
)

sep_plane_algo._permutations = permutations

print(f"Test permutations ({len(permutations)}) :")
print(permutations)
print(f"Test permutations ({len(permutations)}):\n{permutations}")

lgf = LocalGeometryFinder()
lgf.setup_parameters(structure_refinement=lgf.STRUCTURE_REFINEMENT_NONE)
Expand Down
7 changes: 4 additions & 3 deletions dev_scripts/chemenv/get_plane_permutations_optimized.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,10 @@ def random_permutations_iterator(initial_permutation, n_permutations):
perms_used[some_perm] += 1
else:
perms_used[some_perm] = 1
tcurrent = time.process_time()
assert n_permutations is not None
time_left = (n_permutations - idx_perm) * (tcurrent - t0) / idx_perm
t_now = time.process_time()
if n_permutations is None:
raise ValueError(f"{n_permutations=}")
time_left = (n_permutations - idx_perm) * (t_now - t0) / idx_perm
time_left = f"{time_left:.1f}"
idx_perm += 1
print(
Expand Down
2 changes: 1 addition & 1 deletion dev_scripts/nist_codata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Fundamental Physical Constants --- Complete Listing


From: http://physics.nist.gov/constants
From: https://physics.nist.gov/cuu/Constants/index.html



Expand Down
6 changes: 4 additions & 2 deletions dev_scripts/regen_libxcfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ def parse_section(section):
section += [line]
else:
num, entry = parse_section(section)
assert num not in dct
if num in dct:
raise RuntimeError(f"{num=} should not be present in {dct=}.")
dct[num] = entry
section = []
assert section == []
if section:
raise RuntimeError(f"Expected empty section, got {section=}")

return dct

Expand Down
55 changes: 31 additions & 24 deletions dev_scripts/update_pt_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
except ImportError:
BeautifulSoup = None

ptable_yaml_path = "periodic_table.yaml"
PTABLE_YAML_PATH = "periodic_table.yaml"


def parse_oxi_state():
data = loadfn(ptable_yaml_path)
data = loadfn(PTABLE_YAML_PATH)
with open("oxidation_states.txt") as file:
oxi_data = file.read()
oxi_data = re.sub("[\n\r]", "", oxi_data)
Expand Down Expand Up @@ -62,7 +62,7 @@ def parse_oxi_state():


def parse_ionic_radii():
data = loadfn(ptable_yaml_path)
data = loadfn(PTABLE_YAML_PATH)
with open("ionic_radii.csv") as file:
radii_data = file.read()
radii_data = radii_data.split("\r")
Expand Down Expand Up @@ -92,7 +92,7 @@ def parse_ionic_radii():


def parse_radii():
data = loadfn(ptable_yaml_path)
data = loadfn(PTABLE_YAML_PATH)
with open("radii.csv") as file:
radii_data = file.read()
radii_data = radii_data.split("\r")
Expand Down Expand Up @@ -128,7 +128,7 @@ def parse_radii():


def update_ionic_radii():
data = loadfn(ptable_yaml_path)
data = loadfn(PTABLE_YAML_PATH)

for dct in data.values():
if "Ionic_radii" in dct:
Expand All @@ -147,7 +147,7 @@ def update_ionic_radii():


def parse_shannon_radii():
data = loadfn(ptable_yaml_path)
data = loadfn(PTABLE_YAML_PATH)

from openpyxl import load_workbook

Expand Down Expand Up @@ -179,13 +179,13 @@ def parse_shannon_radii():
if el in data:
data[el]["Shannon radii"] = dict(radii[el])

dumpfn(data, ptable_yaml_path)
dumpfn(data, PTABLE_YAML_PATH)
with open("../pymatgen/core/periodic_table.json", mode="w") as file:
json.dump(data, file)


def gen_periodic_table():
data = loadfn(ptable_yaml_path)
data = loadfn(PTABLE_YAML_PATH)

with open("../pymatgen/core/periodic_table.json", mode="w") as file:
json.dump(data, file)
Expand Down Expand Up @@ -217,14 +217,16 @@ def gen_iupac_ordering():
([17], range(6, 1, -1)),
] # At -> F

order = sum((list(product(x, y)) for x, y in order), []) # noqa: RUF017
iupac_ordering_dict = dict(zip([Element.from_row_and_group(row, group) for group, row in order], range(len(order))))
order = [item for sublist in (list(product(x, y)) for x, y in order) for item in sublist]
iupac_ordering_dict = dict(
zip([Element.from_row_and_group(row, group) for group, row in order], range(len(order)), strict=True)
)

# first clean periodic table of any IUPAC ordering
for el in periodic_table:
periodic_table[el].pop("IUPAC ordering", None)

# now add iupac ordering
# now add IUPAC ordering
for el in periodic_table:
if "IUPAC ordering" in periodic_table[el]:
# sanity check that we don't cover the same element twice
Expand All @@ -237,7 +239,7 @@ def gen_iupac_ordering():
def add_electron_affinities():
"""Update the periodic table data file with electron affinities."""

req = requests.get("https://wikipedia.org/wiki/Electron_affinity_(data_page)", timeout=600)
req = requests.get("https://wikipedia.org/wiki/Electron_affinity_(data_page)", timeout=60)
soup = BeautifulSoup(req.text, "html.parser")
table = None
for table in soup.find_all("table"):
Expand All @@ -251,23 +253,26 @@ def add_electron_affinities():
data += [row]
data.pop(0)

ea = {}
element_electron_affinities = {}
max_Z = max(Element(element).Z for element in Element.__members__)
for r in data:
# don't want superheavy elements or less common isotopes
if int(r[0]) > max_Z or r[2] in ea:
if int(r[0]) > max_Z or r[2] in element_electron_affinities:
continue
temp_str = re.sub(r"[\s\(\)]", "", r[3].strip("()[]"))
# hyphen-like characters used that can't be parsed by .float
bytes_rep = temp_str.encode("unicode_escape").replace(b"\\u2212", b"-")
ea[r[2]] = float(bytes_rep.decode("unicode_escape"))

Z_set = {Element.from_name(element).Z for element in ea}
assert Z_set.issuperset(range(1, 93)) # Ensure that we have data for up to U.
print(ea)
element_electron_affinities[r[2]] = float(bytes_rep.decode("unicode_escape"))

Z_set = {Element.from_name(element).Z for element in element_electron_affinities}
# Ensure that we have data for up to Uranium
if not Z_set.issuperset(range(1, 93)):
missing_electron_affinities = set(range(1, 93)) - Z_set
raise ValueError(f"{missing_electron_affinities=}")
print(element_electron_affinities)
pt = loadfn("../pymatgen/core/periodic_table.json")
for key, val in pt.items():
val["Electron affinity"] = ea.get(Element(key).long_name)
val["Electron affinity"] = element_electron_affinities.get(Element(key).long_name)
dumpfn(pt, "../pymatgen/core/periodic_table.json")


Expand All @@ -282,15 +287,17 @@ def add_ionization_energies():
break
data = defaultdict(list)
for row in table.find_all("tr"):
row = [td.get_text().strip() for td in row.find_all("td")]
if row:
if row := [td.get_text().strip() for td in row.find_all("td")]:
Z = int(row[0])
val = re.sub(r"\s", "", row[8].strip("()[]"))
val = None if val == "" else float(val)
data[Z] += [val]
print(data)
print(data[51])
assert set(data).issuperset(range(1, 93)) # Ensure that we have data for up to U.

# Ensure that we have data for up to U.
if not set(data).issuperset(range(1, 93)):
raise RuntimeError("Failed to get data up to Uranium")

pt = loadfn("../pymatgen/core/periodic_table.json")
for key, val in pt.items():
del val["Ionization energy"]
Expand Down
2 changes: 1 addition & 1 deletion docs/Gemfile.lock

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

2 changes: 1 addition & 1 deletion docs/apidoc/conf.py

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

11 changes: 0 additions & 11 deletions docs/apidoc/pymatgen.util.testing.rst

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

6 changes: 3 additions & 3 deletions docs/index.md

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

Loading

0 comments on commit 361b463

Please sign in to comment.