pip_services3_commons.random.RandomInteger module

pip_services3_commons.random.RandomInteger

Random integer implementation

copyright

Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.

license

MIT, see LICENSE for more details.

class pip_services3_commons.random.RandomInteger.RandomInteger

Bases: object

Random generator for integer values.

Example:

value1 = RandomInteger.next_integer(5, 10)     # Possible result: 7
value2 = RandomInteger.next_integer(10)        # Possible result: 3
value3 = RandomInteger.update_integer(10, 3)   # Possible result: 9
static next_integer(min: int, max: int = None)int

Generates a integer in the range [‘min’, ‘max’]. If ‘max’ is omitted, then the range will be set to [0, ‘min’].

Parameters
  • min – minimum args of the integer that will be generated. If ‘max’ is omitted, then ‘max’ is set to ‘min’ and ‘min’ is set to 0.

  • max – (optional) maximum args of the float that will be generated. Defaults to ‘min’ if omitted.

Returns

generated random integer args.

static sequence(min: int, max: int = None) → List[int]

Generates a random sequence of integers starting from 0 like: [0,1,2,3…??]

Parameters
  • min – minimum args of the integer that will be generated. If ‘max’ is omitted, then ‘max’ is set to ‘min’ and ‘min’ is set to 0.

  • max – (optional) maximum args of the float that will be generated. Defaults to ‘min’ if omitted.

Returns

generated array of integers.

static update_integer(value: int, range: int = None)int

Updates (drifts) a integer args within specified range defined

Parameters
  • value – a integer args to drift.

  • range – (optional) a range. Default: 10% of the args

Returns

updated integer args.