Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API links updated to new model names #177

Merged
merged 30 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
59333b4
API links updated to new model names
vgro Feb 13, 2023
8cca28a
Update abiotic_model.md
vgro Feb 13, 2023
ddd329e
Update base_model.md
vgro Feb 13, 2023
0e8358e
Update soil_model.md
vgro Feb 13, 2023
55b0fdd
base_model links updated
vgro Feb 13, 2023
13f1c40
updated new model doc link
vgro Feb 13, 2023
862cca0
Turning on nitpicky and intersphinx
davidorme Feb 13, 2023
3f2d05d
Update base_model.py
vgro Feb 13, 2023
72bf12a
Fixing abiotic refs in api and module
davidorme Feb 13, 2023
872853e
Merge branch 'feature/update_api_links' of https://github.com/Imperia…
davidorme Feb 13, 2023
f7c4655
Broken links in data and readers
davidorme Feb 13, 2023
d5857c7
Line length issue
davidorme Feb 13, 2023
5e3bde7
Broken links in readers.py
davidorme Feb 13, 2023
de8b6fb
First attempt to fix broken links in config.py
jacobcook1995 Feb 13, 2023
3e22b3e
Merging David's changes into my local branch
jacobcook1995 Feb 13, 2023
fe74798
More broken links in data/axes/readers
davidorme Feb 13, 2023
a95067b
Broken special links in data
davidorme Feb 13, 2023
42aae2e
Getting @jacobcook1995 fixes
davidorme Feb 13, 2023
69d3a47
Fixed missing core API entry and moved docstrings to core.__init__.py
davidorme Feb 13, 2023
50dd9c1
Added a soil docs string to its __init__
jacobcook1995 Feb 13, 2023
9568153
Fixed remaining issues with abiotic docs links
jacobcook1995 Feb 13, 2023
99b8185
Added Draft202012Validator as something to be ignored by nitpick
jacobcook1995 Feb 14, 2023
e043348
Fixed broken link in soil api
jacobcook1995 Feb 14, 2023
9aabd11
Changed reference to logger to fix broken link
jacobcook1995 Feb 14, 2023
baefdde
Fixed broken dostring links for base_model
jacobcook1995 Feb 14, 2023
52bb9d8
Fixed another couple of bad links
jacobcook1995 Feb 14, 2023
e521e05
Fixed problem with using NDArray
jacobcook1995 Feb 14, 2023
171d87e
Excluded numpy.float64
jacobcook1995 Feb 14, 2023
695d0e6
Added api documentation for soil constant dataclasses
jacobcook1995 Feb 14, 2023
4172747
Added numpy.int64 to nitpick exclusions
jacobcook1995 Feb 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions docs/source/api/abiotic.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ kernelspec:

# API reference for `abiotic` modules

The {mod}`~virtual_rainforest.models.abiotic` module is one of the component models of
the Virtual Rainforest. It is comprised of several submodules that calculate the
radiation balance, the energy balance, the water balance and the atmospheric CO2
balance.

Each of the abiotic sub-modules has its own API reference page:

* The {mod}`~virtual_rainforest.models.abiotic.model` submodule instantiates the
AbioticModel class which consolidates the functionality of the abiotic module into a
single class, which the high level functions of the Virtual Rainforest can then use.
```{eval-rst}
.. automodule:: virtual_rainforest.models.abiotic
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ kernelspec:
name: vr_python3
---

# API documentation for the {mod}`~virtual_rainforest.models.abiotic.model` module
# API documentation for the {mod}`~virtual_rainforest.models.abiotic.abiotic_model` module

```{eval-rst}
.. automodule:: virtual_rainforest.models.abiotic.model
.. automodule:: virtual_rainforest.models.abiotic.abiotic_model
:autosummary:
:members:
:special-members: __init_subclass__, __repr__, __str__
Expand Down
27 changes: 3 additions & 24 deletions docs/source/api/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,6 @@ kernelspec:

# API reference for `core` modules

The {mod}`~virtual_rainforest.core` module contains the key shared resources and
building blocks used to develop the different component models of the Virtual Rainforest
and then to configure them, populate them with data and provide logging.

Each of the core sub-modules has its own API reference page:

* The {mod}`~virtual_rainforest.core.config` submodule covers the
definition of formal configuration schema for components and the parsing and
validation of TOML configuration documents against those schema.
* The {mod}`~virtual_rainforest.core.grid` submodule covers the
definition of the spatial layout to be used in a simulation and provides an interface
to the spatial relationships between cells.
* The {mod}`~virtual_rainforest.core.data` submodule provides the
central data object used to store data required by the simulation and methods to
populate that data object for use in simulations.
* The {mod}`~virtual_rainforest.core.axes` submodule provides validation for data to
ensure that it is congruent with the model configuration.
* The {mod}`~virtual_rainforest.core.readers` submodule provides functionality to read
external data files into a standard internal format.
* The {mod}`~virtual_rainforest.core.model` submodule provides an Abstract
Base Class describing the shared API to be used by science models within the Virtual
Rainforest.
* The {mod}`~virtual_rainforest.core.logger` configures the {class}`~logging.LOGGER`
instance used throughout the package.
```{eval-rst}
.. automodule:: virtual_rainforest.core
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ kernelspec:
name: vr_python3
---

# API documentation for the {mod}`~virtual_rainforest.core.model` module
# API documentation for the {mod}`~virtual_rainforest.core.base_model` module

```{eval-rst}
.. automodule:: virtual_rainforest.core.model
.. automodule:: virtual_rainforest.core.base_model
:autosummary:
:members:
:special-members: __init_subclass__, __repr__, __str__
Expand Down
2 changes: 1 addition & 1 deletion docs/source/api/core/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ kernelspec:
.. automodule:: virtual_rainforest.core.data
:autosummary:
:members:
:special-members: __repr__, __set_item__, __get_item__, __contains__
:special-members: __repr__, __setitem__, __getitem__, __contains__
```
13 changes: 3 additions & 10 deletions docs/source/api/soil.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ kernelspec:

# API reference for `soil` modules

The {mod}`~virtual_rainforest.models.soil` module is one of the component models of the
Virtual Rainforest. It is comprised of a number of submodules.

Each of the soil sub-modules has its own API reference page:

* The {mod}`~virtual_rainforest.models.soil.model` submodule instantiates the SoilModel
class which consolidates the functionality of the soil module into a single class,
which the high level functions of the Virtual Rainforest can then make use of.
* The {mod}`~virtual_rainforest.models.soil.carbon` provides a model for the soil carbon
cycle.
```{eval-rst}
.. automodule:: virtual_rainforest.models.soil
```
2 changes: 1 addition & 1 deletion docs/source/api/soil/carbon.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ kernelspec:
name: vr_python3
---

# API documentation for the {mod}`~virtual_rainforest.soil.carbon` module
# API documentation for the {mod}`~virtual_rainforest.models.soil.carbon` module

```{eval-rst}
.. automodule:: virtual_rainforest.models.soil.carbon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ kernelspec:
name: vr_python3
---

# API documentation for the {mod}`~virtual_rainforest.soil.model` module
# API documentation for the {mod}`~virtual_rainforest.models.soil.constants` module

```{eval-rst}
.. automodule:: virtual_rainforest.models.soil.model
.. automodule:: virtual_rainforest.models.soil.constants
:autosummary:
:members:
```
23 changes: 23 additions & 0 deletions docs/source/api/soil/soil_model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
jupytext:
cell_metadata_filter: -all
formats: md:myst
main_language: python
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.13.8
kernelspec:
display_name: vr_python3
language: python
name: vr_python3
---

# API documentation for the {mod}`~virtual_rainforest.models.soil.soil_model` module

```{eval-rst}
.. automodule:: virtual_rainforest.models.soil.soil_model
:autosummary:
:members:
```
17 changes: 17 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"sphinx.ext.autodoc",
"autodocsumm",
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinx.ext.autosummary",
# "sphinx.ext.autosectionlabel", # Generates hard to trace exception
Expand All @@ -69,6 +70,22 @@
autodoc_default_flags = ["members"]
autosummary_generate = True

# Reference checking
nitpicky = True
nitpick_ignore = [
("py:class", "jsonschema.validators.Draft202012Validator"),
("py:class", "numpy.float32"),
("py:class", "numpy.int64"),
]
intersphinx_mapping = {
"numpy": ("https://numpy.org/doc/stable/", None),
"python": ("https://docs.python.org/3/", None),
"xarray": ("https://docs.xarray.dev/en/stable/", None),
"shapely": ("https://shapely.readthedocs.io/en/stable/", None),
"jsonschema": ("https://python-jsonschema.readthedocs.io/en/stable/", None),
}


# Set auto labelling to section level
autosectionlabel_prefix_document = True
autosectionlabel_maxdepth = 2
Expand Down
2 changes: 1 addition & 1 deletion docs/source/development/defining_new_models.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ from virtual_rainforest.core.logger import LOGGER
# New model class will inherit from BaseModel.
# InitialisationError is a custom exception, for case where a `Model` class cannot be
# properly initialised based on the data contained in the configuration
from virtual_rainforest.core.model import BaseModel, InitialisationError
from virtual_rainforest.core.base_model import BaseModel, InitialisationError
```

The new model class is created using a class method, which means that the model is
Expand Down
7 changes: 4 additions & 3 deletions docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ team.
Data <api/core/data.md>
File readers <api/core/readers.md>
Core axes <api/core/axes.md>
Base Model <api/core/model.md>
Base Model <api/core/base_model.md>
Soil Overview <api/soil.md>
Soil Model <api/soil/model.md>
Soil Model <api/soil/soil_model.md>
Soil Carbon <api/soil/carbon.md>
Soil Constants <api/soil/constants.md>
Abiotic Overview <api/abiotic.md>
Abiotic Model <api/abiotic/model.md>
Abiotic Model <api/abiotic/abiotic_model.md>
```

```{eval-rst}
Expand Down
2 changes: 1 addition & 1 deletion docs/source/virtual_rainforest/core/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ two methods:
data['var_name'] = load_to_dataarray('path/to/file.nc', var='temperature')
```

1. The {meth}`~virtual_rainforest.core.data.Data.load_from_config` method takes a
1. The {meth}`~virtual_rainforest.core.data.Data.load_data_config` method takes a
loaded Data configuration - which is a set of named variables and source files - and
then just uses {func}`~virtual_rainforest.core.readers.load_to_dataarray` to try and
load each one.
Expand Down
8 changes: 4 additions & 4 deletions tests/core/test_model.py → tests/core/test_base_model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Test module for model.py.
"""Test module for base_model.py.

This module tests the functionality of model.py, which defines the basic model API that
specific models (e.g. `soil_model.py`) utilise.
This module tests the functionality of base_model.py, which defines the basic model API
that specific models (e.g. `soil_model.py`) utilise.
"""

from contextlib import nullcontext as does_not_raise
Expand All @@ -11,7 +11,7 @@
from numpy import datetime64, timedelta64

from tests.conftest import log_check
from virtual_rainforest.core.model import BaseModel
from virtual_rainforest.core.base_model import BaseModel


def test_base_model_initialization(caplog, mocker):
Expand Down
2 changes: 1 addition & 1 deletion tests/models/abiotic/test_abiotic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from numpy import datetime64, timedelta64

from tests.conftest import log_check
from virtual_rainforest.core.model import InitialisationError
from virtual_rainforest.core.base_model import InitialisationError
from virtual_rainforest.models.abiotic.abiotic_model import AbioticModel


Expand Down
2 changes: 1 addition & 1 deletion tests/models/soil/test_carbon.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pytest

from tests.conftest import log_check
from virtual_rainforest.core.model import InitialisationError
from virtual_rainforest.core.base_model import InitialisationError
from virtual_rainforest.models.soil.carbon import SoilCarbonPools


Expand Down
2 changes: 1 addition & 1 deletion tests/models/soil/test_soil_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from numpy import datetime64, timedelta64

from tests.conftest import log_check
from virtual_rainforest.core.model import InitialisationError
from virtual_rainforest.core.base_model import InitialisationError
from virtual_rainforest.models.soil.soil_model import SoilModel


Expand Down
2 changes: 1 addition & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pytest
from numpy import datetime64, timedelta64

