4 """ This Pythonizations module provides a number of useful pythonizations 5 of adaptation of some classes. 14 print "# WARNING: using PyCintex as cppyy implementation" 15 from PyCintex
import gbl
17 if not hasattr(gbl,
'ostream'):
18 gbl.gROOT.ProcessLine(
"#include <ostream>")
19 if not hasattr(gbl,
'stringstream'):
20 gbl.gROOT.ProcessLine(
"#include <sstream>")
27 return 'Histogram 1D "%s" %d bins [%f,%f]' % (h.title(), x.bins(), x.lowerEdge(), x.upperEdge())
32 return map(h.binEntries,
range(x.bins()))
36 x, y = h.xAxis(), h.yAxis()
37 return 'Histogram 2D "%s" %d xbins [%f,%f], %d ybins [%f,%f]' % \
38 (h.title(), x.bins(), x.lowerEdge(), x.upperEdge(),
39 y.bins(), y.lowerEdge(), y.upperEdge())
50 return str(1 == b.bool())
55 s = gbl.stringstream()
59 out = o.__class__.__name__ +
' object' 60 if hasattr(o,
'hasKey')
and o.hasKey():
61 out +=
' key = ' + str(o.key())
63 out = o.__class__.__name__ +
' NULL object' 68 return self.containedObject(k)
72 return self.numberOfObjects()
76 if hasattr(self,
'containedObjects'):
77 sequential = self.containedObjects()
81 limit = self.__len__()
83 yield sequential.__getitem__(count)
89 Draw AIDA histogram (through access to internal ROOT histogram 91 >>> aida = ... # get the historgam 95 _fun = gbl.Gaudi.Utils.Aida2ROOT.aida2root
97 return _root.Draw(*args)
100 gbl.AIDA.IHistogram1D.__repr__ = _printHisto1D
101 gbl.AIDA.IHistogram1D.contents = _contentsHisto1D
102 gbl.AIDA.IHistogram2D.__repr__ = _printHisto2D
103 for h
in (gbl.AIDA.IHistogram,
104 gbl.AIDA.IHistogram1D,
105 gbl.AIDA.IHistogram2D,
106 gbl.AIDA.IHistogram3D,
108 gbl.AIDA.IProfile2D):
112 gbl.StatusCode.__repr__ = _printStatusCode
114 gbl._Bit_reference.__repr__ = _printBitReference
117 gbl.ContainedObject.__repr__ = _printFillStream
118 gbl.DataObject.__repr__ = _printFillStream
119 gbl.ObjectContainerBase.__getitem__ = _container__getitem__
120 gbl.ObjectContainerBase.__len__ = _container__len__
121 gbl.ObjectContainerBase.__iter__ = _container__iter__
123 gbl.IUpdateManagerSvc.update =
lambda self, obj: gbl.IUpdateManagerSvc.PythonHelper.update(
125 gbl.IUpdateManagerSvc.invalidate =
lambda self, obj: gbl.IUpdateManagerSvc.PythonHelper.invalidate(
129 if not hasattr(gbl.StatusCode,
'SUCCESS'):
131 gbl.StatusCode.SUCCESS = 1
132 gbl.StatusCode.FAILURE = 0
135 if hasattr(gbl.Gaudi.StringKey,
'__cpp_eq__'):
136 _eq = gbl.Gaudi.StringKey.__cpp_eq__
137 setattr(gbl.Gaudi.StringKey,
'__eq__', _eq)
140 if hasattr(gbl.Gaudi.StringKey,
'__cpp_ne__'):
141 _ne = gbl.Gaudi.StringKey.__cpp_ne__
142 setattr(gbl.Gaudi.StringKey,
'__ne__', _ne)
146 if gbl.gROOT.GetVersionInt() <= 51800:
148 gbl.GaudiPython.PyROOTPickle.Initialize(libPyROOT, libPyROOT.ObjectProxy)
174 The iterator for MapBase-based containers 176 >>> m = ... ## the map 177 >>> for key in m : print key , m[key] 182 while _index < _size:
183 yield self.key_at(_index)
211 The iterator for MapBase-based containers 213 >>> m = ... ## the map 214 >>> for key,value in m.iteritems() : print key, value 219 while _index < _size:
220 _key = self.key_at(_index)
221 yield (_key, self.at(_key))
248 >>> m = ... ## the map 249 >>> keys = m.keys() ## get the list of keys 254 for i
in range(0, _size):
255 _keys.append(self.key_at(i))
280 Get the list of items 282 >>> m = ... ## the map 283 >>> items = m.keys() ## get the list of items 288 for i
in range(0, _size):
289 _key = self.key_at(i)
290 _value = self.at(_key)
291 _items.append((_key, _value))
316 Get the list of values 318 >>> m = ... ## the map 319 >>> values = m.values() ## get the list of values 324 for i
in range(0, _size):
325 _value = self.value_at(i)
326 _values.append(_value)
351 Check if the certainkey is in the map 353 >>> m = ... ## the map 354 >>> if 'a' in m : ... ## chekc the presence of the key in the map 357 _num = self.count(key)
358 return False if 0 == _num
else True 383 Get the value for the certain key, or 'value' otherwise 385 >>> m = ... ## the map 386 >>> v = m.get ( key , 15 ) 412 Representation of MapBase-based maps: 414 >>> m = ... ## the map 420 for i
in range(0, _size):
421 _key = self.key_at(i)
425 _result +=
" %s : %s " % (str(_key), str(_val))
451 'Set-item' for MapBase-based maps: 453 >>> m = ... ## the map 454 >>> m[key] = value ## set the item 457 _replaced =
True if key
in self
else False 458 self.update(key, value)
484 'Del-item' for MapBase-based maps: 486 >>> m = ... ## the map 490 _erased =
True if key
in self
else False 495 gbl.Gaudi.Utils.MapBase . __len__ =
lambda s: s.size()
496 gbl.Gaudi.Utils.MapBase . __iter__ = __mapbase_iter__
497 gbl.Gaudi.Utils.MapBase . keys = __mapbase_keys__
498 gbl.Gaudi.Utils.MapBase . __iteritems__ = __mapbase_iteritems__
499 gbl.Gaudi.Utils.MapBase . iteritems = __mapbase_iteritems__
500 gbl.Gaudi.Utils.MapBase . items = __mapbase_items__
501 gbl.Gaudi.Utils.MapBase . values = __mapbase_values__
502 gbl.Gaudi.Utils.MapBase . __contains__ = __mapbase_contains__
503 gbl.Gaudi.Utils.MapBase . has_key = __mapbase_contains__
504 gbl.Gaudi.Utils.MapBase . get = __mapbase_get__
505 gbl.Gaudi.Utils.MapBase . __str__ = __mapbase_str__
506 gbl.Gaudi.Utils.MapBase . __repr__ = __mapbase_str__
507 gbl.Gaudi.Utils.MapBase . __setitem__ = __mapbase_setitem__
508 gbl.Gaudi.Utils.MapBase . __delitem__ = __mapbase_delitem__
509 gbl.Gaudi.Utils.MapBase . __getitem__ =
lambda s, key: s.at(key)
def __mapbase_values__(self)
def __mapbase_setitem__(self, key, value)
def __mapbase_contains__(self, key)
def _container__getitem__(self, k)
def __mapbase_iteritems__(self)
def _printBitReference(b)
def __mapbase_items__(self)
def _container__iter__(self)
def __mapbase_keys__(self)
struct GAUDI_API map
Parametrisation class for map-like implementation.
def _draw_aida_(self, args)
def __mapbase_get__(self, key, value=None)
def __mapbase_iter__(self)
decltype(auto) range(Args &&...args)
Zips multiple containers together to form a single range.
def __mapbase_delitem__(self, key)
def _container__len__(self)
def __mapbase_str__(self)