avocado_varianter_cit package

Submodules

avocado_varianter_cit.Cit module

class avocado_varianter_cit.Cit.Cit(input_data, t_value, constraints)

Bases: object

Creation of CombinationMatrix from user input

Parameters
  • input_data – parameters from user

  • t_value – size of one combination

  • constraints – constraints of combinations

change_one_column(matrix)

Randomly choose one column of the matrix. In each cell of this column changes value. The row with the best coverage is the solution.

Parameters

matrix – matrix to be changed

Returns

solution, index of solution inside matrix and parameters which has been changed

change_one_value(matrix, row_index=None, column_index=None)

Change one cell inside the matrix

Parameters
  • matrix – matrix to be changed

  • row_index – row inside matrix. If it’s None it is chosen randomly

  • column_index – column inside matrix. If it’s None it is chosen randomly

Returns

solution, index of solution inside matrix and parameters which has been changed

compute()

Searching for the best solution. It creates one solution and from that, it tries to create smaller solution. This searching process is limited by ITERATIONS_SIZE. When ITERATIONS_SIZE is 0 the last found solution is the best solution.

Returns

The best solution

compute_hamming_distance(row)
Returns

hamming distance of row from final matrix

compute_row()

Computation of one row which covers most of combinations

Returns

new solution row

compute_row_using_hamming_distance()
Returns

row with the biggest hamming distance from final matrix

cover_missing_combination(matrix)

Randomly finds one missing combination. This combination puts into each row of the matrix. The row with the best coverage is the solution

Parameters

matrix – matrix to be changed

Returns

solution, index of solution inside matrix and parameters which has been changed

create_random_row_with_constraints()

Create a new test-case random row, and the row meets the constraints.

Returns

new random row

Return type

list

final_matrix_init()

Creation of the first solution. This solution is the start of searching for the best solution

Returns

solution matrix (list(list))

find_better_solution(counter, matrix)

Changing the matrix to cover all combinations

Parameters
  • counter – maximum number of changes in the matrix

  • matrix – matrix to be changed

Returns

new matrix and is changes have been successful?

get_missing_combination_random()

Randomly finds one missing combination.

Returns

parameter of combination and values of combination

use_random_algorithm(matrix)

Applies one of these algorithms to the matrix. It chooses algorithm by random in proportion 1:1:8

Parameters

matrix – matrix to be changed

Returns

new row of matrix, index of row inside matrix and parameters which has been changed

avocado_varianter_cit.CombinationMatrix module

class avocado_varianter_cit.CombinationMatrix.CombinationMatrix(input_data, t_value)

Bases: object

CombinationMatrix object stores Rows of combinations into dictionary. And also stores which rows are not covered. Keys in dictionary are parameters of combinations and values are CombinationRow objects. CombinationMatrix object has information about how many combinations are uncovered and how many of them are covered more than ones.

Parameters
  • input_data – list of data from user

  • t_value – t number from user

cover_combination(row, parameters)

Cover combination of specific parameters by one row from possible solution

Parameters
  • row – one row from solution

  • parameters – parameters which has to be covered

Returns

number of still uncovered combinations

cover_solution_row(row)

Cover all combination by one row from possible solution

Parameters

row – one row from solution

Returns

number of still uncovered combinations

del_cell(parameters, combination)

Disable one combination. If combination is disabled it means that the combination does not match the constraints

Parameters
  • parameters – parameters whose combination is disabled

  • combination – combination to be disabled

get_row(key)
Parameters

key – identifier of row

Returns

CombinationRow

is_valid_combination(row, parameters)

Is the specific parameters from solution row match the constraints.

Parameters
  • row – one row from solution

  • parameters – parameters from row

is_valid_solution(row)

Is the solution row match the constraints.

Parameters

row – one row from solution

uncover()

Uncover all combinations

uncover_combination(row, parameters)

Uncover combination of specific parameters by one row from possible solution

Parameters
  • row – one row from solution

  • parameters – parameters which has to be covered

Returns

number of uncovered combinations

uncover_solution_row(row)

Uncover all combination by one row from possible solution

