Skip to content

Commit 54caa86

Browse files
authored
Improvements to doc build process (#647)
1 parent 3fae536 commit 54caa86

File tree

12 files changed

+59
-4
lines changed

12 files changed

+59
-4
lines changed

.github/workflows/docs-publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- name: Build
1919
run: |
2020
pip install .
21+
pip list
2122
make -C docs html
2223
- uses: lauchacarro/Azure-Storage-Action@v1.0
2324
with:

docs/source/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
'sphinx_multiversion',
4848
'nbsphinx',
4949
'sphinx.ext.mathjax',
50+
'matplotlib.sphinxext.plot_directive',
5051
]
5152

5253
# Add any paths that contain templates here, relative to this directory.
@@ -86,7 +87,6 @@
8687
html_theme = 'sphinx_rtd_theme'
8788
else:
8889
html_theme = 'pydata_sphinx_theme'
89-
extensions.append('matplotlib.sphinxext.plot_directive')
9090

9191
html_logo = '_static/img/Xarray-Spatial-logo.svg'
9292

@@ -95,9 +95,9 @@
9595
# sphinx-multiversion config
9696
smv_branch_whitelist = 'master'
9797
if os.getenv('THEME') == 'sphinx_rtd_theme':
98-
smv_tag_whitelist = r'^v([0]\.[1]\.[0-5]|[0]\.[0]\.[0-9])'
98+
smv_tag_whitelist = r'^v([0-9]\.[2-9]\.[0-9])'
9999
else:
100-
smv_tag_whitelist = r'^v([0]\.[1]\.[6-9]|[0-9]\.[2-9]\.[0-9])'
100+
smv_tag_whitelist = r'^v([0-9]\.[2-9]\.[0-9])'
101101

102102
# Load releases
103103
with open("releases.json") as f:

xrspatial/aspect.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def aspect(agg: xr.DataArray,
172172
--------
173173
Aspect works with NumPy backed xarray DataArray
174174
.. sourcecode:: python
175+
175176
>>> import numpy as np
176177
>>> import xarray as xr
177178
>>> from xrspatial import aspect
@@ -207,6 +208,7 @@ def aspect(agg: xr.DataArray,
207208
208209
Aspect works with Dask with NumPy backed xarray DataArray
209210
.. sourcecode:: python
211+
210212
>>> import dask.array as da
211213
>>> data_da = da.from_array(data, chunks=(3, 3))
212214
>>> raster_da = xr.DataArray(data_da, dims=['y', 'x'], name='raster_da')
@@ -232,6 +234,7 @@ def aspect(agg: xr.DataArray,
232234
Aspect works with CuPy backed xarray DataArray.
233235
Make sure you have a GPU and CuPy installed to run this example.
234236
.. sourcecode:: python
237+
235238
>>> import cupy
236239
>>> data_cupy = cupy.asarray(data)
237240
>>> raster_cupy = xr.DataArray(data_cupy, dims=['y', 'x'])

xrspatial/classify.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ def reclassify(agg: xr.DataArray,
207207
--------
208208
Reclassify works with NumPy backed xarray DataArray
209209
.. sourcecode:: python
210+
210211
>>> import numpy as np
211212
>>> import xarray as xr
212213
>>> from xrspatial.classify import reclassify
@@ -238,6 +239,7 @@ def reclassify(agg: xr.DataArray,
238239
239240
Reclassify works with Dask with NumPy backed xarray DataArray
240241
.. sourcecode:: python
242+
241243
>>> import dask.array as da
242244
>>> data_da = da.from_array(data, chunks=(3, 3))
243245
>>> agg_da = xr.DataArray(data_da, name='agg_da')
@@ -261,6 +263,7 @@ def reclassify(agg: xr.DataArray,
261263
Reclassify works with CuPy backed xarray DataArray.
262264
Make sure you have a GPU and CuPy installed to run this example.
263265
.. sourcecode:: python
266+
264267
>>> import cupy
265268
>>> data_cupy = cupy.asarray(data)
266269
>>> agg_cupy = xr.DataArray(data_cupy)
@@ -357,6 +360,7 @@ def quantile(agg: xr.DataArray,
357360
--------
358361
Quantile work with numpy backed xarray DataArray
359362
.. sourcecode:: python
363+
360364
>>> import numpy as np
361365
>>> import xarray as xr
362366
>>> from xrspatial.classify import quantile
@@ -628,6 +632,7 @@ def natural_breaks(agg: xr.DataArray,
628632
-------
629633
natural_breaks() works with numpy backed xarray DataArray.
630634
.. sourcecode:: python
635+
631636
>>> import numpy as np
632637
>>> import xarray as xr
633638
>>> from xrspatial.classify import natural_breaks
@@ -654,6 +659,7 @@ def natural_breaks(agg: xr.DataArray,
654659
655660
natural_breaks() works with cupy backed xarray DataArray.
656661
.. sourcecode:: python
662+
657663
>>> import cupy
658664
>>> agg_cupy = xr.DataArray(cupy.asarray(elevation))
659665
>>> cupy_natural_breaks = natural_breaks(agg_cupy)
@@ -750,6 +756,7 @@ def equal_interval(agg: xr.DataArray,
750756
Examples
751757
--------
752758
.. sourcecode:: python
759+
753760
>>> import numpy as np
754761
>>> import xarray as xr
755762
>>> from xrspatial.classify import equal_interval

xrspatial/convolution.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def calc_cellsize(raster):
100100
Examples
101101
--------
102102
.. sourcecode:: python
103+
103104
>>> import numpy as np
104105
>>> import xarray as xr
105106
>>> h, w = 100, 200
@@ -417,6 +418,7 @@ def convolution_2d(agg, kernel, name='convolution_2d'):
417418
--------
418419
convolution_2d() works with NumPy backed DataArray.
419420
.. sourcecode:: python
421+
420422
>>> import numpy as np
421423
>>> import xarray as xr
422424
>>> from xrspatial.convolution import circle_kernel
@@ -447,6 +449,7 @@ def convolution_2d(agg, kernel, name='convolution_2d'):
447449
448450
convolution_2d() works with Dask with NumPy backed DataArray.
449451
.. sourcecode:: python
452+
450453
>>> from xrspatial.convolution import annulus_kernel
451454
>>> kernel = annulus_kernel(1, 1, 1.5, 0.5)
452455
>>> kernel
@@ -474,6 +477,7 @@ def convolution_2d(agg, kernel, name='convolution_2d'):
474477
475478
convolution_2d() works with CuPy backed DataArray.
476479
.. sourcecode:: python
480+
477481
>>> from xrspatial.convolution import custom_kernel
478482
>>> kernel = custom_kernel(np.array([
479483
... [1, 0, 0],

xrspatial/curvature.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ def curvature(agg: xr.DataArray,
125125
--------
126126
Curvature works with NumPy backed xarray DataArray
127127
.. sourcecode:: python
128+
128129
>>> import numpy as np
129130
>>> import xarray as xr
130131
>>> from xrspatial import curvature
@@ -144,6 +145,7 @@ def curvature(agg: xr.DataArray,
144145
145146
Curvature works with Dask with NumPy backed xarray DataArray
146147
.. sourcecode:: python
148+
147149
>>> convex_data = np.array([
148150
[0, 0, 0, 0, 0],
149151
[0, 0, 0, 0, 0],
@@ -179,6 +181,7 @@ def curvature(agg: xr.DataArray,
179181
180182
Curvature works with CuPy backed xarray DataArray.
181183
.. sourcecode:: python
184+
182185
>>> import cupy
183186
>>> concave_data = np.array([
184187
[0, 0, 0, 0, 0],

xrspatial/focal.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def mean(agg, passes=1, excludes=[np.nan], name='mean'):
137137
--------
138138
Focal mean works with NumPy backed xarray DataArray
139139
.. sourcecode:: python
140+
140141
>>> import numpy as np
141142
>>> import xarray as xr
142143
>>> from xrspatial.focal import mean
@@ -160,6 +161,7 @@ def mean(agg, passes=1, excludes=[np.nan], name='mean'):
160161
Focal mean works with Dask with NumPy backed xarray DataArray.
161162
Increase number of runs by setting a specific value for parameter `passes`
162163
.. sourcecode:: python
164+
163165
>>> import dask.array as da
164166
>>> data_da = da.from_array(data, chunks=(3, 3))
165167
>>> raster_da = xr.DataArray(data_da, dims=['y', 'x'], name='raster_da') # noqa
@@ -185,6 +187,7 @@ def mean(agg, passes=1, excludes=[np.nan], name='mean'):
185187
In this example, we set `passes` to the number of elements of the array,
186188
we'll get a mean array where every element has the same value.
187189
.. sourcecode:: python
190+
188191
>>> import cupy
189192
>>> raster_cupy = xr.DataArray(cupy.asarray(data), name='raster_cupy')
190193
>>> mean_cupy = mean(raster_cupy, passes=25)
@@ -336,6 +339,7 @@ def apply(raster, kernel, func=_calc_mean, name='focal_apply'):
336339
--------
337340
Focal apply works with NumPy backed xarray DataArray
338341
.. sourcecode:: python
342+
339343
>>> import numpy as np
340344
>>> import xarray as xr
341345
>>> from xrspatial.convolution import circle_kernel
@@ -368,7 +372,9 @@ def apply(raster, kernel, func=_calc_mean, name='focal_apply'):
368372
the applied function must be decorated with ``numba.jit``
369373
xrspatial already provides ``ngjit`` decorator, where:
370374
``ngjit = numba.jit(nopython=True, nogil=True)``
375+
371376
.. sourcecode:: python
377+
372378
>>> from xrspatial.utils import ngjit
373379
>>> from xrspatial.convolution import custom_kernel
374380
>>> kernel = custom_kernel(np.array([
@@ -470,6 +476,7 @@ def focal_stats(agg,
470476
Examples
471477
--------
472478
.. sourcecode:: python
479+
473480
>>> import numpy as np
474481
>>> import xarray as xr
475482
>>> from xrspatial.convolution import circle_kernel
@@ -700,6 +707,7 @@ def hotspots(raster, kernel):
700707
Examples
701708
--------
702709
.. sourcecode:: python
710+
703711
>>> import numpy as np
704712
>>> import xarray as xr
705713
>>> from xrspatial.convolution import custom_kernel

xrspatial/hillshade.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def hillshade(agg: xr.DataArray,
134134
Examples
135135
--------
136136
.. sourcecode:: python
137+
137138
>>> import numpy as np
138139
>>> import xarray as xr
139140
>>> from xrspatial import hillshade

xrspatial/multispectral.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ def arvi(nir_agg: xr.DataArray,
106106
Examples
107107
--------
108108
In this example, we'll use data available in xrspatial.datasets
109+
109110
.. plot::
110111
:include-source:
112+
111113
>>> from xrspatial.datasets import get_data
112114
>>> data = get_data('sentinel-2') # Open Example Data
113115
>>> nir = data['NIR']
@@ -122,6 +124,7 @@ def arvi(nir_agg: xr.DataArray,
122124
>>> arvi_agg.plot(aspect=2, size=4)
123125
124126
.. sourcecode:: python
127+
125128
>>> y1, x1, y2, x2 = 100, 100, 103, 104
126129
>>> print(nir[y1:y2, x1:x2].data)
127130
[[1519. 1504. 1530. 1589.]
@@ -270,6 +273,7 @@ def evi(nir_agg: xr.DataArray,
270273
>>> evi_agg.plot(aspect=2, size=4)
271274
272275
.. sourcecode:: python
276+
273277
>>> y, x = 100, 100
274278
>>> m, n = 3, 4
275279
>>> print(nir[y1:y2, x1:x2].data)
@@ -409,6 +413,7 @@ def gci(nir_agg: xr.DataArray,
409413
>>> gci_agg.plot(aspect=2, size=4)
410414
411415
.. sourcecode:: python
416+
412417
>>> y1, x1, y2, x2 = 100, 100, 103, 104
413418
>>> print(nir[y1:y2, x1:x2].data)
414419
[[1519. 1504. 1530. 1589.]
@@ -472,6 +477,7 @@ def nbr(nir_agg: xr.DataArray,
472477
--------
473478
.. plot::
474479
:include-source:
480+
475481
>>> from xrspatial.datasets import get_data
476482
>>> data = get_data('sentinel-2') # Open Example Data
477483
>>> nir = data['NIR']
@@ -484,6 +490,7 @@ def nbr(nir_agg: xr.DataArray,
484490
>>> nbr_agg.plot(aspect=2, size=4)
485491
486492
.. sourcecode:: python
493+
487494
>>> y1, x1, y2, x2 = 100, 100, 103, 104
488495
>>> print(nir[y1:y2, x1:x2].data)
489496
[[1519. 1504. 1530. 1589.]
@@ -554,6 +561,7 @@ def nbr2(swir1_agg: xr.DataArray,
554561
--------
555562
.. plot::
556563
:include-source:
564+
557565
>>> from xrspatial.datasets import get_data
558566
>>> data = get_data('sentinel-2') # Open Example Data
559567
>>> swir1 = data['SWIR1']
@@ -566,6 +574,7 @@ def nbr2(swir1_agg: xr.DataArray,
566574
>>> nbr2_agg.plot(aspect=2, size=4)
567575
568576
.. sourcecode:: python
577+
569578
>>> y1, x1, y2, x2 = 100, 100, 103, 104
570579
>>> print(swir1[y1:y2, x1:x2].data)
571580
[[2092. 2242. 2333. 2382.]
@@ -630,7 +639,7 @@ def ndvi(nir_agg: xr.DataArray,
630639
--------
631640
.. plot::
632641
:include-source:
633-
>>> from xrspatial.datasets import get_data
642+
>>> from xrspatial.datasets import get_data
634643
>>> data = get_data('sentinel-2') # Open Example Data
635644
>>> nir = data['NIR']
636645
>>> red = data['Red']
@@ -642,6 +651,7 @@ def ndvi(nir_agg: xr.DataArray,
642651
>>> ndvi_agg.plot(aspect=2, size=4)
643652
644653
.. sourcecode:: python
654+
645655
>>> y1, x1, y2, x2 = 100, 100, 103, 104
646656
>>> print(nir[y1:y2, x1:x2].data)
647657
[[1519. 1504. 1530. 1589.]
@@ -710,6 +720,7 @@ def ndmi(nir_agg: xr.DataArray,
710720
--------
711721
.. plot::
712722
:include-source:
723+
713724
>>> from xrspatial.datasets import get_data
714725
>>> data = get_data('sentinel-2') # Open Example Data
715726
>>> nir = data['NIR']
@@ -722,6 +733,7 @@ def ndmi(nir_agg: xr.DataArray,
722733
>>> ndmi_agg.plot(aspect=2, size=4)
723734
724735
.. sourcecode:: python
736+
725737
>>> y1, x1, y2, x2 = 100, 100, 103, 104
726738
>>> print(nir[y1:y2, x1:x2].data)
727739
[[1519. 1504. 1530. 1589.]
@@ -892,6 +904,7 @@ def savi(nir_agg: xr.DataArray,
892904
--------
893905
.. plot::
894906
:include-source:
907+
895908
>>> from xrspatial.datasets import get_data
896909
>>> data = get_data('sentinel-2') # Open Example Data
897910
>>> nir = data['NIR']
@@ -904,6 +917,7 @@ def savi(nir_agg: xr.DataArray,
904917
>>> savi_agg.plot(aspect=2, size=4)
905918
906919
.. sourcecode:: python
920+
907921
>>> print(nir[y1:y2, x1:x2].data)
908922
[[1519. 1504. 1530. 1589.]
909923
[1491. 1473. 1542. 1609.]
@@ -1020,6 +1034,7 @@ def sipi(nir_agg: xr.DataArray,
10201034
--------
10211035
.. plot::
10221036
:include-source:
1037+
10231038
>>> from xrspatial.datasets import get_data
10241039
>>> data = get_data('sentinel-2') # Open Example Data
10251040
>>> nir = data['NIR']
@@ -1034,6 +1049,7 @@ def sipi(nir_agg: xr.DataArray,
10341049
>>> sipi_agg.plot(aspect=2, size=4)
10351050
10361051
.. sourcecode:: python
1052+
10371053
>>> y1, x1, y2, x2 = 100, 100, 103, 104
10381054
>>> print(nir[y1:y2, x1:x2].data)
10391055
[[1519. 1504. 1530. 1589.]
@@ -1357,6 +1373,7 @@ def true_color(r, g, b, nodata=1, c=10.0, th=0.125, name='true_color'):
13571373
--------
13581374
.. plot::
13591375
:include-source:
1376+
13601377
>>> from xrspatial.datasets import get_data
13611378
>>> data = get_data('sentinel-2') # Open Example Data
13621379
>>> red = data['Red']

0 commit comments

Comments
 (0)