Skip to content

Commit

Permalink
restricted usage of plotly -> ignore import errors, just raise a warn…
Browse files Browse the repository at this point in the history
…ing if plotly is accessed without installation
  • Loading branch information
dlohmeier committed May 11, 2023
1 parent ebd9566 commit ce5564f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pandapipes/std_types/std_type_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
from pandapipes import logger
from pandapower.io_utils import JSONSerializableClass
from scipy.interpolate import interp2d
import plotly.graph_objects as go

try:
import plotly.graph_objects as go
PLOTLY_INSTALLED = True
except ImportError:
PLOTLY_INSTALLED = False


class StdType(JSONSerializableClass):
Expand Down Expand Up @@ -205,7 +210,8 @@ def get_m_head(self, vdot_m3_per_s, speed):
return m_head

def plot_pump_curve(self):

if not PLOTLY_INSTALLED:
logger.error("You need to install plotly to plot the pump curve.")
fig = go.Figure(go.Surface(
contours={
"x": {"show": True, "start": 1.5, "end": 2, "size": 0.04, "color": "white"},
Expand All @@ -223,9 +229,7 @@ def plot_pump_curve(self):
title='Pump Curve', autosize=False,
width=400, height=400,
)
#fig.show()

return fig #self._flowrate_list, self._speed_list, self._head_list
return fig


@classmethod
Expand Down

0 comments on commit ce5564f

Please sign in to comment.