Skip to content

Commit

Permalink
Removed if checks for isGeneric
Browse files Browse the repository at this point in the history
  • Loading branch information
iagomosqueira committed Dec 2, 2024
1 parent 2a1f8a4 commit 0712ca8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 16 deletions.
3 changes: 2 additions & 1 deletion R/SepVPA.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ FLSepVPA.control <- function(sep.age="missing",sep.sel="missing",sep.nyr="missin
} # }}}

## SepVPA {{{
if (!isGeneric("SepVPA"))
setGeneric("SepVPA", function(stock, ...)
standardGeneric("SepVPA"))

Expand Down Expand Up @@ -156,6 +155,8 @@ setMethod("SepVPA", signature(stock="FLStock"),

# assess(FLSepVPA.control) {{{
# assess(new('FLSepVPA.control'), FLStock())
setGeneric("assess", function(control, ...)
standardGeneric("assess"))
setMethod("assess", signature(control="FLSepVPA.control"),
function(control, ...){

Expand Down
5 changes: 1 addition & 4 deletions R/VPA.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@
setClass('FLVPA', representation('FLAssess'))

## VPA {{{
if (!isGeneric("VPA")) {
setGeneric("VPA", function(stock, ...){
value <- standardGeneric("VPA")
value
standardGeneric("VPA")
})
}
setMethod("VPA",signature(stock="FLStock"),
function(stock, fratio="missing", fit.plusgroup=TRUE, desc="",...) {

Expand Down
11 changes: 0 additions & 11 deletions R/accessors.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ setMethod('harvest', signature(object='FLAssess', catch='missing'),
}
)

if(!isGeneric('index.name'))
setGeneric('index.name', function(object, ...) standardGeneric('index.name'))

setMethod('index.name', signature(object='FLAssess'),
Expand All @@ -33,7 +32,6 @@ setMethod('index.name', signature(object='FLAssess'),
}
)

if(!isGeneric('index.range'))
setGeneric('index.range', function(object, ...) standardGeneric('index.range'))

setMethod('index.range', signature(object='FLAssess'),
Expand All @@ -48,7 +46,6 @@ setMethod('index', signature(object='FLAssess'),
}
)

if(!isGeneric('index.res'))
setGeneric('index.res', function(object, ...) standardGeneric('index.res'))

setMethod('index.res', signature(object='FLAssess'),
Expand All @@ -57,7 +54,6 @@ setMethod('index.res', signature(object='FLAssess'),
}
)

if(!isGeneric('index.hat'))
setGeneric('index.hat', function(object, ...) standardGeneric('index.hat'))

setMethod('index.hat', signature(object='FLAssess'),
Expand All @@ -66,7 +62,6 @@ setMethod('index.hat', signature(object='FLAssess'),
}
)

if(!isGeneric('index.var'))
setGeneric('index.var', function(object, ...) standardGeneric('index.var'))

setMethod('index.var', signature(object='FLAssess'),
Expand Down Expand Up @@ -94,7 +89,6 @@ function(object,value){
if(validObject(object)) object else stop("")
})

if(!isGeneric('index.name<-'))
setGeneric('index.name<-', function(object, ..., value) standardGeneric('index.name<-'))

setMethod('index.name<-', signature(object='FLAssess', value = 'character'),
Expand All @@ -103,7 +97,6 @@ function(object,value){
if(validObject(object)) object else stop("")
})

if(!isGeneric('index.range<-'))
setGeneric('index.range<-', function(object, ..., value)
standardGeneric('index.range<-'))

Expand All @@ -113,7 +106,6 @@ function(object,value){
if(validObject(object)) object else stop("")
})

if(!isGeneric('index<-'))
setGeneric('index<-', function(object, ..., value)
standardGeneric('index<-'))

Expand All @@ -123,7 +115,6 @@ function(object,value){
if(validObject(object)) object else stop("")
})

if(!isGeneric('index.res<-'))
setGeneric('index.res<-', function(object, ..., value) standardGeneric('index.res<-'))

setMethod('index.res<-', signature(object='FLAssess', value = 'FLQuants'),
Expand All @@ -132,7 +123,6 @@ function(object,value){
if(validObject(object)) object else stop("")
})

if(!isGeneric('index.hat<-'))
setGeneric('index.hat<-', function(object, ..., value) standardGeneric('index.hat<-'))

setMethod('index.hat<-', signature(object='FLAssess', value = 'FLQuants'),
Expand All @@ -141,7 +131,6 @@ function(object,value){
if(validObject(object)) object else stop("")
})

if(!isGeneric('index.var<-'))
setGeneric('index.var<-', function(object, ..., value) standardGeneric('index.var<-'))

setMethod('index.var<-', signature(object='FLAssess', value = 'FLQuants'),
Expand Down
3 changes: 3 additions & 0 deletions R/handyfuncs.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ if (!isGeneric("Z"))


# Z(stock=FLStock) {{{
setGeneric("Z", function(stock, ...){
standardGeneric("Z")
})
setMethod("Z", signature(stock="FLStock"),
function(stock, ...){
if(all(is.na(harvest(stock))))
Expand Down

0 comments on commit 0712ca8

Please sign in to comment.