fix(nitrogen): port sjos_levels in the afsetools order it documents - #772
Open
lbm364dl wants to merge 1 commit into
Open
fix(nitrogen): port sjos_levels in the afsetools order it documents#772lbm364dl wants to merge 1 commit into
lbm364dl wants to merge 1 commit into
Conversation
whep::sjos_levels documents its labels, order and colours as ported by value from afsetools::load_vectors(), but afsetools wraps SJOS_levels in rev() (load_vectors.R:684), so its realised element 1 is "Exceedance Over" while whep assigned order = 1L to "Within_boundary Under". The colours were ported correctly; only the ordering was inverted. classify_sjos_n() uses sjos_levels$level as the factor levels of its sjos_class column, so the inversion did not change any classification value — only the level order, i.e. the stacking and legend order of any figure meant to reproduce Global's, which stacks on the reversed vector (Global/R/SJOS_N_figs.R:188). nourish_levels was already literal about its own source vector (Nour_levels, unreversed), so this makes the two tables consistent in how they port from afsetools. Reverses the sjos_levels rows (and rebuilds data/sjos_levels.rda), and states the ordering explicitly in the roxygen so it reads as the ported choice it is rather than an accident. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
What was wrong (mechanism)
whep::sjos_levelsdocuments its level labels and colours as ported by valuefrom
afsetools::load_vectors(), but afsetools wrapsSJOS_levelsinrev():so its realised element 1 is
"Exceedance Over". whep assignedorder = 1Lto"Within_boundary Under"— the ordering was inverted relative to the vector itsays it ported. Verified by reading both files; the six colours match
SJOS_coloursexactly, only the order differed.No classification value changes:
classify_sjos_n()usessjos_levels$levelonly as the factor levels of
sjos_class, so membership is unaffected. Whatchanges is
levels(sjos_class), i.e. the stacking and legend order of anyfigure built from these levels — and Global stacks on the reversed vector
(
Global/R/SJOS_N_figs.R:188,Global/R/SJOS_N.R:241), so the reversed orderis the one that reproduces its figures.
Classification: mechanical (faithfulness to a named source), with one visible
presentation consequence stated above. The issue offered the alternative of
keeping whep's ascending order and rewording the
@sourceinstead; I took thefaithful-port option because
nourish_levelsis already literal about its ownsource vector (
Nour_levels, unreversed atload_vectors.R:683), so the twotables now port from afsetools the same way, and because it is the order
Global's figures use. Happy to flip to the doc-only option if you prefer the
ascending reading — say so and I will.
What changed
data-raw/sjos_n_coefficients.R:sjos_levelsrows reversed(
"Exceedance Over"= 1L …"Within_boundary Under"= 6L), with a commentnaming
load_vectors.R:684and therev().data/sjos_levels.rdarebuilt by re-running the builder (the other threetables it writes came out byte-identical).
R/datasets_sjos_n.R:@description/@format/@sourcenow state theordering explicitly, so it is a stated ported choice rather than an accident.
tests/testthat/test_datasets_sjos_n.R: the order assertion now comparesagainst
rev(<ascending vector>)— written the way afsetools writes it — andadditionally asserts
order == seq_along(level).Verification
man/regenerated withdevtools::document(),air format .run, bothchanged R files and the data-raw script lint clean.
Test failing before the fix (old
data/sjos_levels.rdarestored viagit stash, new test in place):Passing after, together with the consumers and the data-raw freshness gate:
Not carried (out of scope, still open in the issue text): afsetools
Nourish_colours_tot/Nourish_levels_tot, the "Total" variants.Closes #754.
🤖 Generated with Claude Code