Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ classifiers = [
requires-python = ">=3.8"
dependencies = [
"numpy>=1.0",
"packaging",
"spglib>=1.14.1",
]
license = {text = "The MIT license"}
Expand Down
11 changes: 9 additions & 2 deletions seekpath/brillouinzone/brillouinzone.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
"""Module to compute the Brillouin zone of a crystal."""

from __future__ import annotations

from collections import defaultdict
import warnings
from typing import Union
from typing import TYPE_CHECKING, Union

import numpy as np
from scipy.spatial import Voronoi, ConvexHull, Delaunay

if TYPE_CHECKING:
from scipy.spatial import ConvexHull, Delaunay


def get_BZ(
Expand Down Expand Up @@ -127,6 +131,9 @@ def _initialize_BZ(
plotting library prefers these - these are not oriented for the
time being)
"""
# scipy is the optional `bz` extra, so import it only when a BZ is built.
from scipy.spatial import ConvexHull, Delaunay, Voronoi

ret_data = {}

supercell_size = 3 # Is this enough?
Expand Down
10 changes: 10 additions & 0 deletions tests/test_import_without_scipy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""scipy is only needed for the Brillouin zone (the `bz` extra)."""

import subprocess
import sys


def test_import_without_scipy():
"""`import seekpath` must work when scipy is not installed."""
code = "import sys; sys.modules['scipy'] = None; import seekpath"
subprocess.run([sys.executable, '-c', code], check=True)