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

Test tern groups #4

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
35 changes: 7 additions & 28 deletions crates/polars-core/src/chunked_array/ops/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,13 @@ macro_rules! impl_ternary_broadcast {
.collect_trusted();
val.rename($self.name());
Ok(val)
}
(_, 1, 1) => {
let right = $other.get(0);
let mask = $mask.get(0).unwrap_or(false);
let mut val: ChunkedArray<$ty> = $self
.into_iter()
.map(|left| ternary_apply(mask, left, right))
.collect_trusted();
val.rename($self.name());
Ok(val)
}
(1, _, 1) => {
let left = $self.get(0);
let mask = $mask.get(0).unwrap_or(false);
let mut val: ChunkedArray<$ty> = $other
.into_iter()
.map(|right| ternary_apply(mask, left, right))
.collect_trusted();
},
(_, _, 1) => {
let mut val: ChunkedArray<$ty> = if let Some(true) = $mask.get(0) {
$self.clone()
} else {
$other.clone()
};
val.rename($self.name());
Ok(val)
},
Expand All @@ -79,16 +68,6 @@ macro_rules! impl_ternary_broadcast {
val.rename($self.name());
Ok(val)
},
(l_len, r_len, 1) if l_len == r_len => {
let mask = $mask.get(0).unwrap_or(false);
let mut val: ChunkedArray<$ty> = $self
.into_iter()
.zip($other)
.map(|(left, right)| ternary_apply(mask, left, right))
.collect_trusted();
val.rename($self.name());
Ok(val)
},
(_, _, _) => Err(polars_err!(
ShapeMismatch: "shapes of `self`, `mask` and `other` are not suitable for `zip_with` operation"
)),
Expand Down
Loading
Loading