|
37 | 37 | "__lt__": "<", |
38 | 38 | "__eq__": "==", |
39 | 39 | "__ne__": "!=", |
| 40 | + "__and__": "&", |
| 41 | + "__rand__": "&", |
| 42 | + "__or__": "|", |
| 43 | + "__ror__": "|", |
| 44 | + "__xor__": "^", |
| 45 | + "__rxor__": "^", |
40 | 46 | } |
41 | 47 |
|
42 | 48 |
|
@@ -157,6 +163,28 @@ def __mod__(self, other: Any) -> Expression: |
157 | 163 | def __rmod__(self, other: Any) -> Expression: |
158 | 164 | return self._with_binary_op("__rmod__", other) |
159 | 165 |
|
| 166 | + # Logical ops |
| 167 | + def __and__(self, other: Any) -> Expression: |
| 168 | + return self._with_binary_op("__and__", other) |
| 169 | + |
| 170 | + def __rand__(self, other: Any) -> Expression: |
| 171 | + return self._with_binary_op("__rand__", other) |
| 172 | + |
| 173 | + def __or__(self, other: Any) -> Expression: |
| 174 | + return self._with_binary_op("__or__", other) |
| 175 | + |
| 176 | + def __ror__(self, other: Any) -> Expression: |
| 177 | + return self._with_binary_op("__ror__", other) |
| 178 | + |
| 179 | + def __xor__(self, other: Any) -> Expression: |
| 180 | + return self._with_binary_op("__xor__", other) |
| 181 | + |
| 182 | + def __rxor__(self, other: Any) -> Expression: |
| 183 | + return self._with_binary_op("__rxor__", other) |
| 184 | + |
| 185 | + def __invert__(self) -> Expression: |
| 186 | + return Expression(lambda df: ~self(df), f"(~{self._repr_str})") |
| 187 | + |
160 | 188 | def __array_ufunc__( |
161 | 189 | self, ufunc: Callable[..., Any], method: str, *inputs: Any, **kwargs: Any |
162 | 190 | ) -> Expression: |
|
0 commit comments