Checks selected variable is in choices available.#254
Checks selected variable is in choices available.#254llrs-roche wants to merge 4 commits intomainfrom
Conversation
|
✅ All contributors have signed the CLA |
Code Coverage SummaryDiff against mainResults for commit: c33e92d Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Unit Tests Summary 1 files 24 suites 6s ⏱️ Results for commit c33e92d. ♻️ This comment has been updated with latest results. |
|
@llrs-roche would you be able to share a tmg example where it didnt fail with a warning and now it fails, and a print screen of the current and expected behavior? Thanks |
|
I have read the CLA Document and I hereby sign the CLA |
|
NB there is an I myself don't believe it's worth it to make this situation an error unless you go through the entire package and change similar places consistently but then I'm not an author here 😉 |
|
@m7pr @chlebowa I added a test case showing that this didn't fail previously at least with just teal.transform code: The current expected behavior is to fail if you requests "OS" but only have "PARAMCD" as variable. |
|
Sorry for not being specific. What I was trying to say is the current design (I believe) is to not treat this situation as an error, which is why your added test didn't fail. This is a design choice that is reflected throughout the package. This change alters that design choice but only for this particular case. If you think this is warranted (with which I respectfully disagree), you should probably apply it in other places as well. I may have been wrong about the |
| if (is.character(selected) && !inherits(choices, "delayed_variable_choices")) { | ||
| if (!all(selected %in% choices$var_choices) || !all(selected %in% choices$var_label)) { | ||
| stop("Selected, '", selected, "' is not in the available choices.") | ||
| } | ||
| } |
There was a problem hiding this comment.
Is it possible to determine this at this point? If choices are delayed, we can't guess if selected is a subset of the chocies.
|
@llrs-roche Let's close it and maybe address the issue here #255 |
|
I'll close but that might make increase the scope of #255. |
Pull Request
Fixes #253
This is a very minimal PR to help users use
choices_selectedandvalue_choicestogether (see test added).The nested if is a matter of style to avoid having a line above 120 characters which would be flagged by the linter.