-
Notifications
You must be signed in to change notification settings - Fork 0
feat!: Introduce new summary section for data metrics #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Moritz Potthoff (MoritzPotthoffQC)
wants to merge
26
commits into
main
Choose a base branch
from
data-inspection-section
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
bff2594
init
MoritzPotthoffQC 51fbda2
add test
MoritzPotthoffQC cb086ef
refactor
MoritzPotthoffQC 526c944
simplify
MoritzPotthoffQC 5732c37
fix
MoritzPotthoffQC 5867021
review
MoritzPotthoffQC 6b705e7
review
MoritzPotthoffQC 6c868d6
review
MoritzPotthoffQC 6802592
review
MoritzPotthoffQC d827967
refactor
MoritzPotthoffQC 2a49d96
simplify
MoritzPotthoffQC eef3d3b
simplify
MoritzPotthoffQC e918bbf
simplify
MoritzPotthoffQC 65d80d6
fix
MoritzPotthoffQC ffeb05a
cleanup
MoritzPotthoffQC c116fdf
improve
MoritzPotthoffQC a57dc0f
docs
MoritzPotthoffQC 1adcf78
review
MoritzPotthoffQC 4000181
fix
MoritzPotthoffQC a52e24c
simplify
MoritzPotthoffQC 2d3f152
fix
MoritzPotthoffQC a0955c0
fix
MoritzPotthoffQC 0d9be70
add test
MoritzPotthoffQC 7ecd908
Potential fix for pull request finding
MoritzPotthoffQC f44fc4f
review
MoritzPotthoffQC 8c7c45a
Potential fix for pull request finding
MoritzPotthoffQC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,50 +1,18 @@ | ||
| # Copyright (c) QuantCo 2025-2026 | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| """Metrics computed per column when generating a summary. | ||
|
|
||
| Two families are provided: | ||
|
|
||
| - Metrics in :mod:`~diffly.metrics.change` describe the change between numeric | ||
| columns itself by aggregating over ``right - left``. | ||
| - Metrics in :mod:`~diffly.metrics.data` describe the left and right datasets | ||
| individually, explaining how a change affects the data. | ||
| - :class:`~diffly.metrics.change.ChangeMetric`s in :mod:`~diffly.metrics.change` describe the change between | ||
| numeric columns itself by aggregating over ``right - left``. | ||
| - :class:`~diffly.metrics.data.DataMetric`s in :mod:`~diffly.metrics.data` describe the left and right | ||
| datasets individually, explaining how a change affects the data. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from . import change, data | ||
| from ._common import Metric, MetricFn | ||
| from .change import ( | ||
| _make_numeric_metric, | ||
| max, | ||
| mean, | ||
| mean_absolute_deviation, | ||
| mean_relative_deviation, | ||
| median, | ||
| min, | ||
| quantile, | ||
| std, | ||
| ) | ||
|
|
||
| DEFAULT_METRICS: dict[str, MetricFn | Metric] = { | ||
| **change.DEFAULT_CHANGE_METRICS, | ||
| } | ||
| """The default preset metrics, consisting of the change default set.""" | ||
| from ._common import DEFAULT_METRICS | ||
|
|
||
| __all__ = [ | ||
| "DEFAULT_METRICS", | ||
| "Metric", | ||
| "MetricFn", | ||
| "change", | ||
| "data", | ||
| "max", | ||
| "mean", | ||
| "mean_absolute_deviation", | ||
| "mean_relative_deviation", | ||
| "median", | ||
| "min", | ||
| "quantile", | ||
| "std", | ||
| "_make_numeric_metric", | ||
| ] | ||
| __all__ = ["DEFAULT_METRICS", "change", "data"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,17 @@ | ||
| # Copyright (c) QuantCo 2025-2026 | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| from __future__ import annotations | ||
| from .change import DEFAULT_CHANGE_METRICS, ChangeMetric, ChangeMetricFn | ||
| from .data import DEFAULT_DATA_METRICS, DataMetric, DataMetricFn | ||
|
|
||
| from collections.abc import Callable | ||
| from dataclasses import dataclass | ||
| Metric = ChangeMetric | DataMetric | ||
|
MoritzPotthoffQC marked this conversation as resolved.
|
||
| """A change or data metric paired with a column-applicability selector.""" | ||
|
|
||
| import polars as pl | ||
| import polars.selectors as cs | ||
| MetricFn = ChangeMetricFn | DataMetricFn | ||
| """A bare change or data metric callable, resolved to a :data:`Metric` by arity.""" | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class Metric: | ||
| """A metric function paired with a column-applicability selector.""" | ||
|
|
||
| fn: MetricFn | ||
| selector: cs.Selector | ||
|
|
||
|
|
||
| MetricFn = Callable[[pl.Expr, pl.Expr], pl.Expr] | ||
| """A metric function maps ``(left_expr, right_expr)`` to a scalar aggregation | ||
| expression. | ||
|
|
||
| The expressions refer to the left-side and right-side values of a single column across | ||
| all joined rows. | ||
| """ | ||
| DEFAULT_METRICS: dict[str, Metric] = { | ||
| **DEFAULT_CHANGE_METRICS, | ||
| **DEFAULT_DATA_METRICS, | ||
| } | ||
| """All preset metrics, combining the change and data default sets.""" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.