1919
2020from ._compat import dy
2121from .comparison import DataFrameComparison , compare_frames
22- from .metrics import MetricFn
22+ from .metrics import Metric , MetricFn
2323
2424
2525def assert_collection_equal (
@@ -40,7 +40,7 @@ def assert_collection_equal(
4040 right_name : str = Side .RIGHT ,
4141 slim : bool = False ,
4242 hidden_columns : list [str ] | None = None ,
43- metrics : Mapping [str , MetricFn ] | None = None ,
43+ metrics : Mapping [str , MetricFn | Metric ] | None = None ,
4444) -> None :
4545 """Assert that two :mod:`dataframely` collections are equal.
4646
@@ -85,9 +85,11 @@ def assert_collection_equal(
8585 hidden_columns: Columns for which no values are printed, e.g. because they
8686 contain sensitive information.
8787 metrics: Optional mapping from display label to a metric callable
88- ``(left_expr, right_expr) -> pl.Expr``. See :mod:`diffly.metrics` for
89- presets. When ``None`` (default), no metrics are computed; presets are
90- not applied automatically.
88+ ``(left_expr, right_expr) -> pl.Expr`` or a :class:`~diffly.metrics.Metric`.
89+ Bare callables are only computed for numerical columns; wrap one in a
90+ :class:`~diffly.metrics.Metric` with a column selector to target other column
91+ types. See :mod:`diffly.metrics` for presets. When ``None`` (default), no
92+ metrics are computed; presets are not applied automatically.
9193
9294 Raises:
9395 AssertionError: If the collections are not equal.
@@ -174,7 +176,7 @@ def assert_frame_equal(
174176 right_name : str = Side .RIGHT ,
175177 slim : bool = False ,
176178 hidden_columns : list [str ] | None = None ,
177- metrics : Mapping [str , MetricFn ] | None = None ,
179+ metrics : Mapping [str , MetricFn | Metric ] | None = None ,
178180) -> None :
179181 """Assert that two :mod:`polars` data frames are equal.
180182
@@ -226,9 +228,11 @@ def assert_frame_equal(
226228 hidden_columns: Columns for which no values are printed, e.g. because they
227229 contain sensitive information.
228230 metrics: Optional mapping from display label to a metric callable
229- ``(left_expr, right_expr) -> pl.Expr``. See :mod:`diffly.metrics` for
230- presets. When ``None`` (default), no metrics are computed; presets are
231- not applied automatically.
231+ ``(left_expr, right_expr) -> pl.Expr`` or a :class:`~diffly.metrics.Metric`.
232+ Bare callables are only computed for numerical columns; wrap one in a
233+ :class:`~diffly.metrics.Metric` with a column selector to target other column
234+ types. See :mod:`diffly.metrics` for presets. When ``None`` (default), no
235+ metrics are computed; presets are not applied automatically.
232236
233237 Raises:
234238 AssertionError: If the data frames are not equal.
0 commit comments