ATLAS Offline Software
Classes | Functions | Variables
python.sugar.iovtype Namespace Reference

Classes

class  IOVType
 

Functions

def restore_iov_type (name, fields, bases, content, empty, _memoized={})
 
def make_iov_type (name, variables, bases=(IOVType,), _memoized={})
 
def define_iov_type (func)
 
def RANGEIOV_VAL ()
 

Variables

 __name__
 
 _has_channel
 
 _has_insertion_time
 
 _emptycls
 

Function Documentation

◆ define_iov_type()

def python.sugar.iovtype.define_iov_type (   func)
A decorator which creates a lightweight iov type.

Definition at line 142 of file iovtype.py.

142 def define_iov_type(func):
143  """
144  A decorator which creates a lightweight iov type.
145  """
146  co_code = func.__code__ if hasattr(func, "__code__") else func.func_code
147  name = func.__name__
148  variables = co_code.co_varnames
149 
150  return make_iov_type(name, variables)
151 
152 @define_iov_type

◆ make_iov_type()

def python.sugar.iovtype.make_iov_type (   name,
  variables,
  bases = (IOVType,),
  _memoized = {} 
)
Create an IOV type and its empty type

Definition at line 114 of file iovtype.py.

114 def make_iov_type(name, variables, bases=(IOVType,), _memoized={}):
115  """
116  Create an IOV type and its empty type
117  """
118  args = name, tuple(variables), bases
119  if args in _memoized:
120  return _memoized[args]
121 
122  has_insertion_time = "insertion_time" in variables
123  has_channel = "channel" in variables
124  all_fields = " ".join(["since", "until"] + list(variables))
125 
126  class cls(namedtuple(name, all_fields)):
127  "Named tuple to store IoV types"
128 
129  cls.__name__ = name
130  cls.__bases__ += bases
131  cls._has_channel = has_channel
132  cls._has_insertion_time = has_insertion_time
133 
134  cls._emptycls = type(name + "_EMPTY", (cls,), dict(
135  _is_empty=True,
136  __bool__ = lambda self: False,
137  ))
138 
139  _memoized[args] = cls
140  return cls
141 

◆ RANGEIOV_VAL()

def python.sugar.iovtype.RANGEIOV_VAL ( )

Definition at line 153 of file iovtype.py.

153 def RANGEIOV_VAL():
154  "Just store a since, until"

◆ restore_iov_type()

def python.sugar.iovtype.restore_iov_type (   name,
  fields,
  bases,
  content,
  empty,
  _memoized = {} 
)
This would be better as a class method, but it's not possible to pickle 
those, hence why this exists.
_memoized is used to store the type to avoid a function call to rebuild the
type un-necessarily

Definition at line 9 of file iovtype.py.

9 def restore_iov_type(name, fields, bases, content, empty, _memoized={}):
10  """
11  This would be better as a class method, but it's not possible to pickle
12  those, hence why this exists.
13  _memoized is used to store the type to avoid a function call to rebuild the
14  type un-necessarily
15  """
16  args = name, fields, bases, empty
17  if args not in _memoized:
18  # Don't take the last argument
19  iov_type = make_iov_type(*args[:-1])
20  _memoized[args] = iov_type._emptycls if empty else iov_type
21  return _memoized[args]._make(content)
22 

Variable Documentation

◆ __name__

python.sugar.iovtype.__name__
private

Definition at line 129 of file iovtype.py.

◆ _emptycls

python.sugar.iovtype._emptycls
private

Definition at line 134 of file iovtype.py.

◆ _has_channel

python.sugar.iovtype._has_channel
private

Definition at line 131 of file iovtype.py.

◆ _has_insertion_time

python.sugar.iovtype._has_insertion_time
private

Definition at line 132 of file iovtype.py.

python.sugar.iovtype.RANGEIOV_VAL
def RANGEIOV_VAL()
Definition: iovtype.py:153
CaloClusterListBadChannel.cls
cls
Definition: CaloClusterListBadChannel.py:8
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.sugar.iovtype.define_iov_type
def define_iov_type(func)
Definition: iovtype.py:142
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
python.sugar.iovtype.restore_iov_type
def restore_iov_type(name, fields, bases, content, empty, _memoized={})
Definition: iovtype.py:9
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.sugar.iovtype.make_iov_type
def make_iov_type(name, variables, bases=(IOVType,), _memoized={})
Definition: iovtype.py:114