randog package

Subpackages and submodules

Module contents

class randog.DictItemExample(example: Any, prop_exists: float = 1.0)

Bases: object

example: Any
prop_exists: float = 1.0
class randog.Example(*objs)

Bases: Sequence

randog.generate_to_csv(factory: Factory, line_num: int, fp: TextIO, csv_columns: Sequence[str | Callable[[Mapping], Any]] | None, *, regenerate: float = 0.0, discard: float = 0.0, raise_on_factory_stopped: bool = False, linesep: str | None = None)

Generate values randomly and output as CSV

Parameters:
  • factory (Factory) – the factory to generate values

  • line_num (int) – the number of the iterator. However, if the argument raise_on_factory_stopped is not True, fewer iterations than the specified size will be executed if the factory is stopped. Also, if the argument discard is specified, the size may be less.

  • fp (TextIO) – CSV output destination

  • csv_columns (list[str, Callable[[Mapping], Any]] | None) – the definitions of each column value. If it is defined with str, the value is taken from the generated object using that as the key. If it is defined with a function, the function is used with the generated object as an argument, and the return value is used.

  • regenerate (float, default=0.0) – the probability that the original factory generation value is not returned as is, but is regenerated. It affects cases where the original factory returns a value that is not completely random.

  • discard (float, default=0.0) – the probability that the original factory generation value is not returned as is, but is discarded. If discarded, the number of times the value is generated is less than size.

  • raise_on_factory_stopped (bool, default=False) – If True, raises FactoryStopException in case the factory cannot generate value due to StopIteration. If False, simply raises StopIteration.

  • linesep (str, optional) – If specified, CSV rows are separated by this string.