Parameters

row – one row from solution

Returns

number of uncovered combinations

avocado_varianter_cit.CombinationRow module

class avocado_varianter_cit.CombinationRow.CombinationRow(input_data, t_value, parameters)

Bases: object

Row object store all combinations between two parameters into dictionary. Keys in dictionary are values of combinations and values in dictionary are information about coverage. Row object has information how many combinations are uncovered and how many of them are covered more than ones.

Parameters
  • input_data – list of data from user

  • t_value – t number from user

  • parameters – the tuple of parameters whose combinations Row object represents

completely_uncover()

Uncover all combinations inside Row

cover_cell(key)

Cover one combination inside Row

Parameters

key – combination to be covered

Returns

number of new covered combinations and number of new covered combinations more than ones

del_cell(key)

Disable one combination. If combination is disabled it means that the combination does not match the constraints

Parameters

key – combination to be disabled

Returns

number of new covered combinations

get_all_uncovered_combinations()
Returns

list of all uncovered combination

is_valid(key)

Is the combination match the constraints.

Parameters

key – combination to valid

uncover_cell(key)

Uncover one combination inside Row

Parameters

key – combination to be uncovered

Returns

number of new covered combinations and number of new covered combinations more than ones

avocado_varianter_cit.Parser module

class avocado_varianter_cit.Parser.Parser

Bases: object

static parse(file_object)

Parsing of input file with parameters and constraints

Parameters

file_object – input file for parsing

Returns

array of parameters and set of constraints

avocado_varianter_cit.Solver module

class avocado_varianter_cit.Solver.Parameter(name, values)

Bases: object

Storage for constraints of one parameter.

This class stores the constraints which constrain the values of one parameter.

Parameters
  • name (int) – identification of parameter

  • size (int) – number of values

  • constraints (list) – list for storing constraints

Parameter initialization.

Parameters
  • name (int) – identification of parameter

  • values – values of parameter

Type

list

add_constraint(constraint, value, index)

Append new constraint to the parameter.

The constraint is placed under the parameter value which is affected by this constraint. And this value is also deleted from the constraint, because is defined by the index in the ‘self.constraints’ list.

Parameters
  • constraint (list) – will be appended to the parameter constraints

  • value (int) – parameter value which is is affected by new constraint

  • index (int) – index of that value inside the constraint

property is_full

Compute if constraints constrain every parameter value.

Return type

bool

class avocado_varianter_cit.Solver.Solver(data, constraints)

Bases: object

CON_NAME = 0
CON_VAL = 1
clean_hash_table(combination_matrix, t_value)
compute_constraints()
get_possible_values(row, parameter)

Compute all possible values for the given parameter.

These values are based on constraints and already picked values of other parameters.

Parameters
  • row (list) – row with picked values. -1 means an unpicked value.

  • parameter (int) – index of the parameter whose we want to know the values

Returns

all possible values for the given parameter

Return type

list

read_constraints()
simplify_constraints()

Module contents

avocado_varianter_cit.DEFAULT_ORDER_OF_COMBINATIONS = 2

The default order of combinations

class avocado_varianter_cit.VarianterCit

Bases: avocado.core.plugin_interfaces.Varianter

Processes the parameters file into variants

description = 'CIT Varianter'
static error_exit(config)
initialize(config)
name = 'cit'
to_str(summary, variants, **kwargs)

Return human readable representation

The summary/variants accepts verbosity where 0 means silent and maximum is up to the plugin.

Parameters
  • summary – How verbose summary to output (int)

  • variants – How verbose list of variants to output (int)

  • kwargs – Other free-form arguments

Return type

str

class avocado_varianter_cit.VarianterCitCLI

Bases: avocado.core.plugin_interfaces.CLI

CIT Varianter options

configure(parser)

Configures the command line parser with options specific to this plugin.

description = "CIT Varianter options for the 'run' subcommand"
name = 'cit'
run(config)

Execute any action the plugin intends.

Example of action may include activating a special features upon finding that the requested command line options were set by the user.

Note: this plugin class is not intended for adding new commands, for that please use CLICmd.