-
Notifications
You must be signed in to change notification settings - Fork 20
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
Enable passing function or misc slots to the use argument in selection functions #173 #174
Conversation
if(is(pop,"HybridPop")){ | ||
stop("Use='bv' is not a valid option for HybridPop") | ||
if(is.character(use)){ | ||
use = tolower(use) |
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.
I had to move use = tolower(use)
and rand
part within the if
and else
block since use can now be a character or a function.
if(is(pop,"HybridPop")){ | ||
stop("Use='bv' is not a valid option for HybridPop") | ||
if(is.character(use)){ | ||
use = tolower(use) |
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.
I had to move use = tolower(use)
and rand
part within the if
and else
block since use can now be a character or a function.
response = genParam(pop,simParam=simParam)$bv | ||
response = trait(response,...) | ||
}else if(is(use,"function")){ | ||
response = trait(use(pop, ...), ...) |
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.
This should enable max flexibility where both trait
and use
are a function
} | ||
response = genParam(pop,simParam=simParam)$bv[,trait,drop=FALSE] | ||
}else if(is(use,"function")){ | ||
response = use(pop, trait=trait, ...) |
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.
I think this will be the most common case when use
is a function. We likely don't need to really pass trait
to use()
but for consistency/flexibility I felt it's probably best.
As discussed in #173
I have implemented this proposal, documented, and tested it.
I look forward to comments! I will provide some notes by commenting some lines of code - see in the conversation.