-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decouple process class from Model (#63)
* embed modified "dataclass" in __xsimlab_cls__ attribute * fix all existing tests
- Loading branch information
Showing
11 changed files
with
228 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.. _testing: | ||
|
||
Testing | ||
======= | ||
|
||
Testing and/or debugging the logic implemented in process classes can | ||
be achieved easily just by instantiating them. The xarray-simlab | ||
framework is not invasive and process classes can be used like other, | ||
regular Python classes. | ||
|
||
.. ipython:: python | ||
:suppress: | ||
import sys | ||
sys.path.append('scripts') | ||
from advection_model import InitUGauss | ||
Here is an example with one of the process classes created in section | ||
:doc:`create_model`: | ||
|
||
.. ipython:: python | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
gauss = InitUGauss(loc=0.3, scale=0.1, x=np.arange(0, 1.5, 0.01)) | ||
gauss.initialize() | ||
@savefig gauss.png width=50% | ||
plt.plot(gauss.x, gauss.u); | ||
Like for any other process class, the parameters of | ||
``InitUGauss.__init__`` correspond to each of the variables declared | ||
in that class with either ``intent='in'`` or ``intent='inout'``. Those | ||
parameters are "keyword only" (see `PEP 3102`_), i.e., it is not | ||
possible to set these as positional arguments. | ||
|
||
.. _`PEP 3102`: https://www.python.org/dev/peps/pep-3102/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.