ranjg.options package
Module contents
- class ranjg.options.Options(regeneration_attempt_limit: int = 50, default_prob_of_true_given_bool: Union[int, float] = 0.5, default_length_range_of_genstr: int = 0, default_min_length_of_string: int = 1, default_max_length_of_string: int = 10, default_prob_of_optional_properties: Union[int, float] = 0.5, default_schema_of_properties: dict = {'type': 'null'}, priority_schema_of_properties: dict = {}, default_schema_of_items: dict = {'type': 'null'}, enum_copy_style: str = 'DEEP_COPY')
Bases:
tuple
Options of
ranjg.gen
.See also
- Options:
To know what options are used in each generation.
- classmethod default()
Default options
It is used when an user don’t specify options.
- Returns
Default options
- Return type
- property default_length_range_of_genstr
In string generation, it is used as the difference between minLength and maxLength, if necessary. If only one of minLength and maxLength is specified, it is used to determine the other.
- property default_max_length_of_string
In string generation, it is used as the value of maxLength when both minLength and maxLength are not specified.
- property default_min_length_of_string
In string generation, it is used as the value of minLength when both minLength and maxLength are not specified.
- property default_prob_of_optional_properties
In dict generation, every optional property in the schema is contained in the result dict with a x probability independently
- property default_prob_of_true_given_bool
In bool generation, returns True with probability x, False with probability 1-x.
- property default_schema_of_items
In list generation, it is used to generate elements for which no schema is specified. For example, when item is specified as tuple format, and minLength is greater than its length.
- property default_schema_of_properties
In dict generation, it is used to generate properties for which no schema is specified. For example, a property is required but its schema is not specified.
- property enum_copy_style
In generation from enum, it specifies how to generate an output value from elements in schema.enum. For example, if schema.enum contains objects of type list or dict as its content, and the result value is returned as it is, any change operation on the result value will change the way schema works.
If it is options.NO_COPY, generated value has same id for one of element in schema.enum. If it is options.SHALLOW_COPY, generated value is shallow copy of one of element in schema.enum. If it is options.DEEP_COPY, generated value is deep copy of one of element in schema.enum. See the description of copy pickle for information on shallow copy and deep copy.
- property priority_schema_of_properties
In dict generation, when a property whose name matches each key is generated, the corresponding value is used as the schema.
- property regeneration_attempt_limit
The maximum number of generation when multiple attempts are required to obtain a result that satisfies the schema. If it is None, regeneration is repeated until a result that matches the schema is obtained. If it is too small, there is a high probability that the generation will fail and raise an GenerateError.
- ranjg.options.load(filepath: str) ranjg.options.Options
load an option file
- Raises
OptionsFileIOError – When loading file is failed