Skip to content

Commit 8ce8565

Browse files
authored
Equality tests won't throw errors.
Fixes #95.
1 parent 7958568 commit 8ce8565

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Pandas.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,6 @@ end
376376

377377
for (jl_op, py_op, py_opᵒ) in [(:+, :__add__, :__add__), (:*, :__mul__, :__mul__),
378378
(:/, :__div__, :__rdiv__), (:-, :__sub__, :__rsub__),
379-
(:(==), :__eq__, :__eq__), (:!=, :__ne__, :__ne__),
380379
(:>, :__gt__, :__lt__), (:<, :__lt__, :__gt__),
381380
(:>=, :__ge__, :__le__), (:<=, :__le__, :__ge__),
382381
(:&, :__and__, :__and__), (:|, :__or__, :__or__)]
@@ -397,6 +396,19 @@ for (jl_op, py_op, py_opᵒ) in [(:+, :__add__, :__add__), (:*, :__mul__, :__mul
397396
end
398397
end
399398

399+
# Special-case the handling of equality-testing to always consider PandasWrapped
400+
# objects as unequal to non-wrapped objects.
401+
(==)(x::PandasWrapped, y) = false
402+
(==)(x, y::PandasWrapped) = false
403+
(!=)(x::PandasWrapped, y) = true
404+
(!=)(x, y::PandasWrapped) = true
405+
function (==)(x::PandasWrapped, y::PandasWrapped)
406+
pandas_wrap(x.pyo.__eq__(y))
407+
end
408+
function (!=)(x::PandasWrapped, y::PandasWrapped)
409+
pandas_wrap(x.pyo.__neq__(y))
410+
end
411+
400412
for op in [(:-, :__neg__)]
401413
@eval begin
402414
$(op[1])(x::PandasWrapped) = pandas_wrap(x.pyo.$(quot(op[2]))())

0 commit comments

Comments
 (0)