Skip to content

Commit

Permalink
chore: /polars/polars-core/src/frame/ readability (#3813)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanrussell committed Jun 26, 2022
1 parent fbfdd3a commit fbe23fe
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions polars/polars-core/src/frame/asof_join/asof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ where
// left: [-1, 0, 1, 2],
// right: [1, 2, 3]
// first values should be None, until left has caught up
let mut left_catched_up = false;
let mut left_caught_up = false;

// init with left so that the distance starts at 0
let mut previous_right = left[0];
Expand All @@ -74,12 +74,12 @@ where
match right.get(offset as usize) {
Some(&val_r) => {
// we fill nulls until left value is larger than right
if !left_catched_up {
if !left_caught_up {
if val_l < val_r {
out.push(None);
break;
} else {
left_catched_up = true;
left_caught_up = true;
}
}

Expand All @@ -106,7 +106,7 @@ where
// we cannot fill the remainder of the value, because we need to check tolerances
None => {
// if we have previous value, continue with that one
let val = if left_catched_up && dist <= tolerance {
let val = if left_caught_up && dist <= tolerance {
Some(offset - 1)
}
// else null
Expand All @@ -133,19 +133,19 @@ pub(super) fn join_asof_backward<T: PartialOrd + Copy + Debug>(
// left: [-1, 0, 1, 2],
// right: [1, 2, 3]
// first values should be None, until left has caught up
let mut left_catched_up = false;
let mut left_caught_up = false;

for &val_l in left {
loop {
match right.get(offset as usize) {
Some(&val_r) => {
// we fill nulls until left value is larger than right
if !left_catched_up {
if !left_caught_up {
if val_l < val_r {
out.push(None);
break;
} else {
left_catched_up = true;
left_caught_up = true;
}
}

Expand All @@ -164,7 +164,7 @@ pub(super) fn join_asof_backward<T: PartialOrd + Copy + Debug>(
// we depleted the right array
None => {
// if we have previous value, continue with that one
let val = if left_catched_up {
let val = if left_caught_up {
Some(offset - 1)
}
// else all null
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-core/src/frame/asof_join/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub(super) unsafe fn join_asof_backward_with_indirection<T: PartialOrd + Copy +

// process the group taken by the `by` operation and keep track of the offset.
// we don't process a group at once but per `index_left` we find the `right_index` and keep track
// of the offsets we have already processed in a seperate hashmap. Then on a next iteration we can
// of the offsets we have already processed in a separate hashmap. Then on a next iteration we can
// continue from that offsets location.
#[allow(clippy::too_many_arguments)]
#[allow(clippy::type_complexity)]
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-core/src/frame/from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ impl TryFrom<StructArray> for DataFrame {
let (fld, arrs, nulls) = arr.into_data();
if nulls.is_some() {
return Err(PolarsError::ComputeError(
"cannot deserialze struct with nulls into a DataFrame".into(),
"cannot deserialize struct with nulls into a DataFrame".into(),
));
}
let columns = fld
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-core/src/frame/groupby/aggregations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use polars_arrow::trusted_len::PushUnchecked;
// window
//
// if the windows don't overlap, we should not use these kernels as they are single threaded, so
// we miss out on easy parallization.
// we miss out on easy parallelization.
fn use_rolling_kernels(groups: &GroupsSlice, chunks: &[ArrayRef]) -> bool {
match groups.len() {
0 | 1 => false,
Expand Down
2 changes: 1 addition & 1 deletion polars/polars-core/src/frame/groupby/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ mod test {
let serie = Series::new("N", [1, 2, 3, 3, 4].as_ref());
series.push(serie);

// Creat the dataframe with the computed series.
// Create the dataframe with the computed series.
let df = DataFrame::new(series).unwrap();

// Compute the aggregated DataFrame by the 13 columns defined in `series_names`.
Expand Down
6 changes: 3 additions & 3 deletions polars/polars-core/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ impl DataFrame {
!self
.columns
.iter()
// The idea is that we creat a hash of the chunk lengths.
// The idea is that we create a hash of the chunk lengths.
// Consisting of the combined hash + the sum (assuming collision probability is nihil)
// if not, we can add more hashes or at worst case we do an extra rechunk.
// the old solution to this was clone all lengths to a vec and compare the vecs
Expand Down Expand Up @@ -2007,7 +2007,7 @@ impl DataFrame {
///
/// # Example
///
/// This is the idomatic way to replace some values a column of a `DataFrame` given range of indexes.
/// This is the idiomatic way to replace some values a column of a `DataFrame` given range of indexes.
///
/// ```rust
/// # use polars_core::prelude::*;
Expand Down Expand Up @@ -2074,7 +2074,7 @@ impl DataFrame {
///
/// # Example
///
/// This is the idomatic way to replace some values a column of a `DataFrame` given a boolean mask.
/// This is the idiomatic way to replace some values a column of a `DataFrame` given a boolean mask.
///
/// ```rust
/// # use polars_core::prelude::*;
Expand Down

0 comments on commit fbe23fe

Please sign in to comment.