DiscreteVariable.posLabel

DiscreteVariable.posLabel(s)

Returns the index of the label s in the variable’s domain (if the variable is a pyagrum.LabelizedVariable)

Raises:
  • NotImplementedError – If the variable is not a pyagrum.LabelizedVariable

  • NotFoundError – If the variable does not contain the label s

Return type:

int

Returns:

int

the index of the label s in the variable’s domain

Parameters:

s (str)

Example

import pyagrum as gum

v = gum.fastVariable("c{red|green|blue}")  # a LabelizedVariable
v.posLabel("green")
# 1

Used by

DiscreteVariable, DiscretizedVariable, IntegerVariable, NumericalDiscreteVariable, RangeVariable

Inheritance diagram of pyagrum.DiscreteVariable, pyagrum.DiscretizedVariable, pyagrum.IntegerVariable, pyagrum.NumericalDiscreteVariable, pyagrum.RangeVariable

Overridden in

LabelizedVariable.posLabel