| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

Functions | Variables

# 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.

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

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.

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

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

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.

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

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.

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

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.

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

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.

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

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.

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

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.

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

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.

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

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

Definition at line 52 of file Pythonizations.py.

    00053                                    :
        return self.containedObject(k)

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

Definition at line 56 of file Pythonizations.py.

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

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

Definition at line 54 of file Pythonizations.py.

    00055                             :
        return self.numberOfObjects()

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

Definition at line 28 of file Pythonizations.py.

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

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.

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

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

Definition at line 18 of file Pythonizations.py.

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

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

Definition at line 38 of file Pythonizations.py.

    00039                           :
        return str(1==b.bool())

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

Definition at line 40 of file Pythonizations.py.

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

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

Definition at line 25 of file Pythonizations.py.

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

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

Definition at line 31 of file Pythonizations.py.

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

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

Definition at line 35 of file Pythonizations.py.

    00036                         :
    00037     if s.isSuccess() : return 'SUCCESS'
        else             : return 'FAILURE'

## 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.

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines