Skip to content

Commit 1a2e868

Browse files
authored
Raise documentation and examples errors in CI (#736)
* Remove unused modules in `floris.tools` * Fix broken import paths * Removed unused reference file * Disable auto-doc for private functions * Fix references format in CC docstring * isort * Add Em Gauss page to toc * Spell check in docstrings * Raise an error when notebooks fail in docs build * Run the examples far away from the top directory This ensures there’s no reliance on the repo struture to find source files * Expand Python version checks * Pin docs dependencies versions Jupyter Book v0.14 supports setting this: nb_execution_show_tb: true nb_execution_raise_on_error: true And sphinx-book-theme 0.4.0rc1 is the required version for JupyterBook v0.14. Note that there is an incompatibility with FLORIS docs and JupyterBook v0.15, sphinx-book-theme v1.0. * Fix configuration parameter * Use index for home page Mostly just to make the docs build on GitHub to test that it exits on error
1 parent a4768d0 commit 1a2e868

35 files changed

+75
-1505
lines changed

.github/workflows/check-working-examples.yaml

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ${{ matrix.os }}
99
strategy:
1010
matrix:
11-
python-version: ["3.10"]
11+
python-version: ["3.9", "3.10", "3.11"]
1212
os: [ubuntu-latest] #, macos-latest, windows-latest]
1313
fail-fast: False
1414

@@ -25,9 +25,14 @@ jobs:
2525
pip install nbconvert # For converting Jupyter notebook to python script in the next step
2626
- name: Run examples
2727
# Run all examples and test that they finish successfully. Do not evaluate the results.
28+
# Copy the examples to a new directory outside of the repo to ensure that there is no
29+
# reliance on the repo directory structure.
2830
run: |
2931
30-
cd examples/
32+
mkdir -p temp1/temp2/temp3
33+
cp -r examples/ temp1/temp2/temp3/.
34+
cd temp1/temp2/temp3/examples/
35+
3136
error_found=0 # 0 is false
3237
error_results="Error in example:"
3338

.github/workflows/continuous-integration-workflow.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ${{ matrix.os }}
99
strategy:
1010
matrix:
11-
python-version: ["3.8", "3.9", "3.10"]
11+
python-version: ["3.8", "3.9", "3.10", "3.11"]
1212
os: [ubuntu-latest] #, macos-latest, windows-latest]
1313
fail-fast: False
1414
env:

docs/_config.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,17 @@ sphinx:
4444
- 'sphinx.ext.viewcode'
4545
- 'sphinx_autodoc_typehints'
4646
- 'sphinxcontrib.autoyaml'
47-
- 'sphinx.ext.napoleon' # Formats google and numpy docstring styles
47+
- 'sphinx.ext.napoleon' # Formats google and numpy docstring styles
4848
- 'sphinxcontrib.mermaid'
4949
config:
5050
html_theme: sphinx_book_theme
5151
templates_path:
5252
- '_templates'
5353
language: 'python'
54+
nb_execution_show_tb: true # Shows the stack trace in stdout; its suppressed otherwise.
55+
nb_execution_raise_on_error: true # Stops the Sphinx build if there is an error in a notebook. See https://github.com/executablebooks/jupyter-book/issues/2011
56+
suppress_warnings:
57+
- etoc.toctree # autodoc output contains toctrees, so suppress this warning. See https://github.com/executablebooks/sphinx-external-toc/issues/36
5458
autoyaml_level: 3
5559
autosummary_generate: true
5660

@@ -60,7 +64,7 @@ sphinx:
6064
members: true
6165
member-order: bysource
6266
undoc-members: true
63-
private-members: true
67+
private-members: false
6468
# special-members: true
6569
# inherited-members
6670
# show-inheritance

docs/_toc.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
# Learn more at https://jupyterbook.org/customize/toc.html
33

44
format: jb-book
5-
root: intro
5+
root: index
66
parts:
77
- caption: Getting Started
88
chapters:
9-
# - file: intro
109
- file: installation
1110

1211
- caption: User Reference
@@ -21,6 +20,8 @@ parts:
2120
- caption: Theory and Background
2221
chapters:
2322
- file: wake_models
23+
sections:
24+
- file: empirical_gauss_model
2425
- file: bibliography
2526

2627
- caption: Developer Reference
File renamed without changes.

docs/reference.md

-1
This file was deleted.

docs/references.bib

+2-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ @article{bastankhah_2021
259259
publisher={Cambridge University Press},
260260
author={Bastankhah, Majid and Welch, Bridget L. and Martínez-Tossas, Luis A. and King, Jennifer and Fleming, Paul},
261261
year={2021},
262-
pages={A53}}
262+
pages={A53}
263+
}
263264

