File tree Expand file tree Collapse file tree 4 files changed +67
-0
lines changed Expand file tree Collapse file tree 4 files changed +67
-0
lines changed 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 . Run the documentation generator: ` python3 scripts/generate_examples_docs.py `
25
+
26
+ The documentation generator will automatically:
27
+ - Create a documentation page at ` docs/user-guide/examples/my_example.md `
28
+ - Update ` mkdocs.yml ` to include the new example in the navigation
29
+
30
+ ### Example README.md Format
31
+
32
+ Your README.md should include:
33
+
34
+ - A title (# Example Name)
35
+ - Description of what the example demonstrates
36
+ - Instructions for running the example
37
+
38
+ ** Note:** The source code will be automatically appended to the documentation when you run the generator script.
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.
You can’t perform that action at this time.
0 commit comments