| The Gaudi Framework v32r1 (f65d50dc)

Public Member Functions | Public Attributes | Private Member Functions | List of all members
GaudiHive.precedence.RndBiasedBooleanValue Class Reference
Inheritance diagram for GaudiHive.precedence.RndBiasedBooleanValue:
[legend]
Collaboration diagram for GaudiHive.precedence.RndBiasedBooleanValue:
[legend]

## Public Member Functions
def | __init__ (self, pattern, seed=None)
def | get (self)
def | get_pattern (self)

## Public Attributes
| pattern
| generator

## Private Member Functions
def | _create_generator (self, pattern)

## Detailed Description

    Provides randomly ordered set of boolean values with requested proportion of True and False.

Definition at line 88 of file precedence.py.

## Constructor & Destructor Documentation

## ◆ __init__()

def GaudiHive.precedence.RndBiasedBooleanValue.__init__ | ( |  | self,
|  |  | pattern,
|  |  | seed = `None`
| ) |  |

    Keyword arguments:
    pattern -- either a dictionary describing proportion of True and False (e.g., {True:5,False:15}), or
       a list/tuple containing a pattern to be used as-is (e.g., [False,True,True,False])
    seed -- an int, long or other hashable object to initialize random number generator (passed to random.shuffle as-is)

Definition at line 91 of file precedence.py.

91 def __init__(self, pattern, seed=None):
92 """
93 Keyword arguments:
94 pattern -- either a dictionary describing proportion of True and False (e.g., {True:5,False:15}), or
95 a list/tuple containing a pattern to be used as-is (e.g., [False,True,True,False])
96 seed -- an int, long or other hashable object to initialize random number generator (passed to random.shuffle as-is)
97 """
98
99 if isinstance(pattern, dict):
100 proportion = pattern
101
102 length = proportion[True] + proportion[False]
103 if length <= 0:
104 raise "ERROR: Wrong set length requested: %i " % length
105
106 self.pattern = [False for i in range(proportion[False])
107 ] + [True for i in range(proportion[True])]
108
109 if seed is not None:
110 random.seed(seed)
111
112 random.shuffle(self.pattern)
113
114 elif isinstance(pattern, (list, tuple)):
115 self.pattern = pattern
116 else:
117 raise "ERROR: unknown pattern type"
118
119 self.generator = self._create_generator(self.pattern)
120
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:71

## Member Function Documentation

## ◆ _create_generator()

def GaudiHive.precedence.RndBiasedBooleanValue._create_generator | ( |  | self,
|  |  | pattern
| ) |  |
| private

Definition at line 121 of file precedence.py.

121 def _create_generator(self, pattern):
122
123 for b in pattern:
124 yield b
125

## ◆ get()

def GaudiHive.precedence.RndBiasedBooleanValue.get | ( |  | self | ) |

Definition at line 126 of file precedence.py.

126 def get(self):
127
128 return next(self.generator)
129
Gaudi::Functional::details::get
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
Definition: FunctionalDetails.h:332

## ◆ get_pattern()

def GaudiHive.precedence.RndBiasedBooleanValue.get_pattern | ( |  | self | ) |

Definition at line 130 of file precedence.py.

130 def get_pattern(self):
131
132 return self.pattern
133
134

## Member Data Documentation

## ◆ generator

GaudiHive.precedence.RndBiasedBooleanValue.generator

Definition at line 119 of file precedence.py.

## ◆ pattern

GaudiHive.precedence.RndBiasedBooleanValue.pattern

Definition at line 106 of file precedence.py.

The documentation for this class was generated from the following file:

- GaudiHive/python/GaudiHive/precedence.py