Skip to content

Commit d4632ad

Browse files
fix: allow writing generic UHI-compatible histograms (#1128)
* 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>
1 parent 8a42e7d commit d4632ad

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/uproot/writing/identify.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ def to_writable(obj):
265265
data = obj.values(flow=True)
266266
fSumw2 = (
267267
obj.variances(flow=True)
268-
if obj.storage_type == boost_histogram.storage.Weight
268+
if boost_histogram is None
269+
or obj.storage_type == boost_histogram.storage.Weight
269270
else None
270271
)
271272

@@ -293,7 +294,8 @@ def to_writable(obj):
293294

294295
tmp = (
295296
obj.variances()
296-
if obj.storage_type == boost_histogram.storage.Weight
297+
if boost_histogram is None
298+
or obj.storage_type == boost_histogram.storage.Weight
297299
else None
298300
)
299301
fSumw2 = None

0 commit comments

Comments
 (0)