File tree Expand file tree Collapse file tree 8 files changed +79
-9
lines changed Expand file tree Collapse file tree 8 files changed +79
-9
lines changed Original file line number Diff line number Diff line change 1+ Reorganize the top-level ` examples ` directory to give each example its own sub-directory. Adds content to the docs for each example.
Original file line number Diff line number Diff line change @@ -298,14 +298,8 @@ assert scalar_value == np.int8(42)
298298Each Zarr data type is a separate Python class that inherits from
299299[ ZDType] [ zarr.dtype.ZDType ] . You can define a custom data type by
300300writing your own subclass of [ ZDType] [ zarr.dtype.ZDType ] and adding
301- your data type to the data type registry. A complete example of this process is included below.
302-
303- The source code for this example can be found in the ` examples/custom_dtype.py ` file in the Zarr
304- Python project directory.
305-
306- ``` python
307- -- 8 < -- " examples/custom_dtype.py"
308- ```
301+ your data type to the data type registry. To see an executable demonstration
302+ of this process, see the [ ` custom_dtype ` example] ( ../user-guide/examples/custom_dtype.md ) .
309303
310304### Data Type Resolution
311305
Original file line number Diff line number Diff line change 1+ --8<-- "examples/custom_dtype/README.md"
2+
3+ ## Source Code
4+
5+ ``` python
6+ -- 8 < -- " examples/custom_dtype/custom_dtype.py"
7+ ```
Original file line number Diff line number Diff line change 1+ # Zarr Python Examples
2+
3+ This directory contains complete, runnable examples demonstrating various features and use cases of Zarr Python.
4+
5+ ## Directory Structure
6+
7+ Each example is organized in its own subdirectory with the following structure:
8+
9+ ```
10+ examples/
11+ ├── example_name/
12+ │ ├── README.md # Documentation for the example
13+ │ └── example_name.py # Python source code
14+ └── ...
15+ ```
16+
17+ ## Adding New Examples
18+
19+ To add a new example:
20+
21+ 1 . Create a new subdirectory: ` examples/my_example/ `
22+ 2 . Add your Python code: ` examples/my_example/my_example.py `
23+ 3 . Create documentation: ` examples/my_example/README.md `
24+ 4 . Create a documentation page at ` docs/user-guide/examples/my_example.md ` . The documentation page should simply link to the ` README.md ` and the source code, e.g.:
25+
26+ ````
27+ # docs/user-guide/examples/my_example.md
28+ --8<-- "examples/my_example/README.md"
29+
30+ ## Source Code
31+
32+ ```python
33+ --8<-- "examples/my_example/my_example.py"
34+ ```
35+ ````
36+ 5. Update `mkdocs.yml` to include the new example in the navigation.
37+
38+ ### Example README.md Format
39+
40+ Your README.md should include:
41+
42+ - A title (`# Example Name`)
43+ - Description of what the example demonstrates
44+ - Instructions for running the example
Original file line number Diff line number Diff line change 1+ # Custom Data Type Example
2+
3+ This example demonstrates how to extend Zarr Python by defining a new data type.
4+
5+ The example shows how to:
6+
7+ - Define a custom ` ZDType ` class for the ` int2 ` data type from [ ` ml_dtypes ` ] ( https://pypi.org/project/ml-dtypes/ )
8+ - Implement all required methods for serialization and deserialization
9+ - Register the custom data type with Zarr's registry
10+ - Create and use arrays with the custom data type in both Zarr v2 and v3 formats
11+
12+ ## Running the Example
13+
14+ ``` bash
15+ python examples/custom_dtype/custom_dtype.py
16+ ```
17+
18+ Or run with uv:
19+
20+ ``` bash
21+ uv run examples/custom_dtype/custom_dtype.py
22+ ```
File renamed without changes.
Original file line number Diff line number Diff line change 2626 - user-guide/gpu.md
2727 - user-guide/consolidated_metadata.md
2828 - user-guide/experimental.md
29+ - Examples :
30+ - user-guide/examples/custom_dtype.md
2931 - API Reference :
3032 - api/index.md
3133 - api/array.md
Original file line number Diff line number Diff line change @@ -251,7 +251,7 @@ dependencies = [
251251features = [' docs' , ' remote' ]
252252
253253[tool .hatch .envs .docs .scripts ]
254- serve = " mkdocs serve"
254+ serve = " mkdocs serve --watch src "
255255build = " mkdocs build"
256256check = " mkdocs build --strict"
257257readthedocs = " rm -rf $READTHEDOCS_OUTPUT/html && cp -r site $READTHEDOCS_OUTPUT/html"
You can’t perform that action at this time.
0 commit comments