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

Enable passing function or misc slots to the use argument in selection functions #173 #174

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

gregorgorjanc
Copy link
Contributor

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.

if(is(pop,"HybridPop")){
stop("Use='bv' is not a valid option for HybridPop")
if(is.character(use)){
use = tolower(use)
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 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)
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 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, ...), ...)
Copy link
Contributor Author

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, ...)
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 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.

@gaynorr gaynorr merged commit 67667f7 into gaynorr:devel Jan 24, 2024
@gregorgorjanc gregorgorjanc deleted the feat_173 branch February 12, 2024 05:29
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.

2 participants