Skip to content

TST: adds a test to check signedness preservation after sum #57306

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

Conversation

banorton
Copy link
Contributor

@banorton banorton commented Feb 8, 2024

Adds a test to make sure the result of sum does not alter the signedness of the input.

def test_signedness_preserved_after_sum(self):
s = Series([1, 2, 3, 4])

result1 = s.astype("int8").sum().dtype
Copy link
Member

Choose a reason for hiding this comment

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

Don't need to test this one

s = Series([1, 2, 3, 4])

result1 = s.astype("int8").sum().dtype
result2 = s.astype("uint8").sum().dtype
Copy link
Member

Choose a reason for hiding this comment

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

Can you assert the actual result of s.astype("uint8").sum()?

Comment on lines 1262 to 1263
def test_signedness_preserved_after_sum(self):
s = Series([1, 2, 3, 4])
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def test_signedness_preserved_after_sum(self):
s = Series([1, 2, 3, 4])
def test_signedness_preserved_after_sum(self):
# GH 37491
ser = Series([1, 2, 3, 4])

@mroeschke mroeschke added the Testing pandas testing functions or related to the test suite label Feb 8, 2024
@banorton
Copy link
Contributor Author

banorton commented Feb 8, 2024

I removed the unnecessary test and added the issue number :)

@mroeschke mroeschke added this to the 3.0 milestone Feb 8, 2024
@mroeschke mroeschke merged commit 1aeaf6b into pandas-dev:main Feb 8, 2024
@mroeschke
Copy link
Member

Thanks @banorton

@banorton banorton deleted the test-sum-signedness-preservation branch February 8, 2024 23:39
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
…ev#57306)

* add a test to check signedness preservation after sum

* removed test for int8 and added issue number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Inconsistent data type conversion with .sum
2 participants