Tensor.contains

Tensor.contains(v)

Check whether a variable is in the tensor.

Parameters:

v (pyagrum.DiscreteVariable) – the variable to check.

Returns:

True if the var is in the tensor

Return type:

bool

Example

import pyagrum as gum

a, b = gum.LabelizedVariable("a", "a", 2), gum.LabelizedVariable("b", "b", 3)
p = gum.Tensor().add(a).add(b).fillWith([1, 2, 3, 4, 5, 6])
p.contains(a)
# True
p.contains(gum.LabelizedVariable("c", "c", 2))
# False

Class

Tensor