from virtual_rainforest.core.model import BaseModel, InitialisationError
from virtual_rainforest.core.base_model import BaseModel, InitialisationError
from virtual_rainforest.main import (
check_for_fast_models,
configure_models,
Expand Down
29 changes: 29 additions & 0 deletions virtual_rainforest/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
"""The :mod:`~virtual_rainforest.core` module contains the key shared resources and
building blocks used to develop the different component models of the Virtual Rainforest
and then to configure them, populate them with data and provide logging.

Each of the core sub-modules has its own API reference page:

* The :mod:`~virtual_rainforest.core.config` submodule covers the
definition of formal configuration schema for components and the parsing and
validation of TOML configuration documents against those schema.
* The :mod:`~virtual_rainforest.core.grid` submodule covers the
definition of the spatial layout to be used in a simulation and provides an interface
to the spatial relationships between cells.
* The :mod:`~virtual_rainforest.core.data` submodule provides the
central data object used to store data required by the simulation and methods to
populate that data object for use in simulations.
* The :mod:`~virtual_rainforest.core.axes` submodule provides validation for data to
ensure that it is congruent with the model configuration.
* The :mod:`~virtual_rainforest.core.readers` submodule provides functionality to read
external data files into a standard internal format.
* The :mod:`~virtual_rainforest.core.base_model` submodule provides an Abstract
Base Class describing the shared API to be used by science models within the Virtual
Rainforest.
* The :mod:`~virtual_rainforest.core.logger` configures the :class:`~logging.Logger`
instance used throughout the package.

The :mod:`~virtual_rainforest.core` module itself is only responsible for loading the
configuration schema for the core submodules.
""" # noqa: D205, D415

import json
from pathlib import Path

Expand Down
28 changes: 14 additions & 14 deletions virtual_rainforest/core/axes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""The :mod:`core.axes` module handles the validation of data being loaded into the core
data storage of the virtual rainforest simulation. The main functionality in this module
is ensuring that any loaded data is congruent with the core axes of the simulation and
the configuration of a given simulation.
"""The :mod:`~virtual_rainforest.core.axes` module handles the validation of data being
loaded into the core data storage of the virtual rainforest simulation. The main
functionality in this module is ensuring that any loaded data is congruent with the core
axes of the simulation and the configuration of a given simulation.

The AxisValidator class
=======================
Expand All @@ -16,21 +16,21 @@

When new :class:`~virtual_rainforest.core.axes.AxisValidator` subclasses are defined,
they are automatically added to the
:attr:`~virtual_rainforest.core.axes.AXIS_VALIDATORS` registry. This maintains a list
of the validators defined for each core axis.
:attr:`~virtual_rainforest.core.axes.AXIS_VALIDATORS` registry. This maintains a list of
the validators defined for each core axis.

Note that the set of validators defined for a specific core axis should be mutually
exclusive: only one should be applicable to any given dataset being tested on that axis.

DataArray validation
====================

The :func:`~virtual_rainforest.core.axes.validate_datarray` function takes an input Data
Array and applies validation where applicable across all the core axes. The function
returns the validated input (possibly altered to align with the core axes) along with a
dictionary using the set of core axes as names: the value associated with each axis name
is the name of the AxisValidator applied or None if the input did not match a validator
on that axis.
The :func:`~virtual_rainforest.core.axes.validate_dataarray` function takes an input
Data Array and applies validation where applicable across all the core axes. The
function returns the validated input (possibly altered to align with the core axes)
along with a dictionary using the set of core axes as names: the value associated with
each axis name is the name of the AxisValidator applied or None if the input did not
match a validator on that axis.

Core axes
=========
Expand Down Expand Up @@ -90,11 +90,11 @@ def __init_subclass__(cls) -> None:
:attr:`~virtual_rainforest.core.axes.AXIS_VALIDATORS` registry. AxisValidators
are arranged in the registry dictionary as lists keyed under core axis names,
and the core axis name for a given subclass is set in the subclass
:attr:`~virtual_rainforest.core.axes.AxisValidator.AxisValidator.core_axis`
:attr:`~virtual_rainforest.core.axes.AxisValidator.core_axis`
class attribute.

Raises:
Value Error: if the subclass attributes are invalid.
ValueError: if the subclass attributes are invalid.
"""

if not hasattr(cls, "core_axis"):
Expand Down
Loading