Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions bindings/distrdf/python/DistRDF/Backends/Dask/Backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,11 @@ def _process_partial_results(self,
cumulative_plots: Dict[int, Any] = {}

# Collect all futures in batches that had arrived since the last iteration
for batch in as_completed(future_tasks, with_results=True).batches():
for future, result in batch:
merged_results = reducer(merged_results, result) if merged_results else result

for batch in as_completed(future_tasks, with_results=False).batches():
for future in batch:
result = future.result()
merged_results = reducer(merged_results, result) if merged_results else result

mergeables = merged_results.mergeables

for pad_num, (drawable_id, (callbacks_list, index, operation_name)) in enumerate(drawables_info_dict.items(), start=1):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,4 @@ def pythonize_th1(klass):
_add_indexing_features(klass)

inject_clone_releasing_ownership(klass)
klass.Fit.__release_gil__ = True
4 changes: 3 additions & 1 deletion bindings/pyroot/pythonizations/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ ROOT_ADD_PYUNITTEST(pyroot_pyz_ttree_branch ttree_branch.py PYTHON_DEPS numpy)
ROOT_ADD_PYUNITTEST(pyroot_pyz_tcolor tcolor.py)

# TH1 and subclasses pythonizations
ROOT_ADD_PYUNITTEST(pyroot_pyz_th1_operators th1_operators.py)
ROOT_ADD_PYUNITTEST(pyroot_pyz_th1 th1.py)
# The above tests a deadlock. It should complete in about 1s. If we don't reduce the timeout, we need to wait 1500 s.
set_tests_properties(pyunittests-bindings-pyroot-pythonizations-pyroot-pyz-th1 PROPERTIES TIMEOUT 30)
ROOT_ADD_PYUNITTEST(pyroot_pyz_th1_fillN th1_fillN.py PYTHON_DEPS numpy)
ROOT_ADD_PYUNITTEST(pyroot_pyz_th2_fillN th2_fillN.py PYTHON_DEPS numpy)
ROOT_ADD_PYUNITTEST(pyroot_pyz_th2 th2.py)
Expand Down
70 changes: 70 additions & 0 deletions bindings/pyroot/pythonizations/test/th1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import unittest

import ROOT


class TH1Operators(unittest.TestCase):
"""
Test for the __imul__ operator of TH1 and subclasses, which
multiplies the histogram by a constant.
"""

# Tests
def test_imul(self):
nbins = 64
h = ROOT.TH1F("testHist", "", nbins, -4, 4)
h.FillRandom("gaus")

initial_bins = [h.GetBinContent(i) for i in range(nbins)]
c = 2

# Multiply in place
h *= c

# Check new value of bins
for i in range(nbins):
self.assertEqual(h.GetBinContent(i), initial_bins[i] * c)


class TH1IMT(unittest.TestCase):
"""
Test a deadlock when IMT is used in conjunction with a fit function in Python.
Since TH1.Fit held the GIL, the fit function could never be evaluated
"""

@classmethod
def setUpClass(cls):
ROOT.ROOT.EnableImplicitMT(4)

@classmethod
def tearDownClass(cls):
ROOT.ROOT.DisableImplicitMT()

def test_fit_python_function(self):
xmin = 0
xmax = 1

h1 = ROOT.TH1F("h1", "", 20, xmin, xmax)
h1.FillRandom("gaus", 1000)

def func(x, pars):
return pars[0] + pars[1] * x[0]

my_func = ROOT.TF1("f1", func, xmin, xmax, npar=2, ndim=1)

my_func.SetParNames(
"A",
"B",
)
my_func.SetParameter(0, 1)
my_func.SetParameter(1, -1)

r = h1.Fit(my_func, "SE0Q", "", xmin, xmax)

self.assertFalse(r.IsEmpty())
self.assertTrue(r.IsValid())
self.assertGreater(r.Parameter(0), 0)


if __name__ == "__main__":
unittest.main()
30 changes: 0 additions & 30 deletions bindings/pyroot/pythonizations/test/th1_operators.py

This file was deleted.

Loading