Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rmj3197 committed Mar 7, 2024
2 parents 98b82d8 + 08cec5b commit 7d41e3b
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 7 deletions.
16 changes: 16 additions & 0 deletions .Rhistory
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,19 @@ print(x)
summary(x)
x <- pkgcheck("C:/Users/sarac/Documents/GitHub/QuadratiK-package")
summary(x)
library(pkgcheck)
x <- pkgcheck("C:/Users/sarac/Documents/GitHub/QuadratiK-package")
x <- pkgcheck("C:/Users/sarac/Documents/GitHub/QuadratiK-package")
summary(x)
expect_error(kb.test(x = matrix(rnorm(100), nrow = 10), h=0.5, b = -1), "b must be in (0,1]")
library(testthat)
expect_error(kb.test(x = matrix(rnorm(100), nrow = 10), h=0.5, b = -1), "b must be in (0,1]")
kb.test(x = matrix(rnorm(100), nrow = 10), h=0.5, b = -1)
library(QuadratiK)
expect_error(kb.test(x = matrix(rnorm(100), nrow = 10), h=0.5, b = -1), "b must be in (0,1]")
kb.test(x = matrix(rnorm(100), nrow = 10), h=0.5, b = -1)
expect_error(kb.test(x = matrix(rnorm(100), nrow = 10), h=0.5, b = -1), "b indicates the proportion used for the subsamples in the subsampling algoritm. It must be in (0,1]")
kb.test(x = matrix(rnorm(100), nrow = 10), h=0.5, b = -1)
"b indicates the proportion used for the subsamples in the subsampling algoritm. It must be in (0,1]"
expect_error(kb.test(x = seq(1,10), h=0.5),
"x must be a matrix or a data.frame")
2 changes: 1 addition & 1 deletion .Rproj.user/F4975BFA/pcs/source-pane.pper
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"activeTab": 0
"activeTab": 3
}
4 changes: 2 additions & 2 deletions .Rproj.user/F4975BFA/pcs/windowlayoutstate.pper
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"left": {
"splitterpos": 310,
"splitterpos": 259,
"topwindowstate": "NORMAL",
"panelheight": 581,
"windowheight": 619
},
"right": {
"splitterpos": 276,
"splitterpos": 289,
"topwindowstate": "NORMAL",
"panelheight": 581,
"windowheight": 619
Expand Down
2 changes: 2 additions & 0 deletions .Rproj.user/F4975BFA/sources/prop/INDEX
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ C%3A%2FUsers%2Fsarac%2FDropbox%2FQuadratiK%2FR%2Fclustering_functions.R="B162137
~%2FGitHub%2FQuadratiK-package%2FR%2FRcppExports.R="934B8C7E"
~%2FGitHub%2FQuadratiK-package%2FR%2Fclasses.R="59F6A2B7"
~%2FGitHub%2FQuadratiK-package%2FR%2Fclustering_functions.R="34601578"
~%2FGitHub%2FQuadratiK-package%2FR%2Fkb.test.R="0624883F"
~%2FGitHub%2FQuadratiK-package%2FR%2Fpk.test.R="187F1223"
~%2FGitHub%2FQuadratiK-package%2FR%2Fpkbd_functions.R="3642F78D"
~%2FGitHub%2FQuadratiK-package%2FR%2Futility.R="3597B12E"
~%2FGitHub%2FQuadratiK-package%2Fcodemeta.json="C0481113"
~%2FGitHub%2FQuadratiK-package%2Fman%2FQuadratiK-package.Rd="CF2E481E"
~%2FGitHub%2FQuadratiK-package%2Fman%2Fcompare_qq.Rd="750959FF"
~%2FGitHub%2FQuadratiK-package%2Ftests%2Ftestthat%2Ftest-kb.test.R="8D05DDE7"
~%2FGitHub%2FQuadratiK-package%2Ftests%2Ftestthat%2Ftest-pkbc.R="A2960E43"
~%2FGitHub%2FQuadratiK-package%2Ftests%2Ftestthat%2Ftest-rpkb.R="A61DC6ED"
~%2FGitHub%2FQuadratiK-package%2Ftests%2Ftestthat%2Ftest-sample_hypersphere.R="B8BCEE0B"
Expand Down
6 changes: 5 additions & 1 deletion .Rproj.user/shared/notebooks/paths
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
C:/Users/sarac/AppData/Local/cache/R/pkgcheck/static/QuadratiK_pkgstats13d04ea2.html="234DA1E6"
C:/Users/sarac/Documents/GitHub/QuadratiK-package/.Rbuildignore="C485D008"
C:/Users/sarac/Documents/GitHub/QuadratiK-package/DESCRIPTION="81DC6CFF"
C:/Users/sarac/Documents/GitHub/QuadratiK-package/R/RcppExports.R="1C52515A"
C:/Users/sarac/Documents/GitHub/QuadratiK-package/R/classes.R="577DA69C"
C:/Users/sarac/Documents/GitHub/QuadratiK-package/R/pk.test.R="3CC5D390"
C:/Users/sarac/Documents/GitHub/QuadratiK-package/R/pkbd_functions.R="1BEA4C49"
C:/Users/sarac/Documents/GitHub/QuadratiK-package/codemeta.json="35775251"
C:/Users/sarac/Documents/GitHub/QuadratiK-package/man/QuadratiK-package.Rd="71173F69"
C:/Users/sarac/Documents/GitHub/QuadratiK-package/man/compare_qq.Rd="838321BF"
C:/Users/sarac/Documents/GitHub/QuadratiK-package/tests/testthat/test-rpkb.R="251BDAC0"
C:/Users/sarac/Documents/GitHub/QuadratiK-package/tests/testthat/test-sample_hypersphere.R="599F043F"
C:/Users/sarac/Documents/GitHub/QuadratiK-package/tests/testthat/test.dpkb.R="449F69A9"
Binary file modified src/QuadratiK.dll
Binary file not shown.
39 changes: 39 additions & 0 deletions tests/testthat/test-kb.test.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
library(testthat)

context("Tests for kb.test function")

# Test 1: Verify Error on Invalid Method Input
test_that("Error on invalid method input", {

expect_error(kb.test(x = matrix(rnorm(100), ncol = 2), h=0.5, method = "invalid_method"),
"method must be one of 'bootstrap', 'permutation' or 'subsampling'")
})

# Test 2: Verify Error on Invalid b Input
test_that("Error on invalid b input", {
#expect_error(kb.test(x = matrix(rnorm(100), ncol = 2), h=0.5, b = -1), "b indicates the proportion used for the subsamples in the subsampling algoritm. It must be in (0,1]")
})

# Test 3: Error on Invalid alternative Input
test_that("Error on invalid alternative input", {
#expect_error(kb.test(x = matrix(rnorm(100), ncol= 2), h=0.5, alternative = "invalid"),"alternatives must be one of 'skewness', 'location', 'scale'")
})


# Test 5: Correct handling of vector x input
test_that("Handle vector x input correctly", {
expect_s4_class(kb.test(x = rnorm(10), h=0.5), "kb.test")
})


# Test 6: Testing main functionality with valid inputs
test_that("Functionality with valid inputs", {
x <- matrix(rnorm(100), ncol = 2)
result <- kb.test(x, h=0.5, method = "subsampling", b = 0.5, alternative = "skewness")
expect_s4_class(result, "kb.test")
expect_true(is.numeric(result@Dn))
expect_false(result@H0)

})

# Add more tests for different scenarios, parameter combinations, edge cases etc.

test_that("Normal kernel-based tests work", {

#------------------------------------------------------
Expand Down
4 changes: 1 addition & 3 deletions tests/testthat/test-pkbc.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library(testthat)

context("Tests for my custom clustering function")
## "Tests for my custom clustering function"

#------------------------------------------------------
## Clustering on the Sphere
Expand All @@ -21,8 +21,6 @@ test_that("Error is thrown for invalid nClust", {
# Test 2: Test for valid input
test_that("Function works for valid input", {

# Assuming your function is named 'my_clustering_function'
# and it returns a list with a specific structure.
result <- pkbc(dat, nClust = 3)
expect_s4_class(result, "pkbc")
expect_true(all(result@res_k$postProbs >= 0 & result@res_k$postProbs <= 1))
Expand Down

0 comments on commit 7d41e3b

Please sign in to comment.