Skip to content

Commit

Permalink
fix: allow writing generic UHI-compatible histograms (#1128)
Browse files Browse the repository at this point in the history
* Allow writing generic UHI-compatible histograms

UHI-compatible histograms should have a function variances, but are not
required to have a storage_type. Also, if the histogram is not from hist
or boost_histogram, boost_histogram is None and the storage type check
fails.

* style: pre-commit fixes

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
YSelfTool and pre-commit-ci[bot] authored Feb 19, 2024
1 parent 8a42e7d commit d4632ad
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/uproot/writing/identify.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ def to_writable(obj):
data = obj.values(flow=True)
fSumw2 = (
obj.variances(flow=True)
if obj.storage_type == boost_histogram.storage.Weight
if boost_histogram is None
or obj.storage_type == boost_histogram.storage.Weight
else None
)

Expand Down Expand Up @@ -293,7 +294,8 @@ def to_writable(obj):

tmp = (
obj.variances()
if obj.storage_type == boost_histogram.storage.Weight
if boost_histogram is None
or obj.storage_type == boost_histogram.storage.Weight
else None
)
fSumw2 = None
Expand Down

0 comments on commit d4632ad

Please sign in to comment.