-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feature 364 add tci calc #369
Conversation
…tributors guide coding standards.
…sing newer sphinx.
…file to get the functions to be clickable per sphinx-doc/sphinx#11998.
… to the gitignore.
…/surface applications.
…ht way to do this.
…ifts Python version for building documentation from 3.8 to 3.10.
I ran the test and I see it passes, but there is a warning:
I'm using numpy version 1.26.4. What version are you using? |
Co-authored-by: Julie Prestopnik <jpresto@ucar.edu>
Same, |
…cpy into feature_364_add_TCI_calc
So the error is originating from this line:
The reason is because for the forecast data, the "Terrestrial Coupling Index" by definition is only computed on land and not over the ocean. The forecast data have What I don't understand, is Xarray's After digging a bit more (numpy/numpy#15219), it seems that NumPy |
OK, I think I understand. Consider these examples:
The Another option is to make another argument to |
…nd xarray. The default is set to True, but a user can override if they wish.
Remaining questions for @bikegeek:
|
1. I use Google style, but I think as long as we have good documentation,
that is what matters.
2. I prefer one test file with multiple tests, then you can re-use test
fixtures for setting up and cleaning up similar tests.
…On Thu, Apr 11, 2024 at 8:58 AM Dan Adriaansen ***@***.***> wrote:
Remaining questions for @bikegeek <https://github.com/bikegeek>:
1. Docstring style for functions? Should we switch to Google or NumPy
docstrings?
2. In METcalcpy/test, instead of test_calc_tci.py, should we make a
single file called test_land_surface.py, and in there it tests all
functions defined in metcalcpy/diagnostics/land_surface.py? I worry if
we end up with 100 functions in land_surface.py, we will have 100
test_*.py files, but maybe they should be contained in a general
test_land_surface.py file?
—
Reply to this email directly, view it on GitHub
<#369 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA4UJHTEMWT4F2KNOHREP6DY42QJLAVCNFSM6AAAAABFZ3KFTCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBZHA4TEMZTHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
…al land_surface diagnostics in the future.
…cstrings and re-writes the docstring using Google format.
This is ready for final review. Thanks all for the feedback so far! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pydocs in the User's Guide is extremely helpful. Thanks for getting this in.
In this PR, there is a new diagnostic function to support the calculation of the Terrestrial Coupling Index. This calculation was put into
metcalcpy/diagnostics/land_surface.py
. The intent is to have a new.py
file underdiagnostics
for categories that loosely correspond to themodel_applications
use case categories in METplus Wrappers, with any additional categories as needed, to try and keep things aligned as best as possible.In an effort to document the functions placed in this area, I implemented new "API" documentation through the Sphinx
autosummary
extension (https://www.sphinx-doc.org/en/master/usage/extensions/autosummary.html). To facilitate this, here is a list of changes I made, and things I discovered along the way:docs/conf.py
, I had to adjust the insertion of the top level of the METcalcpy module to the path, rather than thedocs
directory only.docs/conf.py
, I added theautosummary
extension to the list of Sphinx extensions to use. As far as I can tell, this is included with Sphinx and is not a separate Python package.docs/conf.py
, I addedautosummary_generate = True
to generate the documentation fromautosummary
.docs
to hold theautosummary
documentation, calleddiag_ref
. Inside this file, there is a newindex.rst
file that has RST that controls the display of the top-level HTML of the renderedautosummary
documentation.docs/Users_Guide/index.rst
to point to theautosummary
documentation indocs/diag_ref
so it is available in the Users Guide.docs/diag_ref/index.rst
file, there is a subdirectory underdocs/diag_ref
calledgenerated
where the RST files fromautosummary
are stored when the docs are built.module.rst
file from the Sphinx installation area intodocs/_templates/autosummary
. The file I copied was at{PYTHON_BASE}/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/module.rst
, which now lives and is committed atdocs/_templates/autosummary/module.rst
. This presents some risk, because if Sphinx changes something about this RST file in a new Sphinx release, we should probably re-copy and commit this template to our repository. I could not figure out why Sphinxautosummary
was not using those templates or why it was not working without the file existing in thedocs/_templates
area. It's possible I am missing a setting inconf.py
, but I am not totally sure. I figured this out from a combination of StackOverflow articles, with this one https://stackoverflow.com/a/62613202 being most helpful. This open issue in Sphinx GitHub also was somewhat helpful: By default, make Autosummary templates generate documentation pages for classes, functions, exceptions etc sphinx-doc/sphinx#7912.metcalcpy/diagnostics/land_surface.py
. Per @bikegeek, "Google" style docstrings are desired, so thesphinx.ext.napoleon
extension was enabled to correctly render the Google docstrings usingautosummary
.autosummary
imports all of your*.py
files to generate the documentation. What this means is that the Python environment where the documentation is build (e.g. RTD online and in GHA) now has the same set of dependencies as your entire Python package. For example, previously the docs could build without Pandas and Xarray, but because those are dependencies indiagnostics/land_surface.py
, they are now required when building the docs otherwiseautosummary
reportsImportError
. So be sure any additional dependencies added to any*.py
file you're writing are added to any RTD and docs requirementstxt
andyaml
files.Pull Request Testing
Describe testing already performed for these changes:
Added new test in
test/test_calc_tci.py
Added new test data in
test/data/calc_tci*
Verified function works with METplus Wrappers use case in Enhancement: Enhance Terrestrial Coupling Index (TCI) Use Case METplus#2388.
Recommend testing for the reviewer(s) to perform, including the location of input datasets, and any additional instructions:
Verify that I set up the testing properly.
Do these changes include sufficient documentation updates, ensuring that no errors or warnings exist in the build of the documentation? [Yes or No]
Yes. These changes come with new documentation.
Do these changes include sufficient testing updates? [Yes or No]
Yes.
Will this PR result in changes to the test suite? [Yes or No]
If yes, describe the new output and/or changes to the existing output:
Please complete this pull request review by [Fill in date].
Pull Request Checklist
See the METplus Workflow for details.
Select: Reviewer(s)
Select: Organization level software support Project or Repository level development cycle Project
Select: Milestone as the version that will include these changes