Provides randomly ordered set of boolean values with requested proportion of True and False.
Definition at line 121 of file precedence.py.
◆ __init__()
def 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 124 of file precedence.py.
124 def __init__(self, pattern, seed=None):
127 pattern -- either a dictionary describing proportion of True and False (e.g., {True:5,False:15}), or
128 a list/tuple containing a pattern to be used as-is (e.g., [False,True,True,False])
129 seed -- an int, long or other hashable object to initialize random number generator (passed to random.shuffle as-is)
132 if isinstance(pattern, dict):
135 length = proportion[
True] + proportion[
False]
137 raise "ERROR: Wrong set length requested: %i " % length
139 self.pattern = [
False for i
in range(proportion[
False])] + [
140 True for i
in range(proportion[
True])
146 random.shuffle(self.pattern)
148 elif isinstance(pattern, (list, tuple)):
149 self.pattern = pattern
151 raise "ERROR: unknown pattern type"
153 self.generator = self._create_generator(self.pattern)
◆ _create_generator()
def precedence.RndBiasedBooleanValue._create_generator |
( |
|
self, |
|
|
|
pattern |
|
) |
| |
|
private |
Definition at line 155 of file precedence.py.
155 def _create_generator(self, pattern):
◆ get()
def precedence.RndBiasedBooleanValue.get |
( |
|
self | ) |
|
◆ get_pattern()
def precedence.RndBiasedBooleanValue.get_pattern |
( |
|
self | ) |
|
◆ generator
precedence.RndBiasedBooleanValue.generator |
◆ pattern
precedence.RndBiasedBooleanValue.pattern |
The documentation for this class was generated from the following file: