Skip to content

Commit

Permalink
Only require matplotlib for contours if using datatime data
Browse files Browse the repository at this point in the history
  • Loading branch information
ianthomas23 committed Oct 13, 2023
1 parent 0d653a5 commit fb4eb3f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions holoviews/operation/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,6 @@ class contours(Operation):
_per_element = True

def _process(self, element, key=None):
try:
from matplotlib.dates import num2date, date2num
except ImportError:
raise ImportError("contours operation requires matplotlib.")

try:
from contourpy import contour_generator, FillType, LineType
except ImportError:
Expand All @@ -576,6 +571,11 @@ def _process(self, element, key=None):
if any(data_is_datetime[:2]) and self.p.filled:
raise RuntimeError("Datetime spatial coordinates are not supported "
"for filled contour calculations.")
try:
from matplotlib.dates import num2date, date2num
except ImportError:
raise ImportError("contours operation using datetimes requires matplotlib.")

data = tuple(
date2num(d) if is_datetime else d
for d, is_datetime in zip(data, data_is_datetime)
Expand Down

0 comments on commit fb4eb3f

Please sign in to comment.