Repository: pola-rs/polars
File: crates/polars-plan/src/dsl/mod.rs (Rust)

Code before:
            BooleanFunction::IsBetween { closed },
            lower.into(),
            upper.into(),
        )
    }

    /// Get a mask of unique values.
    #[allow(clippy::wrong_self_convention)]
    #[cfg(feature = "is_unique")]
    pub fn is_unique(self) -> Self {
        self.map_unary(BooleanFunction::IsUnique)
    }

    /// Check whether floating point values are close to each other.
    #[allow(clippy::wrong_self_convention)]
    #[cfg(feature = "is_close")]
    pub fn is_close<E: Into<Expr>>(
        self,
        expr: E,
        abs_tol: f64,
        rel_tol: f64,
        nans_equal: bool,
    ) -> Self {
        self.map_binary(
            BooleanFunction::IsClose {
                abs_tol: NotNan::new(abs_tol).expect("`abs_tol` must not be NaN"),
                rel_tol: NotNan::new(rel_tol).expect("`rel_tol` must not be NaN"),
                nans_equal,
            },
            expr.into(),
        )
    }

    /// Get the approximate count of unique values.
    #[cfg(feature = "approx_unique")]
    pub fn approx_n_unique(self) -> Self {
        self.map_unary(FunctionExpr::ApproxNUnique)
    }

    /// Bitwise "and" operation.
    pub fn and<E: Into<Expr>>(self, expr: E) -> Self {
        binary_expr(self, Operator::And, expr.into())
    }

    /// Bitwise "xor" operation.
    pub fn xor<E: Into<Expr>>(self, expr: E) -> Self {
        binary_expr(self, Operator::Xor, expr.into())
    }

    /// Bitwise "or" operation.
    pub fn or<E: Into<Expr>>(self, expr: E) -> Self {

Review comment (suggestion):
We can check `is_nan` on the floats.

We can make our own `NonNan` wrapper type in `polars-utils`, which does this check on entry.

Code after:
            BooleanFunction::IsBetween { closed },
            lower.into(),
            upper.into(),
        )
    }

    /// Get a mask of unique values.
    #[allow(clippy::wrong_self_convention)]
    #[cfg(feature = "is_unique")]
    pub fn is_unique(self) -> Self {
        self.map_unary(BooleanFunction::IsUnique)
    }

    /// Check whether floating point values are close to each other.
    #[allow(clippy::wrong_self_convention)]
    #[cfg(feature = "is_close")]
    pub fn is_close<E: Into<Expr>>(
        self,
        expr: E,
        abs_tol: f64,
        rel_tol: f64,
        nans_equal: bool,
    ) -> Self {
        self.map_binary(
            BooleanFunction::IsClose {
                abs_tol: TotalOrdWrap(abs_tol),
                rel_tol: TotalOrdWrap(rel_tol),
                nans_equal,
            },
            expr.into(),
        )
    }

    /// Get the approximate count of unique values.
    #[cfg(feature = "approx_unique")]
    pub fn approx_n_unique(self) -> Self {
        self.map_unary(FunctionExpr::ApproxNUnique)
    }

    /// Bitwise "and" operation.
    pub fn and<E: Into<Expr>>(self, expr: E) -> Self {
        binary_expr(self, Operator::And, expr.into())
    }

    /// Bitwise "xor" operation.
    pub fn xor<E: Into<Expr>>(self, expr: E) -> Self {
        binary_expr(self, Operator::Xor, expr.into())
    }

    /// Bitwise "or" operation.
    pub fn or<E: Into<Expr>>(self, expr: E) -> Self {