Exemple #1
0
    def __rsub__(
        self,
        other: datetime.timedelta | pd.Timedelta | IntervalValue,
    ) -> IntervalValue | NotImplemented:
        """Subtract `other` from this interval."""
        import ibis.expr.operations as ops

        return _binop(ops.IntervalSubtract, other, self)
Exemple #2
0
    def __floordiv__(
        self,
        other: ir.IntegerValue,
    ) -> IntervalValue | NotImplemented:
        """Floor-divide this interval by `other`."""
        import ibis.expr.operations as ops

        return _binop(ops.IntervalFloorDivide, self, other)
Exemple #3
0
    def __add__(
        self,
        other: datetime.timedelta | pd.Timedelta | IntervalValue,
    ) -> IntervalValue | NotImplemented:
        """Add this interval to `other`."""
        import ibis.expr.operations as ops

        return _binop(ops.IntervalAdd, self, other)
Exemple #4
0
    def __add__(
        self,
        other: datetime.timedelta | pd.Timedelta | IntervalValue,
    ) -> TimestampValue | NotImplemented:
        """Add an interval to a timestamp."""
        import ibis.expr.operations as ops

        return _binop(ops.TimestampAdd, self, other)
Exemple #5
0
    def __rfloordiv__(
        self,
        other: NumericValue,
    ) -> NumericValue | NotImplemented:
        """Floor divide `other` by `self`."""
        from ibis.expr import operations as ops

        return _binop(ops.FloorDivide, other, self)
Exemple #6
0
    def __mul__(
        self,
        other: int | ir.IntegerValue,
    ) -> IntervalValue | NotImplemented:
        """Multiply this interval by `other`."""
        import ibis.expr.operations as ops

        return _binop(ops.IntervalMultiply, self, other)
Exemple #7
0
    def __rsub__(
        self,
        other: TimeValue | IntervalValue,
    ) -> IntervalValue | TimeValue | NotImplemented:
        """Subtract a time or an interval from a time expression."""
        import ibis.expr.operations as ops
        import ibis.expr.rules as rlz

        other = rlz.any(other)

        if isinstance(other, TimeValue):
            op = ops.TimeDiff
        else:
            op = ops.TimeSub  # let the operation validate

        return _binop(op, other, self)
Exemple #8
0
    def __rsub__(
        self,
        other: datetime.date
        | DateValue
        | datetime.timedelta
        | pd.Timedelta
        | IntervalValue,
    ) -> IntervalValue | DateValue | NotImplemented:
        """Subtract a date or an interval from a date."""
        import ibis.expr.operations as ops
        import ibis.expr.rules as rlz

        other = rlz.one_of([rlz.date, rlz.interval], other)

        if isinstance(other, DateValue):
            op = ops.DateDiff
        else:
            op = ops.DateSub  # let the operation validate

        return _binop(op, other, self)
Exemple #9
0
    def __rsub__(
        self,
        other: datetime.datetime
        | pd.Timestamp
        | TimestampValue
        | datetime.timedelta
        | pd.Timedelta
        | IntervalValue,
    ) -> IntervalValue | TimestampValue | NotImplemented:
        """Subtract a timestamp or an interval from a timestamp."""
        import ibis.expr.operations as ops
        import ibis.expr.rules as rlz

        right = rlz.any(other)

        if isinstance(right, TimestampValue):
            op = ops.TimestampDiff
        else:
            op = ops.TimestampSub  # let the operation validate

        return _binop(op, other, self)
Exemple #10
0
    def __ge__(self, other: Value) -> ir.BooleanValue:
        import ibis.expr.operations as ops
        import ibis.expr.rules as rlz

        return _binop(ops.GreaterEqual, self, rlz.any(other))
Exemple #11
0
    def __xor__(self, other: BooleanValue) -> BooleanValue:
        from ibis.expr import operations as ops
        from ibis.expr import rules as rlz

        return _binop(ops.Xor, self, rlz.any(other))
Exemple #12
0
    def __rsub__(self, other: NumericValue) -> NumericValue | NotImplemented:
        """Substract `self` from `other`."""
        from ibis.expr import operations as ops

        return _binop(ops.Subtract, other, self)
Exemple #13
0
    def __mul__(self,
                n: int | ir.IntegerValue) -> StringValue | NotImplemented:
        import ibis.expr.operations as ops

        return _binop(ops.Repeat, self, n)
Exemple #14
0
    def __rmod__(self, other: NumericValue) -> NumericValue | NotImplemented:
        """Compute `other` modulo `self`."""
        from ibis.expr import operations as ops

        return _binop(ops.Modulus, other, self)
Exemple #15
0
    def __rpow__(self, other: NumericValue) -> NumericValue | NotImplemented:
        """Raise `other` to the `self`th power."""
        from ibis.expr import operations as ops

        return _binop(ops.Power, other, self)
Exemple #16
0
    def __truediv__(self, other):
        """Divide `self` by `other`."""
        from ibis.expr import operations as ops

        return _binop(ops.Divide, self, other)
Exemple #17
0
    def __mul__(self, other: NumericValue) -> NumericValue | NotImplemented:
        """Multiply `self` and `other`."""
        from ibis.expr import operations as ops

        return _binop(ops.Multiply, self, other)
Exemple #18
0
    def __lt__(self, other: Value) -> ir.BooleanValue:
        import ibis.expr.operations as ops
        import ibis.expr.rules as rlz

        return _binop(ops.Less, self, rlz.any(other))
Exemple #19
0
    def __add__(self, other: NumericValue) -> NumericValue | NotImplemented:
        """Add `self` with `other`."""
        from ibis.expr import operations as ops

        return _binop(ops.Add, self, other)