diff --git a/doc/library/tensor/basic.rst b/doc/library/tensor/basic.rst index 1f73220888..e1b3dfbf9b 100644 --- a/doc/library/tensor/basic.rst +++ b/doc/library/tensor/basic.rst @@ -1292,6 +1292,30 @@ The six usual equality and inequality operators share the same interface. Returns a variable representing the result of logical inequality (a!=b). +.. function:: greater(a, b) + + Alias for `gt`. greater is the NumPy name. + +.. function:: greater_equal(a, b) + + Alias for `ge`. greater_equal is the NumPy name. + +.. function:: less(a, b) + + Alias for `lt`. less is the NumPy name. + +.. function:: less_equal(a, b) + + Alias for `le`. less_equal is the NumPy name. + +.. function:: equal(a, b) + + Alias for `eq`. equal is the NumPy name. + +.. function:: not_equal(a, b) + + Alias for `neq`. not_equal is the NumPy name. + .. function:: isnan(a) Returns a variable representing the comparison of ``a`` elements with nan. diff --git a/pytensor/tensor/math.py b/pytensor/tensor/math.py index 6ab92d086d..efc7c20c45 100644 --- a/pytensor/tensor/math.py +++ b/pytensor/tensor/math.py @@ -1013,32 +1013,21 @@ def and_(a, b): """bitwise a & b""" -bitwise_and = and_ # numpy name for it - - @scalar_elemwise def or_(a, b): """bitwise a | b""" -bitwise_or = or_ # numpy name for it - - @scalar_elemwise def xor(a, b): """bitwise a ^ b""" -bitwise_xor = xor # numpy name for it - - @scalar_elemwise def invert(a): """bitwise ~a""" -bitwise_not = invert # numpy alias for it - ########################## # Math ########################## @@ -1167,10 +1156,6 @@ def sqr(a): """square of a""" -# alias to sqr, included to maintain similarity with numpy interface -square = sqr - - def cov(m, y=None, rowvar=True, bias=False, ddof=None, fweights=None, aweights=None): """Calculate the covariance matrix. @@ -2956,6 +2941,21 @@ def vectorize_node_to_matmul(op, node, batched_x, batched_y): return vectorize_node_fallback(op, node, batched_x, batched_y) +# NumPy logical aliases +square = sqr + +bitwise_and = and_ +bitwise_or = or_ +bitwise_xor = xor +bitwise_not = invert + +greater = gt +greater_equal = ge +less = lt +less_equal = le +equal = eq +not_equal = neq + __all__ = [ "max_and_argmax", "max", @@ -2966,11 +2966,17 @@ def vectorize_node_to_matmul(op, node, batched_x, batched_y): "smallest", "largest", "lt", + "less", "gt", + "greater", "le", + "less_equal", "ge", + "greater_equal", "eq", + "equal", "neq", + "not_equal", "isnan", "isinf", "allclose",