Skip to content

Commit 5f1db8b

Browse files
fix: Inverting int now does bitwise inversion rather than sign flip (#574)
1 parent 57e1cca commit 5f1db8b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

bigframes/core/compile/scalar_op_compiler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def expm1_op_impl(x: ibis_types.Value):
397397

398398
@scalar_op_compiler.register_unary_op(ops.invert_op)
399399
def invert_op_impl(x: ibis_types.Value):
400-
return typing.cast(ibis_types.NumericValue, x).negate()
400+
return x.__invert__()
401401

402402

403403
## String Operation

tests/system/small/test_series.py

+15
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,21 @@ def test_abs(scalars_dfs, col_name):
284284
assert_series_equal(pd_result, bf_result)
285285

286286

287+
@pytest.mark.parametrize(
288+
("col_name",),
289+
(
290+
("bool_col",),
291+
("int64_col",),
292+
),
293+
)
294+
def test_series_invert(scalars_dfs, col_name):
295+
scalars_df, scalars_pandas_df = scalars_dfs
296+
bf_result = (~scalars_df[col_name]).to_pandas()
297+
pd_result = ~scalars_pandas_df[col_name]
298+
299+
assert_series_equal(pd_result, bf_result)
300+
301+
287302
def test_fillna(scalars_dfs):
288303
scalars_df, scalars_pandas_df = scalars_dfs
289304
col_name = "string_col"

0 commit comments

Comments
 (0)