From 28404f8e58cb7ffb065c8e9044497e087328feef Mon Sep 17 00:00:00 2001 From: Robin Sonnabend Date: Fri, 16 Feb 2024 14:15:03 +0100 Subject: [PATCH 1/2] 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. --- src/uproot/writing/identify.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uproot/writing/identify.py b/src/uproot/writing/identify.py index 1322b94ba..fe12cfb81 100644 --- a/src/uproot/writing/identify.py +++ b/src/uproot/writing/identify.py @@ -265,7 +265,7 @@ 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 ) @@ -293,7 +293,7 @@ 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 From d35d40ab3916568fd1bcbb717951aaf24d2cb1d1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 16 Feb 2024 13:28:21 +0000 Subject: [PATCH 2/2] style: pre-commit fixes --- src/uproot/writing/identify.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/uproot/writing/identify.py b/src/uproot/writing/identify.py index fe12cfb81..b1f35b852 100644 --- a/src/uproot/writing/identify.py +++ b/src/uproot/writing/identify.py @@ -265,7 +265,8 @@ def to_writable(obj): data = obj.values(flow=True) fSumw2 = ( obj.variances(flow=True) - if boost_histogram is None or obj.storage_type == boost_histogram.storage.Weight + if boost_histogram is None + or obj.storage_type == boost_histogram.storage.Weight else None ) @@ -293,7 +294,8 @@ def to_writable(obj): tmp = ( obj.variances() - if boost_histogram is None or obj.storage_type == boost_histogram.storage.Weight + if boost_histogram is None + or obj.storage_type == boost_histogram.storage.Weight else None ) fSumw2 = None