264265
@Article{bay_2022,
265266
AUTHOR = {Bay, C. J. and Fleming, P. and Doekemeijer, B. and King, J. and Churchfield, M. and Mudafort, R.},

floris/simulation/floris.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def check_deprecated_inputs(self):
200200
def initialize_domain(self):
201201
"""Initialize solution space prior to wake calculations"""
202202

203-
# Initialize field quanitities; doing this immediately prior to doing
203+
# Initialize field quantities; doing this immediately prior to doing
204204
# the calculation step allows for manipulating inputs in a script
205205
# without changing the data structures
206206
self.flow_field.initialize_velocity_field(self.grid)

floris/simulation/flow_field.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def initialize_velocity_field(self, grid: Grid) -> None:
134134
* (grid.z_sorted) ** (self.wind_shear - 1)
135135
)
136136

137-
# If no hetergeneous inflow defined, then set all speeds ups to 1.0
137+
# If no heterogeneous inflow defined, then set all speeds ups to 1.0
138138
if self.het_map is None:
139139
speed_ups = 1.0
140140

floris/simulation/turbine.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def axial_induction(
394394
turbine_type_map: (NDArrayObject[wd, ws, turbines]): The Turbine type definition
395395
for each turbine.
396396
ix_filter (NDArrayFilter | Iterable[int] | None, optional): The boolean array, or
397-
integer indices (as an aray or iterable) to filter out before calculation.
397+
integer indices (as an array or iterable) to filter out before calculation.
398398
Defaults to None.
399399
400400
Returns:

floris/simulation/turbine_multi_dim.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def axial_induction_multidim(
207207
turbine_type_map: (NDArrayObject[wd, ws, turbines]): The Turbine type definition
208208
for each turbine.
209209
ix_filter (NDArrayFilter | Iterable[int] | None, optional): The boolean array, or
210-
integer indices (as an aray or iterable) to filter out before calculation.
210+
integer indices (as an array or iterable) to filter out before calculation.
211211
Defaults to None.
212212
213213
Returns:
@@ -270,7 +270,7 @@ def multidim_Ct_down_select(
270270
conditions (dict): The conditions at which to determine which Ct interpolant to use.
271271
272272
Returns:
273-
NDArray: The downselected Ct interpolants for the selected conditions.
273+
NDArray: The down selected Ct interpolants for the selected conditions.
274274
"""
275275
downselect_turbine_fCts = np.empty_like(turbine_fCts)
276276
# Loop over the wind directions, wind speeds, and turbines, finding the Ct interpolant
@@ -307,7 +307,7 @@ def multidim_power_down_select(
307307
conditions (dict): The conditions at which to determine which Ct interpolant to use.
308308
309309
Returns:
310-
NDArray: The downselected power interpolants for the selected conditions.
310+
NDArray: The down selected power interpolants for the selected conditions.
311311
"""
312312
downselect_power_interps = np.empty_like(power_interps)
313313
# Loop over the wind directions, wind speeds, and turbines, finding the power interpolant

floris/simulation/wake_combination/fls.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def prepare_function(self) -> dict:
2929
def function(self, wake_field: np.ndarray, velocity_field: np.ndarray):
3030
"""
3131
Combines the base flow field with the velocity deficits
32-
using freestream linear superpostion. In other words, the wake
32+
using freestream linear superposition. In other words, the wake
3333
field and base fields are simply added together.
3434
3535
Args:

floris/simulation/wake_combination/max.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def prepare_function(self) -> dict:
3535

3636
def function(self, wake_field: np.ndarray, velocity_field: np.ndarray):
3737
"""
38-
Incorporates the velicty deficits into the base flow field by
38+
Incorporates the velocity deficits into the base flow field by
3939
selecting the maximum of the two for each point.
4040
4141
Args:

floris/simulation/wake_combination/sosfs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def prepare_function(self) -> dict:
2828

2929
def function(self, wake_field: np.ndarray, velocity_field: np.ndarray):
3030
"""
31-
Combines the base flow field with the velocity defecits
31+
Combines the base flow field with the velocity deficits
3232
using sum of squares.
3333
3434
Args:

floris/simulation/wake_deflection/empirical_gauss.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
class EmpiricalGaussVelocityDeflection(BaseModel):
3030
"""
3131
The Empirical Gauss deflection model is based on the form of previous the
32-
Guass deflection model (see :cite:`bastankhah2016experimental` and
32+
Gauss deflection model (see :cite:`bastankhah2016experimental` and
3333
:cite:`King2019Controls`) but simplifies the formulation for simpler
3434
tuning and more independence from the velocity deficit model.
3535
@@ -38,10 +38,10 @@ class EmpiricalGaussVelocityDeflection(BaseModel):
3838
in `parameter_dictionary`. Possible key-value pairs include:
3939
4040
- **horizontal_deflection_gain_D** (*float*): Gain for the
41-
maximum (y-direction) deflection acheived far downstream
41+
maximum (y-direction) deflection achieved far downstream
4242
of a yawed turbine.
4343
- **vertical_deflection_gain_D** (*float*): Gain for the
44-
maximum vertical (z-direction) deflection acheived at a
44+
maximum vertical (z-direction) deflection achieved at a
4545
far downstream location due to rotor tilt. Specifying as
4646
-1 will mean that vertical deflections due to tilt match
4747
horizontal deflections due to yaw.
@@ -101,7 +101,7 @@ def function(
101101
mixing_i (np.array): The wake-induced mixing term for the
102102
ith turbine.
103103
ct_i (np.array): Thrust coefficient for the ith turbine (-).
104-
rotor_diameter_i (np.array): Rotor diamter for the ith
104+
rotor_diameter_i (np.array): Rotor diameter for the ith
105105
turbine (m).
106106
107107
x (np.array): Streamwise direction grid coordinates of the

floris/simulation/wake_deflection/jimenez.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
@define
3030
class JimenezVelocityDeflection(BaseModel):
3131
"""
32-
Jiménez wake deflection model, dervied from
32+
Jiménez wake deflection model, derived from
3333
:cite:`jdm-jimenez2010application`.
3434
3535
References:
@@ -67,7 +67,7 @@ def function(
6767
x: np.ndarray,
6868
):
6969
"""
70-
Calcualtes the deflection field of the wake in relation to the yaw of
70+
Calculates the deflection field of the wake in relation to the yaw of
7171
the turbine. This is coded as defined in [1].
7272
7373
Args:

floris/simulation/wake_velocity/cumulative_gauss_curl.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@
3434
class CumulativeGaussCurlVelocityDeficit(BaseModel):
3535
"""
3636
The cumulative curl model is an implementation of the model described in
37-
:cite:`gdm-bay_2022`, which itself is based on the cumulative model of
38-
:cite:`bastankhah_2021`
37+
:cite:`cc-bay_2022`, which itself is based on the cumulative model of
38+
:cite:`cc-bastankhah_2021`.
3939
4040
References:
41-
.. bibliography:: /references.bib
42-
:style: unsrt
43-
:filter: docname in docnames
44-
:keyprefix: gdm-
41+
.. bibliography:: /references.bib
42+
:style: unsrt
43+
:filter: docname in docnames
44+
:keyprefix: cc-
4545
"""
4646

4747
a_s: float = field(default=0.179367259)
@@ -135,8 +135,8 @@ def function(
135135
y_coord_m = y_coord[:, :, m:m+1]
136136
z_coord_m = z_coord[:, :, m:m+1]
137137

138-
# For computing crossplanes, we don't need to compute downstream
139-
# turbines from out crossplane position.
138+
# For computing cross planes, we don't need to compute downstream
139+
# turbines from out cross plane position.
140140
if x_coord[:, :, m:m+1].size == 0:
141141
break
142142

floris/simulation/wake_velocity/empirical_gauss.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def function(
227227
sigma_y0,
228228
sigma_z0
229229
)
230-
# Normalize to match end of acuator disk model tube
230+
# Normalize to match end of actuator disk model tube
231231
C_mirr = C_mirr / (8 * self.sigma_0_D**2)
232232

233233
# ASSUME sum-of-squares superposition for the real and mirror wakes

floris/simulation/wake_velocity/gauss.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def function(
119119

120120
# Compute the velocity deficit in the NEAR WAKE region
121121
# ONLY If there are points within the near wake boundary
122-
# TODO: for the turbinegrid, do we need to do this near wake calculation at all?
122+
# TODO: for the TurbineGrid, do we need to do this near wake calculation at all?
123123
# same question for any grid with a resolution larger than the near wake region
124124
if np.sum(near_wake_mask):
125125

floris/simulation/wake_velocity/turbopark.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def function(
104104
downstream_mask = (x_i - x >= self.NUM_EPS)
105105
x_dist = (x_i - x) * downstream_mask / rotor_diameters
106106

107-
# Radial distance between turbine i and the centerlines of wakes from all
107+
# Radial distance between turbine i and the center lines of wakes from all
108108
# real/image turbines
109109
r_dist = np.sqrt((y_i - (y + deflection_field)) ** 2 + (z_i - z) ** 2)
110110
r_dist_image = np.sqrt((y_i - (y + deflection_field)) ** 2 + (z_i - (-z)) ** 2)

floris/tools/__init__.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
>>> dir(floris.tools)
3232
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__',
3333
'__name__', '__package__', '__path__', '__spec__', 'cut_plane',
34-
'floris_interface', 'flow_data',
34+
'floris_interface',
3535
'layout_functions', 'optimization', 'plotting', 'power_rose',
36-
'rews', 'sowfa_utilities', 'visualization', 'wind_rose']
36+
'rews', 'visualization', 'wind_rose']
3737
"""
3838

3939
from .floris_interface import FlorisInterface
@@ -52,14 +52,12 @@
5252
# from floris.tools import (
5353
# cut_plane,
5454
# floris_interface,
55-
# flow_data,
5655
# interface_utilities,
5756
# layout_functions,
5857
# optimization,
5958
# plotting,
6059
# power_rose,
6160
# rews,
62-
# sowfa_utilities,
6361
# visualization,
6462
# wind_rose,
6563
# )

0 commit comments

Comments
 (0)