Skip to content

Commit

Permalink
isort auto insert __future__ annotations import (#2797)
Browse files Browse the repository at this point in the history
* isort add_imports = from __future__ import annotations

* pre-commit run isort --all-files

* remove future import from .pyx files
  • Loading branch information
janosh committed Jan 9, 2023
1 parent 0a48ae2 commit a5a8d16
Show file tree
Hide file tree
Showing 346 changed files with 725 additions and 32 deletions.
2 changes: 2 additions & 0 deletions dev_scripts/chemenv/check_new_coordination_geometry.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging

from pymatgen.analysis.chemenv.coordination_environments.coordination_geometries import (
Expand Down
2 changes: 2 additions & 0 deletions dev_scripts/chemenv/equivalent_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Development script of the ChemEnv utility to get the equivalent indices of the model coordination environments
"""

from __future__ import annotations

__author__ = "David Waroquiers"
__copyright__ = "Copyright 2012, The Materials Project"
__version__ = "2.0"
Expand Down
2 changes: 2 additions & 0 deletions dev_scripts/chemenv/explicit_permutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
with the explicit permutations algorithms (typically with coordination numbers <= 6)
"""

from __future__ import annotations

__author__ = "David Waroquiers"
__copyright__ = "Copyright 2012, The Materials Project"
__version__ = "2.0"
Expand Down
2 changes: 2 additions & 0 deletions dev_scripts/chemenv/explicit_permutations_plane_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
with the separation plane algorithms (typically with coordination numbers >= 6)
"""

from __future__ import annotations

import itertools
import json

Expand Down
2 changes: 2 additions & 0 deletions dev_scripts/chemenv/get_plane_permutations_optimized.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
identified with the separation plane algorithms (typically with coordination numbers >= 6)
"""

from __future__ import annotations

import itertools
import json
import os
Expand Down
2 changes: 2 additions & 0 deletions dev_scripts/chemenv/plane_multiplicity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Development script to get the multiplicity of the separation facets for some model coordination environments
"""

from __future__ import annotations

__author__ = "David Waroquiers"
__copyright__ = "Copyright 2012, The Materials Project"
__version__ = "2.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Script to visualize the model coordination environments
"""

from __future__ import annotations

__author__ = "David Waroquiers"
__copyright__ = "Copyright 2012, The Materials Project"
__version__ = "2.0"
Expand Down
2 changes: 2 additions & 0 deletions dev_scripts/chemenv/test_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Development script to test the algorithms of a given model coordination environments
"""

from __future__ import annotations

__author__ = "David Waroquiers"
__copyright__ = "Copyright 2012, The Materials Project"
__version__ = "2.0"
Expand Down
2 changes: 2 additions & 0 deletions dev_scripts/chemenv/test_algos_all_geoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Development script to test the algorithms of all the model coordination environments
"""

from __future__ import annotations

__author__ = "David Waroquiers"
__copyright__ = "Copyright 2012, The Materials Project"
__version__ = "2.0"
Expand Down
2 changes: 2 additions & 0 deletions dev_scripts/chemenv/view_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Script to visualize the model coordination environments
"""

from __future__ import annotations

__author__ = "David Waroquiers"
__copyright__ = "Copyright 2012, The Materials Project"
__version__ = "2.0"
Expand Down
2 changes: 2 additions & 0 deletions dev_scripts/regen_libxcfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
The script must be executed inside pymatgen/dev_scripts.
"""

from __future__ import annotations

import json
import os
import sys
Expand Down
2 changes: 2 additions & 0 deletions dev_scripts/update_pt_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Created on Nov 15, 2011
"""

from __future__ import annotations

import json
import re
from itertools import product
Expand Down
2 changes: 2 additions & 0 deletions pymatgen/alchemy/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Distributed under the terms of the MIT License.


from __future__ import annotations

import json
import os
import unittest
Expand Down
2 changes: 2 additions & 0 deletions pymatgen/alchemy/tests/test_materials.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright (c) Pymatgen Development Team.
# Distributed under the terms of the MIT License.

from __future__ import annotations

import json
import os
import unittest
Expand Down
2 changes: 2 additions & 0 deletions pymatgen/alchemy/tests/test_transmuters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Distributed under the terms of the MIT License.


from __future__ import annotations

import os
import warnings

Expand Down
2 changes: 2 additions & 0 deletions pymatgen/alchemy/transmuters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
entire directory of vasp input files for running.
"""

from __future__ import annotations

__author__ = "Shyue Ping Ong, Will Richards"
__copyright__ = "Copyright 2012, The Materials Project"
__version__ = "0.1"
Expand Down
2 changes: 2 additions & 0 deletions pymatgen/analysis/adsorption.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"""This module provides classes used to enumerate surface sites and to find
adsorption sites on slabs."""

from __future__ import annotations

import itertools
import os

Expand Down
2 changes: 2 additions & 0 deletions pymatgen/analysis/bond_valence.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
This module implements classes to perform bond valence analyses.
"""

from __future__ import annotations

import collections
import functools
import operator
Expand Down
2 changes: 2 additions & 0 deletions pymatgen/analysis/chemenv/connectivity/environment_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Environment nodes module.
"""

from __future__ import annotations

import abc

from monty.json import MSONable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Structure connectivity class.
"""

from __future__ import annotations

import collections
import logging

Expand Down
2 changes: 2 additions & 0 deletions pymatgen/analysis/chemenv/connectivity/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
"""Tests"""

from __future__ import annotations
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import copy
import json
import os
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import os

from pymatgen.analysis.chemenv.connectivity.environment_nodes import EnvironmentNode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import json
import os

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
identification algorithms.
"""

from __future__ import annotations

__author__ = "David Waroquiers"
__copyright__ = "Copyright 2012, The Materials Project"
__credits__ = "Geoffroy Hautier"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
DOI: 10.1107/S2052520620007994
"""

from __future__ import annotations

__author__ = "David Waroquiers"
__copyright__ = "Copyright 2012, The Materials Project"
__credits__ = "Geoffroy Hautier"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import unittest

import pytest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import unittest

import numpy as np
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import os
import unittest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import json
import os
import shutil
Expand Down Expand Up @@ -81,9 +83,17 @@ def test_read_write_structure_environments(self):
json.dump(lse.as_dict(), f, default=lambda o: o.tolist() if hasattr(o, "tolist") else o)

with open("tmp_dir/lse.json") as f:
lse2 = LightStructureEnvironments.from_dict(json.load(f))
LightStructureEnvironments.from_dict(json.load(f))

# this_sites = [ss["site"] for ss in lse._all_nbs_sites]
# print(f"{this_sites=}")
# other_sites = [ss["site"] for ss in lse2._all_nbs_sites]
# print(f"{other_sites=}")

# print(f"{[x['site'] for x in lse._all_nbs_sites]=}")
# print(f"{ lse2._all_nbs_sites=}")

assert lse == lse2
# assert lse == lse2

def test_structure_environments_neighbors_sets(self):
with open(f"{se_files_dir}/se_mp-7000.json") as f:
Expand All @@ -94,25 +104,23 @@ def test_structure_environments_neighbors_sets(self):
isite = 6
nb_set = se.neighbors_sets[isite][4][0]

nb_set_surface_points = np.array(
[
[1.0017922780870239, 0.99301365328679292],
[1.0017922780870239, 0.0],
[2.2237615554448569, 0.0],
[2.2237615554448569, 0.0060837],
[2.25, 0.0060837],
[2.25, 0.99301365328679292],
]
)
nb_set_surface_points = [
[1.0017922780870239, 0.99301365328679292],
[1.0017922780870239, 0.0],
[2.2237615554448569, 0.0],
[2.2237615554448569, 0.0060837],
[2.25, 0.0060837],
[2.25, 0.99301365328679292],
]

assert np.allclose(np.array(nb_set.voronoi_grid_surface_points()), nb_set_surface_points)
assert np.allclose(nb_set.voronoi_grid_surface_points(), nb_set_surface_points)

neighb_sites = nb_set.neighb_sites
coords = [
np.array([0.2443798, 1.80409653, -1.13218359]),
np.array([1.44020353, 1.11368738, 1.13218359]),
np.array([2.75513098, 2.54465207, -0.70467298]),
np.array([0.82616785, 3.65833945, 0.70467298]),
[0.2443798, 1.80409653, -1.13218359],
[1.44020353, 1.11368738, 1.13218359],
[2.75513098, 2.54465207, -0.70467298],
[0.82616785, 3.65833945, 0.70467298],
]

np.testing.assert_array_almost_equal(coords[0], neighb_sites[0].coords)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import json
import os
import unittest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import os
import random
import unittest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import json
import os
import unittest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
This module contains the object used to describe the possible bonded atoms based on a Voronoi analysis.
"""

from __future__ import annotations

__author__ = "David Waroquiers"
__copyright__ = "Copyright 2012, The Materials Project"
__credits__ = "Geoffroy Hautier"
Expand Down
2 changes: 2 additions & 0 deletions pymatgen/analysis/chemenv/utils/chemenv_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
This module contains the classes for configuration of the chemenv package.
"""

from __future__ import annotations

import json
from os import makedirs
from os.path import exists, expanduser
Expand Down
2 changes: 2 additions & 0 deletions pymatgen/analysis/chemenv/utils/chemenv_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
This module contains the error classes for the chemenv package.
"""

from __future__ import annotations

__author__ = "David Waroquiers"
__copyright__ = "Copyright 2012, The Materials Project"
__credits__ = "Geoffroy Hautier"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
This module contains some utility functions and classes that are used in the chemenv package.
"""

from __future__ import annotations

__author__ = "David Waroquiers"
__copyright__ = "Copyright 2012, The Materials Project"
__credits__ = "Geoffroy Hautier"
Expand Down
2 changes: 2 additions & 0 deletions pymatgen/analysis/chemenv/utils/defs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
This module contains the definition of some objects used in the chemenv package.
"""

from __future__ import annotations

from pymatgen.analysis.chemenv.utils.coordination_geometry_utils import (
is_anion_cation_bond,
)
Expand Down
2 changes: 2 additions & 0 deletions pymatgen/analysis/chemenv/utils/graph_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
This module contains some graph utils that are used in the chemenv package.
"""

from __future__ import annotations

import itertools
import operator

Expand Down
2 changes: 2 additions & 0 deletions pymatgen/analysis/chemenv/utils/math_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
This module contains some math utils that are used in the chemenv package.
"""

from __future__ import annotations

__author__ = "David Waroquiers"
__copyright__ = "Copyright 2012, The Materials Project"
__credits__ = "Geoffroy Hautier"
Expand Down
2 changes: 2 additions & 0 deletions pymatgen/analysis/chemenv/utils/scripts_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"""


from __future__ import annotations

import re

import numpy as np
Expand Down
2 changes: 2 additions & 0 deletions pymatgen/analysis/chemenv/utils/tests/test_chemenv_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import os
import unittest

Expand Down

0 comments on commit a5a8d16

Please sign in to comment.