Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
HYCAR-Hydro
airGRteaching
Commits
5143b123
Commit
5143b123
authored
Aug 04, 2021
by
Delaigue Olivier
Browse files
refactor: replace the use of 'class' by 'inherits' in all check conditions
Refs
#45
parent
e088b828
Pipeline
#26071
passed with stage
in 1 minute and 44 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
R/CalGR.R
View file @
5143b123
...
@@ -12,7 +12,7 @@ CalGR <- function(PrepGR, CalCrit = c("NSE", "KGE", "KGE2", "RMSE"),
...
@@ -12,7 +12,7 @@ CalGR <- function(PrepGR, CalCrit = c("NSE", "KGE", "KGE2", "RMSE"),
}
}
if
(
!
any
(
clas
s
(
PrepGR
)
%in%
"PrepGR"
))
{
if
(
!
inherit
s
(
PrepGR
,
"PrepGR"
))
{
stop
(
"Non convenient data for argument \"PrepGR\". Must be of class \"PrepGR\""
)
stop
(
"Non convenient data for argument \"PrepGR\". Must be of class \"PrepGR\""
)
}
}
...
...
R/SimGR.R
View file @
5143b123
...
@@ -12,7 +12,7 @@ SimGR <- function(PrepGR, CalGR = NULL, Param, EffCrit = c("NSE", "KGE", "KGE2",
...
@@ -12,7 +12,7 @@ SimGR <- function(PrepGR, CalGR = NULL, Param, EffCrit = c("NSE", "KGE", "KGE2",
}
}
if
(
!
any
(
clas
s
(
PrepGR
)
%in%
"PrepGR"
))
{
if
(
!
inherit
s
(
PrepGR
,
"PrepGR"
))
{
stop
(
"Non convenient data for argument \"PrepGR\". Must be of class \"PrepGR\""
)
stop
(
"Non convenient data for argument \"PrepGR\". Must be of class \"PrepGR\""
)
}
}
...
@@ -23,7 +23,7 @@ SimGR <- function(PrepGR, CalGR = NULL, Param, EffCrit = c("NSE", "KGE", "KGE2",
...
@@ -23,7 +23,7 @@ SimGR <- function(PrepGR, CalGR = NULL, Param, EffCrit = c("NSE", "KGE", "KGE2",
if
(
missing
(
Param
))
{
if
(
missing
(
Param
))
{
Param
<-
NULL
Param
<-
NULL
}
}
if
(
!
any
(
clas
s
(
CalGR
)
%in%
"CalGR"
)
&
!
is.null
(
CalGR
))
{
if
(
!
inherit
s
(
CalGR
,
"CalGR"
)
&
!
is.null
(
CalGR
))
{
stop
(
"Non convenient data for argument \"CalGR\". Must be of class \"CalGR\""
)
stop
(
"Non convenient data for argument \"CalGR\". Must be of class \"CalGR\""
)
}
}
if
(
is.null
(
CalGR
)
&
is.null
(
Param
))
{
if
(
is.null
(
CalGR
)
&
is.null
(
Param
))
{
...
...
R/Utils.R
View file @
5143b123
...
@@ -81,7 +81,7 @@ if (getRversion() >= "2.15.1") {
...
@@ -81,7 +81,7 @@ if (getRversion() >= "2.15.1") {
if
(
!
is.list
(
x
))
{
if
(
!
is.list
(
x
))
{
x
<-
list
(
TypeModel
=
x
)
x
<-
list
(
TypeModel
=
x
)
}
}
if
(
any
(
class
(
x
)
%in%
c
(
"PrepGR"
,
"CalGR"
,
"SimGR"
))
||
names
(
x
)
%in%
"TypeModel"
)
{
if
(
inherits
(
x
,
c
(
"PrepGR"
,
"CalGR"
,
"SimGR"
))
||
names
(
x
)
%in%
"TypeModel"
)
{
x
<-
x
$
TypeModel
x
<-
x
$
TypeModel
}
}
...
...
R/dyplot.CalGR.R
View file @
5143b123
dyplot.CalGR
<-
function
(
x
,
...
)
{
dyplot.CalGR
<-
function
(
x
,
...
)
{
if
(
!
any
(
class
(
x
)
%in%
"CalGR"
))
{
if
(
!
inherits
(
x
,
"CalGR"
))
{
stop
(
"Non convenient data for x argument. Must be of class \"CalGR\""
)
stop
(
"Non convenient data for x argument. Must be of class \"CalGR\""
)
}
}
...
...
R/dyplot.PrepGR.R
View file @
5143b123
dyplot.PrepGR
<-
function
(
x
,
...
)
{
dyplot.PrepGR
<-
function
(
x
,
...
)
{
if
(
!
any
(
class
(
x
)
%in%
"PrepGR"
))
{
if
(
!
inherits
(
x
,
"PrepGR"
))
{
stop
(
"Non convenient data for x argument. Must be of class \"PrepGR\""
)
stop
(
"Non convenient data for x argument. Must be of class \"PrepGR\""
)
}
}
...
...
R/dyplot.SimGR.R
View file @
5143b123
dyplot.SimGR
<-
function
(
x
,
...
)
{
dyplot.SimGR
<-
function
(
x
,
...
)
{
if
(
!
any
(
class
(
x
)
%in%
"SimGR"
))
{
if
(
!
inherits
(
x
,
"SimGR"
))
{
stop
(
"Non convenient data for x argument. Must be of class \"SimGR\""
)
stop
(
"Non convenient data for x argument. Must be of class \"SimGR\""
)
}
}
...
...
R/dyplot.default.R
View file @
5143b123
...
@@ -7,7 +7,7 @@ dyplot.default <- function(x, Qsup = NULL, Qsup.name = "Qsup",
...
@@ -7,7 +7,7 @@ dyplot.default <- function(x, Qsup = NULL, Qsup.name = "Qsup",
# barChartPrecip <- scan(file = system.file("plugins/barChartPrecip.js", package = "airGRteaching"),
# barChartPrecip <- scan(file = system.file("plugins/barChartPrecip.js", package = "airGRteaching"),
# what = "character", quiet = TRUE)
# what = "character", quiet = TRUE)
if
(
!
any
(
class
(
x
)
%in%
c
(
"PrepGR"
,
"CalGR"
,
"SimGR"
)))
{
if
(
!
inherits
(
x
,
c
(
"PrepGR"
,
"CalGR"
,
"SimGR"
)))
{
stop
(
"Non convenient data for x argument. Must be of class \"PrepGR\", \"CalGR\" or \"SimGR\""
)
stop
(
"Non convenient data for x argument. Must be of class \"PrepGR\", \"CalGR\" or \"SimGR\""
)
}
}
...
@@ -34,7 +34,7 @@ dyplot.default <- function(x, Qsup = NULL, Qsup.name = "Qsup",
...
@@ -34,7 +34,7 @@ dyplot.default <- function(x, Qsup = NULL, Qsup.name = "Qsup",
}
}
if
(
any
(
class
(
x
)
%in%
"PrepGR"
))
{
if
(
inherits
(
x
,
"PrepGR"
))
{
data
<-
data.frame
(
DatesR
=
x
$
InputsModel
$
DatesR
,
data
<-
data.frame
(
DatesR
=
x
$
InputsModel
$
DatesR
,
Precip
=
x
$
InputsModel
$
Precip
,
Precip
=
x
$
InputsModel
$
Precip
,
Qobs
=
x
$
Qobs
,
Qobs
=
x
$
Qobs
,
...
...
R/plot.CalGR.R
View file @
5143b123
plot.CalGR
<-
function
(
x
,
xlab
=
NULL
,
ylab
=
NULL
,
main
=
NULL
,
which
=
c
(
"perf"
,
"iter"
,
"ts"
),
...
)
{
plot.CalGR
<-
function
(
x
,
xlab
=
NULL
,
ylab
=
NULL
,
main
=
NULL
,
which
=
c
(
"perf"
,
"iter"
,
"ts"
),
...
)
{
if
(
!
any
(
class
(
x
)
%in%
"CalGR"
))
{
if
(
!
inherits
(
x
,
"CalGR"
))
{
stop
(
"Non convenient data for x argument. Must be of class \"CalGR\""
)
stop
(
"Non convenient data for x argument. Must be of class \"CalGR\""
)
}
}
if
(
!
any
(
which
%in%
c
(
"perf"
,
"iter"
,
"ts"
)))
{
if
(
!
any
(
which
%in%
c
(
"perf"
,
"iter"
,
"ts"
)))
{
...
...
R/plot.PrepGR.R
View file @
5143b123
plot.PrepGR
<-
function
(
x
,
type
=
"l"
,
col.Precip
=
"royalblue"
,
col.Q
=
"black"
,
col.na
=
"grey"
,
plot.PrepGR
<-
function
(
x
,
type
=
"l"
,
col.Precip
=
"royalblue"
,
col.Q
=
"black"
,
col.na
=
"grey"
,
xlab
=
NULL
,
ylab
=
NULL
,
main
=
NULL
,
plot.na
=
TRUE
,
...
)
{
xlab
=
NULL
,
ylab
=
NULL
,
main
=
NULL
,
plot.na
=
TRUE
,
...
)
{
if
(
!
any
(
class
(
x
)
%in%
"PrepGR"
))
{
if
(
!
inherits
(
x
,
"PrepGR"
))
{
stop
(
"Non convenient data for x argument. Must be of class \"PrepGR\""
)
stop
(
"Non convenient data for x argument. Must be of class \"PrepGR\""
)
}
}
...
...
R/plot.SimGR.R
View file @
5143b123
plot.SimGR
<-
function
(
x
,
...
)
{
plot.SimGR
<-
function
(
x
,
...
)
{
if
(
!
any
(
class
(
x
)
%in%
"SimGR"
))
{
if
(
!
inherits
(
x
,
"SimGR"
))
{
stop
(
"Non convenient data for x argument. Must be of class \"SimGR\""
)
stop
(
"Non convenient data for x argument. Must be of class \"SimGR\""
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment