pymc.math.eq#
- pymc.math.eq = Elemwise(scalar_op=EQ,inplace_pattern=<frozendict {}>)[source]#
a == b
Computes element-wise equality between two tensors.
- Parameters:
- a
TensorLike
First input tensor
- b
TensorLike
Second input tensor
- a
- Returns:
TensorVariable
Output tensor of type bool, with 1 (True) where elements are equal, and 0 (False) elsewhere.
Notes
Due to Python rules, it is not possible to overload the equality symbol == for hashable objects and have it return something other than a boolean, so eq must always be used to compute the Elemwise equality of TensorVariables (which are hashable).
Examples
>>> import pytensor >>> import pytensor.tensor as pt >>> import numpy as np >>> x = pt.vector("x") >>> y = pt.vector("y") >>> f = pytensor.function([x, y], pt.eq(x, y)) >>> f([1, 2, 3], [1, 4, 3]) array([ True, False, True])