Skip to content

Conversation

santhoshbethi
Copy link
Contributor

@santhoshbethi santhoshbethi commented Oct 15, 2025

Comment on lines +1574 to +1576
if isinstance(self, SparseArray) and self.fill_value == 0:
# special case where we can avoid max recursion depth
return SparseArray(self.to_dense().cumsum())
Copy link
Member

Choose a reason for hiding this comment

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

This fix seems to specific. Additionally especially for the open issue, it doesn't appear to_dense is needed

Copy link
Contributor Author

@santhoshbethi santhoshbethi Oct 15, 2025

Choose a reason for hiding this comment

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

Yeah, This fix is very specific to given use case.

       ` if isinstance(self, SparseArray) and self.fill_value == 0:
            # special case where we can avoid max recursion depth
            return SparseArray(self.cumsum())

If I don't add I am getting sameError: maximum recursion depth exceeded`

Choose a reason for hiding this comment

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

I think the fix being specific is fine. It is basically using the same "trick" that the code was previously using for float arrays with nan fill, which was that if it is non-nan fill, densify and resparse so now the fill is nan, and call .cumsum() again. So it recurses once. This trick broke for integer arrays because when you do the densify and reparsing, the default fill is 0. This fix now catches that case ensuring that int arrays also only recurse once.

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.

BUG: Calling SparseArray.cumsum leads to infinite recursion

3 participants