Skip to content

IPython checking in verbose_optimization.py doesn't work #31

@trevorcampbell

Description

@trevorcampbell

In optimization/verbose_optimization.py, the following code tries to check whether it's being run from within an IPython notebook:

try:  # pragma: no cover
               from IPython.display import display
               from ipywidgets import IntProgress, HTML, Box, VBox, HBox
               self.text = HTML(width='100%')
               self.progress = IntProgress(min=0, max=maxiters)
               #self.progresstext = Text(width='100%', disabled=True, value='0/{}'.format(maxiters))
               self.model_show = HTML()
               self.ipython_notebook = ipython_notebook
           except:
               # Not in Ipython notebook
               self.ipython_notebook = False

but when I run code in my shell (not a notebook) that calls this, self.ipython_notebook is True after this block executes.

According to this stackoverflow post, a good way to do this check is

try:
   get_ipython
   self.ipython_notebook=True
except:
   self.ipython_notebook=False

For reference:
python 3.6.7
ipython 6.5.0
ipywidgets 7.4.0
paramz 0.9.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions