Skip to content

Commit

Permalink
Improved BinaryOp and Comparisson operation
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab committed May 2, 2018
1 parent dd2c15a commit 32321c2
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions ibis/expr/operations.py
Expand Up @@ -285,6 +285,8 @@ class UnaryOp(ValueOp):


class BinaryOp(ValueOp):
"""A binary operation"""

left = Arg(rlz.any)
right = Arg(rlz.any)

Expand Down Expand Up @@ -767,22 +769,6 @@ class StringAscii(UnaryOp):
output_type = rlz.shape_like('arg', dt.int32)


class BinaryOp(ValueOp):
"""A binary operation"""

# Casting rules for type promotions (for resolving the output type) may
# depend in some cases on the target backend.
#
# TODO: how will overflows be handled? Can we provide anything useful in
# Ibis to help the user avoid them?

def __init__(self, left, right):
super(BinaryOp, self).__init__(*self._maybe_cast_args(left, right))

def _maybe_cast_args(self, left, right):
return left, right


# ----------------------------------------------------------------------


Expand Down Expand Up @@ -2149,6 +2135,19 @@ class Comparison(BinaryOp, BooleanValueOp):
left = Arg(rlz.any)
right = Arg(rlz.any)

def __init__(self, left, right):
"""
Casting rules for type promotions (for resolving the output type) may
depend in some cases on the target backend.
TODO: how will overflows be handled? Can we provide anything useful in
Ibis to help the user avoid them?
:param left:
:param right:
"""
super(BinaryOp, self).__init__(*self._maybe_cast_args(left, right))

def _maybe_cast_args(self, left, right):
# it might not be necessary?
with compat.suppress(com.IbisTypeError):
Expand Down

0 comments on commit 32321c2

Please sign in to comment.