Skip to content

Instantly share code, notes, and snippets.

@jhamman
Created February 7, 2024 06:12
Show Gist options
  • Save jhamman/78d8c038d759805534218232e0a7863b to your computer and use it in GitHub Desktop.
Save jhamman/78d8c038d759805534218232e0a7863b to your computer and use it in GitHub Desktop.
Zarr V3 status update
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "18b69086-3380-418f-bbae-71872f6bfb96",
"metadata": {},
"outputs": [],
"source": [
"from zarr.v3 import Array, Group\n",
"from zarr.v3.store import LocalStore\n",
"\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "d3331872-e0f2-46c9-b47e-806ab1ba5f65",
"metadata": {},
"outputs": [],
"source": [
"!rm -r /Users/jhamman/workdir/demo\n",
"store = LocalStore(\"/Users/jhamman/workdir/demo\", )"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "51b6a217-b7cb-43cf-832f-f53604b5c11b",
"metadata": {},
"outputs": [],
"source": [
"root_group = Group.create(store, attributes={\"title\": \"Demo root group\"})\n",
"foo_group = root_group.create_group(\"foo\", attributes={\"title\": \"foo group!\"})\n",
"bar_array = foo_group.create_array(\"bar\", shape=(10, 10), dtype=\"int16\", chunk_shape=(2, 2))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "ab9f9edd-04a8-4ff0-8cc9-0055dc01eccf",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36m/Users/jhamman/workdir/demo/\u001b[0m\n",
"├── \u001b[1;36mfoo\u001b[0m\n",
"│ ├── \u001b[1;36mbar\u001b[0m\n",
"│ │ └── zarr.json\n",
"│ └── zarr.json\n",
"└── zarr.json\n",
"\n",
"3 directories, 3 files\n"
]
}
],
"source": [
"!tree /Users/jhamman/workdir/demo/"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "e57ab102-121d-4bb8-93c7-77ddc0a1bb8f",
"metadata": {},
"outputs": [],
"source": [
"bar_array[:] = np.random.randint(0, 100, size=(10, 10))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "c198a9a0-52dc-44e8-9fa9-52d43a206001",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1;36m/Users/jhamman/workdir/demo/\u001b[0m\n",
"├── \u001b[1;36mfoo\u001b[0m\n",
"│ ├── \u001b[1;36mbar\u001b[0m\n",
"│ │ ├── \u001b[1;36mc\u001b[0m\n",
"│ │ │ ├── \u001b[1;36m0\u001b[0m\n",
"│ │ │ │ ├── 0\n",
"│ │ │ │ ├── 1\n",
"│ │ │ │ ├── 2\n",
"│ │ │ │ ├── 3\n",
"│ │ │ │ └── 4\n",
"│ │ │ ├── \u001b[1;36m1\u001b[0m\n",
"│ │ │ │ ├── 0\n",
"│ │ │ │ ├── 1\n",
"│ │ │ │ ├── 2\n",
"│ │ │ │ ├── 3\n",
"│ │ │ │ └── 4\n",
"│ │ │ ├── \u001b[1;36m2\u001b[0m\n",
"│ │ │ │ ├── 0\n",
"│ │ │ │ ├── 1\n",
"│ │ │ │ ├── 2\n",
"│ │ │ │ ├── 3\n",
"│ │ │ │ └── 4\n",
"│ │ │ ├── \u001b[1;36m3\u001b[0m\n",
"│ │ │ │ ├── 0\n",
"│ │ │ │ ├── 1\n",
"│ │ │ │ ├── 2\n",
"│ │ │ │ ├── 3\n",
"│ │ │ │ └── 4\n",
"│ │ │ └── \u001b[1;36m4\u001b[0m\n",
"│ │ │ ├── 0\n",
"│ │ │ ├── 1\n",
"│ │ │ ├── 2\n",
"│ │ │ ├── 3\n",
"│ │ │ └── 4\n",
"│ │ └── zarr.json\n",
"│ └── zarr.json\n",
"└── zarr.json\n",
"\n",
"9 directories, 28 files\n"
]
}
],
"source": [
"!tree /Users/jhamman/workdir/demo/"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "70d78c6a-3834-4f03-9eb2-b09562e14911",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment