Skip to content

Commit fb537d5

Browse files
committed
Move the GridKind and Index documentation directly into the docs
Previously they documented actual values in the code, but now that the generic parameters are more ephemeral, there was nothing to document.
1 parent 8079de6 commit fb537d5

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

docs/api/conventions/interface.rst

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Convention interface
77
.. contents::
88
:local:
99

10+
.. currentmodule:: emsarray.conventions
11+
1012
Each supported convention implements
1113
the :class:`~emsarray.conventions.Convention` interface.
1214

@@ -25,8 +27,37 @@ the :class:`~emsarray.conventions.Convention` interface.
2527
.. autoclass:: emsarray.conventions.SpatialIndexItem
2628
:members:
2729

28-
.. autodata:: emsarray.conventions._base.GridKind
29-
.. autodata:: emsarray.conventions._base.Index
30+
.. type:: GridKind
31+
32+
Some type that can enumerate the different :ref:`grid types <grids>`
33+
present in a dataset.
34+
This can be an :class:`enum.Enum` listing each different kind of grid.
35+
36+
:type:`Index` values will be included in the feature properties
37+
of exported geometry from :mod:`emsarray.operations.geometry`.
38+
If the index type includes the grid kind,
39+
the grid kind needs to be JSON serializable.
40+
The easiest way to achieve this is to make your GridKind type subclass :class:`str`:
41+
42+
.. code-block:: python
43+
44+
class MyGridKind(str, enum.Enum):
45+
face = 'face'
46+
edge = 'edge'
47+
node = 'node'
48+
49+
For cases where the convention only supports a single grid,
50+
a singleton enum can be used.
51+
52+
More esoteric cases involving datasets with a potentially unbounded numbers of grids
53+
can use a type that supports this instead.
54+
55+
.. type:: Index
56+
57+
An :ref:`index <indexing>` to a specific point on a grid in this convention.
58+
For conventions with :ref:`multiple grids <grids>` (e.g. cells, edges, and nodes),
59+
this should be a tuple whos first element is :type:`.GridKind`.
60+
For conventions with a single grid, :type:`.GridKind` is not required.
3061

3162
.. autoclass:: emsarray.conventions.Specificity
3263
:members:

src/emsarray/conventions/_base.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -38,37 +38,6 @@
3838
logger = logging.getLogger(__name__)
3939

4040

41-
#: Some type that can enumerate the different :ref:`grid types <grids>`
42-
#: present in a dataset.
43-
#: This can be an :class:`enum.Enum` listing each different kind of grid.
44-
#:
45-
#: :data:`Index` values will be included in the feature properties
46-
#: of exported geometry from :mod:`emsarray.operations.geometry`.
47-
#: If the index type includes the grid kind,
48-
#: the grid kind needs to be JSON serializable.
49-
#: The easiest way to achieve this is to make your GridKind type subclass :class:`str`:
50-
#:
51-
#: .. code-block:: python
52-
#:
53-
#: class MyGridKind(str, enum.Enum):
54-
#: face = 'face'
55-
#: edge = 'edge'
56-
#: node = 'node'
57-
#:
58-
#: For cases where the convention only supports a single grid,
59-
#: a singleton enum can be used.
60-
#:
61-
#: More esoteric cases involving datasets with a potentially unbounded numbers of grids
62-
#: can use a type that supports this instead.
63-
# GridKind = TypeVar("GridKind")
64-
65-
#: An :ref:`index <indexing>` to a specific point on a grid in this convention.
66-
#: For conventions with :ref:`multiple grids <grids>` (e.g. cells, edges, and nodes),
67-
#: this should be a tuple whos first element is :data:`.GridKind`.
68-
#: For conventions with a single grid, :data:`.GridKind` is not required.
69-
# Index = TypeVar("Index")
70-
71-
7241
@dataclasses.dataclass
7342
class SpatialIndexItem[Index]:
7443
"""Information about an item in the :class:`~shapely.strtree.STRtree`

0 commit comments

Comments
 (0)