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

Minor apparent bug in "error catch" for gmse_apply #65

Closed
jejoenje opened this issue Sep 15, 2020 · 8 comments
Closed

Minor apparent bug in "error catch" for gmse_apply #65

jejoenje opened this issue Sep 15, 2020 · 8 comments
Labels
bug Bugs to address in GMSE code

Comments

@jejoenje
Copy link
Collaborator

Very minor apparent bug which does not seem to be affecting anything much, but points erroneous error specification in manage_target to scaring, while the latter is specified correctly.
Haven't had time to investigate specifically but the reference to input_list[41] which should produce the error message, by my count relates to manage_target in input_list.

Example code to reproduce the "issue" below:

library(GMSE)

### Baseline check:
test1 = gmse_apply(get_res = "Full", scaring = TRUE, manage_target = 1200)

### Reading manager target as vector
MANAGE_TARGET1 = c(1200, 1200)

### Specifying manager target as element of vector, works as expected:
test2 = gmse_apply(get_res = "Full", scaring = TRUE, manage_target = MANAGE_TARGET1[1])

### "Mistake" not specifying manage_target correctly. Note error message relates to scaring, not manage target!
test3 = gmse_apply(get_res = "Full", scaring = TRUE, manage_target = MANAGE_TARGET1)

### Oddly, misspecifying manage_target when it is a list does not produce the same error relating to scaring:
MANAGE_TARGET2 = list(1200, 1200)
test4 = gmse_apply(get_res = "Full", scaring = TRUE, manage_target = MANAGE_TARGET2)

@jejoenje jejoenje added the bug Bugs to address in GMSE code label Sep 15, 2020
@bradduthie
Copy link
Member

Thanks @jejoenje -- I'll take a look. I count the index input_list[41] to be scaring though?

@jejoenje
Copy link
Collaborator Author

Huh, I must have miscounted! Not sure what happened there... Sorry!

Still not sure whats going on re. the error relating to manage_target above, though. It appears I can give it a single TRUE or FALSE without issue, it's just that list it's choking on and blaming scaring.

As I said though, not a big issue at all, just thought I'd put it in here for reference.

@bradduthie
Copy link
Member

Odd. I'll take a look @jejoenje -- I wonder if the vector form of manage_target is somehow screwing up the input_list by not taking the first element? And it does with list? I'm just guessing here, but would be good to find out.

@jejoenje
Copy link
Collaborator Author

Ah, yeah, it probably is that actually. I note input_list is a "straight" concatenation of the input variables, so I guess list or vector inputs where a single value is expected will mess up the order in that vector, and hence the numeric references.
This is an example of a similar issue, with another error message relating to something else:

gmse_apply(get_res = "Full", scaring = c(TRUE, FALSE), manage_target = 1000)

I guess this is OK as long as such a parameter input mistake is actually caught at the error checking stage... Not sure what would happen if not - more than likely just a crash, but I can imagine there may be a (perhaps exceptional) case where everyhing is passed and gmse_apply appears to run but just not with the expected inputs?

@bradduthie
Copy link
Member

It might be good to write a function that just checks all relevant inputs to make sure that they are scalars? At least, we might want to check the obvious ones that should be TRUE/FALSE for the user and raise a flag if they're trying to insert something with the wrong structure. I'll add it to the TODO list for v0.7.

@jejoenje
Copy link
Collaborator Author

Sounds good @bradduthie. I will definitely help with the TODO list (sorry for being rubbish so far!).
Was also wondering if it would be possible to switch to named vectors/lists for parameter inputs, just to avoid confusion, but this may be rather a lot of rewriting and perhaps overkill.

@bradduthie
Copy link
Member

Cheers! I guess a named vector/list switch would depend on how much would need to be refactored and changed, and how it might affect the backwards compatibility.

@bradduthie bradduthie mentioned this issue Jul 27, 2021
26 tasks
@bradduthie
Copy link
Member

I think I have this one fixed (or, at least, giving an appropriate error message). I'll tag this and then close it when I push the commit.

bradduthie added a commit that referenced this issue Jul 28, 2021
…aised. This should now give an error when trying to input an argument with more elements than it is supposed to take
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs to address in GMSE code
Projects
None yet
Development

No branches or pull requests

2 participants