Skip to content

Commit

Permalink
BUG: notebook in python 3 failing
Browse files Browse the repository at this point in the history
The helloRadiomics notebook was failing due to an error that was thrown by the Click progressbar. Remove the Click progressbar example, as it also does not render the progressbar if the output is not a terminal (as is the case in a jupyter notebook).
  • Loading branch information
JoostJM committed May 15, 2017
1 parent 5f83aba commit 756bfcf
Showing 1 changed file with 0 additions and 49 deletions.
49 changes: 0 additions & 49 deletions notebooks/helloRadiomics.ipynb
Expand Up @@ -270,55 +270,6 @@
" pass # tqdm package not available, skip setting up the progressbar for tqdm"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `click` package also exposes a progress bar, which can also take an iterable as its first argument, but the label is passed in keyword 'label'. To use `click`, we need to create a simple wrapper that redirects the 'desc' keyword to the 'label' keyword.\n",
"\n",
"The cell below is an alternative to the cell showing how to use `tqdm` as progressbar.\n",
"\n",
"**N.B. This cell will only work if the 'click' package is installed, which is not included in the requirements of PyRadiomics.**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"try:\n",
" import click\n",
"\n",
" class progressWrapper():\n",
" def __init__(self, iterable, desc=''):\n",
" # For a click progressbar, the description must be provided in the 'label' keyword argument.\n",
" # The iterable can be passed as first argument to click, no changes needed\n",
" self.bar = click.progressbar(iterable, label=desc) \n",
"\n",
" def __iter__(self):\n",
" return self.bar.__iter__() # Redirect to the __iter__ function of the click progressbar\n",
"\n",
" def __enter__(self):\n",
" return self.bar.__enter__() # Redirect to the __enter__ function of the click progressbar\n",
"\n",
" def __exit__(self, exc_type, exc_value, tb):\n",
" return self.bar.__exit__(exc_type, exc_value, tb) # Redirect to the __exit__ function of the click progressbar\n",
"\n",
" radiomics.progressReporter = progressWrapper\n",
" \n",
" extractor.settings['enableCExtensions'] = False\n",
"\n",
" # Enable the GLCM class to show the progress bar\n",
" extractor.enableFeatureClassByName('glcm')\n",
"\n",
" radiomics.setVerbosity(logging.INFO) # Verbosity must be at least INFO to enable progress bar\n",
"except ImportError:\n",
" pass # Click package not available, skip setting up the progressbar for click"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit 756bfcf

Please sign in to comment.