pyhf icon indicating copy to clipboard operation
pyhf copied to clipboard

fix: Cast non-hashable types to floats in toms748_scan

Open matthewfeickert opened this issue 1 year ago • 2 comments
trafficstars

Description

Resolves #2466

As toms748_scan uses caching of results it requires that the results are hashable objects, which arrays are not. So to keep using this approach convert to floats as needed.

Add testing for all backends for the upper limits inference tests.

Checklist Before Requesting Reviewer

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

Before Merging

For the PR Assignees:

  • [x] Summarize commit messages into a comprehensive review of the PR
* In pyhf.infer.intervals.upper_limits.toms748_scan a caching approach to a dict
  is used. This requires that the objects cached are hashable, but generic
  ndarrays are not. To avoid this problem, cast single value tensors to floats
  as needed.
* Use pyhf.tensorlib.transpose to support TensorFlow, as the `.T` operator is not
  supported.
* Add testing of all backends to the toms748_scan and upper_limit tests in 
  tests/test_infer.py.
   - Add notes to change tests after TensorFlow support is dropped.

matthewfeickert avatar Apr 18 '24 06:04 matthewfeickert

CI is currently failing for Apple silicon macOS.

matthewfeickert avatar Apr 18 '24 06:04 matthewfeickert

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.21%. Comparing base (64ab264) to head (e815612).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2467   +/-   ##
=======================================
  Coverage   98.21%   98.21%           
=======================================
  Files          69       69           
  Lines        4543     4546    +3     
  Branches      804      805    +1     
=======================================
+ Hits         4462     4465    +3     
  Misses         48       48           
  Partials       33       33           
Flag Coverage Δ
contrib 97.80% <100.00%> (+<0.01%) :arrow_up:
doctest 98.08% <100.00%> (+<0.01%) :arrow_up:
unittests-3.10 ?
unittests-3.11 ?
unittests-3.12 96.23% <100.00%> (+<0.01%) :arrow_up:
unittests-3.8 96.26% <100.00%> (+<0.01%) :arrow_up:
unittests-3.9 ?

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Apr 18 '24 07:04 codecov[bot]