Skip to content

Commit

Permalink
添加xor函数
Browse files Browse the repository at this point in the history
  • Loading branch information
wukan1986 committed Nov 6, 2024
1 parent d32332f commit 7f42e0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion polars_ta/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.11"
__version__ = "0.2.12"
7 changes: 5 additions & 2 deletions polars_ta/wq/logical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from polars import when, Int8, Boolean


# TODO 本文件返回bool时是否有必要转换成 0/1 ?

def and_(a: Expr, b: Expr, *args) -> Expr:
"""Logical AND operator, returns true if both operands are true and returns false otherwise"""
return all_horizontal(a, b, *args)
Expand Down Expand Up @@ -54,6 +52,11 @@ def or_(a: Expr, b: Expr, *args) -> Expr:
return any_horizontal(a, b, *args)


def xor(a: Expr, b: Expr) -> Expr:
"""Logical XOR operator returns true if exactly one of the inputs is true and returns false otherwise"""
return a.xor(b)


def int_(a: Expr) -> Expr:
"""convert bool to int"""
return a.cast(Int8)
Expand Down

0 comments on commit 7f42e0b

Please sign in to comment.