-
Notifications
You must be signed in to change notification settings - Fork 34
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
checkfunargs: use defaults, allow ellipses #102
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -313,16 +313,22 @@ function( x0, | |
if( any(is.na(m1)) ){ | ||
mx1 = which( is.na(m1) ) | ||
for( i in 1:length(mx1) ){ | ||
stop(paste(funname, " requires argument '", fnms[mx1[i]], "' but this has not been passed to the 'nloptr' function.\n", sep = "")) | ||
has_default = !(fnms[mx1[i]] == "") | ||
if (!has_default) { | ||
stop(paste(funname, " requires argument '", fnms[mx1[i]], "' but this has not been passed to the 'nloptr' function.\n", sep = "")) | ||
} | ||
} | ||
} | ||
m2 = match(rnms, fnms) | ||
if( any(is.na(m2)) ){ | ||
mx2 = which( is.na(m2) ) | ||
for( i in 1:length(mx2) ){ | ||
stop(paste(rnms[mx2[i]], "' passed to (...) in 'nloptr' but this is not required in the ", funname, " function.\n", sep = "")) | ||
if( !("..." %in% names(flist)) ) { | ||
m2 = match(rnms, fnms) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you run again this? It is already in |
||
if( any(is.na(m2)) ){ | ||
mx2 = which( is.na(m2) ) | ||
for( i in 1:length(mx2) ){ | ||
stop(paste(rnms[mx2[i]], "' passed to (...) in 'nloptr' but this is not required in the ", funname, " function.\n", sep = "")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove parenthesis around ellipsis. |
||
} | ||
} | ||
} | ||
m2 = match(rnms, fnms) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you run again this? It is already in |
||
} | ||
return( 0 ) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be checking the value in the list here, not the name, i.e.
has_default = flist[[mx1[i] + 1]] != ""
.