feat: add % of Stores (numeric distribution) metric#457
Conversation
Add PctOfStores class that computes the percentage of stores selling each product. Includes ratio_metric utility in metrics/base.py for safe division with NaN on zero denominator. Also refactors ACV to use the updated conventions: group_by → group_col, keyword-only params, unconditional validate_columns, and input handling before parameter validation. Updates docs, CLAUDE.md, ColumnHelper, and consolidates duplicate tests across date and options modules. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @murray-ds's task in 2m 21s —— View job PR Review: feat: add % of Stores (numeric distribution) metric
Overall this is a clean, well-structured PR. The
|
| Area | Status |
|---|---|
| Core logic correctness | ✅ |
| Edge cases (empty, single store, dedupe, within_group) | ✅ |
API consistency with Acv conventions |
✅ |
| Test quality | ✅ |
Missing test for new TypeError in date.py |
|
.count() vs .nunique() semantic clarity |
Minor |
| Codecov partial branch | Minor |
🚀 Cloudflare Pages Deployment✅ Preview deployed successfully! Preview URL: https://52253f13.pyretailscience-docs.pages.dev This preview will be updated automatically when you push new changes to this PR. |
Codecov Report❌ Patch coverage is
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
- Add full Google-style docstring to _normalize_datetime (#10) - Adopt ColumnHelper in test_acv.py for consistency (#7) - Rename misleading test_within_group_with_user_column_named_total_stores to test_within_group_ignores_unrelated_extra_columns (#4) - Add group_col/within_group examples to docs/metrics.md (#9) - Fix PR description: product_col is str | None, not list (#2) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
product_col now accepts str | list[str] | None as specified in the metric spec. Adds test_custom_product_col_list to verify multi-column product granularity. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Assume Ibis datasets could be 1B–10B rows; avoid redundant operations on already-deduplicated data and prefer the cheapest correct operation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
PctOfStoresclass inpyretailscience/metrics/distribution/pct_of_stores.pythat computes the percentage of stores selling each product (numeric distribution)ratio_metricutility inpyretailscience/metrics/base.pyfor safe division with NaN on zero denominatorAcvto follow updated conventions:group_by→group_col, keyword-only params, unconditionalvalidate_columns, input handling before parameter validationColumnHelperguideline to CLAUDE.md and addproduct_idtoColumnHelperdocs/metrics.mdanddocs/api/metrics/distribution.mdtest_date.pyandtest_options.pyusingpytest.mark.parametrizeColumnHelperintest_acv.pyfor consistency with new guidelineTest plan
ColumnHelperandgroup_col🤖 Generated with Claude Code