import polars as pl

from .compounds import featurise



def _unique_with_featurisation(
    df: pl.DataFrame,
    of: str = "mol",
    descriptor: str = "morgan",
    alias: str | None = None,
    **kwargs,
) -> pl.DataFrame:
    alias = alias if alias else descriptor
    return df.with_columns(pl.col(of).alias(alias)).map_columns(
        alias,
        lambda x: featurise(x, descriptor, **kwargs),
    )
