pyhf icon indicating copy to clipboard operation
pyhf copied to clipboard

feat: Type hints

Open kratsg opened this issue 5 years ago • 2 comments

Description

Resolves #1284

See:

  • https://www.python.org/dev/peps/pep-0484/
  • https://www.python.org/dev/peps/pep-0544/
  • https://pypi.org/project/typing-extensions/
  • https://github.com/scikit-hep/hist/issues/64
  • https://github.com/Princeton-Penn-Vents/princeton-penn-flowmeter/blob/2f71f613aafc04ea604f3ff7ed7be1b99a40b4cc/nurse/qt.py#L92-L131

typing-extensions is used for python 3.6, 3.7 for certain things such as Protocol classes.

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

  • [ ] Summarize commit messages into a comprehensive review of the PR

kratsg avatar Jul 14 '20 23:07 kratsg

Codecov Report

Merging #948 (bcef1cf) into master (025ffe9) will decrease coverage by 1.01%. The diff coverage is 55.10%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #948      +/-   ##
==========================================
- Coverage   97.65%   96.63%   -1.02%     
==========================================
  Files          63       64       +1     
  Lines        4006     4104      +98     
  Branches      565      566       +1     
==========================================
+ Hits         3912     3966      +54     
- Misses         55       98      +43     
- Partials       39       40       +1     
Flag Coverage Δ
contrib 25.09% <8.16%> (-0.42%) :arrow_down:
unittests 96.41% <55.10%> (-1.02%) :arrow_down:

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

Impacted Files Coverage Δ
src/pyhf/typing.py 53.48% <53.48%> (ø)
src/pyhf/tensor/jax_backend.py 96.42% <66.66%> (-0.66%) :arrow_down:
src/pyhf/tensor/numpy_backend.py 97.76% <66.66%> (-0.72%) :arrow_down:
src/pyhf/tensor/pytorch_backend.py 97.67% <66.66%> (-0.74%) :arrow_down:
src/pyhf/tensor/tensorflow_backend.py 96.59% <66.66%> (-0.63%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 025ffe9...bcef1cf. Read the comment docs.

codecov[bot] avatar Jul 15 '20 00:07 codecov[bot]

#1472 provides some motivation for typing of the tensor return values from the pyhf API.

alexander-held avatar May 28 '21 16:05 alexander-held