Skip to content

Commit

Permalink
EPV testing (#90)
Browse files Browse the repository at this point in the history
Duplicated testing for xT threat function on EPV function.

Included 4 tests:

- Opta type
- Statsbomb type
- Empty dataframe
- Dataframe with missing columns

Works on Issue #44
  • Loading branch information
abhiamishra authored Jul 10, 2022
1 parent 33a5302 commit d267183
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tests/testthat/test_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -780,14 +780,18 @@ test_that("Testing plotting pass networks: ", {


############# |- CALCULATE_EPV ################
df <- data.frame(
#Opta Dataset
opta_df <- data.frame(
x = seq(81, 100, by = 1),
y = seq(81, 100, by = 1),
finalX = seq(51, 70, by = 1),
finalY = seq(61, 80, by = 1)
finalX = seq(81, 100, by = 1),
finalY = seq(81, 100, by = 1)
)

# Creating an empty dataframe
#Statsbomb Dataset
sb_df <- SampleSBData

# Creating an empty dataframes
df_empty <- data.frame(matrix(ncol = 4, nrow = 0))
x <- c("x", "y", "finalX", "finalY")
colnames(df_empty) <- x
Expand All @@ -799,12 +803,13 @@ df_absent <- data.frame(
finalY = seq(61, 80, by = 1)
)


test_that("Testing calculation of expected threat: ", {
p <- calculate_epv(df, type = "statsbomb")
expect_equal((ncol(df) + 2), ncol(p))
p <- calculate_epv(opta_df, type = "statsbomb")
expect_equal((ncol(opta_df) + 2), ncol(p))

p <- calculate_epv(df)
expect_equal((ncol(df) + 2), ncol(p))
p <- calculate_epv(sb_df)
expect_equal((ncol(sb_df) + 2), ncol(p))


# testing for plotting on an empty dataframe
Expand Down

0 comments on commit d267183

Please sign in to comment.