Skip to content

Commit 07003b8

Browse files
authored
Merge pull request #696 from xylar/fix-docs
Fix conda-package docs
2 parents de8c670 + c0f5884 commit 07003b8

11 files changed

Lines changed: 93 additions & 48 deletions

File tree

.github/workflows/build_workflow.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ jobs:
8484
conda install conda conda-build
8585
conda build -m "conda_package/ci/linux_64_python${{ matrix.python-version }}.____cpython.yaml" "conda_package/recipe"
8686
# Add local build channel first for subsequent micromamba usage
87-
micromamba config append channels "$CONDA_PREFIX/conda-bld"
88-
micromamba config append channels conda-forge
8987
9088
- name: Create Test Environment
9189
run: |
9290
micromamba create -y -n mpas_tools_test \
93-
python=${{ env.BUILD_PYTHON_VERSION }} \
91+
-c ${CONDA_PREFIX}/conda-bld \
92+
-c conda-forge \
93+
python=${{ matrix.python-version }} \
9494
mpas_tools \
9595
sphinx \
9696
mock \
@@ -100,4 +100,4 @@ jobs:
100100
run: |
101101
micromamba activate mpas_tools_test
102102
cd conda_package/docs
103-
DOCS_VERSION=test make versioned-html
103+
DOCS_VERSION=test make versioned-html WERROR=1

conda_package/docs/Makefile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,25 @@
22
#
33

44
# You can set these variables from the command line.
5-
SPHINXOPTS =
5+
SPHINXOPTS ?=
66
SPHINXBUILD = sphinx-build
77
SPHINXPROJ = mpas_tools
88
SOURCEDIR = .
99
BUILDDIR = _build
1010

11+
# Select behavior via an environment/CLI variable
12+
# make versioned-html # normal
13+
# make versioned-html WERROR=1 # treat warnings as errors
14+
ifeq ($(WERROR),1)
15+
SPHINXWARNOPTS = -W --keep-going
16+
else
17+
SPHINXWARNOPTS =
18+
endif
19+
1120
# Build into a versioned subdirectory
1221
versioned-html:
13-
@echo "Building version: $(DOCS_VERSION)"
14-
$(SPHINXBUILD) -b html "$(SOURCEDIR)" "$(BUILDDIR)/html/$(DOCS_VERSION)"
22+
@echo "Building version: $(DOCS_VERSION) (WERROR=$(WERROR))"
23+
$(SPHINXBUILD) $(SPHINXWARNOPTS) -b html "$(SOURCEDIR)" "$(BUILDDIR)/html/$(DOCS_VERSION)"
1524
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html/$(DOCS_VERSION)."
1625
@echo "Setting up shared version switcher for local preview..."
1726
mkdir -p _build/html/shared

conda_package/docs/api.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _api_reference:
2+
13
#############
24
API reference
35
#############
@@ -375,8 +377,8 @@ Visualization
375377
:toctree: generated/
376378

377379
MpasToXdmf
378-
MpasToXdmf.load()
379-
MpasToXdmf.convert_to_xdmf()
380+
MpasToXdmf.load
381+
MpasToXdmf.convert_to_xdmf
380382
main
381383

382384
.. currentmodule:: mpas_tools.viz.mesh_to_triangles

conda_package/docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179

