diff --git a/h2o-py/h2o/explanation/_explain.py b/h2o-py/h2o/explanation/_explain.py index 1e09223e879a..0e195dabd487 100644 --- a/h2o-py/h2o/explanation/_explain.py +++ b/h2o-py/h2o/explanation/_explain.py @@ -46,7 +46,7 @@ def _dont_display(object): """ import matplotlib.figure plt = get_matplotlib_pyplot(False, raise_if_not_available=True) - if isinstance(object, matplotlib.figure.Figure): + if isinstance(object, matplotlib.figure.Figure) or is_decorated_plot_result(object) and (object.figure() is not None): plt.close() return object @@ -179,7 +179,10 @@ class H2OExplanation(OrderedDict): def _ipython_display_(self): from IPython.display import display for v in self.values(): - display(v) + if is_decorated_plot_result(v): + display(v.figure()) + else: + display(v) @contextmanager diff --git a/h2o-py/h2o/plot/_plot_result.py b/h2o-py/h2o/plot/_plot_result.py index 08aae9e7a1ca..ad8b3bab2d87 100644 --- a/h2o-py/h2o/plot/_plot_result.py +++ b/h2o-py/h2o/plot/_plot_result.py @@ -4,10 +4,19 @@ __no_export = set(dir()) # all variables defined above this are not exported + class _MObject(object): pass + + class _MTuple(tuple): pass + + class _MList(list): pass + + class _MDict(dict): pass + + class _MStr(str): pass @@ -31,7 +40,7 @@ def get_figure(): dec = _MDict(res) elif isinstance(res, str): dec = _MStr(res) - else: # should be an H2O instance, should be mutable + else: # should be an H2O instance, should be mutable dec = res dec.figure = get_figure dec._is_decorated_plot_result = True