diff --git a/R/ta_APO.R b/R/ta_APO.R index 907ac26e..48bc4085 100644 --- a/R/ta_APO.R +++ b/R/ta_APO.R @@ -172,15 +172,7 @@ absolute_price_oscillator.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_BBANDS.R b/R/ta_BBANDS.R index a02d74e4..3676bb6a 100644 --- a/R/ta_BBANDS.R +++ b/R/ta_BBANDS.R @@ -182,15 +182,7 @@ bollinger_bands.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_CMO.R b/R/ta_CMO.R index 746249e3..21301770 100644 --- a/R/ta_CMO.R +++ b/R/ta_CMO.R @@ -151,15 +151,7 @@ chande_momentum_oscillator.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_DEMA.R b/R/ta_DEMA.R index 8dc00b6c..e7d0a423 100644 --- a/R/ta_DEMA.R +++ b/R/ta_DEMA.R @@ -163,15 +163,7 @@ double_exponential_moving_average.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_EMA.R b/R/ta_EMA.R index e85e4d49..e999fc54 100644 --- a/R/ta_EMA.R +++ b/R/ta_EMA.R @@ -163,15 +163,7 @@ exponential_moving_average.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_HT_DCPERIOD.R b/R/ta_HT_DCPERIOD.R index e806d99c..d65003f8 100644 --- a/R/ta_HT_DCPERIOD.R +++ b/R/ta_HT_DCPERIOD.R @@ -142,15 +142,7 @@ dominant_cycle_period.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_HT_DCPHASE.R b/R/ta_HT_DCPHASE.R index 315e5007..401954a8 100644 --- a/R/ta_HT_DCPHASE.R +++ b/R/ta_HT_DCPHASE.R @@ -142,15 +142,7 @@ dominant_cycle_phase.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_HT_PHASOR.R b/R/ta_HT_PHASOR.R index 27f29560..f2984771 100644 --- a/R/ta_HT_PHASOR.R +++ b/R/ta_HT_PHASOR.R @@ -142,15 +142,7 @@ phasor_components.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_HT_SINE.R b/R/ta_HT_SINE.R index dad2622e..7de5d1d6 100644 --- a/R/ta_HT_SINE.R +++ b/R/ta_HT_SINE.R @@ -142,15 +142,7 @@ sine_wave.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_HT_TRENDLINE.R b/R/ta_HT_TRENDLINE.R index f0051a5a..3ffbe7b8 100644 --- a/R/ta_HT_TRENDLINE.R +++ b/R/ta_HT_TRENDLINE.R @@ -142,15 +142,7 @@ trendline.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_HT_TRENDMODE.R b/R/ta_HT_TRENDMODE.R index dcbbacf1..a3d0fc48 100644 --- a/R/ta_HT_TRENDMODE.R +++ b/R/ta_HT_TRENDMODE.R @@ -142,15 +142,7 @@ trend_cycle_mode.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_KAMA.R b/R/ta_KAMA.R index 5f0f0d31..2e02e82f 100644 --- a/R/ta_KAMA.R +++ b/R/ta_KAMA.R @@ -163,15 +163,7 @@ kaufman_adaptive_moving_average.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_MACD.R b/R/ta_MACD.R index 364b16b8..5e900a28 100644 --- a/R/ta_MACD.R +++ b/R/ta_MACD.R @@ -172,15 +172,7 @@ moving_average_convergence_divergence.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_MACDEXT.R b/R/ta_MACDEXT.R index 23d99dd0..5b9b4f7b 100644 --- a/R/ta_MACDEXT.R +++ b/R/ta_MACDEXT.R @@ -178,15 +178,7 @@ extended_moving_average_convergence_divergence.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_MACDFIX.R b/R/ta_MACDFIX.R index 636895fc..9bf9dd6d 100644 --- a/R/ta_MACDFIX.R +++ b/R/ta_MACDFIX.R @@ -152,15 +152,7 @@ fixed_moving_average_convergence_divergence.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_MAMA.R b/R/ta_MAMA.R index 7918e21e..863fe8f5 100644 --- a/R/ta_MAMA.R +++ b/R/ta_MAMA.R @@ -182,15 +182,7 @@ mesa_adaptive_moving_average.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_MOM.R b/R/ta_MOM.R index df712020..e0d93908 100644 --- a/R/ta_MOM.R +++ b/R/ta_MOM.R @@ -151,15 +151,7 @@ momentum.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_PPO.R b/R/ta_PPO.R index 0b54a3a7..509b2efc 100644 --- a/R/ta_PPO.R +++ b/R/ta_PPO.R @@ -172,15 +172,7 @@ percentage_price_oscillator.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_ROC.R b/R/ta_ROC.R index 65a5b432..554e9496 100644 --- a/R/ta_ROC.R +++ b/R/ta_ROC.R @@ -151,15 +151,7 @@ rate_of_change.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_ROCR.R b/R/ta_ROCR.R index a387f257..64adfaad 100644 --- a/R/ta_ROCR.R +++ b/R/ta_ROCR.R @@ -151,15 +151,7 @@ ratio_of_change.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_RSI.R b/R/ta_RSI.R index 557646de..1d0263df 100644 --- a/R/ta_RSI.R +++ b/R/ta_RSI.R @@ -151,15 +151,7 @@ relative_strength_index.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_SMA.R b/R/ta_SMA.R index da7f1995..79c660f1 100644 --- a/R/ta_SMA.R +++ b/R/ta_SMA.R @@ -163,15 +163,7 @@ simple_moving_average.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_STOCHRSI.R b/R/ta_STOCHRSI.R index c42c4642..8573ca9b 100644 --- a/R/ta_STOCHRSI.R +++ b/R/ta_STOCHRSI.R @@ -173,15 +173,7 @@ stochastic_relative_strength_index.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_T3.R b/R/ta_T3.R index 34ac9aca..933356d9 100644 --- a/R/ta_T3.R +++ b/R/ta_T3.R @@ -173,15 +173,7 @@ t3_exponential_moving_average.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_TEMA.R b/R/ta_TEMA.R index 07c50252..98857cbc 100644 --- a/R/ta_TEMA.R +++ b/R/ta_TEMA.R @@ -163,15 +163,7 @@ triple_exponential_moving_average.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_TRIMA.R b/R/ta_TRIMA.R index 5b49db27..a63af257 100644 --- a/R/ta_TRIMA.R +++ b/R/ta_TRIMA.R @@ -163,15 +163,7 @@ triangular_moving_average.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_TRIX.R b/R/ta_TRIX.R index 269a686c..e4b64072 100644 --- a/R/ta_TRIX.R +++ b/R/ta_TRIX.R @@ -151,15 +151,7 @@ triple_exponential_average.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_VOLUME.R b/R/ta_VOLUME.R index 11e587d6..f60c636d 100644 --- a/R/ta_VOLUME.R +++ b/R/ta_VOLUME.R @@ -159,15 +159,7 @@ trading_volume.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/R/ta_WMA.R b/R/ta_WMA.R index e6fcc602..7053c48e 100644 --- a/R/ta_WMA.R +++ b/R/ta_WMA.R @@ -163,15 +163,7 @@ weighted_moving_average.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/codegen/generate_unit-tests.sh b/codegen/generate_unit-tests.sh index 07e5dd98..685ea702 100755 --- a/codegen/generate_unit-tests.sh +++ b/codegen/generate_unit-tests.sh @@ -345,20 +345,16 @@ testthat::test_that(desc = ' methods', code = { ${FUN}(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) EOF -fi \ No newline at end of file +fi diff --git a/codegen/templates/moving_average_template.R.in b/codegen/templates/moving_average_template.R.in index a7fbec5c..228b774a 100644 --- a/codegen/templates/moving_average_template.R.in +++ b/codegen/templates/moving_average_template.R.in @@ -155,15 +155,7 @@ $FUN.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/codegen/templates/numeric_template.R.in b/codegen/templates/numeric_template.R.in index adc86c37..32d89dbf 100644 --- a/codegen/templates/numeric_template.R.in +++ b/codegen/templates/numeric_template.R.in @@ -26,15 +26,7 @@ ${FUN}.numeric <- function( as.logical(na.bridge) ) - ## check if it has 'dims' - ## and convert to double if - ## not to honor the 'type-safety'-esque - ## approach - ## - ## NOTE: this adds a few ns overhead but - ## its a robust alternative to code it - ## manually. Any suggestions are welcome - if (is.null(dim(x))) { + if (dim(x)[2] == 1L) { x <- as.double(x) } diff --git a/tests/testthat/test-ta_APO.R b/tests/testthat/test-ta_APO.R index 1b3387c0..6a44cfee 100644 --- a/tests/testthat/test-ta_APO.R +++ b/tests/testthat/test-ta_APO.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { absolute_price_oscillator(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_BBANDS.R b/tests/testthat/test-ta_BBANDS.R index 3690e5e9..238809d1 100644 --- a/tests/testthat/test-ta_BBANDS.R +++ b/tests/testthat/test-ta_BBANDS.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { bollinger_bands(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_CMO.R b/tests/testthat/test-ta_CMO.R index 41d42161..f4ebea87 100644 --- a/tests/testthat/test-ta_CMO.R +++ b/tests/testthat/test-ta_CMO.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { chande_momentum_oscillator(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_DEMA.R b/tests/testthat/test-ta_DEMA.R index 9ee69bfc..6a6ba8e7 100644 --- a/tests/testthat/test-ta_DEMA.R +++ b/tests/testthat/test-ta_DEMA.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { double_exponential_moving_average(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_EMA.R b/tests/testthat/test-ta_EMA.R index 4803a154..9727c2f6 100644 --- a/tests/testthat/test-ta_EMA.R +++ b/tests/testthat/test-ta_EMA.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { exponential_moving_average(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_HT_DCPERIOD.R b/tests/testthat/test-ta_HT_DCPERIOD.R index 7b396040..8ccdab5e 100644 --- a/tests/testthat/test-ta_HT_DCPERIOD.R +++ b/tests/testthat/test-ta_HT_DCPERIOD.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { dominant_cycle_period(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_HT_DCPHASE.R b/tests/testthat/test-ta_HT_DCPHASE.R index 4e710459..d2db1826 100644 --- a/tests/testthat/test-ta_HT_DCPHASE.R +++ b/tests/testthat/test-ta_HT_DCPHASE.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { dominant_cycle_phase(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_HT_PHASOR.R b/tests/testthat/test-ta_HT_PHASOR.R index 5cf64d6d..f08458d9 100644 --- a/tests/testthat/test-ta_HT_PHASOR.R +++ b/tests/testthat/test-ta_HT_PHASOR.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { phasor_components(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_HT_SINE.R b/tests/testthat/test-ta_HT_SINE.R index c37440e1..501aaf0c 100644 --- a/tests/testthat/test-ta_HT_SINE.R +++ b/tests/testthat/test-ta_HT_SINE.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { sine_wave(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_HT_TRENDLINE.R b/tests/testthat/test-ta_HT_TRENDLINE.R index 5476e434..2989d5a3 100644 --- a/tests/testthat/test-ta_HT_TRENDLINE.R +++ b/tests/testthat/test-ta_HT_TRENDLINE.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { trendline(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_HT_TRENDMODE.R b/tests/testthat/test-ta_HT_TRENDMODE.R index 1a2709bb..d3cdaa2a 100644 --- a/tests/testthat/test-ta_HT_TRENDMODE.R +++ b/tests/testthat/test-ta_HT_TRENDMODE.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { trend_cycle_mode(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_KAMA.R b/tests/testthat/test-ta_KAMA.R index f93fb9ef..3aa0f28b 100644 --- a/tests/testthat/test-ta_KAMA.R +++ b/tests/testthat/test-ta_KAMA.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { kaufman_adaptive_moving_average(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_MACD.R b/tests/testthat/test-ta_MACD.R index 095b330f..36a1ae58 100644 --- a/tests/testthat/test-ta_MACD.R +++ b/tests/testthat/test-ta_MACD.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { moving_average_convergence_divergence(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_MACDEXT.R b/tests/testthat/test-ta_MACDEXT.R index beb57c9d..72fb5980 100644 --- a/tests/testthat/test-ta_MACDEXT.R +++ b/tests/testthat/test-ta_MACDEXT.R @@ -249,18 +249,14 @@ testthat::test_that(desc = ' methods', code = { extended_moving_average_convergence_divergence(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_MACDFIX.R b/tests/testthat/test-ta_MACDFIX.R index d619fb7f..dc316ca4 100644 --- a/tests/testthat/test-ta_MACDFIX.R +++ b/tests/testthat/test-ta_MACDFIX.R @@ -243,18 +243,14 @@ testthat::test_that(desc = ' methods', code = { fixed_moving_average_convergence_divergence(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_MAMA.R b/tests/testthat/test-ta_MAMA.R index 53bd0ce8..43eefc0e 100644 --- a/tests/testthat/test-ta_MAMA.R +++ b/tests/testthat/test-ta_MAMA.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { mesa_adaptive_moving_average(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_MOM.R b/tests/testthat/test-ta_MOM.R index 7fa114c4..ce5dc95e 100644 --- a/tests/testthat/test-ta_MOM.R +++ b/tests/testthat/test-ta_MOM.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { momentum(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_PPO.R b/tests/testthat/test-ta_PPO.R index 7157bfeb..963cb3bb 100644 --- a/tests/testthat/test-ta_PPO.R +++ b/tests/testthat/test-ta_PPO.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { percentage_price_oscillator(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_ROC.R b/tests/testthat/test-ta_ROC.R index b17ac22a..9ac9dff8 100644 --- a/tests/testthat/test-ta_ROC.R +++ b/tests/testthat/test-ta_ROC.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { rate_of_change(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_ROCR.R b/tests/testthat/test-ta_ROCR.R index 54d1c43d..3224cb18 100644 --- a/tests/testthat/test-ta_ROCR.R +++ b/tests/testthat/test-ta_ROCR.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { ratio_of_change(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_RSI.R b/tests/testthat/test-ta_RSI.R index dff50d26..40cc132d 100644 --- a/tests/testthat/test-ta_RSI.R +++ b/tests/testthat/test-ta_RSI.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { relative_strength_index(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_SMA.R b/tests/testthat/test-ta_SMA.R index abfaeb27..3e09822d 100644 --- a/tests/testthat/test-ta_SMA.R +++ b/tests/testthat/test-ta_SMA.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { simple_moving_average(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_STOCHRSI.R b/tests/testthat/test-ta_STOCHRSI.R index 76ffb2cf..07f61656 100644 --- a/tests/testthat/test-ta_STOCHRSI.R +++ b/tests/testthat/test-ta_STOCHRSI.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { stochastic_relative_strength_index(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_T3.R b/tests/testthat/test-ta_T3.R index 42a74872..49a2ea84 100644 --- a/tests/testthat/test-ta_T3.R +++ b/tests/testthat/test-ta_T3.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { t3_exponential_moving_average(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_TEMA.R b/tests/testthat/test-ta_TEMA.R index 5511c07c..2ac581df 100644 --- a/tests/testthat/test-ta_TEMA.R +++ b/tests/testthat/test-ta_TEMA.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { triple_exponential_moving_average(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_TRIMA.R b/tests/testthat/test-ta_TRIMA.R index 4dfb628e..e2eec73a 100644 --- a/tests/testthat/test-ta_TRIMA.R +++ b/tests/testthat/test-ta_TRIMA.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { triangular_moving_average(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_TRIX.R b/tests/testthat/test-ta_TRIX.R index 21a9b387..626d5358 100644 --- a/tests/testthat/test-ta_TRIX.R +++ b/tests/testthat/test-ta_TRIX.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { triple_exponential_average(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } }) diff --git a/tests/testthat/test-ta_WMA.R b/tests/testthat/test-ta_WMA.R index 0a0b08c9..22d69882 100644 --- a/tests/testthat/test-ta_WMA.R +++ b/tests/testthat/test-ta_WMA.R @@ -240,18 +240,14 @@ testthat::test_that(desc = ' methods', code = { weighted_moving_average(BTC[[1]]) ) - ## the numeric methods returns - ## depending on the underlying functions - ## so the checks for equal lengths is conditional target_length <- length(BTC[[1]]) - if (is.null(dim(x))) { - testthat::expect_true( - length(x) == target_length - ) + if (NCOL(x) == 1L) { + testthat::expect_true(is.double(x)) + testthat::expect_false(is.matrix(x)) + testthat::expect_equal(length(x), target_length) } else { - testthat::expect_true( - nrow(x) == target_length - ) + testthat::expect_true(is.matrix(x)) + testthat::expect_equal(nrow(x), target_length) } })