Skip to content

Rename dig*() callback argument weightsdegrees with deprecation shim - #60

Merged
beerda merged 3 commits into
develfrom
copilot/rename-weights-to-degrees
Sep 21, 2026
Merged

beerda merged 3 commits into
develfrom
copilot/rename-weights-to-degrees

Conversation

Copilot AI commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

dig() and dig_grid() callbacks currently use weights for per-row fuzzy truth values. This updates the canonical callback API to degrees, keeps weights temporarily supported, and documents/tests the deprecation path.

  • API change (callback contract)

    • dig() now recognizes degrees as the canonical callback argument.
    • dig_grid(type = "fuzzy") now requires d + (degrees or deprecated weights), with degrees as the primary name.
    • Callback-argument docs were updated accordingly.
  • Backward compatibility + deprecation behavior

    • Legacy callbacks declaring weights continue to work.
    • Deprecation warnings are emitted when weights is used in dig() or dig_grid().
    • Runtime mapping redirects computed degrees values into weights for legacy callback signatures.
  • Core implementation rename (R + C++)

    • Renamed internal argument handling from “weights” terminology to “degrees” in callback plumbing.
    • C++ config/parser now accepts both degrees and weights request tokens, normalizing to degrees semantics.
  • Docs + examples

    • Updated roxygen/man pages and vignettes to use degrees in callback signatures and explanations.
    • Updated NEWS with the rename + deprecation note.
  • Tests

    • Existing callback tests migrated to degrees.
    • Added explicit deprecation coverage for legacy weights callbacks in both dig() and dig_grid().
# new callback style
dig(x, f = function(condition, degrees) {
  list(weighted_support = sum(degrees) / nrow(x))
})

# legacy style (still works, now deprecated)
dig(x, f = function(condition, weights) {
  list(weighted_support = sum(weights) / nrow(x))
})

Copilot AI and others added 2 commits September 21, 2026 13:14
Co-authored-by: beerda <26056018+beerda@users.noreply.github.com>
Co-authored-by: beerda <26056018+beerda@users.noreply.github.com>
@codecov

codecov Bot commented Sep 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.72727% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.26%. Comparing base (0ac9940) to head (3d70350).

Files with missing lines Patch % Lines
R/dig_grid.R 84.61% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            devel      #60   +/-   ##
=======================================
  Coverage   87.25%   87.26%           
=======================================
  Files         134      134           
  Lines        6907     6942   +35     
=======================================
+ Hits         6027     6058   +31     
- Misses        880      884    +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The na_rm handling has a moderate correctness issue, and warning/parser coverage needs strengthening.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Low severity

Open (2)
What changed in this PR

Renames the fuzzy callback argument from weights to canonical degrees while preserving deprecated legacy callbacks.

Changes:

  • Adds degrees handling with deprecated weights compatibility and warnings.
  • Updates R/C++ plumbing, documentation, vignettes, NEWS, and tests.
File Summary and review notes
vignettes/​nuggets.Rmd Updated callback example.
vignettes/​custom-patterns.Rmd Updated callback documentation and examples.
tests/​testthat/​test-dig.R Nit (3 votes): Assert the deprecation warning instead of suppressing it.
tests/​testthat/​test-dig_grid.R Nit (2 votes): Assert deprecation warnings at the affected calls on lines 417 and 426.
src/​test-dig-Config.cpp Nit (1 vote): Add degrees and weights parser cases asserting hasDegreesArgument().
src/​dig/​Pattern.h Renamed stored degree accessor.
src/​dig/​Digger.h Passes degree callbacks.
src/​dig/​Config.h Nit (1 vote): Add parser coverage for both argument tokens.
src/​dig/​CallbackCaller.h Emits degrees callback values.
R/​dig.R Adds legacy callback mapping and deprecation warning.
R/​dig_tautologies.R Updated terminology.
R/​dig_itemsets.R Updated terminology.
R/​dig_grid.R Moderate (1 vote): Correct na_rm = TRUE handling so degrees retains matching length and drops omitted indices only when applicable.
R/​dig_associations.R Updated terminology.
NEWS.md Documents the rename and deprecation.
man/​dig.Rd Updated documentation.
man/​dig_tautologies.Rd Updated terminology.
man/​dig_itemsets.Rd Updated terminology.
man/​dig_grid.Rd Updated documentation.
man/​dig_associations.Rd Updated terminology.
Files not reviewed (5)
  • man/dig.Rd: Generated file
  • man/dig_associations.Rd: Generated file
  • man/dig_grid.Rd: Generated file
  • man/dig_itemsets.Rd: Generated file
  • man/dig_tautologies.Rd: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/testthat/test-dig.R
Comment on lines +263 to +265
suppressWarnings(
res <- dig(m, function(weights) list(w = weights))
)
Comment on lines +417 to +424
suppressWarnings(
res <- dig_grid(x = d,
f = f,
type = "fuzzy",
condition = where(is.numeric),
xvars = where(is.character),
yvars = where(is.character))
)
@beerda
beerda merged commit 0eca276 into devel Sep 21, 2026
8 of 9 checks passed
@beerda
beerda deleted the copilot/rename-weights-to-degrees branch September 21, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants