This is the utility module, with some utility functions of general use, like list item swap, random utilities and etc.
Swaps elements A and B in a 2D list (matrix).
>>> l = [ [1,2,3], [4,5,6] ]
>>> Util.list2DSwapElement(l, (0,1), (1,1) )
>>> l
[[1, 5, 3], [4, 2, 6]]
Parameters: |
|
---|---|
Return type: | None |
Swaps elements A and B in a list.
>>> l = [1, 2, 3]
>>> Util.listSwapElement(l, 1, 2)
>>> l
[1, 3, 2]
Parameters: |
|
---|---|
Return type: | None |
Raise an exception and logs the message.
>>> Util.raiseException('The value is not an integer', ValueError)
Parameters: |
|
---|---|
Return type: | None |
Returns True with the p probability. If the p is 1.0, the function will always return True, or if is 0.0, the function will return always False.
>>> Util.randomFlipCoin(1.0)
True
Parameter: | p – probability, between 0.0 and 1.0 |
---|---|
Return type: | True or False |