feat: boost-histogram 1.0 compatibility and typing updates #204
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This enables support for
boost-histogram>=1.0.0
. SubclassingHistogram
requires afamily
keyword argument (optional starting withboost-histogram
1.0.1), and theboost-histogram
library is now typed.resolves #201
Overview of changes
Typing changes
For reading yields and variances, switch to using
h.values()
andh.variances()
instead ofh.view().value
andh.view().variance
. Theview()
-based method is still used for writing yields / variances directly.Calling
numpy
functions with values/variances requires a# type: ignore
, as does setting values viaview()
.See scikit-hep/boost-histogram#527 and scikit-hep/boost-histogram#525 (comment)). Some of these
# type: ignore
may possibly be removed in the future withboost-histogram
updates.The typing revealed a small typing bug in
cabinetry.route
, which will be resolved in a separate PR (here only temporarily fixed via# type: ignore
).CI / pre-commit updates
The CI is updated to skip
mypy
with Python 3.7, since theboost-histogram
syntax requires at least Python 3.8 (see scikit-hep/boost-histogram#525 (comment)).For type checking, the requirement is
boost-histogram>=1.0.1
due to scikit-hep/boost-histogram#525 (comment). Thepre-commit
version requirement is set accordingly.boost-histogram
1.0.0 will fail withmypy
due to two typing bugs (ellipsis/constructor), see also 1.0.1 changelog.To get
mypy
working correctly inpre-commit
, also addingboost-histogram
to the environment requirements (and adding typednumpy
at the same time).Other notes
Also adding a test for
Histogram
properties.