Skip to content

Commit

Permalink
Fix: Added missing dependencies. Also add better warnings for missing…
Browse files Browse the repository at this point in the history
… dependencies.
  • Loading branch information
clemens-fricke committed Jan 22, 2024
1 parent 8b71c3d commit 36734b7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
8 changes: 7 additions & 1 deletion gustaf/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
import numpy as np

from gustaf import utils
from gustaf.utils.notebook_helper import K3DPlotterN

try:
from gustaf.utils.notebook_helper import K3DPlotterN
except ImportError as err:
from gustaf.helpers.raise_if import ModuleImportRaiser

K3DPlotterN = ModuleImportRaiser("IPython and ipywidgets", err)

# @linux it raises error if vedo is imported inside the function.
try:
Expand Down
7 changes: 7 additions & 0 deletions gustaf/utils/notebook_helper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import importlib

import numpy as np
import vedo
from IPython.display import display
Expand Down Expand Up @@ -39,6 +41,11 @@ def get_shape(N, x, y):

class K3DPlotterN(GridspecLayout):
def __init__(self, N, size, background=0xFFFFFF):
if importlib.util.find_spec("k3d") is None:
raise ImportError(
"k3d is not installed. Please install it with `pip "
"install k3d`."
)
self.N = N
self.x, self.y = get_shape(N, *(2160, 1440))
self.shape = (self.x, self.y)
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ all = [
"meshio",
"napf>=0.0.5",
"funi>=0.0.1",
"requests"
"requests",
"ipywidgets",
"k3d",
]
test = [
"pytest",
Expand All @@ -57,6 +59,8 @@ dev = [
"meshio",
"requests",
"pre-commit",
"ipywidgets",
"k3d",
]

[tool.setuptools]
Expand Down

0 comments on commit 36734b7

Please sign in to comment.