Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
PyROOT Namespace Reference

Classes

class  RPyROOTApplication
 Interactive application for Python. More...
 
class  TMemoryRegulator
 

Typedefs

typedef std::unordered_map< Cppyy::TCppObject_t, Cppyy::TCppType_tObjectMap_t
 

Functions

PyObjectAddBranchAttrSyntax (PyObject *self, PyObject *args)
 Allow branches to be accessed as attributes of a tree.
 
PyObjectAddCPPInstancePickling (PyObject *self, PyObject *args)
 Set reduce attribute for CPPInstance objects.
 
PyObjectAddPrettyPrintingPyz (PyObject *self, PyObject *args)
 Add pretty printing pythonization.
 
PyObjectAddTClassDynamicCastPyz (PyObject *self, PyObject *args)
 Add pythonization for TClass::DynamicCast.
 
PyObjectAddTObjectEqNePyz (PyObject *self, PyObject *args)
 Add pythonization for equality and inequality operators in TObject.
 
PyObjectAsRTensor (PyObject *self, PyObject *obj)
 Adopt memory of a Python object with array interface using an RTensor.
 
PyObjectAsRVec (PyObject *self, PyObject *obj)
 Adopt memory of a Python object with array interface using an RVec.
 
PyObjectBranchPyz (PyObject *self, PyObject *args)
 Add pythonization for TTree::Branch.
 
PyObjectClearProxiedObjects (PyObject *self, PyObject *args)
 
PyObjectCPPInstanceExpand (PyObject *self, PyObject *args)
 Deserialize pickled objects.
 
PyObjectGetDataPointer (PyObject *self, PyObject *args)
 Get pointer to the data of an object.
 
PyObjectGetEndianess (PyObject *self, PyObject *args)
 Get endianess of the system.
 
PyObjectGetSizeOfType (PyObject *self, PyObject *args)
 Set of helper functions that are invoked from the pythonizors, on the Python side.
 
void Init ()
 
PyObjectMakeNumpyDataFrameImpl (PyObject *self, PyObject *obj)
 Make an RDataFrame from a dictionary of numpy arrays.
 
PyObjectSetBranchAddressPyz (PyObject *self, PyObject *args)
 Add pythonization for TTree::SetBranchAddress.
 

Variables

PyObjectgRootModule = 0
 

Typedef Documentation

◆ ObjectMap_t

Definition at line 49 of file TMemoryRegulator.h.

Function Documentation

◆ AddBranchAttrSyntax()

PyObject * PyROOT::AddBranchAttrSyntax ( PyObject self,
PyObject args 
)

Allow branches to be accessed as attributes of a tree.

Parameters
[in]selfAlways null, since this is a module function.
[in]argsPointer to a Python tuple object containing the arguments received from Python.

Allow access to branches/leaves as if they were Python data attributes of the tree (e.g. mytree.branch)

Definition at line 187 of file TTreePyz.cxx.

◆ AddCPPInstancePickling()

PyObject * PyROOT::AddCPPInstancePickling ( PyObject self,
PyObject args 
)

Set reduce attribute for CPPInstance objects.

Parameters
[in]selfAlways null, since this is a module function.
[in]argsPointer to a Python tuple object containing the arguments received from Python.

The C++ function op_reduce defined above is wrapped in a Python method so that it can be injected in CPPInstance

Definition at line 125 of file CPPInstancePyz.cxx.

◆ AddPrettyPrintingPyz()

PyObject * PyROOT::AddPrettyPrintingPyz ( PyObject self,
PyObject args 
)

Add pretty printing pythonization.

Parameters
[in]selfAlways null, since this is a module function.
[in]argsPointer to a Python tuple object containing the arguments received from Python.

This function adds the following pythonizations to print the object more user-friendly than cppyy by using the output of cling::printValue as the return value of the special method str.

Definition at line 110 of file GenericPyz.cxx.

◆ AddTClassDynamicCastPyz()

PyObject * PyROOT::AddTClassDynamicCastPyz ( PyObject self,
PyObject args 
)

Add pythonization for TClass::DynamicCast.

Parameters
[in]selfAlways null, since this is a module function.
[in]argsPointer to a Python tuple object containing the arguments received from Python.

TClass::DynamicCast returns a void* that the user still has to cast (it will have the proper offset, though). Fix this by providing the requested binding if the cast succeeded.

Definition at line 76 of file TClassPyz.cxx.

◆ AddTObjectEqNePyz()

PyObject * PyROOT::AddTObjectEqNePyz ( PyObject self,
PyObject args 
)

Add pythonization for equality and inequality operators in TObject.

Parameters
[in]selfAlways null, since this is a module function.
[in]argsPointer to a Python tuple object containing the arguments received from Python.

The equality and inequality operators are better implemented in C++, since we need to need to rely on Cppyy's rich comparison if the object we are comparing ourselves with is not a Python proxy or if it contains a null pointer. For example, we need to support the comparison to None.

The rest of comparison operators (i.e. those that define order) can be implemented in Python, throwing a NotImplemented exception if we are not comparing two proxies to TObject or derivate.

Definition at line 60 of file TObjectPyz.cxx.

◆ AsRTensor()

PyObject * PyROOT::AsRTensor ( PyObject self,
PyObject obj 
)

Adopt memory of a Python object with array interface using an RTensor.

Parameters
[in]selfAlways null, since this is a module function.
[in]objPyObject with array interface

This function returns an RTensor which adopts the memory of the given PyObject. The RTensor takes the data pointer and the shape from the array interface dictionary.

Definition at line 30 of file RTensorPyz.cxx.

◆ AsRVec()

PyObject * PyROOT::AsRVec ( PyObject self,
PyObject obj 
)

Adopt memory of a Python object with array interface using an RVec.

Parameters
[in]selfself object
[in]objPyObject with array interface

This function returns an RVec which adopts the memory of the given PyObject. The RVec takes the data pointer and the size from the array interface dictionary.

Definition at line 30 of file RVecPyz.cxx.

◆ BranchPyz()

PyObject * PyROOT::BranchPyz ( PyObject self,
PyObject args 
)

Add pythonization for TTree::Branch.

Parameters
[in]selfAlways null, since this is a module function.
[in]argsPointer to a Python tuple object containing the arguments received from Python.

Modify the behaviour of Branch so that proxy references can be passed as arguments from the Python side, more precisely in cases where the C++ implementation of the method expects the address of a pointer.

For example:

v = ROOT.std.vector('int')()
t.Branch('my_vector_branch', v)

The following signatures are treated in this pythonization:

  • ( const char*, void*, const char*, Int_t = 32000 )
  • ( const char*, const char*, T**, Int_t = 32000, Int_t = 99 )
  • ( const char*, T**, Int_t = 32000, Int_t = 99 )

Definition at line 400 of file TTreePyz.cxx.

◆ ClearProxiedObjects()

PyObject * PyROOT::ClearProxiedObjects ( PyObject self,
PyObject args 
)

Definition at line 65 of file PyROOTWrapper.cxx.

◆ CPPInstanceExpand()

PyObject * PyROOT::CPPInstanceExpand ( PyObject self,
PyObject args 
)

Deserialize pickled objects.

Parameters
[in]selfAlways null, since this is a module function.
[in]argsPointer to a Python tuple object containing the arguments received from Python.

Helper function that deserializes pickled objects. It needs to be included in the extension module API because otherwise it is not callable from Python. This is important because it will be Python itself calling it when trying to expand a serialized object.

Definition at line 39 of file CPPInstancePyz.cxx.

◆ GetDataPointer()

PyObject * PyROOT::GetDataPointer ( PyObject self,
PyObject args 
)

Get pointer to the data of an object.

Parameters
[in]selfAlways null, since this is a module function.
[in]args[0] Python representation of the C++ object. [1] Data-type of the C++ object as Python string. [2] Method to be called on the C++ object to get the data pointer as Python string

This function returns the pointer to the data of an object as an Python integer retrieved by the given method.

Definition at line 62 of file PyzPythonHelpers.cxx.

◆ GetEndianess()

PyObject * PyROOT::GetEndianess ( PyObject self,
PyObject args 
)

Get endianess of the system.

Parameters
[in]selfAlways null, since this is a module function.
[in]argsPointer to an empty Python tuple.
Returns
Endianess as Python string

This function returns endianess of the system as a Python integer. The return value is either '<' or '>' for little or big endian, respectively.

Definition at line 96 of file PyzPythonHelpers.cxx.

◆ GetSizeOfType()

PyObject * PyROOT::GetSizeOfType ( PyObject self,
PyObject args 
)

Set of helper functions that are invoked from the pythonizors, on the Python side.

For that purpose, they are included in the interface of the PyROOT extension module.

Get size of C++ data-type

Parameters
[in]selfAlways null, since this is a module function.
[in]argsC++ data-type as Python string

This function returns the length of a C++ data-type in bytes as a Python integer.

Definition at line 36 of file PyzPythonHelpers.cxx.

◆ Init()

void PyROOT::Init ( )

Definition at line 49 of file PyROOTWrapper.cxx.

◆ MakeNumpyDataFrameImpl()

PyObject * PyROOT::MakeNumpyDataFrameImpl ( PyObject self,
PyObject pydata 
)

Make an RDataFrame from a dictionary of numpy arrays.

Parameters
[in]selfAlways null, since this is a module function.
[in]pydataDictionary with numpy arrays

This function takes a dictionary of numpy arrays and creates an RDataFrame using the keys as column names and the numpy arrays as data.

Definition at line 32 of file RDataFramePyz.cxx.

◆ SetBranchAddressPyz()

PyObject * PyROOT::SetBranchAddressPyz ( PyObject self,
PyObject args 
)

Add pythonization for TTree::SetBranchAddress.

Parameters
[in]selfAlways null, since this is a module function.
[in]argsPointer to a Python tuple object containing the arguments received from Python.

Modify the behaviour of SetBranchAddress so that proxy references can be passed as arguments from the Python side, more precisely in cases where the C++ implementation of the method expects the address of a pointer.

For example:

v = ROOT.std.vector('int')()
t.SetBranchAddress("my_vector_branch", v)

Definition at line 209 of file TTreePyz.cxx.

Variable Documentation

◆ gRootModule

R__EXTERN PyObject * PyROOT::gRootModule = 0

Definition at line 36 of file PyROOTModule.cxx.