Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning for unset 'where' argument in toolGetMapping function #180

Merged
merged 15 commits into from
Sep 28, 2023

Conversation

whitehacker
Copy link
Contributor

As it was discussed here, the changes are made to display a warning to alert users when the where argument is not set in toolGetMapping() function.

}
globalassign("readTest")
expect_warning(readSource("Test", convert = "onlycorrect"),
"No correct function for Test could be found. Set convert to FALSE.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is not testing the warning you added. I think passing convert = FALSE or not passing convert at all might already be enough to trigger your warning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried both options, but the tests failed.

Copy link
Contributor

@fbenke-pik fbenke-pik Aug 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to Pascal's comment, this test is not checking for the right warning.

tests/testthat/test-toolGetMapping.R Outdated Show resolved Hide resolved
@@ -31,6 +31,16 @@ toolGetMapping <- function(name, type = NULL, where = NULL,
returnPathOnly = FALSE, activecalc = NULL) {

setWrapperInactive("wrapperChecks")
if (isWrapperActive("wrapperChecks")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you testing this condition? As this wrapper is being activated in the line before, your new code portion is never executed.

Copy link
Contributor

@fbenke-pik fbenke-pik Aug 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once you remove this line, a lot of tests fail.

The first reason I can see are iinstances where the tests call madrat functions like madrat::regionscode which currently call toolGetMapping without a where argument and therefore now produce the new warning. Here, I am not sure what the right approach is: either add the where argument to madrat functions or enhance the check to not throw the warning when called from within madrat functions. @pfuehrlich-pik what do you think?

There might be other reasons why the test fail, but we can look into them once this reason has been removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing this question on to @tscheypidi

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the isWrapperActive should exactly achieve that the checks are only active outside of madrat functions. What happens if the checks are being performed before the wrapperChecks-wrapper is being deactived?

inst/extdata/test.csv Outdated Show resolved Hide resolved
@fbenke-pik
Copy link
Contributor

fbenke-pik commented Aug 23, 2023

Btw, you have two WIP commits. Please merge the three commits into one for a clean git history once everything else has been solved. (I assume, Pascal and Jan would appreciate it).

@pfuehrlich-pik
Copy link
Contributor

Btw, you have two WIP commits. Please merge the three commits into one for a clean git history once everything else has been solved. (I assume, Pascal and Jan would appreciate it).

I'm fine with WIP commits, I would rather not mess with the history. Clean git history is not really a priority for madrat I believe.

@pfuehrlich-pik pfuehrlich-pik marked this pull request as ready for review September 28, 2023 09:22
@pfuehrlich-pik pfuehrlich-pik merged commit 4d7fcc6 into pik-piam:master Sep 28, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants