Skip to content

Commit

Permalink
Equality tests won't throw errors.
Browse files Browse the repository at this point in the history
Fixes #95.
  • Loading branch information
malmaud committed Jul 25, 2022
1 parent 0d82ce7 commit 5ab0fbc
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Pandas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ end

for (jl_op, py_op, py_opᵒ) in [(:+, :__add__, :__add__), (:*, :__mul__, :__mul__),
(:/, :__div__, :__rdiv__), (:-, :__sub__, :__rsub__),
(:(==), :__eq__, :__eq__), (:!=, :__ne__, :__ne__),
(:>, :__gt__, :__lt__), (:<, :__lt__, :__gt__),
(:>=, :__ge__, :__le__), (:<=, :__le__, :__ge__),
(:&, :__and__, :__and__), (:|, :__or__, :__or__)]
Expand All @@ -397,6 +396,19 @@ for (jl_op, py_op, py_opᵒ) in [(:+, :__add__, :__add__), (:*, :__mul__, :__mul
end
end

# Special-case the handling of equality-testing to always consider PandasWrapped
# objects as unequal to non-wrapped objects.
(==)(x::PandasWrapped, y) = false
(==)(x, y::PandasWrapped) = false
(!=)(x::PandasWrapped, y) = true
(!=)(x, y::PandasWrapped) = true
function (==)(x::PandasWrapped, y::PandasWrapped)
pandas_wrap(x.pyo.__eq__(y))
end
function (!=)(x::PandasWrapped, y::PandasWrapped)
pandas_wrap(x.pyo.__neq__(y))
end

for op in [(:-, :__neg__)]
@eval begin
$(op[1])(x::PandasWrapped) = pandas_wrap(x.pyo.$(quot(op[2]))())
Expand Down

0 comments on commit 5ab0fbc

Please sign in to comment.