Repository navigation
Conversation
The length / as.integer / is.character combinations repeated across the package made the argument checks hard to read. is_integerish(), is_scalar_integerish(), is_scalar_numeric(), is_scalar_character() and is_scalar_logical() replace them everywhere; none accepts NA, so a few checks become stricter: id_periods must be whole numbers, select_maximize may not be NA, next_id() rejects a fractional n instead of truncating it, and create_coords_t_square() takes an integer resolution too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019fog72qNWbuSjiGBWuP3np
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.
Stacked on #57, as asked in its review. Merge #57 first; this PR's base then moves to
develop.The argument checks spelled out
length(x) == 1L && as.integer(x) == xand similar combinations in every function.R/util.Rnow has predicates for the conditions of a namedstopifnot(), so the name stays the message the user sees:is_integerish(): finite whole numbers, any length including 0;is_scalar_integerish();is_scalar_numeric();is_scalar_character();is_scalar_logical():TRUEorFALSE.None of them accepts
NA.They replace the hand-written checks throughout
R/: allocators, views,neighbors_t,pred_data_t,runs_t,trans_models_t,lp_problem,ducklake_db,coords_tandvalidation.devdocs/style/r.mdpoints to them.The only check left spelled out is
distance_breaksinneighbors_t, which needs at least two elements. Thetrans_rates_lppenalty checks stay as they are becauseterminal_bandmay beNA.Stricter checks
id_periodsinalloc_clumpy(),alloc_dinamica()andalloc_greedy()must be whole numbers, not just numeric.select_maximizemay not beNA. Inalloc_dinamica()'seval_alloc_params_t()path, the oldselect_maximize || !select_maximizealso accepted non-logical values.$next_id(n = )rejects a fractionalninstead of truncating it.create_coords_t_square()accepts an integerresolutionas well as a double, and now reports throughstopifnot()instead ofstop().Tests
test_util.Rchecks each predicate against 11 candidate values:1L,1,1.5,c(1, 2),integer(0),NA_integer_,Inf,"1","a",TRUEandNA.tinytest::build_install_test(): all ok, 656 results.Generated by Claude Code