feat: Implement Six New Series Methods - #23
Conversation
Added the following methods to the `Series` class: - add - sub - mul - div - pow - mod
|
👋 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 For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
| 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) |
There was a problem hiding this comment.
@google-labs-jules please explain in some comments the logic of rmod. I'm having trouble understanding it at a glance.
There was a problem hiding this comment.
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!
| 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) |
There was a problem hiding this comment.
@google-labs-jules likewise, pow and rpow could use further explanation in comments
This commit implements six new methods for the
Seriesclass as part of the work outlined inspecs/2025-09-16-series-methods.md. The implemented methods includeadd,sub,mul,div,pow, andmod, 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