From 4bda6c03335499bd79725267826debcabda92f81 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Sat, 5 Oct 2019 14:52:10 +0530 Subject: [PATCH] Support notebook target --- .../turicreate/toolkits/image_classifier/_evaluation.py | 3 +++ src/python/turicreate/visualization/_plot.py | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/python/turicreate/toolkits/image_classifier/_evaluation.py b/src/python/turicreate/toolkits/image_classifier/_evaluation.py index ad0d6d0582..2ec069bb93 100644 --- a/src/python/turicreate/toolkits/image_classifier/_evaluation.py +++ b/src/python/turicreate/toolkits/image_classifier/_evaluation.py @@ -63,8 +63,11 @@ def explore(self): params = (self._get_eval_json()+"\n", self.data["test_data"], self, ) # Suppress visualization output if 'none' target is set from ...visualization._plot import _target + from ...visualization._plot import show if _target == 'none': return + if _target == 'notebook': + return show() _thread.start_new_thread(_start_process, params) diff --git a/src/python/turicreate/visualization/_plot.py b/src/python/turicreate/visualization/_plot.py index eeec30a3d7..104fbb5db8 100644 --- a/src/python/turicreate/visualization/_plot.py +++ b/src/python/turicreate/visualization/_plot.py @@ -66,11 +66,12 @@ def set_target(target='auto'): otherwise launch a native GUI window. * 'browser': opens a web browser pointing to http://localhost. * 'gui': always launch a native GUI window. + * 'notebook': launch in a notebook. * 'none': prevent all visualizations from being displayed. """ global _target - if target not in ['auto', 'browser', 'gui', 'none']: - raise ValueError("Expected target to be one of: 'auto', 'browser', 'gui', 'none'.") + if target not in ['auto', 'browser', 'gui', 'notebook', 'none']: + raise ValueError("Expected target to be one of: 'auto', 'browser', 'gui', 'notebook', 'none'.") _target = target @@ -144,7 +145,7 @@ def show(self): # If auto target is set, try to show inline in Jupyter Notebook try: - if _target == 'auto' and \ + if (_target == 'auto' or _target == 'notebook') and \ get_ipython().__class__.__name__ == "ZMQInteractiveShell": self._repr_javascript_() return