Rules

class code_generation.rules.AppendProducer(producers, samples=[], exclude_samples=[], scopes='global', invert=False, update_output=True)[source]

ProducerRule is a base class for all rules that modify producers.

Parameters:
  • producers (Producer | ProducerGroup | List[Producer | ProducerGroup]) – A list of producers or producer groups to be modified.

  • samples (str | List[str]) – A list of samples, for which the rule should be applied. Only one of samples and exclude_samples can be defined.

  • exclude_samples (str | List[str]) – A list of samples, for which the rule should not be applied. Only one of samples and exclude_samples can be defined.

  • scopes (str | List[str]) – The scopes, in which the rule should be applied. Defaults to “global”.

  • invert (bool) – If set, the invert of the rule is applied. Defaults to False.

  • update_output (bool) – If set, the output quantities are updated. Defaults to True.

update_outputs(outputs_to_be_updated)[source]
Parameters:

outputs_to_be_updated (Dict[str, Set[Quantity]])

Return type:

None

update_producers(producers_to_be_updated, unpacked_producers)[source]
Parameters:
Return type:

None

class code_generation.rules.ProducerRule(producers, samples=[], exclude_samples=[], scopes='global', invert=False, update_output=True)[source]

ProducerRule is a base class for all rules that modify producers.

Parameters:
  • producers (Producer | ProducerGroup | List[Producer | ProducerGroup]) – A list of producers or producer groups to be modified.

  • samples (str | List[str]) – A list of samples, for which the rule should be applied. Only one of samples and exclude_samples can be defined.

  • exclude_samples (str | List[str]) – A list of samples, for which the rule should not be applied. Only one of samples and exclude_samples can be defined.

  • scopes (str | List[str]) – The scopes, in which the rule should be applied. Defaults to “global”.

  • invert (bool) – If set, the invert of the rule is applied. Defaults to False.

  • update_output (bool) – If set, the output quantities are updated. Defaults to True.

affected_producers()[source]
Return type:

List[Producer | ProducerGroup]

affected_scopes()[source]
Return type:

List[str]

apply(sample, producers_to_be_updated, unpacked_producers, outputs_to_be_updated)[source]
Parameters:
Return type:

None

is_applicable(sample)[source]
Parameters:

sample (str)

Return type:

bool

set_available_sampletypes(available_samples)[source]
Return type:

None

set_global_scope(global_scope)[source]
Parameters:

global_scope (str)

Return type:

None

set_scopes(scopes)[source]
Parameters:

scopes (List[str])

Return type:

None

update_outputs(outputs_to_be_updated)[source]
Parameters:

outputs_to_be_updated (Dict[str, Set[Quantity]])

Return type:

None

update_producers(producers_to_be_updated, unpacked_producers)[source]
Parameters:
Return type:

None

validate_sampletypes(sampletypes)[source]

Function to check, if a rule is applicable, or if one of the defined samples is not available.

Parameters:
  • available_samples (List[str]) – List of available samples.

  • sampletypes (List[str])

Returns:

None

Return type:

None

class code_generation.rules.RemoveProducer(producers, samples=[], exclude_samples=[], scopes='global', invert=False, update_output=True)[source]

ProducerRule is a base class for all rules that modify producers.

Parameters:
  • producers (Producer | ProducerGroup | List[Producer | ProducerGroup]) – A list of producers or producer groups to be modified.

  • samples (str | List[str]) – A list of samples, for which the rule should be applied. Only one of samples and exclude_samples can be defined.

  • exclude_samples (str | List[str]) – A list of samples, for which the rule should not be applied. Only one of samples and exclude_samples can be defined.

  • scopes (str | List[str]) – The scopes, in which the rule should be applied. Defaults to “global”.

  • invert (bool) – If set, the invert of the rule is applied. Defaults to False.

  • update_output (bool) – If set, the output quantities are updated. Defaults to True.

update_outputs(outputs_to_be_updated)[source]
Parameters:

outputs_to_be_updated (Dict[str, Set[Quantity]])

Return type:

None

update_producers(producers_to_be_updated, unpacked_producers)[source]
Parameters:
Return type:

None

class code_generation.rules.ReplaceProducer(producers, samples=[], exclude_samples=[], scopes='global', invert=False, update_output=True)[source]

ProducerRule is a base class for all rules that modify producers.

Parameters:
  • producers (Producer | ProducerGroup | List[Producer | ProducerGroup]) – A list of producers or producer groups to be modified.

  • samples (str | List[str]) – A list of samples, for which the rule should be applied. Only one of samples and exclude_samples can be defined.

  • exclude_samples (str | List[str]) – A list of samples, for which the rule should not be applied. Only one of samples and exclude_samples can be defined.

  • scopes (str | List[str]) – The scopes, in which the rule should be applied. Defaults to “global”.

  • invert (bool) – If set, the invert of the rule is applied. Defaults to False.

  • update_output (bool) – If set, the output quantities are updated. Defaults to True.

update_outputs(outputs_to_be_updated)[source]
Parameters:

outputs_to_be_updated (Dict[str, Set[Quantity]])

Return type:

None

update_producers(producers_to_be_updated, unpacked_producers)[source]
Parameters:
Return type:

None