Skip to content

Commit

Permalink
Include notebook demonstrating tree
Browse files Browse the repository at this point in the history
Provides a quick demo showing how to use `tree` to get text-based and
HTML-based representations of a Zarr `Group` object.
  • Loading branch information
jakirkham committed Oct 27, 2017
1 parent 0f67052 commit f9170cd
Showing 1 changed file with 177 additions and 0 deletions.
177 changes: 177 additions & 0 deletions notebooks/repr_tree.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import zarr"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"g1 = zarr.group()\n",
"g3 = g1.create_group('bar')\n",
"g3.create_group('baz')\n",
"g5 = g3.create_group('quux')\n",
"g5.create_dataset('baz', shape=100, chunks=10)\n",
"g7 = g3.create_group('zoo')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"/\n",
" +-- bar\n",
" +-- baz\n",
" +-- quux\n",
" | +-- baz[...]\n",
" +-- zoo\n"
]
}
],
"source": [
"print(g1.tree())"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<style type=\"text/css\">\n",
"div.zarrTree {\n",
" font-family: Courier, monospace;\n",
" font-size: 11pt;\n",
" font-style: normal;\n",
"}\n",
"\n",
"div.zarrTree ul,\n",
"div.zarrTree li,\n",
"div.zarrTree li > div {\n",
" display: block;\n",
" position: relative;\n",
"}\n",
"\n",
"div.zarrTree ul,\n",
"div.zarrTree li {\n",
" list-style-type: none;\n",
"}\n",
"\n",
"div.zarrTree li {\n",
" border-left: 2px solid #000;\n",
" margin-left: 1em;\n",
"}\n",
"\n",
"div.zarrTree li > div {\n",
" padding-left: 1.3em;\n",
" padding-top: 0.225em;\n",
" padding-bottom: 0.225em;\n",
"}\n",
"\n",
"div.zarrTree li > div::before {\n",
" content: '';\n",
" position: absolute;\n",
" top: 0;\n",
" left: -2px;\n",
" bottom: 50%;\n",
" width: 1.2em;\n",
" border-left: 2px solid #000;\n",
" border-bottom: 2px solid #000;\n",
"}\n",
"\n",
"div.zarrTree > ul > li:first-child > div {\n",
" padding-left: 4%;\n",
"}\n",
"\n",
"div.zarrTree > ul > li:first-child > div::before {\n",
" border: 0 none transparent;\n",
"}\n",
"\n",
"div.zarrTree ul > li:last-child {\n",
" border-left: 2px solid transparent;\n",
"}\n",
"</style>\n",
"\n",
"<div class=\"zarrTree\">\n",
"<ul>\n",
" <li><div>/</div>\n",
" <ul>\n",
" <li><div>bar</div>\n",
" <ul>\n",
" <li><div>baz</div></li>\n",
" <li><div>quux</div>\n",
" <ul>\n",
" <li><div>baz[...]</div></li>\n",
" </ul>\n",
" </li>\n",
" <li><div>zoo</div></li>\n",
" </ul>\n",
" </li>\n",
" </ul>\n",
" </li>\n",
"</ul>\n",
"</div>\n"
],
"text/plain": [
"/\n",
" +-- bar\n",
" +-- baz\n",
" +-- quux\n",
" | +-- baz[...]\n",
" +-- zoo"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"g1.tree()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.6.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit f9170cd

Please sign in to comment.