feat: Add data metrics for numeric columns - #46
Conversation
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: EgeKaraismailogluQC <[email protected]>
…_fraction.py Co-authored-by: EgeKaraismailogluQC <[email protected]>
Co-authored-by: quant-ranger[bot] <132915763+quant-ranger[bot]@users.noreply.github.com> Co-authored-by: Marius Merkle <[email protected]> Co-authored-by: Marius Merkle <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #46 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 13 13
Lines 1127 1127
=========================================
Hits 1127 1127 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds additional data metrics (computed per-side, then rendered as old -> new (delta)) for numeric columns, and updates summary rendering + golden fixtures to accommodate the expanded metric set.
Changes:
- Added new data-metric functions (
mean_data,median_data,min_data,max_data,std_data) and expandedDEFAULT_DATA_METRICS. - Updated summary table rendering to apply consistent overflow handling to metric columns.
- Updated tests, docs, and regenerated summary fixtures to reflect the new preset metrics/labels and the updated table layout.
Reviewed changes
Copilot reviewed 86 out of 86 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| diffly/metrics/data.py | Adds numeric “data” metrics and updates the data-metric presets/utilities. |
| diffly/summary.py | Applies consistent overflow behavior to metric columns in the Columns section. |
| docs/api/metrics.rst | Updates API docs to list the newly added data metrics and renamed null-fraction metric. |
| tests/test_metrics.py | Adds unit tests for new data metrics and renames null-fraction test targets. |
| tests/cli/test_cli.py | Updates CLI metric-selection test to use the new data-metric preset label. |
| tests/summary/fixtures/metrics_null_fraction/test_metrics_null_fraction.py | Updates fixture generator test to use the expanded data-metric preset set. |
| tests/summary/fixtures/metrics_presets_many/gen/pretty_True_perfect_True_top_True_slim_True_sample_rows_True_sample_pk_True.txt | Golden fixture updated for new/wrapped metric headers. |
| tests/summary/fixtures/metrics_presets_many/gen/pretty_True_perfect_True_top_True_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for new/wrapped metric headers. |
| tests/summary/fixtures/metrics_presets_many/gen/pretty_True_perfect_True_top_True_slim_False_sample_rows_True_sample_pk_True.txt | Golden fixture updated for new/wrapped metric headers. |
| tests/summary/fixtures/metrics_presets_many/gen/pretty_True_perfect_True_top_True_slim_False_sample_rows_False_sample_pk_False.txt | Golden fixture updated for new/wrapped metric headers. |
| tests/summary/fixtures/metrics_presets_many/gen/pretty_True_perfect_False_top_True_slim_True_sample_rows_True_sample_pk_True.txt | Golden fixture updated for new/wrapped metric headers. |
| tests/summary/fixtures/metrics_presets_many/gen/pretty_True_perfect_False_top_True_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for new/wrapped metric headers. |
| tests/summary/fixtures/metrics_presets_many/gen/pretty_True_perfect_False_top_True_slim_False_sample_rows_True_sample_pk_True.txt | Golden fixture updated for new/wrapped metric headers. |
| tests/summary/fixtures/metrics_presets_many/gen/pretty_True_perfect_False_top_True_slim_False_sample_rows_False_sample_pk_False.txt | Golden fixture updated for new/wrapped metric headers. |
| tests/summary/fixtures/metrics_presets_many/gen/pretty_False_perfect_True_top_True_slim_True_sample_rows_True_sample_pk_True.txt | Golden fixture updated for new/wrapped metric headers. |
| tests/summary/fixtures/metrics_presets_many/gen/pretty_False_perfect_True_top_True_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for new/wrapped metric headers. |
| tests/summary/fixtures/metrics_presets_many/gen/pretty_False_perfect_True_top_True_slim_False_sample_rows_True_sample_pk_True.txt | Golden fixture updated for new/wrapped metric headers. |
| tests/summary/fixtures/metrics_presets_many/gen/pretty_False_perfect_True_top_True_slim_False_sample_rows_False_sample_pk_False.txt | Golden fixture updated for new/wrapped metric headers. |
| tests/summary/fixtures/metrics_presets_many/gen/pretty_False_perfect_False_top_True_slim_True_sample_rows_True_sample_pk_True.txt | Golden fixture updated for new/wrapped metric headers. |
| tests/summary/fixtures/metrics_presets_many/gen/pretty_False_perfect_False_top_True_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for new/wrapped metric headers. |
| tests/summary/fixtures/metrics_presets_many/gen/pretty_False_perfect_False_top_True_slim_False_sample_rows_True_sample_pk_True.txt | Golden fixture updated for new/wrapped metric headers. |
| tests/summary/fixtures/metrics_presets_many/gen/pretty_False_perfect_False_top_True_slim_False_sample_rows_False_sample_pk_False.txt | Golden fixture updated for new/wrapped metric headers. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_False_slim_True_sample_rows_True_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_False_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_False_slim_False_sample_rows_True_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_True_top_False_slim_False_sample_rows_False_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_False_slim_True_sample_rows_True_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_False_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_False_slim_False_sample_rows_True_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_True_perfect_False_top_False_slim_False_sample_rows_False_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_True_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_True_slim_False_sample_rows_False_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_False_slim_True_sample_rows_True_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_False_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_False_slim_False_sample_rows_True_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_True_top_False_slim_False_sample_rows_False_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_True_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_True_slim_False_sample_rows_False_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_False_slim_True_sample_rows_True_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_False_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_False_slim_False_sample_rows_True_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_null_fraction/gen/pretty_False_perfect_False_top_False_slim_False_sample_rows_False_sample_pk_False.txt | Golden fixture updated for expanded data metrics in the Columns table. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_True_perfect_True_top_True_slim_True_sample_rows_True_sample_pk_True.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_True_perfect_True_top_True_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_True_perfect_True_top_True_slim_False_sample_rows_True_sample_pk_True.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_True_perfect_True_top_True_slim_False_sample_rows_False_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_True_perfect_True_top_False_slim_True_sample_rows_True_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_True_perfect_True_top_False_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_True_perfect_True_top_False_slim_False_sample_rows_True_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_True_perfect_True_top_False_slim_False_sample_rows_False_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_True_perfect_False_top_True_slim_True_sample_rows_True_sample_pk_True.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_True_perfect_False_top_True_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_True_perfect_False_top_False_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_True_perfect_False_top_False_slim_False_sample_rows_True_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_True_perfect_False_top_False_slim_False_sample_rows_False_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_False_perfect_True_top_True_slim_True_sample_rows_True_sample_pk_True.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_False_perfect_True_top_True_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_False_perfect_True_top_True_slim_False_sample_rows_True_sample_pk_True.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_False_perfect_True_top_True_slim_False_sample_rows_False_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_False_perfect_True_top_False_slim_True_sample_rows_True_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_False_perfect_True_top_False_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_False_perfect_True_top_False_slim_False_sample_rows_True_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_False_perfect_True_top_False_slim_False_sample_rows_False_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_False_perfect_False_top_True_slim_True_sample_rows_True_sample_pk_True.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_False_perfect_False_top_True_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_False_perfect_False_top_True_slim_False_sample_rows_True_sample_pk_True.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_False_perfect_False_top_True_slim_False_sample_rows_False_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_False_perfect_False_top_False_slim_True_sample_rows_True_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_False_perfect_False_top_False_slim_True_sample_rows_False_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_False_perfect_False_top_False_slim_False_sample_rows_True_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
| tests/summary/fixtures/metrics_long_labels/gen/pretty_False_perfect_False_top_False_slim_False_sample_rows_False_sample_pk_False.txt | Golden fixture updated for wrapped headers with long metric labels. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 34 out of 34 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
diffly/metrics/data.py:63
- The newly added preset data metrics (Mean/Median/Min/Max) don’t have direct unit-test coverage.
tests/test_metrics.pycurrently tests onlynull_fractionfor data metrics, and there are no assertions anywhere forDEFAULT_DATA_METRICS["Mean"|"Median"|"Min"|"Max"]evaluation/selector behavior. Adding a few small tests (e.g., for a numeric column with/without nulls) would protect these presets from regressions independently of summary fixture generation.
"Mean": DataMetric(
fn=lambda col: col.mean(),
formatter=lambda value: f"{round(value, 2)}",
selector=cs.numeric(),
),
Motivation
Building on #43 and #47, we would like to provide a few more "data" metrics, this time for numeric columns only.
Changes