Commit 5143b123 authored by Delaigue Olivier's avatar 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
......@@ -12,7 +12,7 @@ CalGR <- function(PrepGR, CalCrit = c("NSE", "KGE", "KGE2", "RMSE"),
}
if (! any(class(PrepGR) %in% "PrepGR")) {
if (!inherits(PrepGR, "PrepGR")) {
stop("Non convenient data for argument \"PrepGR\". Must be of class \"PrepGR\"")
}
......
......@@ -12,7 +12,7 @@ SimGR <- function(PrepGR, CalGR = NULL, Param, EffCrit = c("NSE", "KGE", "KGE2",
}
if (! any(class(PrepGR) %in% "PrepGR")) {
if (!inherits(PrepGR, "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",
if (missing(Param)) {
Param <- NULL
}
if (! any(class(CalGR) %in% "CalGR") & !is.null(CalGR)) {
if (!inherits(CalGR, "CalGR") & !is.null(CalGR)) {
stop("Non convenient data for argument \"CalGR\". Must be of class \"CalGR\"")
}
if (is.null(CalGR) & is.null(Param)) {
......
......@@ -81,7 +81,7 @@ if (getRversion() >= "2.15.1") {
if (!is.list(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
}
......
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\"")
}
......
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\"")
}
......
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\"")
}
......
......@@ -7,7 +7,7 @@ dyplot.default <- function(x, Qsup = NULL, Qsup.name = "Qsup",
# barChartPrecip <- scan(file = system.file("plugins/barChartPrecip.js", package = "airGRteaching"),
# 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\"")
}
......@@ -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,
Precip = x$InputsModel$Precip,
Qobs = x$Qobs,
......
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\"")
}
if (! any(which %in% c("perf", "iter", "ts"))) {
......
plot.PrepGR <- function(x, type = "l", col.Precip = "royalblue", col.Q = "black", col.na = "grey",
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\"")
}
......
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\"")
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment