Beispiel #1
0
  def access(self, **kw):
    """
    Access numpy indexes informing pattern and observation index through keywords dict:
      - pidx|fidx;
      - oidx;
    respectively. 

    You can use the char ':' to expand the full dimension. This is the same as
    using slice(None).
    """
    if set(("pidx","fidx")) <= set(kw.keys()):
      raise KeyError('Cannot use both pidx and fidx keywords')
    pidx = kw.pop('pidx', slice(None))
    if pidx is None: pidx = kw.pop('fidx', None)
    oidx = kw.pop('oidx', slice(None))
    checkForUnusedVars(kw)
    if type(pidx) is str and pidx == ':': pidx = slice(None)
    if type(oidx) is str and oidx == ':': oidx = slice(None)
    if type(pidx) == tuple:
      pidx = slice(*pidx)
    if type(oidx) == tuple:
      oidx = slice(*oidx)
    if self.__useFortran:
      return pidx, oidx
    else:
      return oidx, pidx
 def __init__(self, transientAttrs = set(), toPublicAttrs = set(), **kw):
   "Initialize streamer and declare transient variables."
   Logger.__init__(self, kw)
   self.transientAttrs = set(transientAttrs) | {'_readVersion',}
   self.toPublicAttrs = set(toPublicAttrs)
   from RingerCore.util import checkForUnusedVars
   checkForUnusedVars( kw, self._logger.warning )
Beispiel #3
0
 def __init__(self, **kw):
   Logger.__init__(self, kw)
   self.__useFortran = kw.pop( 'useFortran', False )
   self.order          = 'F' if self.__useFortran else 'C'
   self.pdim           = 0   if self.__useFortran else 1
   self.odim           = 1   if self.__useFortran else 0
   self.fp_dtype       = np.dtype( kw.pop( 'fp_dtype',       np.float64 ) )
   self.int_dtype      = np.dtype( kw.pop( 'int_dtype',      np.int64   ) )
   self.scounter_dtype = np.dtype( kw.pop( 'scounter_dtype', np.uint8   ) )
   self.flag_dtype     = np.dtype( kw.pop( 'flag_dtype',     np.int8    ) )
   checkForUnusedVars(kw)
Beispiel #4
0
  def __init__(self, *args, **kw):
    """
      Set values using min:incr:max and matlabFlag as explained in class
      documentation.
    """
    from RingerCore.util import checkForUnusedVars
    Logger.__init__(self, kw)
    self._matlabFlag = kw.pop('matlabFlag', False )
    checkForUnusedVars( kw, self._logger.warning )
    del kw

    if len(args) > 3: 
      raise ValueError("Input more than 3 values, format should be [min=0:[incr=1:]]max")

    if len(args) == 0: 
      raise ValueError("No input. Format should be [min=0,[incr=1,]]max")

    if isinstance(args[0], LoopingBounds ):
      self._vec = args[0]._vec
      oldFlag = self._matlabFlag
      self._matlabFlag = args[0]._matlabFlag
      if oldFlag != self._matlabFlag:
        if self._matlabFlag:
          self.turnMatlabFlagOn()
        else:
          self.turnMatlabFlagOff()
      return
    elif isinstance(args[0], list ):
      self._vec = args[0]
    else:
      self._vec = list(args)

    if len(self._vec) == 1:
      self._vec.append( self._vec[0] + 1 )
      if not self._matlabFlag:
        self._vec[1] -= 1
      self._vec[0] = 1 if self._matlabFlag else 0
    elif len(self._vec) == 2:
      if self._matlabFlag: 
        self._vec[1] += 1
    else:
      tmp = self._vec[1]
      if self._matlabFlag:
        if tmp > 0:
          self._vec[1] = self._vec[2] + 1
        else:
          self._vec[1] = self._vec[2] - 1
      else:
        self._vec[1] = self._vec[2]
      self._vec[2] = tmp

    if len(self._vec) == 3 and self._vec[2] == 0:
      raise ValueError("Attempted to create looping bounds without increment.")
 def __init__(self, ignoreAttrs = set(), toProtectedAttrs = set(), ignoreRawChildren = False, **kw ):
   """
     -> ignoreAttrs: not consider this attributes on the dictionary values.
     -> toProtectedAttrs: change public attributes to protected or private
       attributes. That is, suppose the dictionary value is 'val' and the class
       value should be _val or __val, then add toProtectedAttrs = ['_val'] or
       '__val'.
     -> ignoreRawChildren: Do not attempt to conver raw children to higher level object.
   """
   Logger.__init__(self, kw)
   ignoreAttrs = list(set(ignoreAttrs) | RawDictCnv.baseAttrs)
   import re
   self.ignoreAttrs = [re.compile(ignoreAttr) for ignoreAttr in ignoreAttrs]
   self.toProtectedAttrs = set(toProtectedAttrs)
   self.ignoreRawChildren = ignoreRawChildren
   from RingerCore.util import checkForUnusedVars
   checkForUnusedVars( kw, self._logger.warning )
Beispiel #6
0
 def shape(self, **kw):
   """
   Return shape using total number of observations and patterns.
   Retuned shape will always be a matrix.
   """
   if set(("npat","nfeat")) <= set(kw.keys()):
     raise KeyError('Cannot use both pidx and fidx keywords')
   npat = kw.pop('npat', None)
   if npat is None: npat = kw.pop('nfeat', None)
   nobs = kw.pop('nobs', None)
   checkForUnusedVars(kw)
   if npat is None:
     npat = 1
   if nobs is None:
     nobs = 1
   if self.__useFortran:
     return (npat, nobs)
   else:
     return (nobs, npat)
  def __init__(self, tes, **kw):
    Logger.__init__( self, **kw )
    import logging
    self.baseDir        = kw.pop('baseDir','')
    self.bucketName     = kw.pop('bucketName','')
    self.pidName        = kw.pop('pidName','tight')
    self._level         = kw.pop('level',logging.INFO)
    self.appName        = kw.pop('appName','TrigAnalysisTool')
    checkForUnusedVars(kw)
    del kw

    self._logger.info('Start wrapper between python and c++ core.')
    
    self._trigAnalysisTool = ROOT.TrigAnalysisTool(self.appName,
                                                   self.bucketName,
                                                   self.baseDir,
                                                   self.pidName,
                                                   self._level)
    for te in tes:
      self._trigAnalysisTool.push_back( te() )

    self._logger.info('TrigAnalysisTool has been created.' )