Skip to content

Commit

Permalink
Migrate new functionality froim 2022.
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep committed Mar 9, 2021
1 parent c1268d3 commit 998a4f8
Show file tree
Hide file tree
Showing 23 changed files with 116 additions and 10,100 deletions.
3 changes: 2 additions & 1 deletion pymatgen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
__email__ = "pymatgen@googlegroups.com"
__maintainer__ = "Shyue Ping Ong"
__maintainer_email__ = "shyuep@gmail.com"
__version__ = "2021.3.5"
__version__ = "2021.3.9"

# Useful aliases for commonly used objects and modules.
# Allows from pymatgen import <class> for quick usage.
# Note that these have to come after the SETTINGS have been loaded. Otherwise, import does not work.

from .core import SETTINGS, SETTINGS_FILE # noqa
from .core.composition import Composition # noqa
from .core.lattice import Lattice # noqa
from .core.operations import SymmOp # noqa
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/alchemy/tests/test_materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import unittest
import warnings

from pymatgen.settings import SETTINGS
from pymatgen.core import SETTINGS
from pymatgen.alchemy.filters import ContainsSpecieFilter
from pymatgen.alchemy.materials import TransformedStructure
from pymatgen.core.structure import Structure
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/analysis/chemenv/utils/chemenv_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from os import makedirs
from os.path import exists, expanduser

from pymatgen.settings import SETTINGS
from pymatgen.core import SETTINGS
from pymatgen.analysis.chemenv.utils.scripts_utils import strategies_class_lookup


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from monty.tempfile import ScratchDir

from pymatgen.settings import SETTINGS
from pymatgen.core import SETTINGS
from pymatgen.analysis.chemenv.utils.chemenv_config import ChemEnvConfig

config_file_dir = os.path.join(
Expand Down
7 changes: 7 additions & 0 deletions pymatgen/analysis/diffusion_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
__status__ = "Beta"
__date__ = "5/2/13"

warnings.warn(
"All code in pymatgen.analysis.diffusion_analyzer has been moved to the separate add-on package"
"pymatgen-diffusion, which also includes a lot more functionality for analyzing diffusion"
"calculations. This module here is retained for backwards compatibility. It will be removed from"
"2022.1.1."
)


class DiffusionAnalyzer(MSONable):
"""
Expand Down
8 changes: 3 additions & 5 deletions pymatgen/analysis/tests/test_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
import os
import unittest

import pymatgen
from pymatgen.util.testing import PymatgenTest
from pymatgen.analysis.cost import CostAnalyzer, CostDBCSV, CostDBElements

module_dir = os.path.join(os.path.dirname(pymatgen.__file__), "..", "test_files")


class CostAnalyzerTest(unittest.TestCase):
def setUp(self):
self.ca1 = CostAnalyzer(CostDBCSV(os.path.join(module_dir, "costdb_1.csv")))
self.ca2 = CostAnalyzer(CostDBCSV(os.path.join(module_dir, "costdb_2.csv")))
self.ca1 = CostAnalyzer(CostDBCSV(os.path.join(PymatgenTest.TEST_FILES_DIR, "costdb_1.csv")))
self.ca2 = CostAnalyzer(CostDBCSV(os.path.join(PymatgenTest.TEST_FILES_DIR, "costdb_2.csv")))

def test_cost_per_kg(self):
self.assertAlmostEqual(self.ca1.get_cost_per_kg("Ag"), 3, 3)
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/analysis/tests/test_pourbaix_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np
from monty.serialization import loadfn

from pymatgen.settings import SETTINGS
from pymatgen.core import SETTINGS
from pymatgen.analysis.pourbaix_diagram import (
IonEntry,
MultiEntry,
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/cli/pmg.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from tabulate import tabulate, tabulate_formats

from pymatgen.settings import SETTINGS
from pymatgen.core import SETTINGS
from pymatgen.core.structure import Structure
from pymatgen.cli.pmg_analyze import analyze
from pymatgen.cli.pmg_config import configure_pmg
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/cli/pmg_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from monty.serialization import dumpfn, loadfn

from pymatgen.settings import SETTINGS_FILE
from pymatgen.core import SETTINGS_FILE


def setup_potcars(args):
Expand Down
39 changes: 39 additions & 0 deletions pymatgen/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,49 @@
operations on them.
"""

import os

try:
import ruamel.yaml as yaml
except ImportError:
try:
import ruamel_yaml as yaml # type: ignore # noqa
except ImportError:
import yaml # type: ignore # noqa

from .composition import Composition # noqa
from .lattice import Lattice # noqa
from .operations import SymmOp # noqa
from .periodic_table import DummySpecies, Element, Species # noqa
from .sites import PeriodicSite, Site # noqa
from .structure import IMolecule, IStructure, Molecule, Structure # noqa
from .units import ArrayWithUnit, FloatWithUnit, Unit # noqa


__author__ = "Pymatgen Development Team"
__email__ = "pymatgen@googlegroups.com"
__maintainer__ = "Shyue Ping Ong"
__maintainer_email__ = "shyuep@gmail.com"
__version__ = "2022.0.4"
SETTINGS_FILE = os.path.join(os.path.expanduser("~"), ".pmgrc.yaml")


def _load_pmg_settings():
try:
with open(SETTINGS_FILE, "rt") as f:
d = yaml.safe_load(f)
except IOError:
# If there are any errors, default to using environment variables
# if present.
d = {}
for k, v in os.environ.items():
if k.startswith("PMG_"):
d[k] = v
elif k in ["VASP_PSP_DIR", "MAPI_KEY", "DEFAULT_FUNCTIONAL"]:
d["PMG_" + k] = v
d = d or {}
return dict(d)


SETTINGS = _load_pmg_settings()
locals().update(SETTINGS)

0 comments on commit 998a4f8

Please sign in to comment.