Skip to content
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

chore: Use or_else for raising #18206

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions crates/polars-core/src/chunked_array/ops/append.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ where
self.length = self
.length
.checked_add(other.length)
.ok_or(polars_err!(ComputeError: LENGTH_LIMIT_MSG))?;
.ok_or_else(|| polars_err!(ComputeError: LENGTH_LIMIT_MSG))?;
self.null_count += other.null_count;
new_chunks(&mut self.chunks, &other.chunks, len);
Ok(())
Expand All @@ -161,7 +161,7 @@ impl ListChunked {
self.length = self
.length
.checked_add(other.length)
.ok_or(polars_err!(ComputeError: LENGTH_LIMIT_MSG))?;
.ok_or_else(|| polars_err!(ComputeError: LENGTH_LIMIT_MSG))?;
self.null_count += other.null_count;
new_chunks(&mut self.chunks, &other.chunks, len);
self.set_sorted_flag(IsSorted::Not);
Expand All @@ -184,7 +184,7 @@ impl ArrayChunked {
self.length = self
.length
.checked_add(other.length)
.ok_or(polars_err!(ComputeError: LENGTH_LIMIT_MSG))?;
.ok_or_else(|| polars_err!(ComputeError: LENGTH_LIMIT_MSG))?;
self.null_count += other.null_count;

new_chunks(&mut self.chunks, &other.chunks, len);
Expand All @@ -205,7 +205,7 @@ impl StructChunked {
self.length = self
.length
.checked_add(other.length)
.ok_or(polars_err!(ComputeError: LENGTH_LIMIT_MSG))?;
.ok_or_else(|| polars_err!(ComputeError: LENGTH_LIMIT_MSG))?;
self.null_count += other.null_count;

new_chunks(&mut self.chunks, &other.chunks, len);
Expand All @@ -222,7 +222,7 @@ impl<T: PolarsObject> ObjectChunked<T> {
self.length = self
.length
.checked_add(other.length)
.ok_or(polars_err!(ComputeError: LENGTH_LIMIT_MSG))?;
.ok_or_else(|| polars_err!(ComputeError: LENGTH_LIMIT_MSG))?;
self.null_count += other.null_count;
self.set_sorted_flag(IsSorted::Not);
new_chunks(&mut self.chunks, &other.chunks, len);
Expand Down
1 change: 1 addition & 0 deletions py-polars/polars/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,7 @@ def _arithmetic(self, other: Any, op_s: str, op_ffi: str) -> Self:
else:
other = maybe_cast(other, self.dtype)
f = get_ffi_func(op_ffi, self.dtype, self._s)
print(f)
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing this one got in by mistake? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Oei.. yes.

if f is None:
msg = (
f"cannot do arithmetic with Series of dtype: {self.dtype!r} and argument"
Expand Down
Loading