{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "This file is part of the [test suite](./tests) and will be moved there when [nbval#116](https://github.com/computationalmodelling/nbval/issues/116#issuecomment-793148404) is fixed.\n", "\n", "See [DEMO.ipynb](DEMO.ipynb) instead for notebook examples." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from functools import partial\n", "from time import sleep\n", "\n", "from tqdm.notebook import tqdm_notebook\n", "from tqdm.notebook import tnrange\n", "\n", "# avoid displaying widgets by default (pollutes output cells)\n", "tqdm = partial(tqdm_notebook, display=False)\n", "trange = partial(tnrange, display=False)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on function display in module tqdm.notebook:\n", "\n", "display(self, msg=None, pos=None, close=False, bar_style=None, check_delay=True)\n", " Use `self.sp` to display `msg` in the specified `pos`.\n", " \n", " Consider overloading this function when inheriting to use e.g.:\n", " `self.some_frontend(**self.format_dict)` instead of `self.sp`.\n", " \n", " Parameters\n", " ----------\n", " msg : str, optional. What to display (default: `repr(self)`).\n", " pos : int, optional. Position to `moveto`\n", " (default: `abs(self.pos)`).\n", "\n" ] } ], "source": [ "help(tqdm_notebook.display)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "7c18c038bf964b55941e228503292506", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/9 [00:00=8\n", " getattr(widget, \"visible\", False), getattr(widget, \"_ipython_display_\", None)) # ipyw<8\n", "\n", "assert not is_hidden(t.container)\n", "for total in (1, 9):\n", " with tqdm(total=total, leave=False) as t:\n", " print(t)\n", " t.update()\n", " print(t)\n", " assert total != 1 or is_hidden(t.container)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0it [00:00, ?it/s]\n", "1it [00:00, 47.87it/s]\n" ] } ], "source": [ "# NBVAL_TEST_NAME: no total\n", "with tqdm() as t:\n", " print(t)\n", " t.update()\n", " print(t)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "disable: None\n", " 0%| | 0/1 [00:00