Repository navigation
cd_anomaly() and the consumer chain: accept series outside cd_variables() - #94
Merged
NewGraphEnvironment merged 5 commits intoSep 29, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GignjoKpZADXywTf6pAMgj
Relates to #92 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GignjoKpZADXywTf6pAMgj
cd_anomaly() takes anomaly_type, unit (the anomaly's unit) and long_name from the input where present, falling back to cd_variables() row by row, and aborts on a type it cannot resolve instead of returning NA. cd_trend() carries the metadata through and cd_summary() uses it. One row per variable/period/year is now enforced across cd_baseline, cd_anomaly, cd_compare and cd_trend, so stacked stations are refused rather than pooled; grouped input is accepted. Fixes #92 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GignjoKpZADXywTf6pAMgj
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GignjoKpZADXywTf6pAMgj
This was referenced Sep 29, 2026
NewGraphEnvironment
deleted the
92-cd-anomaly-series-outside-cd-variables
branch
September 29, 2026 05:18
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
cd_anomaly()resolvesanomaly_type,unit(the anomaly's unit, same meaning ascd_variables()$unit) andlong_namefrom the input where present, falling back tocd_variables()row by row. A variable whose type can't be resolved is now an error naming it, not a silentNA. Contract documented under "Input contract" in?cd_anomaly, with a runnable non-ERA5 example.cd_trend()carrieslong_namethrough, plusanomaly_type/unitwhen trending anomalies (not raw values, where the anomaly unit would mislabel the slope).cd_summary()uses them, then the registry, then the variable name.(variable, period, year)is enforced incd_baseline,cd_anomaly,cd_compare,cd_trend, so two stations stacked under onevariableare refused instead of pooled. Grouped input is accepted. The rules live in three shared helpers inR/cd_anomaly.R(series_check,meta_resolve,meta_check).Behaviour changes for existing callers
NAanomalies now errors.(variable, period, year)rows used to be pooled silently; it now errors. All committed vignette series have 0 duplicates.cd_trend(cd_anomaly(...))output has two extra columns (anomaly_type,unit).Suggest a minor bump at merge.
Related Issues
Test plan
devtools::test(): 278 pass, 0 fail (2 warnings are pre-existing, intest-cd_plot_comparison.R)cd_trend(ano)reproduce the committedtrnexactly, andcd_summary()output is identicalpkgdown::check_pkgdown()fails locally on main as well (DESCRIPTION URL), and no exports were addedNotes
Review: one plan review and three code-check rounds found 10 issues and all were fixed. Two sat inside earlier fixes. The last was a plain
ungroup()that turned station-grouped input from an error into silent pooling. The loop ended by enumerating every export against the shared helpers, not on a clean round. Details are inplanning/archive/2026-09-issue-92-series-outside-cd-variables/.Known and not fixed, both pre-existing:
cd_trend()on zero rows returns a tibble with no columns, and a series with no baseline row still getsanomaly = NA.🤖 Generated with Claude Code
https://claude.ai/code/session_01GignjoKpZADXywTf6pAMgj