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

Namespaces

namespace  PyStrings
 

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.
 
PyObjectAddDirectoryGetAttrPyz (PyObject *self, PyObject *args)
 Add attr syntax to TDirectory.
 
PyObjectAddDirectoryWritePyz (PyObject *self, PyObject *args)
 Add pythonisation of TDirectory::WriteObject.
 
PyObjectAddFileOpenPyz (PyObject *self, PyObject *args)
 Make TFile::Open equivalent to a constructor.
 
PyObjectAddPrettyPrintingPyz (PyObject *self, PyObject *args)
 Add pretty printing pythonization.
 
PyObjectAddSetItemTCAPyz (PyObject *self, PyObject *args)
 Customize the setting of an item of a TClonesArray.
 
PyObjectAddTClassDynamicCastPyz (PyObject *self, PyObject *args)
 Add pythonization for TClass::DynamicCast.
 
PyObjectAddTDirectoryFileGetPyz (PyObject *self, PyObject *args)
 Add pythonisation of TDirectoryFile::Get()
 
PyObjectAddTObjectEqNePyz (PyObject *self, PyObject *args)
 Add pythonization for equality and inequality operators in TObject.
 
PyObjectAddUsingToClass (PyObject *self, PyObject *args)
 Add base class overloads of a given method to a derived class.
 
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.
 
PyObjectCreateBufferFromAddress (PyObject *self, PyObject *addr)
 Get a buffer starting at a given address.
 
bool CreatePyStrings ()
 
PyObjectDestroyPyStrings ()
 Remove all cached python strings.
 
PyObjectGetEndianess (PyObject *self, PyObject *args)
 Get endianess of the system.
 
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 174 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 129 of file CPPInstancePyz.cxx.

◆ AddDirectoryGetAttrPyz()

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

Add attr syntax to TDirectory.

Parameters
[in]selfAlways null, since this is a module function.
[in]argsPointer to a Python tuple object containing the arguments This allows to use TDirectory and daughters (such as TDirectoryFile and TFile) as follows
myfile.mydir.mysubdir.myHist.Draw()

Definition at line 122 of file TDirectoryPyz.cxx.

◆ AddDirectoryWritePyz()

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

Add pythonisation of TDirectory::WriteObject.

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

Definition at line 133 of file TDirectoryPyz.cxx.

◆ AddFileOpenPyz()

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

Make TFile::Open equivalent to a constructor.

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

Definition at line 23 of file TFilePyz.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 54 of file GenericPyz.cxx.

◆ AddSetItemTCAPyz()

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

Customize the setting of an item of a TClonesArray.

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

Inject a setitem implementation that customizes the setting of an item into a TClonesArray.

The setitem pythonization that TClonesArray inherits from TSeqCollection does not apply in this case and a redefinition is required. The reason is TClonesArray sets objects by constructing them in-place, which is impossible to support as the Python object given as value must exist a priori. It can, however, be memcpy'd and stolen.

Definition at line 167 of file TClonesArrayPyz.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 89 of file TClassPyz.cxx.

◆ AddTDirectoryFileGetPyz()

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

Add pythonisation of TDirectoryFile::Get()

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 objects through the Get() method. (e.g. dirfile.Get(key))

Definition at line 69 of file TDirectoryFilePyz.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 57 of file TObjectPyz.cxx.

◆ AddUsingToClass()

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

Add base class overloads of a given method to a derived class.

Parameters
[in]selfAlways null, since this is a module function.
[in]args[0] Derived class. [1] Name of the method whose base class overloads to inject in the derived class.

This function adds base class overloads to a derived class for a given method. This covers the 'using' case, which is not supported by default by the bindings.

Definition at line 116 of file PyzPythonHelpers.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 29 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 29 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 394 of file TTreePyz.cxx.

◆ ClearProxiedObjects()

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

Definition at line 66 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.

◆ CreateBufferFromAddress()

PyObject * PyROOT::CreateBufferFromAddress ( PyObject self,
PyObject addr 
)

Get a buffer starting at a given address.

Parameters
[in]selfAlways null, since this is a module function.
[in]addrAddress to create buffer from
Returns
A cppyy LowLevelView object on the received address, i.e. an indexable buffer starting at that address.

Definition at line 28 of file FacadeHelpers.cxx.

◆ CreatePyStrings()

bool PyROOT::CreatePyStrings ( )

Definition at line 29 of file PyROOTStrings.cxx.

◆ DestroyPyStrings()

PyObject * PyROOT::DestroyPyStrings ( )

Remove all cached python strings.

Definition at line 46 of file PyROOTStrings.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 46 of file PyzPythonHelpers.cxx.

◆ Init()

void PyROOT::Init ( )

Definition at line 50 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 30 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 196 of file TTreePyz.cxx.

Variable Documentation

◆ gRootModule

R__EXTERN PyObject * PyROOT::gRootModule = 0

Definition at line 39 of file PyROOTModule.cxx.