Skip to content

fix: Inverting int now does bitwise inversion rather than sign flip #574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bigframes/core/compile/scalar_op_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def expm1_op_impl(x: ibis_types.Value):

@scalar_op_compiler.register_unary_op(ops.invert_op)
def invert_op_impl(x: ibis_types.Value):
return typing.cast(ibis_types.NumericValue, x).negate()
return x.__invert__()


## String Operation
Expand Down
15 changes: 15 additions & 0 deletions tests/system/small/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,21 @@ def test_abs(scalars_dfs, col_name):
assert_series_equal(pd_result, bf_result)


@pytest.mark.parametrize(
("col_name",),
(
("bool_col",),
("int64_col",),
),
)
def test_series_invert(scalars_dfs, col_name):
scalars_df, scalars_pandas_df = scalars_dfs
bf_result = (~scalars_df[col_name]).to_pandas()
pd_result = ~scalars_pandas_df[col_name]

assert_series_equal(pd_result, bf_result)


def test_fillna(scalars_dfs):
scalars_df, scalars_pandas_df = scalars_dfs
col_name = "string_col"
Expand Down