Skip to content

Commit

Permalink
Reformat.
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonspeed committed Nov 21, 2024
1 parent d022c32 commit 1ce74dd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions crates/polars-ops/src/series/ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ mod floor_divide;
mod fused;
mod horizontal;
mod index;
#[cfg(feature = "index_of")]
mod index_of;
mod int_range;
#[cfg(any(feature = "interpolate_by", feature = "interpolate"))]
mod interpolation;
Expand Down Expand Up @@ -53,8 +55,6 @@ mod rle;
mod rolling;
#[cfg(feature = "round_series")]
mod round;
#[cfg(feature = "index_of")]
mod index_of;
#[cfg(feature = "search_sorted")]
mod search_sorted;
#[cfg(feature = "to_dummies")]
Expand Down Expand Up @@ -87,6 +87,7 @@ pub use fused::*;
pub use horizontal::*;
#[cfg(feature = "index_of")]
pub use index::*;
pub use index_of::*;
pub use int_range::*;
#[cfg(feature = "interpolate")]
pub use interpolation::interpolate::*;
Expand Down Expand Up @@ -125,7 +126,6 @@ pub use rle::*;
pub use rolling::*;
#[cfg(feature = "round_series")]
pub use round::*;
pub use index_of::*;
#[cfg(feature = "search_sorted")]
pub use search_sorted::*;
#[cfg(feature = "to_dummies")]
Expand Down
5 changes: 3 additions & 2 deletions crates/polars-plan/src/dsl/function_expr/index_of.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use polars_ops::series::{index_of as index_of_op, cast_if_lossless};
use polars_ops::series::{cast_if_lossless, index_of as index_of_op};

use super::*;

Expand All @@ -17,7 +17,8 @@ pub(super) fn index_of(s: &mut [Column]) -> PolarsResult<Option<Column>> {
// If the Series is sorted, we can use an optimized binary search to
// find the value.
IsSorted::Ascending | IsSorted::Descending if !value.is_null() => {
let Ok(value_as_series) = s[1].as_materialized_series().strict_cast(series.dtype()) else {
let Ok(value_as_series) = s[1].as_materialized_series().strict_cast(series.dtype())
else {
// If we can't cast, means we couldn't find the value.
return Ok(None);
};
Expand Down
6 changes: 3 additions & 3 deletions crates/polars-plan/src/dsl/function_expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ mod ewm_by;
mod fill_null;
#[cfg(feature = "fused")]
mod fused;
#[cfg(feature = "index_of")]
mod index_of;
mod list;
#[cfg(feature = "log")]
mod log;
Expand All @@ -57,8 +59,6 @@ mod round;
#[cfg(feature = "row_hash")]
mod row_hash;
pub(super) mod schema;
#[cfg(feature = "index_of")]
mod index_of;
#[cfg(feature = "search_sorted")]
mod search_sorted;
mod shift_and_fill;
Expand Down Expand Up @@ -929,7 +929,7 @@ impl From<FunctionExpr> for SpecialEq<Arc<dyn ColumnsUdf>> {
#[cfg(feature = "index_of")]
IndexOf => {
wrap!(index_of::index_of)
}
},
#[cfg(feature = "search_sorted")]
SearchSorted(side) => {
map_as_slice!(search_sorted::search_sorted_impl, side)
Expand Down
2 changes: 1 addition & 1 deletion py-polars/polars/expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2322,7 +2322,7 @@ def index_of(self, element: NonNestedLiteral | IntoExpr | None) -> Expr:
Examples
--------
>>> df = pl.DataFrame({"a": [1, None, 17]})
>>> df = pl.DataFrame({"a": [1, None, 17]})
>>> df.select(
... [
... pl.col("a").index_of(17).alias("seventeen"),
Expand Down

0 comments on commit 1ce74dd

Please sign in to comment.