| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# GaudiPython::Pythonizations Namespace Reference

## Functions
def | _loadDict
def | _printHisto1D
def | _contentsHisto1D
def | _printHisto2D
def | _printStatusCode
def | _printBitReference
def | _printFillStream
def | _container__getitem__
def | _container__len__
def | _container__iter__
def | _draw_aida_
def | __mapbase_iter__
| decorate some map-like objects ============================================================================= The iterator for MapBase class
def | __mapbase_iteritems__
| The iterator for MapBase class.
def | __mapbase_keys__
| Get the list of keys for the map.
def | __mapbase_items__
| Get the list of items for the map.
def | __mapbase_values__
| Get the list of values for the map.
def | __mapbase_contains__
| Check if the certain key is in the map.
def | __mapbase_get__
| Get the value for certain key, return predefined value otherwise.
def | __mapbase_str__
| Representation of MapBase-based maps.
def | __mapbase_setitem__
| "Setitem" for MapBase-based maps:
def | __mapbase_delitem__
| "Del-item" for MapBase-based maps:
## Variables
list | __all__ = [ ]
| gbl = PyCintex.gbl
| _loadDict_save = PyCintex.loadDict
| _eq = gbl.Gaudi.StringKey.__cpp_eq__
| _ne = gbl.Gaudi.StringKey.__cpp_ne__

## Function Documentation

def GaudiPython::Pythonizations::__mapbase_contains__ | ( |  | self,
|  |  | key |
| ) |  |  |

Check if the certain key is in the map.

        >>> m      = ...        ## the map
        >>> if 'a' in m : print 'key is in the map!'

See also:
  Gaudi::Utils::MapBase

  GaudiUtils::Map

  GaudiUtils::HashMap

  GaudiUtils::VectorMap

  GaudiUtils::Map::count

  GaudiUtils::HashMap::count @ see GaudiUtils::VectorMap::count

Author:
  Vanya BELYAEV Ivan.BElyaev@itep.ru

Date:
  2010-02-20

      Check if the certainkey is in the map

      >>> m     = ...        ## the map
      >>> if 'a' in m : ...  ##  chekc the presence of the key in the map

Definition at line 307 of file Pythonizations.py.

    00307                                         :
    00308     """
    00309     Check if the certainkey is in the map
    00310
    00311     >>> m     = ...        ## the map
    00312     >>> if 'a' in m : ...  ##  chekc the presence of the key in the map
    00313
    00314     """
    00315     _num = self.count ( key )
    00316     return False if 0 == _num else True
    00317
    00318 # ============================================
    ## Get the value for certain key,

def GaudiPython::Pythonizations::__mapbase_delitem__ | ( |  | self,
|  |  | key |
| ) |  |  |

"Del-item" for MapBase-based maps:

        >>> m        = ...   ## the map
        >>> del m [ key]     ## del th eitem

See also:
  Gaudi::Utils::MapBase

  GaudiUtils::Map

  GaudiUtils::HashMap

  GaudiUtils::VectorMap

  GaudiUtils::Map::erase

  GaudiUtils::HashMap::erase

  GaudiUtils::VectorMap::erase

Author:
  Vanya BELYAEV Ivan.BElyaev@itep.ru

Date:
  2010-02-20

      'Del-item' for MapBase-based maps:

      >>> m      = ...        ## the map
      >>> del m[key]

Definition at line 430 of file Pythonizations.py.

    00430                                        :
    00431     """
    00432     'Del-item' for MapBase-based maps:
    00433
    00434     >>> m      = ...        ## the map
    00435     >>> del m[key]
    00436
    00437     """
    00438     _erased = True if key in self else False
    00439     self.erase ( key )
    00440     return _erased
    00441
    00442 gbl.Gaudi.Utils.MapBase . __len__       = lambda s   : s.size()
    00443 gbl.Gaudi.Utils.MapBase . __iter__      = __mapbase_iter__
    00444 gbl.Gaudi.Utils.MapBase .   keys        = __mapbase_keys__
    00445 gbl.Gaudi.Utils.MapBase . __iteritems__ = __mapbase_iteritems__
    00446 gbl.Gaudi.Utils.MapBase .   iteritems   = __mapbase_iteritems__
    00447 gbl.Gaudi.Utils.MapBase .   items       = __mapbase_items__
    00448 gbl.Gaudi.Utils.MapBase .   values      = __mapbase_values__
    00449 gbl.Gaudi.Utils.MapBase . __contains__  = __mapbase_contains__
    00450 gbl.Gaudi.Utils.MapBase .   has_key     = __mapbase_contains__
    00451 gbl.Gaudi.Utils.MapBase .   get         = __mapbase_get__
    00452 gbl.Gaudi.Utils.MapBase . __str__       = __mapbase_str__
    00453 gbl.Gaudi.Utils.MapBase . __repr__      = __mapbase_str__
    00454 gbl.Gaudi.Utils.MapBase . __setitem__   = __mapbase_setitem__
    00455 gbl.Gaudi.Utils.MapBase . __delitem__   = __mapbase_delitem__
    00456 gbl.Gaudi.Utils.MapBase . __getitem__   = lambda s,key : s.at ( key )
    gbl.Gaudi.Utils.MapBase . __getitem__   = lambda s,key : s.at ( key )

def GaudiPython::Pythonizations::__mapbase_get__ | ( |  | self,
|  |  | key,
|  |  | value = `None` |
| ) |  |  |

Get the value for certain key, return predefined value otherwise.

        >>> m      = ...          ## the map
        >>> v = m.get( key , 15 ) ## return the value[key] for existing key, else 15

See also:
  Gaudi::Utils::MapBase

  GaudiUtils::Map

  GaudiUtils::HashMap

  GaudiUtils::VectorMap

  GaudiUtils::Map::count

  GaudiUtils::HashMap::count @ see GaudiUtils::VectorMap::count

Author:
  Vanya BELYAEV Ivan.BElyaev@itep.ru

Date:
  2010-02-20

      Get the value for the certain key, or 'value' otherwise

      >>> m     = ...        ## the map
      >>> v = m.get ( key , 15 )

Definition at line 337 of file Pythonizations.py.

    00337                                                   :
    00338     """
    00339     Get the value for the certain key, or 'value' otherwise
    00340
    00341     >>> m     = ...        ## the map
    00342     >>> v = m.get ( key , 15 )
    00343
    00344     """
    00345     if key in self : return self.at( key )
    00346     return value
    00347
    00348 # ============================================
    ## Representation of MapBase-based maps

def GaudiPython::Pythonizations::__mapbase_items__ | ( |  | self | ) |

Get the list of items for the map.

        >>> m     = ...        ## the map
        >>> items = m.items()   ## get the list of items

See also:
  Gaudi::Utils::MapBase

  GaudiUtils::Map

  GaudiUtils::HashMap

  GaudiUtils::VectorMap

  GaudiUtils::Map::key_at

  GaudiUtils::HashMap::key_at @ see GaudiUtils::VectorMap::key_at

Author:
  Vanya BELYAEV Ivan.BElyaev@itep.ru

Date:
  2010-02-20

      Get the list of items

      >>> m     = ...        ## the map
      >>> items = m.keys()   ## get the list of items

Definition at line 240 of file Pythonizations.py.

    00240                                :
    00241     """
    00242     Get the list of items
    00243
    00244     >>> m     = ...        ## the map
    00245     >>> items = m.keys()   ## get the list of items
    00246
    00247     """
    00248     _size  = len ( self )
    00249     _items = []
    00250     for i in range ( 0 , _size )  :
    00251         _key   = self.key_at   ( i     )
    00252         _value = self.at       ( _key  )
    00253         _items.append ( ( _key , _value ) )
    00254     return _items
    00255
    00256 # ============================================
    ## Get the list of values for the map

def GaudiPython::Pythonizations::__mapbase_iter__ | ( |  | self | ) |

decorate some map-like objects ============================================================================= The iterator for MapBase class

        >>> m = ...  ## the map
        >>> for key in m : print key , m[key]

See also:
  Gaudi::Utils::MapBase

  GaudiUtils::Map

  GaudiUtils::HashMap

  GaudiUtils::VectorMap

  GaudiUtils::Map::key_at

  GaudiUtils::HashMap::key_at

  GaudiUtils::VectorMap::key_at

Author:
  Vanya BELYAEV Ivan.Belyaev@itep.ru

Date:
  2010-02-20

      The iterator for MapBase-based containers

      >>> m = ...  ## the map
      >>> for key in m : print key , m[key]

Definition at line 141 of file Pythonizations.py.

    00141                               :
    00142     """
    00143     The iterator for MapBase-based containers
    00144
    00145     >>> m = ...  ## the map
    00146     >>> for key in m : print key , m[key]
    00147
    00148     """
    00149     _size  = len ( self )
    00150     _index = 0
    00151     while _index < _size :
    00152         yield self.key_at ( _index )
    00153         _index +=1
    00154
    00155 # =============================================================================
    ## The iterator for MapBase class

def GaudiPython::Pythonizations::__mapbase_iteritems__ | ( |  | self | ) |

The iterator for MapBase class.

        >>> m = ...  ## the map
        >>> for key,value in m.iteritems() : print key , value

See also:
  Gaudi::Utils::MapBase

  GaudiUtils::Map

  GaudiUtils::HashMap

  GaudiUtils::VectorMap

  GaudiUtils::Map::key_at

  GaudiUtils::HashMap::key_at

  GaudiUtils::VectorMap::key_at

  GaudiUtils::Map::value_at

  GaudiUtils::HashMap::value_at

  GaudiUtils::VectorMap::value_at

Author:
  Vanya BELYAEV Ivan.Belyaev@itep.ru

Date:
  2010-02-20

      The iterator for MapBase-based containers

      >>> m = ...  ## the map
      >>> for key,value in m.iteritems() : print key, value

Definition at line 176 of file Pythonizations.py.

    00176                                    :
    00177     """
    00178     The iterator for MapBase-based containers
    00179
    00180     >>> m = ...  ## the map
    00181     >>> for key,value in m.iteritems() : print key, value
    00182
    00183     """
    00184     _size  = len ( self )
    00185     _index = 0
    00186     while _index < _size :
    00187         _key = self.key_at  ( _index )
    00188         yield ( _key , self.at ( _key ) )
    00189         _index +=1
    00190
    00191 # ============================================
    ## Get the list of keys for the map

def GaudiPython::Pythonizations::__mapbase_keys__ | ( |  | self | ) |

Get the list of keys for the map.

        >>> m    = ...        ## the map
        >>> keys = m.keys()   ## get the list of keys

See also:
  Gaudi::Utils::MapBase

  GaudiUtils::Map

  GaudiUtils::HashMap

  GaudiUtils::VectorMap

  GaudiUtils::Map::key_at

  GaudiUtils::HashMap::key_at @ see GaudiUtils::VectorMap::key_at

Author:
  Vanya BELYAEV Ivan.BElyaev@itep.ru

Date:
  2010-02-20

      Get the list of keys

      >>> m = ...           ## the map
      >>> keys = m.keys()   ## get the list of keys

Definition at line 209 of file Pythonizations.py.

    00209                               :
    00210     """
    00211     Get the list of keys
    00212
    00213     >>> m = ...           ## the map
    00214     >>> keys = m.keys()   ## get the list of keys
    00215
    00216     """
    00217     _size  = len ( self )
    00218     _keys  = []
    00219     for i in range ( 0 , _size ) : _keys.append ( self.key_at ( i ) )
    00220     return _keys
    00221
    00222 # ============================================
    ## Get the list of items for the map

def GaudiPython::Pythonizations::__mapbase_setitem__ | ( |  | self,
|  |  | key,
|  |  | value |
| ) |  |  |

"Setitem" for MapBase-based maps:

        >>> m        = ...        ## the map
        >>> m [ key] = value    ## set the item

See also:
  Gaudi::Utils::MapBase

  GaudiUtils::Map

  GaudiUtils::HashMap

  GaudiUtils::VectorMap

  GaudiUtils::Map::update

  GaudiUtils::HashMap::update

  GaudiUtils::VectorMap::update

Author:
  Vanya BELYAEV Ivan.BElyaev@itep.ru

Date:
  2010-02-20

      'Set-item' for MapBase-based maps:

      >>> m      = ...        ## the map
      >>> m[key] = value     ## set the item

Definition at line 399 of file Pythonizations.py.

    00399                                                :
    00400     """
    00401     'Set-item' for MapBase-based maps:
    00402
    00403     >>> m      = ...        ## the map
    00404     >>> m[key] = value     ## set the item
    00405
    00406     """
    00407     _replaced = True if key in self else False
    00408     self.update ( key , value )
    00409     return _replaced
    00410
    00411 # ============================================
    ## "Del-item" for MapBase-based maps:

def GaudiPython::Pythonizations::__mapbase_str__ | ( |  | self | ) |

Representation of MapBase-based maps.

        >>> m      = ...        ## the map
        >>> print m

See also:
  Gaudi::Utils::MapBase

  GaudiUtils::Map

  GaudiUtils::HashMap

  GaudiUtils::VectorMap

Author:
  Vanya BELYAEV Ivan.BElyaev@itep.ru

Date:
  2010-02-20

      Representation of MapBase-based maps:

      >>> m     = ...        ## the map
      >>> print map

Definition at line 363 of file Pythonizations.py.

    00363                               :
    00364     """
    00365     Representation of MapBase-based maps:
    00366
    00367     >>> m     = ...        ## the map
    00368     >>> print map
    00369
    00370     """
    00371     _result  = ' { '
    00372     _size  = len ( self )
    00373     for i in range ( 0 , _size ) :
    00374         _key = self.key_at   ( i    )
    00375         _val = self.at       ( _key )
    00376         if 0 != i : _result += ' , '
    00377         _result += " %s : %s " % ( str ( _key ) , str ( _val ) )
    00378     _result += ' } '
    00379     return _result
    00380
    00381 # ============================================
    ## "Setitem" for MapBase-based maps:

def GaudiPython::Pythonizations::__mapbase_values__ | ( |  | self | ) |

Get the list of values for the map.

        >>> m      = ...           ## the map
        >>> values = m.values ()   ## get the list of values

See also:
  Gaudi::Utils::MapBase

  GaudiUtils::Map

  GaudiUtils::HashMap

  GaudiUtils::VectorMap

  GaudiUtils::Map::value_at

  GaudiUtils::HashMap::value_at @ see GaudiUtils::VectorMap::value_at

Author:
  Vanya BELYAEV Ivan.Belyaev@itep.ru

Date:
  2010-02-20

      Get the list of values

      >>> m      = ...          ## the map
      >>> values = m.values()   ## get the list of values

Definition at line 274 of file Pythonizations.py.

    00274                                 :
    00275     """
    00276     Get the list of values
    00277
    00278     >>> m      = ...          ## the map
    00279     >>> values = m.values()   ## get the list of values
    00280
    00281     """
    00282     _size   = len ( self )
    00283     _values = []
    00284     for i in range ( 0 , _size ) :
    00285         _value = self.value_at ( i )
    00286         _values.append ( _value )
    00287     return _values
    00288
    00289 # ============================================
    ## Check if the certain key is in the map

def GaudiPython::Pythonizations::_container__getitem__ | ( |  | self,
|  |  | k |
| ) |  |  | `[private]`

Definition at line 52 of file Pythonizations.py.

    00052                                    :
    00053     return self.containedObject(k)
    def _container__len__(self) :

def GaudiPython::Pythonizations::_container__iter__ | ( |  | self | ) | `[private]`

Definition at line 56 of file Pythonizations.py.

    00056                              :
    00057     if hasattr(self,'containedObjects') : sequential = self.containedObjects()
    00058     else                                : sequential = self
    00059     count = 0
    00060     limit = self.__len__()
    00061     while count < limit :
    00062         yield sequential.__getitem__(count)
    00063         count += 1
    00064
    def _draw_aida_ ( self , *args ) :

def GaudiPython::Pythonizations::_container__len__ | ( |  | self | ) | `[private]`

Definition at line 54 of file Pythonizations.py.

    00054                             :
    00055     return self.numberOfObjects()
    def _container__iter__(self) :

def GaudiPython::Pythonizations::_contentsHisto1D | ( |  | h | ) | `[private]`

Definition at line 28 of file Pythonizations.py.

    00028                         :
    00029     x = h.axis()
    00030     return  map(h.binEntries, range(x.bins()))
    def _printHisto2D(h) :

def GaudiPython::Pythonizations::_draw_aida_ | ( |  | self,
|  |  | args |
| ) |  |  | `[private]`

    Draw AIDA histogram (through access to internal ROOT histogram

    >>> aida = ...    # get the historgam
    >>> aida.Draw()

Definition at line 65 of file Pythonizations.py.

    00065                                  :
    00066     """
    00067     Draw AIDA histogram (through access to internal ROOT histogram
    00068
    00069     >>> aida = ...    # get the historgam
    00070     >>> aida.Draw()
    00071
    00072     """
    00073     _fun = PyCintex.gbl.Gaudi.Utils.Aida2ROOT.aida2root
    00074     _root = _fun ( self )
    00075     return _root.Draw( *args )
    00076
    00077 gbl.AIDA.IHistogram1D.__repr__ = _printHisto1D
    00078 gbl.AIDA.IHistogram1D.contents = _contentsHisto1D
    00079 gbl.AIDA.IHistogram2D.__repr__ = _printHisto2D
    for h in (  gbl.AIDA.IHistogram   ,

def GaudiPython::Pythonizations::_loadDict | ( |  | name | ) | `[private]`

Definition at line 18 of file Pythonizations.py.

    00018                    :
    00019     import sys
    00020     if sys.platform != 'win32' and name[:3] != 'lib' : name = 'lib'+name
    00021     return _loadDict_save(name)
    00022 PyCintex.loadDict = _loadDict
    00023
    00024 #--- Adding extra functionality to C++ raw classes------------------------------------
    def _printHisto1D(h) :

def GaudiPython::Pythonizations::_printBitReference | ( |  | b | ) | `[private]`

Definition at line 38 of file Pythonizations.py.

    00038                           :
    00039     return str(1==b.bool())
    def _printFillStream(o) :

def GaudiPython::Pythonizations::_printFillStream | ( |  | o | ) | `[private]`

Definition at line 40 of file Pythonizations.py.

    00040                         :
    00041     if  o :
    00042         s = gbl.stringstream()
    00043         o.fillStream(s)
    00044         out = s.str()
    00045         if out == '' :
    00046             out = o.__class__.__name__ + ' object'
    00047             if hasattr( o, 'hasKey') and o.hasKey() :
    00048                 out += ' key = '+ str(o.key())
    00049     else :
    00050         out = o.__class__.__name__ + ' NULL object'
    00051     return out
    def _container__getitem__(self, k) :

def GaudiPython::Pythonizations::_printHisto1D | ( |  | h | ) | `[private]`

Definition at line 25 of file Pythonizations.py.

    00025                      :
    00026     x = h.axis()
    00027     return  'Histogram 1D "%s" %d bins [%f,%f]' % (h.title(), x.bins(), x.lowerEdge(), x.upperEdge())
    def _contentsHisto1D(h) :

def GaudiPython::Pythonizations::_printHisto2D | ( |  | h | ) | `[private]`

Definition at line 31 of file Pythonizations.py.

    00031                      :
    00032     x,y = h.xAxis(),h.yAxis()
    00033     return  'Histogram 2D "%s" %d xbins [%f,%f], %d ybins [%f,%f]' % \
    00034     (h.title(), x.bins(), x.lowerEdge(), x.upperEdge(), y.bins(), y.lowerEdge(), y.upperEdge() )
    def _printStatusCode(s) :

def GaudiPython::Pythonizations::_printStatusCode | ( |  | s | ) | `[private]`

Definition at line 35 of file Pythonizations.py.

    00035                         :
    00036     if s.isSuccess() : return 'SUCCESS'
    00037     else             : return 'FAILURE'
    def _printBitReference(b) :

## Variable Documentation

list GaudiPython::Pythonizations::__all__ = [ ]

Definition at line 8 of file Pythonizations.py.

GaudiPython::Pythonizations::_eq = gbl.Gaudi.StringKey.__cpp_eq__

Definition at line 107 of file Pythonizations.py.

GaudiPython::Pythonizations::_loadDict_save = PyCintex.loadDict

Definition at line 17 of file Pythonizations.py.

GaudiPython::Pythonizations::_ne = gbl.Gaudi.StringKey.__cpp_ne__

Definition at line 112 of file Pythonizations.py.

GaudiPython::Pythonizations::gbl = PyCintex.gbl

Definition at line 11 of file Pythonizations.py.