-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c8a7b3f
commit 6babc50
Showing
4 changed files
with
277 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# jabbar usage example" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"All we need to do is import the `jabbar` bar object." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import time\n", | ||
"from jabbar import jabbar" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"jabbar can simply wrap around any iterable to make loops show a little progress bar:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"100% |████████████████████████| 666/666 \n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"for _ in jabbar(range(666)):\n", | ||
" time.sleep(0.002)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"The updating scheme can also be individually specified:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"100% |████████████████████████████████████████| 1000/1000 \n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"with jabbar(total=1000, width=40) as bar:\n", | ||
" for _ in range(50):\n", | ||
" time.sleep(0.001)\n", | ||
" bar.inc(20)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"The final count can be higher than the pre-defined maximum in case that is not completely known a-priori:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"100% |████████████████████████| 420/420 \n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"with jabbar(total=420) as bar:\n", | ||
" for _ in range(420):\n", | ||
" time.sleep(0.001)\n", | ||
" bar.inc()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"You can also go fully manual without the context manager if needed. Just manually finish the bar afterwards:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"100% |████████████████████████| 753/753 \n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"bar = jabbar(total=753)\n", | ||
"for _ in range(753):\n", | ||
" time.sleep(0.001)\n", | ||
" bar.inc()\n", | ||
"# call finish afterwards\n", | ||
"bar.finish()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"You can also individualize the used symbols:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"100% |========================| 404/404 \n", | ||
"100% |yoyoyoyoyoyoyoyoyoyoyoyo| 404/404 \n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"for _ in jabbar(range(404), bar_symbols='='):\n", | ||
" time.sleep(0.002)\n", | ||
"for _ in jabbar(range(404), bar_symbols='yo'):\n", | ||
" time.sleep(0.002)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Why not a bar of 🦄 or 🙄? Bam." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"100% |🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄| 42/42 \n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"for _ in jabbar(range(42), bar_symbols='🦄'):\n", | ||
" time.sleep(0.05)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Just be aware that in particular unicorns are shy and may not show up sometimes." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Further configurations and details can be found in the API documentation." | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters