From e0858f7bfe92c113c3b1dee4943e05941794de55 Mon Sep 17 00:00:00 2001 From: Chris Fonnesbeck Date: Mon, 3 Oct 2016 13:37:40 -0500 Subject: [PATCH] Removed interactive_sampling --- pymc3/__init__.py | 1 - pymc3/interactive_sampling.py | 112 ---------------------------------- 2 files changed, 113 deletions(-) delete mode 100644 pymc3/interactive_sampling.py diff --git a/pymc3/__init__.py b/pymc3/__init__.py index e84d5d58f1a..9c4dcc2aac7 100644 --- a/pymc3/__init__.py +++ b/pymc3/__init__.py @@ -6,7 +6,6 @@ from .model import * from .stats import * from .sampling import * -from .interactive_sampling import * from .step_methods import * from .theanof import * from .tuning import * diff --git a/pymc3/interactive_sampling.py b/pymc3/interactive_sampling.py deleted file mode 100644 index b17e900f008..00000000000 --- a/pymc3/interactive_sampling.py +++ /dev/null @@ -1,112 +0,0 @@ -try: - __IPYTHON__ - import IPython - import ipywidgets as widgets - from IPython.core import display - from traitlets import Unicode, Integer, Float - import json - from numpy.random import seed - import time - from .backends.base import MultiTrace - from .sampling import _iter_sample -except (NameError, ImportError): - IPython = False - -_no_notebook_error_message = "nbsample can only be run inside IPython Notebook." -if IPython: - __all__ = ['nbsample'] - - _javascript = """ - """ - - class ISampleWidget(widgets.DOMWidget): - _view_name = Unicode('ISampleWidget', sync=True) - current_samples = Integer(sync=True) - max_samples = Integer(sync=True) - clock = Unicode(sync=True) - - def __init__(self, *args, **kwargs): - widgets.DOMWidget.__init__(self, *args, **kwargs) - self.iteration = 0 - self.on_msg(self._handle_custom_msg) - self.send_state() - self.stopped = False - - def _handle_custom_msg(self, message): - if message == "stop": - self.stopped = True - - def nbsample(draws, step, start=None, trace=None, chain=0, tune=None, model=None, random_seed=None): - try: - assert(hasattr(IPython.get_ipython(), 'comm_manager')) - except (AssertionError, NameError, KeyError) as e: - raise NotImplementedError(_no_notebook_error_message) - - display.display_html(_javascript, raw=True) - w = ISampleWidget() - display.display(w) - t_start = time.time() - t_last = time.time() - - w.max_samples = draws - w.current_samples = 0 - - sampling = _iter_sample(draws, step, start=start, trace=trace, - chain=chain, tune=tune, model=model, - random_seed=random_seed) - - for i, trace in enumerate(sampling, 1): - elapsed = time.time() - t_start - elapsed_last = time.time() - t_last - - if elapsed_last > 0.1: - t_last = time.time() - w.current_samples = i - w.clock = "%02i:%02i:%02i" % ( - elapsed / 60 / 60, elapsed / 60 % 60, elapsed % 60) - get_ipython().kernel.do_one_iteration() - if w.stopped: - trace.close() - break - w.current_samples = i - return MultiTrace([trace]) -else: - def nbsample(*args, **kwargs): - raise NotImplemented(_no_notebook_error_message)