tests: notebook: ncols

This commit is contained in:
Casper da Costa-Luis 2021-03-09 00:53:19 +00:00
parent aa2e430865
commit 1ddb6745c5
No known key found for this signature in database
GPG Key ID: F5126E5FBD2512AD
1 changed files with 91 additions and 13 deletions

View File

@ -16,7 +16,6 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"from functools import partial\n", "from functools import partial\n",
"from time import sleep\n",
"\n", "\n",
"from tqdm.notebook import tqdm_notebook\n", "from tqdm.notebook import tqdm_notebook\n",
"from tqdm.notebook import tnrange\n", "from tqdm.notebook import tnrange\n",
@ -97,20 +96,69 @@
"8\n", "8\n",
"9\n" "9\n"
] ]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e29668be41ca4e40b16fb98572b333a5",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/10 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
} }
], ],
"source": [ "source": [
"for i in tqdm_notebook(range(10)):\n", "with tqdm_notebook(range(10)) as t:\n",
" sleep(0.01)\n", " for i in t:\n",
" print(i)" " print(i)\n",
"\n",
"t = tqdm_notebook(total=10)\n",
"t.update()\n",
"t.refresh()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# reset"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
"source": [] {
"name": "stdout",
"output_type": "stream",
"text": [
" 10%|█ | 1/10 [00:00<00:00, 30.04it/s]\n",
" 20%|██ | 1/5 [00:00<00:00, 495.37it/s]\n"
]
}
],
"source": [
"print(t)\n",
"t.reset(total=5)\n",
"t.update(1)\n",
"print(t)"
]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -121,7 +169,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 5,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -155,7 +203,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 6,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -164,7 +212,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 7,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -183,7 +231,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 8,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -193,7 +241,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 9,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -219,7 +267,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 10,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -237,6 +285,36 @@
" t.update()\n", " t.update()\n",
" print(t)" " print(t)"
] ]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# ncols"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0%| | 0/10 [00:00<?, ?it/s]\n",
" 10%|███ | 1/10 [00:00<00:00, 32.29it/s]\n"
]
}
],
"source": [
"with trange(10, ncols=66) as t:\n",
" print(t)\n",
" for i in t:\n",
" if i == 1:\n",
" break\n",
" print(t)"
]
} }
], ],
"metadata": { "metadata": {