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

Docstrings examples for string methods #7669

Merged
merged 59 commits into from
Apr 19, 2023
Merged

Docstrings examples for string methods #7669

merged 59 commits into from
Apr 19, 2023

Conversation

remigathoni
Copy link
Contributor

Adds docstring examples to some string methods (#6793 ).
Please let me know if there are any changes I need to make. Thank you!

remigathoni and others added 27 commits March 14, 2023 20:04
@remigathoni remigathoni marked this pull request as draft March 24, 2023 13:18
remigathoni added 2 commits March 24, 2023 16:54
Solves the incosistent whitespace error
Copy link
Collaborator

@headtr1ck headtr1ck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice addition!

Dimensions without coordinates: x

Using regex:
>>> pat = "jj\\w+"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could come up with a more interesting example.
Maybe add a number after one of the "jj" in the DataArray, and then look for "jj\d"?

But this version is already a good start.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do, thank you!

Dimensions without coordinates: x

Using regex:
>>> pat = "jj\\w+"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the build system does not like the double escaped strings.
No idea how to solve this though, maybe we could use a raw string pat = r"jj\w+"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried using the raw string but I had to also escape the backslash pat = r"jj\\w+" for the warning to disappear.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, then I think this is a bug of our docstring parser.
The problem is that if we use this example, it will pass the CI pipeline, but it will be actually wrong?
Or how does this render in the webpage?

Maybe we can construct an example without backslashes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah! I think I can just use [a-z] or [0-9].

Copy link
Collaborator

@keewis keewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got a few more suggestions, but otherwise this does look good to me.

The failing docs CI is caused by pydata-sphinx-theme=0.13.2 being incompatible with sphinx-book-theme=1.0.0. I think we can pin pydata-sphinx-theme!=0.13.2 until they fixed that (though maybe that should be done in a new PR).

xarray/core/accessor_str.py Outdated Show resolved Hide resolved
xarray/core/accessor_str.py Outdated Show resolved Hide resolved
xarray/core/accessor_str.py Show resolved Hide resolved
xarray/core/accessor_str.py Outdated Show resolved Hide resolved
@headtr1ck
Copy link
Collaborator

headtr1ck commented Mar 31, 2023

The failing docs CI is caused by pydata-sphinx-theme=0.13.2 being incompatible with sphinx-book-theme=1.0.0. I think we can pin pydata-sphinx-theme!=0.13.2 until they fixed that (though maybe that should be done in a new PR).

Just saw this comment. I have opened #7703 for this

@dcherian
Copy link
Contributor

dcherian commented Apr 6, 2023

The docs build failure is real, from some rst formatting error

/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.count:58: ERROR: Unexpected indentation.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.count:56: WARNING: Block quote ends without a blank line; unexpected unindent.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.pad:53: ERROR: Unexpected indentation.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.pad:52: WARNING: Block quote ends without a blank line; unexpected unindent.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.pad:64: ERROR: Unexpected indentation.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.pad:63: WARNING: Block quote ends without a blank line; unexpected unindent.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.pad:53: ERROR: Unexpected indentation.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.pad:52: WARNING: Block quote ends without a blank line; unexpected unindent.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.pad:64: ERROR: Unexpected indentation.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.pad:63: WARNING: Block quote ends without a blank line; unexpected unindent.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.count:58: ERROR: Unexpected indentation.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.count:56: WARNING: Block quote ends without a blank line; unexpected unindent.

@remigathoni
Copy link
Contributor Author

The docs build failure is real, from some rst formatting error

/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.count:58: ERROR: Unexpected indentation.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.count:56: WARNING: Block quote ends without a blank line; unexpected unindent.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.pad:53: ERROR: Unexpected indentation.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.pad:52: WARNING: Block quote ends without a blank line; unexpected unindent.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.pad:64: ERROR: Unexpected indentation.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.pad:63: WARNING: Block quote ends without a blank line; unexpected unindent.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.pad:53: ERROR: Unexpected indentation.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.pad:52: WARNING: Block quote ends without a blank line; unexpected unindent.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.pad:64: ERROR: Unexpected indentation.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.pad:63: WARNING: Block quote ends without a blank line; unexpected unindent.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.count:58: ERROR: Unexpected indentation.
/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7669/xarray/core/accessor_str.py:docstring of xarray.core.accessor_str.StringAccessor.count:56: WARNING: Block quote ends without a blank line; unexpected unindent.

I'll fix it!

@headtr1ck headtr1ck added the plan to merge Final call for comments label Apr 17, 2023
@dcherian dcherian enabled auto-merge (squash) April 18, 2023 22:33
@dcherian dcherian disabled auto-merge April 18, 2023 22:33
@dcherian dcherian merged commit c75ac8b into pydata:main Apr 19, 2023
@dcherian
Copy link
Contributor

Thanks @remigathoni great PR!

dcherian added a commit to dcherian/xarray that referenced this pull request Apr 25, 2023
* main:
  Bump codecov/codecov-action from 3.1.2 to 3.1.3 (pydata#7781)
  Fix whats-new
  [skip-ci] dev whats-new (pydata#7775)
  [skip-ci] Release 2023.04.2 (pydata#7774)
  Fix groupby_bins when labels are specified (pydata#7769)
  Docstrings examples for string methods (pydata#7669)
  Add dev whats-new
  Add benchmark against latest release on main. (pydata#7753)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants