Replace dispEM with native warning/error and ravenList#659
Merged
Conversation
Drop the dispEM helper and replace all 317 call sites with native
MATLAB warning()/error() using the new ravenList() formatter:
- Add utils/ravenList.m: formats a header + tab-indented item list for
passing to warning() or error(), with optional trim to 10 items.
- Rewrite queries/checkModelStruct.m: replace evalc-based collect mode
with a nested reportIssue() function that closes over throwErrors,
trimWarnings, and the output issues array. Removes parseIssueText.
- Replace dispEM(EM) calls with error('RAVEN:badInput', '%s', EM).
- Replace dispEM(EM, false) calls with warning('RAVEN:warning', '%s', EM).
- Replace dispEM(EM, false, list) with warning using ravenList(EM, list).
- Delete utils/dispEM.m.
- Update testing/function_tests/tUtils.m to test ravenList instead.
Function test results206 tests 185 ✅ 38s ⏱️ Results for commit 8a09516. ♻️ This comment has been updated with latest results. |
ravenList: return header unchanged when items is empty, so callers
that pass an empty list do not crash in strjoin.
checkModelStruct/reportIssue: when called with three arguments and the
items list is empty, return silently (matches the original dispEM
behaviour where dispEM(msg, flag, {}) was a no-op). Without this guard,
checks that produce empty lists (e.g. the grRules start/end check when
no violations exist) incorrectly threw or warned with no items.
- tQueries/checkModelStructValidModel: drop verifyWarningFree. The old dispEM helper used fprintf (invisible to verifyWarningFree); advisory checks now issue proper MATLAB warnings via warning(), so the test expectation changes from no-warnings to no-thrown-error. - checkModelStruct/reportIssue: tighten the silent-no-op comment. - INIT/ftINIT.m: remove dead commented-out code block (flux-sanity check that was already disabled). - reconstruction/guessComposition.m: remove two commented-out composition-mismatch warning blocks.
Removed comments about flux handling in reactions.
Contractions expanded (does not, cannot, will not, etc.), single-quoted strings in doc-comment examples converted to double-quoted, possessives reworded. Code lines and MATLAB transpose operators left untouched.
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
utils/ravenList.m: thin formatter that takes a header string and item list, returnsheader + newline + tab-indented itemsready forwarning()/error(). Trims to 10 items by default.queries/checkModelStruct.m: replace theevalc-based collect mode with a nestedreportIssue(severity, msg, items)function that closes overthrowErrors,trimWarnings, and the outputissuesarray. TheparseIssueTextsubfunction is removed.dispEMcall sites (317 calls across 67 files):dispEM(EM)→error('RAVEN:badInput', ...),dispEM(EM, false)→warning('RAVEN:warning', ...), withravenList()for calls that pass an item list.utils/dispEM.m.testing/function_tests/tUtils.m: replace the threedispEM-specific tests with threeravenListunit tests covering basic formatting, default trim, and explicit no-trim.Motivation
dispEMhad several problems: it usedfprintfto print warnings (bypassing the MATLAB warning system and makingwarning('off', ...)ineffective), it threwMException('')with an empty ID (making errors uncatchable by category), it usedtextwrapwithget(0,'CommandWindowSize')which crashes in headless mode, andcheckModelStructcollected issues by calling itself recursively and parsing its own stdout.Test plan
tUtils— all threeravenListtests passcheckModelStruct(model)on a valid model — no outputcheckModelStruct(model)on a model with issues — warnings/errors emittedissues = checkModelStruct(model)— returns struct array without printingwarning('off', 'RAVEN:warning')suppresses advisory warnings