Skip to content

Update visualize docstrings#6383

Merged
mrocklin merged 3 commits intodask:masterfrom
zzhengnan:fix-docstring
Jul 11, 2020
Merged

Update visualize docstrings#6383
mrocklin merged 3 commits intodask:masterfrom
zzhengnan:fix-docstring

Conversation

@zzhengnan
Copy link
Contributor

@zzhengnan zzhengnan commented Jul 9, 2020

To reflect the fact that the filename kwarg can now accept file extensions.

dask/dask/dot.py

Lines 276 to 278 in 3903843

if format is None and any(filename.lower().endswith(fmt) for fmt in fmts):
filename, format = os.path.splitext(filename)
format = format[1:].lower()

  • Tests added / passed
  • Passes black dask / flake8 dask

Copy link
Member

@mrocklin mrocklin left a comment

Choose a reason for hiding this comment

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

Thank you for your work @ZhengnanZhao !

I've added a couple of comments and suggestions below.

dask/base.py Outdated
Examples
--------
>>> x.visualize(filename='dask.pdf') # doctest: +SKIP
>>> x.visualize(filename='dask') # doctest: +SKIP
Copy link
Member

Choose a reason for hiding this comment

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

Hrm, even though we choose to add an extension, I don't think that we should encourage users to do this. I would rather that they be explicit. This seems like good practice generally, and also that way if we choose to reverse this decision in the future (which seems possible) then fewer people will be upset with us.

Suggested change
>>> x.visualize(filename='dask') # doctest: +SKIP

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you explain a bit more what you mean by "explicit"? Are you saying we should encourage users to use .visualize(filename='dask', format='pdf') over .visualize(filename='dask.pdf'), or is it the other way around?

dask/base.py Outdated
For example a Dask.array turns into a :func:`numpy.array` and a Dask.dataframe
turns into a Pandas dataframe. The entire dataset must fit into memory
For example a Dask.array turns into a :func:`numpy.array` and a Dask.dataframe
turns into a :func:`pandas.dataframe`. The entire dataset must fit into memory
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand these changes. I think that you're trying to do cross sphinx linking. If so, I think that you actually want pandas.DataFrame (note capitalization) and numpy.ndarray. Regardless, if you want to make this change then I encourage you to try building the docs (see https://docs.dask.org/en/latest/develop.html#contributing-to-documentation) and verify that this is an improvement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I wasn't thinking that. I added :func: around pandas.dataframe simply to keep consistency with what was already done for numpy.array on the previous line.

I'll look into the linked resource and test it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mrocklin Following instructions in the link above, I wasn't able to see the change take effect

  1. Are the official docs based on contents in the docs directory of this repo?
  2. If so, it looks like this particular docstring isn't referenced anywhere in the docs. I did a code search for For example a Dask.array turns into throughout the codebase and the only hit was this docstring; explicitly, it's not referenced in any HTML files

Copy link
Member

Choose a reason for hiding this comment

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

  1. Yes
  2. In that case it probably doesn't make sense to use sphinx-style entires like this, and we should go with normal human-readable text like Pandas dataframe rather than :func:pandas.dataframe

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 agree. Just pushed another commit to address all your feedback. Please re-review.

dask/base.py Outdated
Examples
--------
>>> x.visualize(filename='dask.pdf') # doctest: +SKIP
>>> x.visualize(filename='dask') # doctest: +SKIP
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
>>> x.visualize(filename='dask') # doctest: +SKIP

@mrocklin
Copy link
Member

mrocklin commented Jul 9, 2020 via email

@mrocklin mrocklin merged commit 51d3f11 into dask:master Jul 11, 2020
@mrocklin
Copy link
Member

Thank you for the fix @ZhengnanZhao ! This is in.

Also, I notice that this is your first contribution to this repository. Welcome!

@zzhengnan zzhengnan deleted the fix-docstring branch July 11, 2020 02:22
kumarprabhu1988 pushed a commit to kumarprabhu1988/dask that referenced this pull request Oct 29, 2020
* Fix docstrings to reflect filename can contain extension
* Remove Sphinx link in favor of plain text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants