Repository navigation
Description
Proposed new feature or change:
New (and probably, continuing) developer experience could be improved a decent amount by including a docstring at the top of each python file. This can also help any users who utilize help to learn more about how to use the code.
Docstrings could be as simple as:
"""
File Purpose: UxDataArray class
"""This helps to suggest there's nothing else important going on in the file; it's just all about defining the UxDataArray class.
Or, they can be more complicated, such as the one already in uxarray/core/accessors.py:
"""
Delegation-based accessor classes for UXarray groupby operations.
These classes wrap xarray's groupby/resample/etc objects and ensure that
operations return UxDataArray/UxDataset objects with preserved uxgrid.
"""This allows you to quickly understand the purpose of the file, and also provides a nice place to include anything that isn't perfectly intuitive immediately from the file name. For example, uxarray/core/api.py currently has no docstring, so it takes a minute to realize this is the core public api, not an internal api, and not some other sort of api. A simple docstring like "File Purpose: core public api methods" would save that time and help avoid getting lost in the code.
Another good example is uxarray/core/zonal.py. When I was first exploring the code, before I read the readthedocs page, I initially thought maybe there could be a whole bunch of "zonal-related" methods. Now that I understand a bit more, I might put a docstring like:
"""
File Purpose: zonal averaging
Averages computed along one or more lines (or bands) of constant latitude.
"""This defines what "zonal averaging" means, and clarifies that it is the entire purpose of the file; every method in this file is somehow connected to zonal averages, there's not any other type of "zonal" operation to watch out for.
Bonus benefits: these come up when applying introspection to modules directly, e.g. help(ux.core.accessors) includes the docstring above. Additionally, this matches xarray style, for example, you can import xarray as xr; help(xr.plot) or help(xr.tutorial), and you will see a description is included. Doing something like help(ux.grid) is currently sort of disappointing, there isn't any description about the basic purpose, nor any help suggesting where to look for more details.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fields📝 To-Do
Activity
Sevans711 commentedon Oct 22, 2026
Reportback from internal discussion today: concerns were expressed about keeping signal-to-noise ratio high for top-of-file docstrings. For example, these docstrings should not be filled with any long-winded ramblings of LLMs.
My personal understanding is that these docstrings would still be appreciated if kept concise, though, especially if explaining anything particularly unexpected within the file.
erogluorhan commentedon Oct 23, 2026
I am hesitant about doing this for the whole code base because most, if not all, of the files are already self-explanatory with their names and in what namepsace they are present, e.g.
plot/contour.py. Such docstrings might only need to be tackled if actually needed.That said, if there is no particular file in mind, I'd suggest that we close this as unplanned.
Sevans711 commentedon Oct 26, 2026
My personal preference would still be to have this in every file, even if just a one-line docstring, but I can also understand if that's not the direction we end up going with. Some extra thoughts beyond the initial post:
To make this a bit more concrete, I surveyed the codebase for the "best" candidate files to consider here. If my points above about adding docstrings everywhere aren't particularly convincing, maybe we can just focus on these files which I think are most in need of docstrings?
uxarray/grid/integrate.pycore/zonal.py. A docstring would state that scope and point to zonal averaging.uxarray/core/zonal.pyuxarray/core/api.pyopen_grid,open_dataset,open_mfdataset,concat, ...), not an internal one.uxarray/conventions/ugrid.pyuxarray/grid/slice.py.isel()and.sel()onUxDatasetandUxDataArray. It is not itself user-facing.uxarray/grid/geometry.py(~1500 lines)__init__.pyfiles (grid,core,plot,io,remap,subset,cross_sections,utils,conventions)help(ux.grid)and similar give no description of the subpackage's purpose. A one- or two-line docstring would make that output useful.(Table text is from copilot/claude, but reflects my views after some back-and-forth iteration.)
erogluorhan commentedon Oct 27, 2026
Sure, it would make sense to me if you added docstrings into the files in the above table your provided.