Tools for jupyter/ipython-style notebooks, and detection that you are, or are _not_, using one right now.
Class | etree |
Produces a colorized representation of selection within an XML document. (works only within IPython/jupyter style notebooks, via a HTML representation.) |
Class |
|
A sequence-iterating progress bar (like tqdm) that supports both notebooks and console, and prefers notebook over console style in notebooks. |
Function | detect |
Use this to detect what kind of environment the calling code is running in. |
Function | is |
returns whether we are using an interactive thing (see detect_env) |
Function | is |
returns whether IPython is available (see detect_env) - note that you might want to combine this with is_interactive (depending on what you are really testing ) |
Function | is |
return whether this seems to be interactive in the REPL-like sense (is_ipython and is_interactive) |
Function | is |
returns whether we are running in a notebook (see detect_env) |
Function | progress |
A progress bar that should work in notebooks -- but also outside them if you have tqdm installed |
Function | set |
Might throw an exception, e.g. an ImportError' |
Use this to detect what kind of environment the calling code is running in.
Returns a dict with keys that map to booleans:
- 'interactive' - whether it's interactive (e.g. regular python REPL, ipython REPL, notebook, or qtconsole)
- 'notebook' - whether it's a notebook (also including colab, qtconsole)
- 'ipython' - whether IPython is available (note this will also return True if the module just happens to be installed and available)
(when we see pytest, we fake all False, because that's probably closer -- probably better than noticing the IPython that pytest seems to mock)
returns whether IPython is available (see detect_env) - note that you might want to combine this with is_interactive (depending on what you are really testing )
A progress bar that should work in notebooks -- but also outside them if you have tqdm installed
More precisely:
- wraps tqdm and ipywidgets's IntProgress progress bar;
- prefers tqdm if installed, falls back to IntProgress.
CONSIDER: parameter to force text mode
Compared to ProgressBar
, this one is more typing but also does a little more, letting you set (and get) .value and .description on the fly, so e.g. usable like:
prog = progress_bar( 10, 'overall' ) for i in range(10): prog.value += 1 time.sleep(1) prog.description = 'finished'
Parameters | |
maxval | maximum value to count towards (required) |
description | text to also show in the progress bar |
display | if True, (default), then in a notebook we will call display() on the IPython widget, so you don't have to do so to get it visible. |
Returns | |
an object representing a progress bar, that you can set the .value and .description on. |