180180
# Example configuration for intersphinx: refer to the Python standard library.
181181
intersphinx_mapping = {
182-
'python': ('https://docs.python.org/', None),
182+
'python': ('https://docs.python.org/3/', None),
183183
'numpy': ('http://docs.scipy.org/doc/numpy/', None),
184184
'xarray': ('http://xarray.pydata.org/en/stable/', None),
185185
'geometric_features':

conda_package/docs/interpolation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
.. _mesh_interpolation:
2-
31
.. |---| unicode:: U+2014 .. em dash, trimming surrounding whitespace
42
:trim:
53

4+
.. _mesh_interpolation:
5+
66
*************
77
Interpolation
88
*************

conda_package/docs/mesh_conversion.rst

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,26 @@ Extensibility and Limitations
266266
- For advanced use cases (e.g., custom mask types or additional properties),
267267
see the source code and docstrings for guidance.
268268

269-
See also the API documentation for :py:mod:`mpas_tools.mesh.mask` for further details.
269+
See also the API documentation for :py:mod:`mpas_tools.mesh.mask` for further
270+
details.
270271

271-
See also the API documentation for :py:mod:`mpas_tools.mesh.mask` for further details.
272+
.. code-block::
273+
274+
$ compute_mpas_region_masks --help
275+
usage: compute_mpas_region_masks [-h] -m MESH_FILE_NAME -g GEOJSON_FILE_NAME
276+
-o MASK_FILE_NAME
277+
[-t MASK_TYPES [MASK_TYPES ...]]
278+
[-c CHUNK_SIZE] [--show_progress]
279+
[-s SUBDIVISION]
280+
[--process_count PROCESS_COUNT]
281+
[--multiprocessing_method MULTIPROCESSING_METHOD]
282+
283+
optional arguments:
284+
-h, --help show this help message and exit
285+
-m MESH_FILE_NAME, --mesh_file_name MESH_FILE_NAME
272286
An MPAS mesh file
273287
-g GEOJSON_FILE_NAME, --geojson_file_name GEOJSON_FILE_NAME
274-
An Geojson file containing mask regions
288+
A GeoJSON file containing mask regions
275289
-o MASK_FILE_NAME, --mask_file_name MASK_FILE_NAME
276290
An output MPAS region masks file
277291
-t MASK_TYPES [MASK_TYPES ...], --mask_types MASK_TYPES [MASK_TYPES ...]
@@ -367,7 +381,7 @@ The command-line tool takes the following arguments:
367381
-m MESH_FILE_NAME, --mesh_file_name MESH_FILE_NAME
368382
An MPAS mesh file
369383
-g GEOJSON_FILE_NAME, --geojson_file_name GEOJSON_FILE_NAME
370-
An Geojson file containing transects
384+
A GeoJSON file containing transects
371385
-o MASK_FILE_NAME, --mask_file_name MASK_FILE_NAME
372386
An output MPAS transect masks file
373387
-t MASK_TYPES [MASK_TYPES ...], --mask_types MASK_TYPES [MASK_TYPES ...]
@@ -423,7 +437,7 @@ The command-line tool takes the following arguments:
423437
-m MESH_FILE_NAME, --mesh_file_name MESH_FILE_NAME
424438
An MPAS mesh file
425439
-g GEOJSON_FILE_NAME, --geojson_file_name GEOJSON_FILE_NAME
426-
An Geojson file containing points at which to start
440+
A GeoJSON file containing points at which to start
427441
the flood fill
428442
-o MASK_FILE_NAME, --mask_file_name MASK_FILE_NAME
429443
An output MPAS region masks file
@@ -461,7 +475,7 @@ The command-line tool takes the following arguments:
461475
--lon LON The name of the longitude coordinate
462476
--lat LAT The name of the latitude coordinate
463477
-g GEOJSON_FILE_NAME, --geojson_file_name GEOJSON_FILE_NAME
464-
An Geojson file containing mask regions
478+
A GeoJSON file containing mask regions
465479
-o MASK_FILE_NAME, --mask_file_name MASK_FILE_NAME
466480
An output MPAS region masks file
467481
-c CHUNK_SIZE, --chunk_size CHUNK_SIZE

conda_package/docs/mesh_creation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
.. _mesh_creation:
2-
31
.. |---| unicode:: U+2014 .. em dash, trimming surrounding whitespace
42
:trim:
53

4+
.. _mesh_creation:
5+
66
*************
77
Mesh Creation
88
*************

conda_package/docs/mpas_to_xdmf.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@ The converter can be used via its command-line interface ``mpas_to_xdmf`` or as
2626
a Python library.
2727

2828
.. note::
29-
Special variable keys:
30-
- ``allOnCells``: all variables with dimension ``nCells``
31-
- ``allOnEdges``: all variables with dimension ``nEdges``
32-
- ``allOnVertices``: all variables with dimension ``nVertices``
33-
Extra dimensions (e.g., ``nVertLevels``) can be sliced using the ``-d``
34-
CLI option or the ``extra_dims`` argument in Python.
29+
30+
Special variable keys:
31+
32+
- ``allOnCells``: all variables with dimension ``nCells``
33+
- ``allOnEdges``: all variables with dimension ``nEdges``
34+
- ``allOnVertices``: all variables with dimension ``nVertices``
35+
36+
Extra dimensions (e.g., ``nVertLevels``) can be sliced using the ``-d``
37+
CLI option or the ``extra_dims`` argument in Python.
3538

3639
Command-Line Arguments
3740
----------------------

conda_package/docs/releasing.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ Version Bump and Dependency Updates
1717
- ``conda_package/mpas_tools/__init__.py``
1818
- ``conda_package/recipe/meta.yaml``
1919

20-
- Make sure the version follows [semantic versioning](https://semver.org/).
20+
- Make sure the version follows semantic versioning (see
21+
https://semver.org/).
2122
For release candidates, use versions like ``1.3.0rc1`` (no ``v`` prefix).
2223

2324
2. **Check and Update Dependencies**
2425

2526
- Ensure that dependencies and their constraints are up-to-date and
2627
consistent in:
28+
2729
- ``conda_package/recipe/meta.yaml`` (dependencies for the conda-forge
2830
release)
2931
- ``conda_package/pyproject.toml`` (dependencies for PyPI; used as a

conda_package/mpas_tools/mesh/mask.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ def compute_mpas_region_masks(
111111
logger.info(f' Computing {maskType} masks:')
112112

113113
# create shapely geometry for lon and lat
114-
points = [shapely.geometry.Point(x, y) for x, y in zip(lon, lat)]
114+
points = [
115+
shapely.geometry.Point(x, y) for x, y in zip(lon, lat, strict=True)
116+
]
115117
regionNames, masks, properties = _compute_region_masks(
116118
fcMask,
117119
points,
@@ -171,7 +173,7 @@ def entry_point_compute_mpas_region_masks():
171173
dest='geojson_file_name',
172174
type=str,
173175
required=True,
174-
help='An Geojson file containing mask regions',
176+
help='A GeoJSON file containing mask regions',
175177
)
176178
parser.add_argument(
177179
'-o',
@@ -418,7 +420,7 @@ def entry_point_compute_mpas_transect_masks():
418420
dest='geojson_file_name',
419421
type=str,
420422
required=True,
421-
help='An Geojson file containing transects',
423+
help='A GeoJSON file containing transects',
422424
)
423425
parser.add_argument(
424426
'-o',
@@ -612,7 +614,7 @@ def entry_point_compute_mpas_flood_fill_mask():
612614
dest='geojson_file_name',
613615
type=str,
614616
required=True,
615-
help='An Geojson file containing points at which to '
617+
help='A GeoJSON file containing points at which to '
616618
'start the flood fill',
617619
)
618620
parser.add_argument(
@@ -708,7 +710,9 @@ def compute_lon_lat_region_masks(
708710
Lat = Lat.ravel()
709711

710712
# create shapely geometry for lon and lat
711-
points = [shapely.geometry.Point(x, y) for x, y in zip(Lon, Lat)]
713+
points = [
714+
shapely.geometry.Point(x, y) for x, y in zip(Lon, Lat, strict=True)
715+
]
712716
regionNames, masks, properties = _compute_region_masks(
713717
fcMask,
714718
points,
@@ -783,7 +787,7 @@ def entry_point_compute_lon_lat_region_masks():
783787
dest='geojson_file_name',
784788
type=str,
785789
required=True,
786-
help='An Geojson file containing mask regions',
790+
help='A GeoJSON file containing mask regions',
787791
)
788792
parser.add_argument(
789793
'-o',
@@ -932,7 +936,8 @@ def compute_projection_grid_region_masks(
932936

933937
# create shapely geometry for lon and lat
934938
points = [
935-
shapely.geometry.Point(x, y) for x, y in zip(lon.ravel(), lat.ravel())
939+
shapely.geometry.Point(x, y)
940+
for x, y in zip(lon.ravel(), lat.ravel(), strict=True)
936941
]
937942
regionNames, masks, properties = _compute_region_masks(
938943
fcMask,
@@ -1005,7 +1010,7 @@ def entry_point_compute_projection_grid_region_masks():
10051010
dest='geojson_file_name',
10061011
type=str,
10071012
required=True,
1008-
help='An Geojson file containing mask regions',
1013+
help='A GeoJSON file containing mask regions',
10091014
)
10101015
parser.add_argument(
10111016
'-o',
@@ -1349,7 +1354,7 @@ def _compute_transect_masks(
13491354
if subdivisionResolution is None:
13501355
new_coords.append(coords)
13511356
else:
1352-
lon, lat = zip(*coords)
1357+
lon, lat = zip(*coords, strict=True)
13531358
x, y, z = lon_lat_to_cartesian(
13541359
lon, lat, earthRadius, degrees=True
13551360
)
@@ -1359,7 +1364,9 @@ def _compute_transect_masks(
13591364
lon, lat = cartesian_to_lon_lat(
13601365
x, y, z, earthRadius, degrees=True
13611366
)
1362-
new_coords.append([list(a) for a in zip(lon, lat)])
1367+
new_coords.append(
1368+
[list(a) for a in zip(lon, lat, strict=True)]
1369+
)
13631370

13641371
if geom_type == 'LineString':
13651372
shape = shapely.geometry.LineString(new_coords[0])
@@ -1471,7 +1478,7 @@ def _get_polygons(dsMesh, maskType):
14711478

14721479
polygons = []
14731480
for index in range(lon.shape[0]):
1474-
coords = zip(lon[index, :], lat[index, :])
1481+
coords = zip(lon[index, :], lat[index, :], strict=True)
14751482
polygons.append(shapely.geometry.Polygon(coords))
14761483

14771484
return polygons, nPolygons, duplicatePolygons
@@ -1608,14 +1615,17 @@ def _compute_edge_sign(dsMesh, edgeMask, shape):
16081615
local_voe[local_mask] = local_v
16091616

16101617
graph = Graph(
1611-
n=len(unique_vertices), edges=zip(local_voe[:, 0], local_voe[:, 1])
1618+
n=len(unique_vertices),
1619+
edges=zip(local_voe[:, 0], local_voe[:, 1], strict=True),
16121620
)
16131621
graph.vs['distance'] = distance
16141622
graph.vs['lon'] = unique_lon
16151623
graph.vs['lat'] = unique_lat
16161624
graph.vs['vertices'] = numpy.arange(len(unique_vertices))
16171625
graph.es['edges'] = edge_indices
1618-
graph.es['vertices'] = [(v0, v1) for v0, v1 in zip(voe[:, 0], voe[:, 1])]
1626+
graph.es['vertices'] = [
1627+
(v0, v1) for v0, v1 in zip(voe[:, 0], voe[:, 1], strict=True)
1628+
]
16191629

16201630
edgeSign = numpy.zeros(edgeMask.shape, dtype=numpy.int32)
16211631

0 commit comments

Comments
 (0)