-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Improve docstrings for better discoverability #7378
Comments
That's a useful observation, thank you @maawoo! This comes from the way we generate our code for the many different aggregations xarray can perform. We actually use this script to automatically generate all the source code for all the aggregations in this file. That script has a template that is filled in for each method. Currently the template looks like this TEMPLATE_REDUCTION_SIGNATURE = '''
def {method}(
self,
dim: Dims = None,
*,{extra_kwargs}
keep_attrs: bool | None = None,
**kwargs: Any,
) -> {obj}:
"""
Reduce this {obj}'s data by applying ``{method}`` along some dimension(s).
Parameters
----------''' where in the case of variance the How might we fix this? One immediate thought that might help is to change the template to use a Or we might change the docstrings in some other, more granular way. Adding examples to aggregation methods would also have to deal with the fact they are autogenerated #6793 |
Hi @TomNicholas, |
Hi @TomNicholas , I would like to contribute to this issue.Could I be assigned to it? |
Hi @mahamtariq58, thanks for your interest! We don't normally assign issues to individuals, you are just welcome to have a go at solving any issue that interests you. |
Okay thank you @TomNicholas |
Hey @TomNicholas |
Hi @Amisha2778 - great to hear you are interested. You don't need my permission - please have a go at solving any issue that looks interesting to you, and please ask questions if you have any difficulties! |
Hey @TomNicholas . You mentioned one way of fixing this issue would be to also use |
Yes I think so.
Yes things like |
What is your issue?
I noticed that the docstrings of the aggregation methods are mostly written in the same style, e.g.: "Reduce this Dataset's data by applying xy along some dimension(s).". Let's say a user is interested in calculating the variance and searches for the appropriate method. Neither xarray.DataArray.var nor xarray.Dataset.var will be returned (see here), because "variance" is not mentioned at all in the docstrings. Same problem exists for other methods like
.std
,.prod
,.cumsum
,.cumprod
, and probably others.#6793 is related, but I guess it already has enough tasks.
The text was updated successfully, but these errors were encountered: