Tensor.extract
- Tensor.extract(*args)
create a new Tensor extracted from self given a partial instantiation.
- Parameters:
inst (
pyagrum.Instantiation) – a partial instantiationdict (
dict) – a dictionnary containing values for some discrete variables.
Warning
if the dictionnary contains a key that is not the name of a variable in the
pyagrum.Tensor, this key is just not used without notification. Thenpyagrum.Tensor.extractconcerns only the variables that both are in the Tensor and in the dictionnary.- Returns:
the new Tensor
- Return type:
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])
q = p.extract({"a": 1})
q.names
# ('b',)
q.tolist()
# [2.0, 4.0, 6.0]
Class