Skip to content

Commit 0e49f77

Browse files
committed
make dscribe optional
1 parent 6ef833e commit 0e49f77

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

pymatgen/analysis/defects/finder.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@
55
from typing import List, Tuple
66

77
import numpy as np
8-
from dscribe.descriptors import SOAP
98
from monty.json import MSONable
109
from numpy.typing import ArrayLike, NDArray
1110
from pymatgen.core.structure import Structure
1211
from pymatgen.io.ase import AseAtomsAdaptor
1312
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
1413

14+
# Optional imports
15+
try:
16+
from dscribe.descriptors import SOAP
17+
except ImportError:
18+
SOAP = None
19+
20+
1521
__author__ = "Jimmy Shen"
1622
__copyright__ = "Copyright 2022, The Materials Project"
1723
__maintainer__ = "Jimmy Shen @jmmshn"
@@ -34,6 +40,10 @@ def __init__(self, symprec: float = 0.01, angle_tolerance: float = 5.0):
3440
symprec (float): Symmetry tolerance parameter for SpacegroupAnalyzer
3541
angle_tolerance (float): Angle tolerance parameter for SpacegroupAnalyzer
3642
"""
43+
if SOAP is None:
44+
raise ImportError(
45+
"dscribe is required to use DefectSiteFinder. Install with ``pip install dscribe``."
46+
)
3747
self.symprec = symprec
3848
self.angle_tolerance = angle_tolerance
3949

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ classifiers = [
1515
"Topic :: Other/Nonlisted Topic",
1616
"Topic :: Scientific/Engineering",
1717
]
18-
dependencies = ["pymatgen>=2022.7.19", "dscribe>=1.2.1", "scikit-image>=0.19.3"]
18+
dependencies = ["pymatgen>=2022.7.19", "scikit-image>=0.19.3"]
1919
description = "Pymatgen extension for defects analysis"
2020
dynamic = ["version"]
2121
keywords = ["high-throughput", "automated", "dft", "defects"]
@@ -25,6 +25,7 @@ readme = "README.rst"
2525
requires-python = '>="3.8"'
2626

2727
[project.optional-dependencies]
28+
finder = ["dscribe>=1.2.1"]
2829
dev = ["pre-commit>=2.12.1"]
2930
docs = [
3031
"sphinx==5.0.2",

0 commit comments

Comments
 (0)