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

fix: Disallow sphinx-copybutton v0.5.1 to avoid output in copy #2192

Merged
merged 1 commit into from
Apr 30, 2023

Conversation

matthewfeickert
Copy link
Member

@matthewfeickert matthewfeickert commented Apr 30, 2023

Description

sphinx-copybutton v0.5.1 has a bug that will place lines of output in the copy contents, so explicitly disallow v0.5.1. This bug is fixed in sphinx-copybutton v0.5.2.


In sphinx-copybutton v0.5.1 the following reStructuredText block

pyhf/README.rst

Lines 68 to 82 in 0cac458

.. code:: pycon
>>> import pyhf
>>> import requests
>>> pyhf.set_backend("numpy")
>>> url = "https://raw.githubusercontent.com/scikit-hep/pyhf/main/docs/examples/json/2-bin_1-channel.json"
>>> wspace = pyhf.Workspace(requests.get(url).json())
>>> model = wspace.model()
>>> data = wspace.data(model)
>>> test_mu = 1.0
>>> CLs_obs, CLs_exp = pyhf.infer.hypotest(
... test_mu, data, model, test_stat="qtilde", return_expected=True
... )
>>> print(f"Observed: {CLs_obs:.8f}, Expected: {CLs_exp:.8f}")
Observed: 0.35998409, Expected: 0.35998409

when copied will contain the line

Observed: 0.05251497, Expected: 0.06445321

in the output which is not the desired effect.

v0.5.0 copy contents:

import pyhf
pyhf.set_backend("numpy")
model = pyhf.simplemodels.uncorrelated_background(
    signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0]
)
data = [51, 48] + model.config.auxdata
test_mu = 1.0
CLs_obs, CLs_exp = pyhf.infer.hypotest(
    test_mu, data, model, test_stat="qtilde", return_expected=True
)
print(f"Observed: {CLs_obs:.8f}, Expected: {CLs_exp:.8f}")

v0.5.1 copy contents:

import pyhf
pyhf.set_backend("numpy")
model = pyhf.simplemodels.uncorrelated_background(
    signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0]
)
data = [51, 48] + model.config.auxdata
test_mu = 1.0
CLs_obs, CLs_exp = pyhf.infer.hypotest(
    test_mu, data, model, test_stat="qtilde", return_expected=True
)
print(f"Observed: {CLs_obs:.8f}, Expected: {CLs_exp:.8f}")
Observed: 0.05251497, Expected: 0.06445321

v0.5.2 copy contents:

import pyhf
pyhf.set_backend("numpy")
model = pyhf.simplemodels.uncorrelated_background(
    signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0]
)
data = [51, 48] + model.config.auxdata
test_mu = 1.0
CLs_obs, CLs_exp = pyhf.infer.hypotest(
    test_mu, data, model, test_stat="qtilde", return_expected=True
)
print(f"Observed: {CLs_obs:.8f}, Expected: {CLs_exp:.8f}")

Checklist Before Requesting Reviewer

  • Tests are passing
  • "WIP" removed from the title of the pull request
  • Selected an Assignee for the PR to be responsible for the log summary

Before Merging

For the PR Assignees:

  • Summarize commit messages into a comprehensive review of the PR
* sphinx-copybutton v0.5.1 has a bug that will place lines of output in
  the copy contents, so explicitly disallow v0.5.1. This bug is fixed
  in sphinx-copybutton v0.5.2.

* sphinx-copybutton v0.5.1 has a bug that will place lines of output in
  the copy contents, so explicitly disallow v0.5.1. This bug is fixied
  in sphinx-copybutton v0.5.2.
@matthewfeickert matthewfeickert added docs Documentation related fix A bug fix build Changes that affect the build system or external dependencies labels Apr 30, 2023
@matthewfeickert matthewfeickert self-assigned this Apr 30, 2023
@matthewfeickert matthewfeickert added the need-to-backport tmp label until can be backported to patch release branch label Apr 30, 2023
@matthewfeickert
Copy link
Member Author

I'm going to approve and merge this myself. As always, PRs approved by a single core dev can be reverted as needed by the rest of the dev team.

@codecov
Copy link

codecov bot commented Apr 30, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (0cac458) 98.30% compared to head (b591275) 98.30%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2192   +/-   ##
=======================================
  Coverage   98.30%   98.30%           
=======================================
  Files          69       69           
  Lines        4533     4533           
  Branches      801      801           
=======================================
  Hits         4456     4456           
  Misses         45       45           
  Partials       32       32           
Flag Coverage Δ
contrib 97.88% <ø> (ø)
doctest 61.12% <ø> (ø)
unittests-3.10 96.31% <ø> (ø)
unittests-3.11 96.31% <ø> (ø)
unittests-3.8 96.33% <ø> (ø)
unittests-3.9 96.36% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@matthewfeickert matthewfeickert merged commit bc801ca into main Apr 30, 2023
@matthewfeickert matthewfeickert deleted the docs/fix-copybuotton-copy-of-text branch April 30, 2023 07:56
@matthewfeickert matthewfeickert removed the need-to-backport tmp label until can be backported to patch release branch label May 16, 2023
matthewfeickert added a commit that referenced this pull request May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Changes that affect the build system or external dependencies docs Documentation related fix A bug fix
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant