Remove unreachable checks and improve test coverage - #1291
Merged
Merged
Conversation
…sted The v1.0 coverage review (rc-work/coverage-review.md) went through every uncovered line. Some were checks nothing can reach: validate_exe_file() runs after the model's own assert_current() has already caught a missing executable, validate_build_record() rechecked a format_version that read_build_record() checks before calling it, and the draws-format helpers carried rvars cases that assert_valid_draws_format() rejects first. Those go, along with .remove_leftmost_dim()'s branches for shapes draws_of() never produces and an unused CmdStanProcs getter. The guard against reading a fit whose chains all failed was repeated in six public methods with three different messages. It now lives only in each class's read_csv_(), which every reader reaches, so $draws(), $summary(), $print(), $metadata(), $sampler_diagnostics() and $inv_metric() give the same error, and the shared $draws() no longer errors when the draws are already cached. The new tests go through the public API. One existing test gets fixed: it passed `variables =` to posterior::subset_draws(), which ignores it, so the "draws_array without lp__" test had been running with lp__ all along. Part of #1258.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v1.0 #1291 +/- ##
=======================================
Coverage ? 93.89%
=======================================
Files ? 19
Lines ? 7289
Branches ? 0
=======================================
Hits ? 6844
Misses ? 445
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
On Windows stanc ends its output lines with CRLF, and format() passes that through, so capture.output() left a carriage return on each line and the line that is exactly 30 characters long measured 31. Reading the file format_stan_file() writes back with readLines() drops the line terminator on every platform. Part of #1258.
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.
Submission Checklist
Summary
Part of #1258. Before the v1.0 release candidate we went through every
line Codecov reports as uncovered (Linux and Windows sessions merged) and
decided each one: a test, a removal, or an accepted gap.
Removed, because nothing can reach them:
validate_exe_file(): every method that runs the executable calls themodel's
assert_current()first, which already reports a missingexecutable.
format_versioncheck invalidate_build_record():read_build_record()checks the version before calling the validatorand
new_build_record()writes it.assert_valid_draws_format()rejects that format first.
$unconstrain_draws()now uses that assertioninstead of its own check.
.remove_leftmost_dim()for shapesdraws_of()neverproduces, and the unused
show_stderr_messages()getter.The guard against reading a fit whose chains all failed was repeated in
six public methods with three different messages. It now lives only in
each class's
read_csv_(), so$draws(),$summary(),$print(),$metadata(),$sampler_diagnostics()and$inv_metric()give the sameerror, and
$draws()no longer errors when the draws are already cached.No NEWS entry: only the wording of that error changes.
New tests go through the public API:
iter_warmup = 0withsave_warmup = TRUE, a fit asinitthat failed or has differentparameters,
$diagnostic_summary(quiet = TRUE),$loo(r_eff = TRUE),$print(line_numbers = TRUE),format_stan_file()withcanonicalize = TRUEandmax_line_length, the release-candidate branch ofcmdstan_default_path(), a makefile without a version line, the knitrengine's cache branches,
save_object(format = "qs2")without qs2, thepathfinder method in the shared fit tests, and the remaining draws-format
values. One existing test is fixed: it passed
variables =toposterior::subset_draws(), which ignores it, so the "draws_arraywithout lp__" test had been running with
lp__all along.Left uncovered on purpose: the WSL helpers (the WSL job runs the checks,
not covr, and adding covr there would take about as long again), code
that needs a failing CmdStan build or download, and guards in the
stdout state machine for output CmdStan doesn't print.
Copyright and Licensing
Please list the copyright holder for the work you are submitting
(this will be you or your assignee, such as a university or company):
Jonah Gabry
By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the following licenses: