From 184e6ab94ffd9afc5734fb5ab57a573076a92ff4 Mon Sep 17 00:00:00 2001 From: fkrempl Date: Wed, 16 Sep 2026 13:58:41 +0200 Subject: [PATCH 1/3] [PyROOT][Doc] Add RNTuple pythonization docs --- .../python/ROOT/_pythonization/_rntuple.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py b/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py index 446476971151e..724d58cffacbe 100644 --- a/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py +++ b/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py @@ -8,6 +8,40 @@ # For the list of contributors see $ROOTSYS/README/CREDITS. # ################################################################################ +r""" +\pythondoc RNTupleWriter + +RNTupleWriter can be used to write RNTuples to storage. + +A simple way to write an RNTuple is done by: +- create a model and add fields to it +- open a RNTupleWriter +- create entries and fill them with data +- commit entries to the RNTuple via writer.Fill(entry) + +\code{.py} +import ROOT + +# Create the model +model = ROOT.RNTupleModel.Create() + +# Define the schema by adding fields to the model. +model.MakeField['int']("foo") + +# Create a writer as a context manager +with ROOT.RNTupleWriter.Recreate(model, "myNtuple", "file.root") as writer: + # create entries and write them to the RNTuple + for i in range(0,10): + entry = writer.CreateEntry() + entry['foo'] = i + writer.Fill(entry) +# On destruction, the writer will flush the written data to disk + +\endcode + +\endpythondoc +""" + from . import pythonization from ._pyz_utils import MethodTemplateGetter, MethodTemplateWrapper From 77bcb7bbeab1a9ccc6591401b27d2dfaef5ea31b Mon Sep 17 00:00:00 2001 From: fkrempl Date: Wed, 16 Sep 2026 14:09:50 +0200 Subject: [PATCH 2/3] [PyROOT][Doc] Add RNTuple pythonization docs --- .../python/ROOT/_pythonization/_rntuple.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py b/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py index 724d58cffacbe..8b30caed0e166 100644 --- a/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py +++ b/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py @@ -11,13 +11,13 @@ r""" \pythondoc RNTupleWriter -RNTupleWriter can be used to write RNTuples to storage. +RNTupleWriter is an interface to write RNTuples to storage. -A simple way to write an RNTuple is done by: -- create a model and add fields to it -- open a RNTupleWriter -- create entries and fill them with data -- commit entries to the RNTuple via writer.Fill(entry) +A simple way to write an RNTuple in python is by: +- creating a model and adding fields to it +- opening an RNTupleWriter +- creating entries and filling them with data +- committing entries to the RNTuple via writer.Fill(entry) \code{.py} import ROOT From 0d383e7d04fca5c9e65c647946497d97843a8933 Mon Sep 17 00:00:00 2001 From: Franz <139059326+franz053@users.noreply.github.com> Date: Tue, 13 Oct 2026 09:37:04 +0200 Subject: [PATCH 3/3] moved entry creation out of loop in the example --- .../pythonizations/python/ROOT/_pythonization/_rntuple.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py b/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py index 8b30caed0e166..abb435adbe1b0 100644 --- a/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py +++ b/bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py @@ -30,9 +30,9 @@ # Create a writer as a context manager with ROOT.RNTupleWriter.Recreate(model, "myNtuple", "file.root") as writer: - # create entries and write them to the RNTuple + # create an entry and use it to write data to the RNTuple + entry = writer.CreateEntry() for i in range(0,10): - entry = writer.CreateEntry() entry['foo'] = i writer.Fill(entry) # On destruction, the writer will flush the written data to disk