-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
264 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
test_that("calculate_angles_for_track works correctly", { | ||
# Create sample data | ||
track_data <- data.frame( | ||
x = c(1, 2, 3, 4, 5), | ||
y = c(1, 2, 1, 2, 1) | ||
) | ||
|
||
# Calculate angles | ||
angles <- calculate_angles_for_track(track_data, "x", "y") | ||
|
||
# Expected results | ||
expected_angles <- c(NA, 90, 90, 90, NA) | ||
|
||
# Check if the angles are as expected (within a tolerance) | ||
expect_equal(angles, expected_angles, tolerance = 1e-6) | ||
|
||
# Test with insufficient points | ||
track_data_insufficient <- data.frame( | ||
x = c(1, 2), | ||
y = c(1, 2) | ||
) | ||
angles_insufficient <- calculate_angles_for_track(track_data_insufficient, "x", "y") | ||
expect_equal(angles_insufficient, c(NA, NA)) | ||
|
||
# Test with missing column names | ||
expect_error(calculate_angles_for_track(track_data, "a", "b"), "x and y must be valid column names in track_data") | ||
|
||
# Test with incorrect data type | ||
expect_error(calculate_angles_for_track(list(a = 1, b = 2), "x", "y"), "track_data must be a data frame") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
test_that("plot_motion generates a ggplot object", { | ||
# Create sample data | ||
sample_data <- data.frame( | ||
x = c(1, 2, 3, 4, 5, 1+1, 2+2, 3+3, 4+4, 5+5), | ||
y = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2), | ||
frames = rep(1:5, 2) | ||
) | ||
|
||
# Generate the plot | ||
plot <- plot_motion(sample_data, x, y, frames) | ||
|
||
# Check if the output is a ggplot object | ||
expect_s3_class(plot, "ggplot") | ||
}) | ||
|
||
test_that("plot_degrees generates a ggplot object and calculates angles correctly", { | ||
# Create sample data | ||
sample_data <- data.frame( | ||
x = c(1, 2, 3, 4, 5, 1+1, 2+2, 3+3, 4+4, 5+5, 1, 2, 3, 4, 5), | ||
y = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3), | ||
joint_ids = rep(1:3, each = 5), | ||
frames = rep(1:5, 3) | ||
) | ||
|
||
# Generate the plot | ||
plot <- plot_degrees(sample_data, x, y, joint_ids, frames) | ||
|
||
# Check if the output is a ggplot object | ||
expect_s3_class(plot, "ggplot") | ||
|
||
# Check if the angles are calculated correctly | ||
angle_data <- plot_degrees(sample_data, x, y, joint_ids, frames, plot = FALSE) | ||
expect_true("angle" %in% names(angle_data)) | ||
|
||
# Check the angle values | ||
expected_angles <- c(NA, NA, NA, NA, NA, 90, 126.8, 143.1, | ||
151.9, 157.3, NA, NA, NA, NA, NA) | ||
expect_equal(angle_data$angle, expected_angles, tolerance = 1e-3) | ||
}) | ||
|
||
test_that("plot_degrees returns data with angle measurements when plot is FALSE", { | ||
# Create sample data | ||
sample_data <- data.frame( | ||
x = c(1, 2, 3, 4, 5, 1+1, 2+2, 3+3, 4+4, 5+5, 1, 2, 3, 4, 5), | ||
y = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3), | ||
joint_ids = rep(1:3, each = 5), | ||
frames = rep(1:5, 3) | ||
) | ||
|
||
# Get the angle data | ||
angle_data <- plot_degrees(sample_data, x, y, joint_ids, frames, plot = FALSE) | ||
|
||
# Check if the output is a data frame | ||
expect_s3_class(angle_data, "data.frame") | ||
|
||
# Check if the angle column exists | ||
expect_true("angle" %in% names(angle_data)) | ||
}) |