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

Docs: Add bz2 usage examples #13258

Merged
merged 9 commits into from
May 13, 2019
Merged

Conversation

bsolomon1124
Copy link
Contributor

  • Adds an "Examples of usage" section inspired by the one
    found in the gzip docs
  • Corrects the descriptions for compresslevel and data:
    • compresslevel must be an int, not any number. For
      instance, passing a float will raise TypeError
    • Note that data must be bytes-like

@bedevere-bot bedevere-bot added docs Documentation in the Doc dir awaiting review labels May 12, 2019
@csabella csabella requested a review from pitrou May 12, 2019 09:36
Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

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

LGTM generally. I'll let someone else review the grammar.

- Adds an "Examples of usage" section inspired by the one
  found in the gzip docs
- Corrects the descriptions for ``compresslevel`` and ``data``:
    - ``compresslevel`` must be an `int`, not any number.  For
      instance, passing a float will raise ``TypeError``
    - Notes that `data` must be bytes-like
@gpshead gpshead self-assigned this May 13, 2019
@gpshead
Copy link
Member

gpshead commented May 13, 2019

i made an edit that I believe will fix the failing doctest. otherwise this looks good to me. waiting on CI now. as this is just a documentation improvement, no issue or news entry necessary.

@bsolomon1124
Copy link
Contributor Author

bsolomon1124 commented May 13, 2019

Thanks for having a look @gpshead - two thoughts/questions:

  1. Why might the 502 (bytes written) output make doctests fail? Would this number vary by platform or something like that?
  2. One example that I can be self-critical of is the one with gen_data(): because the data is very random, the compression ratio is actually < 1. (I.e. compression ratio will be much higher for non-random-looking data.) Do you think that this deserves some type of rewrite to a more realistic scenario, or does it still get the point across?

Also:

@bsolomon1124
Copy link
Contributor Author

bsolomon1124 commented May 13, 2019

Looks like the build is failing because a "`" is used inside a function docstring. News to me that that wasn't allowed.

Screen Shot 2019-05-12 at 10 01 00 PM

@gpshead
Copy link
Member

gpshead commented May 13, 2019

Why might the 502 (bytes written) output make doctests fail?

It was in the wrong place as ... 502 as if it were be entered as a line of code in the interactive session rather than 502 as the result. I could've left it there, but it was an irrelevant detail and would need updating if the data string above were ever changed.

btw, i removed the extra ``s. i just obey whatever sphinx says for this sort of thing.

This modifies the compression ratio by a hair.
@gpshead
Copy link
Member

gpshead commented May 13, 2019

One example that I can be self-critical of is the one with gen_data(): because the data is very random, the compression ratio is actually < 1. (I.e. compression ratio will be much higher for non-random-looking data.) Do you think that this deserves some type of rewrite to a more realistic scenario, or does it still get the point across?

heh, true. compressing random data is rather pointless. how about just changing that to yield something else. Even if it just yields chunks of b'z' * chunksize that'd be fine.

Compressing random data (low compression ratio) is a
less realistic and less useful example.
@gpshead gpshead merged commit be6939f into python:master May 13, 2019
@miss-islington
Copy link
Contributor

Thanks @bsolomon1124 for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 13, 2019
* Docs: Add bz2 usage examples

- Adds an "Examples of usage" section inspired by the one
  found in the gzip docs
- Corrects the descriptions for ``compresslevel`` and ``data``:
    - ``compresslevel`` must be an `int`, not any number.  For
      instance, passing a float will raise ``TypeError``
    - Notes that `data` must be bytes-like
(cherry picked from commit be6939f)

Co-authored-by: Brad <brad.solomon.1124@gmail.com>
@bedevere-bot
Copy link

GH-13294 is a backport of this pull request to the 3.7 branch.

@gpshead
Copy link
Member

gpshead commented May 13, 2019

Thanks for the documentation improvement, always appreciated!

@bsolomon1124
Copy link
Contributor Author

@gpshead appreciate your guidance. It was a positive experience as my first CPython PR.

@bsolomon1124 bsolomon1124 deleted the docs-bz2-examples branch May 13, 2019 18:30
miss-islington added a commit that referenced this pull request May 13, 2019
* Docs: Add bz2 usage examples

- Adds an "Examples of usage" section inspired by the one
  found in the gzip docs
- Corrects the descriptions for ``compresslevel`` and ``data``:
    - ``compresslevel`` must be an `int`, not any number.  For
      instance, passing a float will raise ``TypeError``
    - Notes that `data` must be bytes-like
(cherry picked from commit be6939f)

Co-authored-by: Brad <brad.solomon.1124@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants