Skip to content

feat(series): truediv for bools #1314

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cmp0xff
Copy link
Contributor

@cmp0xff cmp0xff commented Aug 11, 2025

This is inspired by #1312 (comment) and a follow-up for #1311.

  • Tests added: Please use assert_type() to assert the type of any return value


def test_truediv_py_scalar() -> None:
"""Test pd.Series[bool] / Python native scalars"""
i, f, c = 1, 1.0, 1j
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valid to add a test with b=True in the divisor and the dividend


def test_truediv_py_sequence() -> None:
"""Test pd.Series[bool] / Python native sequence"""
i, f, c = [2, 3, 5], [1.0, 2.0, 3.0], [1j, 1j, 4j]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valid to have b = [True, False, True] here


def test_truediv_numpy_array() -> None:
"""Test pd.Series[bool] / numpy array"""
i = np.array([2, 3, 5], np.int64)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can add a b=np.array([True, False, True], np.bool_) here


def test_truediv_pd_series() -> None:
"""Test pd.Series[bool] / pandas series"""
i = pd.Series([2, 3, 5])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the only case where you can't test b=pd.Series([True, False, True]) because it will fail at runtime in all these operations.

Ideally, it would be cool to have a if TYPE_CHECKING_INVALID_USAGE: when b is involved to see if we can catch this usage with static typing.

@@ -10,7 +10,7 @@

def test_truediv_py_scalar() -> None:
"""Test pd.Series[float] / Python native scalars"""
i, f, c = 1, 1.0, 1j
b, i, f, c = True, 1, 1.0, 1j
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this function and other funcs in this file, you have to add the tests for b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants