Skip to content

feat: Implement Six New Series Methods - #23

Closed
google-labs-jules[bot] wants to merge 1 commit into
mainfrom
feat-add-series-methods-1
Closed

feat: Implement Six New Series Methods#23
google-labs-jules[bot] wants to merge 1 commit into
mainfrom
feat-add-series-methods-1

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

This commit implements six new methods for the Series class as part of the work outlined in specs/2025-09-16-series-methods.md. The implemented methods include add, sub, mul, div, pow, and mod, along with their corresponding dunder methods. Comprehensive unit tests have been added for both scalar and series operations to ensure the correctness of the new functionality. Additionally, the spec file has been updated to reflect the completion of these methods.


PR created automatically by Jules for task 12050708900107404300 started by @tswast

Added the following methods to the `Series` class:
- add
- sub
- mul
- div
- pow
- mod
@google-labs-jules

Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

New to Jules? Learn more at jules.google/docs.

Comment thread leanframe/core/series.py
Comment on lines +118 to +133
def __rmod__(self, other) -> Series:
return Series(getattr(other, "_data", other) % self._data)

other_data = getattr(other, "_data", other)
result = self._data**other_data

is_self_int = self._data.type().is_integer()
is_other_int = False
if isinstance(other_data, ibis_types.Column):
is_other_int = other_data.type().is_integer()
elif isinstance(other_data, int):
is_other_int = True

if is_self_int and is_other_int:
return Series(result.cast("int64"))
return Series(result)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@google-labs-jules please explain in some comments the logic of rmod. I'm having trouble understanding it at a glance.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've added comments to all the reverse binary operators to clarify their purpose. I also noticed some stray code in __rmod__ and a duplicate __pow__ definition, which I've now fixed. Thanks for catching that!

Comment thread leanframe/core/series.py
Comment on lines +135 to +163
def __pow__(self, other):
other_data = getattr(other, "_data", other)
result = self._data**other_data

is_self_int = self._data.type().is_integer()
is_other_int = False
if isinstance(other_data, ibis_types.Column):
is_other_int = other_data.type().is_integer()
elif isinstance(other_data, int):
is_other_int = True

if is_self_int and is_other_int:
return Series(result.cast("int64"))
return Series(result)

def __rpow__(self, other):
other_data = getattr(other, "_data", other)
result = other_data**self._data

is_self_int = self._data.type().is_integer()
is_other_int = False
if isinstance(other_data, ibis_types.Column):
is_other_int = other_data.type().is_integer()
elif isinstance(other_data, int):
is_other_int = True

if is_self_int and is_other_int:
return Series(result.cast("int64"))
return Series(result)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@google-labs-jules likewise, pow and rpow could use further explanation in comments

@tswast tswast closed this Nov 17, 2025
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.

1 participant