Skip to content

FIX: prevent unnecessary type casts in rolling mean #10341

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
May 22, 2025

Conversation

kmuehlbauer
Copy link
Contributor

@kmuehlbauer kmuehlbauer commented May 21, 2025

Use dtype from intermediate sum for casting of count instead of current "int" when calculating mean in rolling operations to prevent unnecessary casting to/from int

  • Closes ReadTheDocs builds broken #10340
  • Tests added
  • User visible changes (including notable bug fixes) are documented in whats-new.rst
  • New functions/methods are listed in api.rst

…current "int" when calculating mean in rolling operations to prevent unnecessary casting to/from int
@kmuehlbauer
Copy link
Contributor Author

kmuehlbauer commented May 21, 2025

In #10319 a fix was introduced to correctly calculate mean for boolean arrays. Unfortunately with the cost of additional type casting to/from int for any non-int/non-bool types.

@gcaria This should prevent the unnecessary type casts to/from int by preserving the wanted/needed dtype from the calculation of the sum. This also works in case of boolean arrays.

There is might be need for a test to catch any unwanted type cast to prevent any regressions. If someone has an idea, please suggest!

@max-sixty
Copy link
Collaborator

thanks @kmuehlbauer !

@kmuehlbauer kmuehlbauer added the plan to merge Final call for comments label May 22, 2025
@kmuehlbauer
Copy link
Contributor Author

I've added a code comment and an entry to whats-new.rst. Maybe new tests aren't needed as preservation of float types as well as correct calculation of bool mean is tested. Added "plan to merge" label and will go ahead with that later today if no one beats me to it.

@kmuehlbauer kmuehlbauer merged commit dd6222f into pydata:main May 22, 2025
37 of 38 checks passed
@kmuehlbauer kmuehlbauer deleted the fix-rolling-mean branch May 22, 2025 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReadTheDocs builds broken
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy