Skip to content

Commit

Permalink
refactor(python): make cloning PyExpr consistent (#11956)
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego authored Oct 23, 2023
1 parent ce3dd72 commit 7c83592
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 149 deletions.
16 changes: 8 additions & 8 deletions py-polars/src/expr/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ impl PyExpr {

#[cfg(feature = "binary_encoding")]
fn bin_hex_decode(&self, strict: bool) -> Self {
self.clone()
.inner
self.inner
.clone()
.map(
move |s| {
s.binary()?
Expand All @@ -39,8 +39,8 @@ impl PyExpr {

#[cfg(feature = "binary_encoding")]
fn bin_base64_decode(&self, strict: bool) -> Self {
self.clone()
.inner
self.inner
.clone()
.map(
move |s| {
s.binary()?
Expand All @@ -55,8 +55,8 @@ impl PyExpr {

#[cfg(feature = "binary_encoding")]
fn bin_hex_encode(&self) -> Self {
self.clone()
.inner
self.inner
.clone()
.map(
move |s| s.binary().map(|s| Some(s.hex_encode().into_series())),
GetOutput::from_type(DataType::Utf8),
Expand All @@ -67,8 +67,8 @@ impl PyExpr {

#[cfg(feature = "binary_encoding")]
fn bin_base64_encode(&self) -> Self {
self.clone()
.inner
self.inner
.clone()
.map(
move |s| s.binary().map(|s| Some(s.base64_encode().into_series())),
GetOutput::from_type(DataType::Utf8),
Expand Down
40 changes: 20 additions & 20 deletions py-polars/src/expr/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ impl PyExpr {
}

fn dt_epoch_seconds(&self) -> Self {
self.clone()
.inner
self.inner
.clone()
.map(
|s| {
s.timestamp(TimeUnit::Milliseconds)
Expand Down Expand Up @@ -92,58 +92,58 @@ impl PyExpr {
}

fn dt_year(&self) -> Self {
self.clone().inner.dt().year().into()
self.inner.clone().dt().year().into()
}
fn dt_is_leap_year(&self) -> Self {
self.clone().inner.dt().is_leap_year().into()
self.inner.clone().dt().is_leap_year().into()
}
fn dt_iso_year(&self) -> Self {
self.clone().inner.dt().iso_year().into()
self.inner.clone().dt().iso_year().into()
}
fn dt_quarter(&self) -> Self {
self.clone().inner.dt().quarter().into()
self.inner.clone().dt().quarter().into()
}
fn dt_month(&self) -> Self {
self.clone().inner.dt().month().into()
self.inner.clone().dt().month().into()
}
fn dt_week(&self) -> Self {
self.clone().inner.dt().week().into()
self.inner.clone().dt().week().into()
}
fn dt_weekday(&self) -> Self {
self.clone().inner.dt().weekday().into()
self.inner.clone().dt().weekday().into()
}
fn dt_day(&self) -> Self {
self.clone().inner.dt().day().into()
self.inner.clone().dt().day().into()
}
fn dt_ordinal_day(&self) -> Self {
self.clone().inner.dt().ordinal_day().into()
self.inner.clone().dt().ordinal_day().into()
}
fn dt_time(&self) -> Self {
self.clone().inner.dt().time().into()
self.inner.clone().dt().time().into()
}
fn dt_date(&self) -> Self {
self.clone().inner.dt().date().into()
self.inner.clone().dt().date().into()
}
fn dt_datetime(&self) -> Self {
self.clone().inner.dt().datetime().into()
self.inner.clone().dt().datetime().into()
}
fn dt_hour(&self) -> Self {
self.clone().inner.dt().hour().into()
self.inner.clone().dt().hour().into()
}
fn dt_minute(&self) -> Self {
self.clone().inner.dt().minute().into()
self.inner.clone().dt().minute().into()
}
fn dt_second(&self) -> Self {
self.clone().inner.dt().second().into()
self.inner.clone().dt().second().into()
}
fn dt_millisecond(&self) -> Self {
self.clone().inner.dt().millisecond().into()
self.inner.clone().dt().millisecond().into()
}
fn dt_microsecond(&self) -> Self {
self.clone().inner.dt().microsecond().into()
self.inner.clone().dt().microsecond().into()
}
fn dt_nanosecond(&self) -> Self {
self.clone().inner.dt().nanosecond().into()
self.inner.clone().dt().nanosecond().into()
}
fn dt_timestamp(&self, time_unit: Wrap<TimeUnit>) -> Self {
self.inner.clone().dt().timestamp(time_unit.0).into()
Expand Down
Loading

0 comments on commit 7c83592

Please sign in to comment.