Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdc5334e

Browse files
d-v-bmaxrjones
andauthored
docs/examples (#3502)
* add documentation for examples* update docs deployment* fix broken link* update main examples documentation* changelog* Update mkdocs.ymlCo-authored-by: Max Jones <14077947+maxrjones@users.noreply.github.com>---------Co-authored-by: Max Jones <14077947+maxrjones@users.noreply.github.com>
1 parent49db79a commitdc5334e

File tree

8 files changed

+79
-9
lines changed

8 files changed

+79
-9
lines changed

‎changes/3502.doc.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Reorganize the top-level`examples` directory to give each example its own sub-directory. Adds content to the docs for each example.

‎docs/user-guide/data_types.md‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,8 @@ assert scalar_value == np.int8(42)
298298
Each Zarr data type is a separate Python class that inherits from
299299
[ZDType][zarr.dtype.ZDType]. You can define a custom data type by
300300
writing 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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
--8<-- "examples/custom_dtype/README.md"
2+
3+
##Source Code
4+
5+
```python
6+
--8<--"examples/custom_dtype/custom_dtype.py"
7+
```

‎examples/README.md‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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

‎examples/custom_dtype/README.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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.

‎mkdocs.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ nav:
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

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ dependencies = [
251251
features = ['docs','remote']
252252

253253
[tool.hatch.envs.docs.scripts]
254-
serve ="mkdocs serve"
254+
serve ="mkdocs serve --watch src"
255255
build ="mkdocs build"
256256
check ="mkdocs build --strict"
257257
readthedocs ="rm -rf $READTHEDOCS_OUTPUT/html && cp -r site $READTHEDOCS_OUTPUT/html"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp